Skip to content

Commit

Permalink
Merge pull request #163 from effekt-lang/feature/machine-evidence
Browse files Browse the repository at this point in the history
Machine: Fix arity mismatch with effect handlers due to evidence
  • Loading branch information
b-studios authored Sep 30, 2022
2 parents 45f3f99 + 199dbf9 commit 46952f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 0 additions & 6 deletions effekt/jvm/src/test/scala/effekt/LLVMTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ class LLVMTests extends EffektTests {

override lazy val ignored: List[File] = List(
// computes the wrong results
examplesDir / "llvm" / "generator.effekt",
examplesDir / "llvm" / "capabilities.effekt",
examplesDir / "llvm" / "nested.effekt",
examplesDir / "llvm" / "stored.effekt",

// crashes
examplesDir / "llvm" / "forking.effekt",

// polymorphic effect operations not supported, yet
examplesDir / "llvm" / "choice.effekt",
Expand Down
11 changes: 7 additions & 4 deletions effekt/shared/src/main/scala/effekt/machine/Transformer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ object Transformer {

case lifted.App(lifted.BlockVar(id), List(), args) =>
// TODO deal with BlockLit
// TODO deal with evidence
id match {
case symbols.UserFunction(_, _, _, _, _, _, _) =>
// TODO this is a hack, values is in general shorter than environment
Expand All @@ -142,9 +141,11 @@ object Transformer {
}
case symbols.ResumeParam(_) =>
// TODO currently only scoped resumptions are supported
// TODO assuming first parameter is evidence TODO actually use evidence?
transform(args).run { values =>
val (evidence :: returnedValues) = values;
PushStack(Variable(transform(id), Type.Stack()),
Return(values))
Return(returnedValues))
}
case _ =>
Context.abort(s"Unsupported blocksymbol: $id")
Expand Down Expand Up @@ -183,7 +184,6 @@ object Transformer {
}

case lifted.Handle(lifted.BlockLit(List(ev, id), body), tpe, List(handler)) =>
// TODO deal with evidence
// TODO more than one handler
val variable = Variable(freshName("a"), transform(tpe))
val returnClause = Clause(List(variable), Return(List(variable)))
Expand Down Expand Up @@ -311,7 +311,10 @@ object Transformer {
case lifted.Handler(_, List((operationName, lifted.BlockLit(params :+ resume, body)))) =>
// TODO we assume here that resume is the last param
// TODO we assume that there are no block params in handlers
List(Clause(params.map(transform),
// TODO we assume that evidence has to be passed as first param
// TODO actually use evidence to determine number of stacks popped
val ev = Variable(freshName("evidence"), builtins.Evidence)
List(Clause(ev +: params.map(transform),
PopStack(Variable(transform(resume).name, Type.Stack()),
transform(body))))
case _ =>
Expand Down

0 comments on commit 46952f1

Please sign in to comment.