Commit a3a52ceb authored by Luca Bataillard's avatar Luca Bataillard
Browse files

fix wrong implicit usage

parent 849e0c6e
...@@ -221,7 +221,8 @@ class CPSInterpreterLow(log: SymbolicCPSTreeModuleLow.Tree => Unit) ...@@ -221,7 +221,8 @@ class CPSInterpreterLow(log: SymbolicCPSTreeModuleLow.Tree => Unit)
allocBlock(t, Array.fill(s)(BitsV(0))) allocBlock(t, Array.fill(s)(BitsV(0)))
case (BlockTag, Seq(BlockV(_, t, _))) => BitsV(t) case (BlockTag, Seq(BlockV(_, t, _))) => BitsV(t)
case (BlockLength, Seq(BlockV(_, _, c))) => BitsV(c.length) case (BlockLength, Seq(BlockV(_, _, c))) => BitsV(c.length)
case (BlockGet, Seq(BlockV(_, _, c), BitsV(i))) => c(i) case (BlockGet, Seq(BlockV(_, _, c), BitsV(i))) =>
c(i)
case (BlockSet, Seq(BlockV(_, _, c), BitsV(i), v)) => case (BlockSet, Seq(BlockV(_, _, c), BitsV(i), v)) =>
c(i) = v; BitsV(0) c(i) = v; BitsV(0)
......
...@@ -90,7 +90,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) { ...@@ -90,7 +90,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
def iterate(fvMap: FVMap): FVMap = def iterate(fvMap: FVMap): FVMap =
definedFuns.map { definedFuns.map {
case H.Fun(fName, _, fArgs, fBody) => case H.Fun(fName, _, fArgs, fBody) =>
val newFv = (fv(fBody, fvMap - fName) - fName) -- fArgs val newFv = (fv(fBody, fvMap - fName)) -- fArgs
(fName, newFv) (fName, newFv)
}.toMap }.toMap
...@@ -123,7 +123,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) { ...@@ -123,7 +123,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
val workers = initialFuns map { case H.Fun(fName, fRetC, fArgs, fBody) => val workers = initialFuns map { case H.Fun(fName, fRetC, fArgs, fBody) =>
val (wName, _, fvs) = knownFuns(fName) val (wName, _, fvs) = knownFuns(fName)
val us = fvs.map(f => Symbol.fresh("fv_" + f.name)) val us = fvs.map(f => Symbol.fresh("fv_" + f.name))
val wBody = substitute(apply(fBody))((fvs zip us).toMap) val wBody = substitute(transform(fBody)(knownFuns))((fvs zip us).toMap)
L.Fun(wName, fRetC, fArgs ++ us, wBody) L.Fun(wName, fRetC, fArgs ++ us, wBody)
} }
...@@ -136,7 +136,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) { ...@@ -136,7 +136,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
val sArgs = fArgs map (f => Symbol.fresh("n_" + f.name)) val sArgs = fArgs map (f => Symbol.fresh("n_" + f.name))
val sBody = bindArguments(wName, sCntName, envName, fvs, 1, sArgs map (L.AtomN(_))) val sBody = bindArguments(wName, sCntName, envName, fvs, 1, sArgs map (L.AtomN(_)))
L.Fun(sName, sCntName, sArgs, sBody) L.Fun(sName, sCntName, envName +: sArgs, sBody)
} }
def initFuns(funsAndVars: Seq[(Symbol, (Worker, Wrapper, FreeVars))], lastBody: L.Tree): L.Tree = { def initFuns(funsAndVars: Seq[(Symbol, (Worker, Wrapper, FreeVars))], lastBody: L.Tree): L.Tree = {
......
...@@ -21,8 +21,10 @@ object Main { ...@@ -21,8 +21,10 @@ object Main {
andThen CPSInterpreterLow andThen CPSInterpreterLow
) )
val todoargs = Seq("../tests/stmt-defrec.l3")
val basePath = Paths.get(".").toAbsolutePath val basePath = Paths.get(".").toAbsolutePath
Either.cond(! args.isEmpty, args.toIndexedSeq, "no input file given") Either.cond(! todoargs.isEmpty, todoargs.toIndexedSeq, "no input file given")
.flatMap(L3FileReader.readFilesExpandingModules(basePath, _)) .flatMap(L3FileReader.readFilesExpandingModules(basePath, _))
.flatMap(p => L3Parser.parse(p._1, p._2)) .flatMap(p => L3Parser.parse(p._1, p._2))
.flatMap(CL3NameAnalyzer) .flatMap(CL3NameAnalyzer)
......
Markdown is supported
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