Commit 0ddd02df authored by Luca Bataillard's avatar Luca Bataillard
Browse files

add function name to worker var substition

parent a5800231
......@@ -44,7 +44,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
val fv = ((freeVars(f.body) - f.name) -- f.args).toList
// Creates a letP
def argsBindings(freeVars: Seq[Symbol], counter: Int, accSubst: Map[Symbol, Symbol]): L.Tree = freeVars match {
def argsBindings(freeVars: Seq[Symbol], counter: Int, accSubst: Subst[Symbol]): L.Tree = freeVars match {
case Nil =>
substitute(funBody)(accSubst)
case freeVar :: vs =>
......@@ -54,7 +54,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
argsBindings(vs, counter + 1, accSubst + (freeVar -> v)))
}
val newFunBody = argsBindings(fv, 1, Map())
val newFunBody = argsBindings(fv, 1, subst(f.name, envName))
val newFun = L.Fun(workerFun, f.retC, newArgs, newFunBody)
(newFun, fv, f.name) +: transformFunAbs(fs)
}
......@@ -92,7 +92,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
// Substitutes _free_ variables in `tree`
// meaning that `subst` should only contain variables
// that are free in `tree`
def substitute(tree: L.Tree)(implicit subst: Map[Symbol, Symbol]): L.Tree = {
def substitute(tree: L.Tree)(implicit subst: Subst[Symbol]): L.Tree = {
def subtituteArgs(args: Seq[L.Atom]): Seq[L.Atom] = args.map(substituteAtom)
def substituteAtom(atom: L.Atom) = atom match {
......
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