Skip to content

Commit 1a41a27

Browse files
committed
Transform ImpureApp pt2
1 parent 957e4bd commit 1a41a27

File tree

1 file changed

+7
-2
lines changed
  • effekt/shared/src/main/scala/effekt/core

1 file changed

+7
-2
lines changed

effekt/shared/src/main/scala/effekt/core/Show.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,13 @@ object Show extends Phase[CoreTransformed, CoreTransformed] {
9292
case Let(id, annotatedTpe, binding, body) =>
9393
Let(id, annotatedTpe, transform(binding), transform(body))
9494
case Return(expr) => Return(transform(expr))
95-
// TODO: We might need to do the same thing as in PureApp if we want to allow show(something) instead of something.show
96-
case ImpureApp(id, callee, targs, vargs, bargs, body) => ImpureApp(id, callee, targs, vargs, bargs, body)
95+
case ImpureApp(id, BlockVar(bid, annotatedTpe, annotatedCapt), targs, vargs, bargs, body) if bid.name.name == "myshow" =>
96+
if (targs.length != 1) sys error "expected targs to only have one argument"
97+
ctx.getShowBlockVar(targs(0)) match {
98+
case BlockVar(bid, annotatedTpe, annotatedCapt) =>
99+
Stmt.Val(id, TString, Stmt.App(BlockVar(bid, annotatedTpe, annotatedCapt), List.empty, vargs map transform, bargs map transform), transform(body))
100+
}
101+
case ImpureApp(id, callee, targs, vargs, bargs, body) => ImpureApp(id, callee, targs, vargs, bargs, transform(body))
97102
case o => println(o); ???
98103
}
99104

0 commit comments

Comments
 (0)