Commit 32c98d65 authored by Sapphie's avatar Sapphie
Browse files

Fix block-set bug

parent 91f52f3c
......@@ -60,20 +60,21 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
}
def allocInitFun(funsAndVars: Seq[(L.Fun, Seq[Symbol], Symbol)], lastBody: L.Tree): L.Tree = {
def initFun(remVars: Seq[Symbol], counter: Int, rest: Seq[(L.Fun, Seq[Symbol], Symbol)]): L.Tree = remVars match {
def initFun(remVars: Seq[Symbol], counter: Int, blockAtom: L.Atom, rest: Seq[(L.Fun, Seq[Symbol], Symbol)]): L.Tree = remVars match {
case Nil => allocInitFun(rest, lastBody)
case v :: vs =>
val nextBody = initFun(vs, counter + 1, rest)
val args = Seq(L.AtomL(counter), L.AtomN(v))
val nextBody = initFun(vs, counter + 1, blockAtom, rest)
val args: Seq[L.Atom] = Seq(blockAtom, L.AtomL(counter), L.AtomN(v))
L.LetP(Symbol.fresh("blockset_unused"), CPS.BlockSet, args, nextBody)
}
funsAndVars match {
case Nil => lastBody
case (fun, vars, workerFun) :: rest =>
val varInits = initFun(vars, 1, rest)
val blockAtom = L.AtomN(fun.name)
val varInits = initFun(vars, 1, blockAtom, rest)
val t1 = Symbol.fresh("t1")
val primArgs = Seq(L.AtomL(0), L.AtomN(workerFun))
val primArgs = Seq(blockAtom, L.AtomL(0), L.AtomN(workerFun))
val nextBody = L.LetP(t1, CPS.BlockSet, primArgs, varInits)
L.LetP(fun.name, CPS.BlockAlloc(202), Seq(L.AtomL(vars.length + 1)), nextBody)
}
......
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