Commit e7b87da1 authored by Sapphie's avatar Sapphie
Browse files

Implement halt translation

parent 16a5ec53
......@@ -19,7 +19,7 @@ object CL3ToCPSTranslator extends (S.Tree => C.Tree) {
val ctxCNme = Symbol.fresh("c")
val ctxCId = C.AtomN(ctxCNme)
// Context continuation arg
val ctxCArg = Symbol.fresh("a")
val ctxCArg = Symbol.fresh("a")
// Context continuation body
// This is simply what we already had
val ctxCBody = ctx(C.AtomN(ctxCArg))
......@@ -41,6 +41,8 @@ object CL3ToCPSTranslator extends (S.Tree => C.Tree) {
val newIf = S.If(newCnd, els, thn)(cnd.pos)
transform(newIf)(ctx)
}
case S.Halt(arg) =>
transform(arg)(a => C.Halt(a))
}
}
......@@ -50,11 +52,13 @@ object CL3ToCPSTranslator extends (S.Tree => C.Tree) {
elseC: C.Name): C.Tree = {
val start: C.Tree = C.If(p, Seq(), thenC, elseC)
primArgs.foldLeft(start){
primArgs.foldLeft(start) {
case (C.If(_, s, _, _), e) =>
transform(e)(v => {
C.If(p, s :+ v, thenC, elseC)
})
case _ => ??? // put some exception here idk
// (this is just to shut the compiler up)
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment