@@ -153,8 +153,15 @@ def findConstraints(stmt: Stmt)(using ctx: MonoFindContext): Constraints = stmt
153153 // TODO: part 2, also update the implementation in monomorphize if changing this
154154 case App (Unbox (ValueVar (id, annotatedType)), targs, vargs, bargs) =>
155155 List (Constraint (targs.map(findId).toVector, id)) ++ vargs.flatMap(findConstraints) ++ bargs.flatMap(findConstraints)
156+ case App (callee, targs, vargs, bargs) =>
157+ findConstraints(callee) ++ vargs.flatMap(findConstraints) ++ bargs.flatMap(findConstraints)
158+ // TODO: Maybe need to do something with methodTpe
156159 case Invoke (callee : BlockVar , method, methodTpe, targs, vargs, bargs) =>
157160 List (Constraint (targs.map(findId).toVector, callee.id)) ++ vargs.flatMap(findConstraints) ++ bargs.flatMap(findConstraints)
161+ case Invoke (Unbox (ValueVar (id, annotatedType)), method, methodTpe, targs, vargs, bargs) =>
162+ List (Constraint (targs.map(findId).toVector, id)) ++ vargs.flatMap(findConstraints) ++ bargs.flatMap(findConstraints)
163+ case Invoke (callee, method, methodTpe, targs, vargs, bargs) =>
164+ findConstraints(callee) ++ vargs.flatMap(findConstraints) ++ bargs.flatMap(findConstraints)
158165 case Reset (body) => findConstraints(body)
159166 case If (cond, thn, els) => findConstraints(cond) ++ findConstraints(thn) ++ findConstraints(els)
160167 case Def (id, BlockLit (tparams, cparams, vparams, bparams, bbody), body) =>
@@ -170,7 +177,6 @@ def findConstraints(stmt: Stmt)(using ctx: MonoFindContext): Constraints = stmt
170177 case Alloc (id, init, region, body) => findConstraints(init) ++ findConstraints(body)
171178 case Region (body) => findConstraints(body)
172179 case Hole (span) => List .empty
173- case o => println(o); ???
174180
175181def findConstraints (opt : Option [Stmt ])(using ctx : MonoFindContext ): Constraints = opt match
176182 case None => List .empty
@@ -310,7 +316,8 @@ def monomorphize(blockVar: BlockVar, replacementId: FunctionId)(using ctx: MonoC
310316 case BlockVar (id, BlockType .Function (tparams, cparams, vparams, bparams, result), annotatedCapt) =>
311317 val monoAnnotatedTpe = BlockType .Function (List .empty, cparams, vparams map monomorphize, bparams map monomorphize, monomorphize(result))
312318 BlockVar (replacementId, monoAnnotatedTpe, annotatedCapt)
313- case o => println(o); ???
319+ case BlockVar (id, annotatedTpe : BlockType .Interface , annotatedCapt) =>
320+ BlockVar (id, monomorphize(annotatedTpe), annotatedCapt)
314321
315322def monomorphize (stmt : Stmt )(using ctx : MonoContext ): Stmt = stmt match
316323 case Return (expr) => Return (monomorphize(expr))
@@ -326,12 +333,18 @@ def monomorphize(stmt: Stmt)(using ctx: MonoContext): Stmt = stmt match
326333 case App (Unbox (ValueVar (id, annotatedTpe)), targs, vargs, bargs) =>
327334 val replacementData = replacementDataFromTargs(id, targs)
328335 App (Unbox (ValueVar (id, monomorphize(annotatedTpe))), List .empty, vargs map monomorphize, bargs map monomorphize)
336+ case App (callee, targs, vargs, bargs) =>
337+ App (monomorphize(callee), List .empty, vargs map monomorphize, bargs map monomorphize)
329338 case Let (id, annotatedTpe, binding, body) => Let (id, monomorphize(annotatedTpe), monomorphize(binding), monomorphize(body))
330339 case If (cond, thn, els) => If (monomorphize(cond), monomorphize(thn), monomorphize(els))
331340 case Invoke (Unbox (pure), method, methodTpe, targs, vargs, bargs) =>
332341 Invoke (Unbox (monomorphize(pure)), method, methodTpe, List .empty, vargs map monomorphize, bargs map monomorphize)
333342 case Invoke (BlockVar (id, annotatedTpe, annotatedCapt), method, methodTpe, targs, vargs, bargs) =>
334343 Invoke (BlockVar (id, monomorphize(annotatedTpe), annotatedCapt), method, methodTpe, List .empty, vargs map monomorphize, bargs map monomorphize)
344+ case Invoke (callee, method, methodTpe, targs, vargs, bargs) =>
345+ Invoke (monomorphize(callee), method, methodTpe, List .empty, vargs map monomorphize, bargs map monomorphize)
346+ case Resume (k, body) =>
347+ Resume (monomorphize(k), monomorphize(body))
335348 // TODO: Monomorphizing here throws an error complaining about a missing implementation
336349 // Not sure what is missing, altough it does works like this
337350 case Reset (body) => Reset (body)
@@ -360,7 +373,6 @@ def monomorphize(stmt: Stmt)(using ctx: MonoContext): Stmt = stmt match
360373 Alloc (id, monomorphize(init), region, monomorphize(body))
361374 case Region (body) => Region (monomorphize(body))
362375 case Hole (span) => Hole (span)
363- case o => println(o); ???
364376
365377def monomorphize (opt : Option [Stmt ])(using ctx : MonoContext ): Option [Stmt ] = opt match
366378 case None => None
@@ -380,7 +392,8 @@ def monomorphize(expr: Expr)(using ctx: MonoContext): Expr = expr match
380392 case Box (b, annotatedCapture) =>
381393 // TODO: Does this need other handling?
382394 Box (b, annotatedCapture)
383- case o => println(o); ???
395+ case ValueVar (id, annotatedType) =>
396+ ValueVar (id, monomorphize(annotatedType))
384397
385398def monomorphize (pure : Pure )(using ctx : MonoContext ): Pure = pure match
386399 case ValueVar (id, annotatedType) => ValueVar (id, monomorphize(annotatedType))
0 commit comments