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

revert expr-fun and remove extra printlns

parent c15ee6be
......@@ -62,11 +62,6 @@ sealed abstract class CPSInterpreter[M <: CPSTreeModule](
case AppF(fun, retC, args) =>
val FunV(fRetC, fArgs, fBody, fEnv) = unwrapFunV(resolve(fun))
if (fArgs.length != args.length) {
println(fun)
println(fArgs.length)
println(args.length)
}
assume(fArgs.length == args.length)
val rArgs = args map resolve
val env1 = ((fRetC +: fArgs) zip (env(retC) +: rArgs)).toMap orElse fEnv
......
......@@ -37,17 +37,12 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
if (knownFuns.contains(fName)) {
val (wName, sName, fvs) = knownFuns(fName)
val newArgs = (args map rewrite) ++ (fvs map L.AtomN)
val res = L.AppF(L.AtomN(wName), retC, newArgs)
res
L.AppF(L.AtomN(wName), retC, newArgs)
} else {
val f = Symbol.fresh("closure")
val newBody = L.AppF(L.AtomN(f), retC, rewrite(fun) +: args.map(rewrite))
val newArgs = Seq(rewrite(fun), L.AtomL(0))
val res = L.LetP(f, CPS.BlockGet, newArgs, newBody)
println("aaaaaaaaaaaa")
println(fName)
println(res)
res
L.LetP(f, CPS.BlockGet, newArgs, newBody)
}
}
......@@ -111,10 +106,6 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
val fv = fvs(fName)
(fName -> (wName, sName, fv))
}
println("eeeee")
println(initialFuns.map(_.name))
println(definedFuns)
println()
val knownFuns = oldKnownFuns ++ definedFuns
val workers = initialFuns map { case H.Fun(fName, fRetC, fArgs, fBody) =>
......
......@@ -2,39 +2,31 @@
;; Test the "fun" expression
;;(@byte-write 73)
(@byte-write 73)
;;((fun (b) (@byte-write b)) 65)
;;((fun (b)
;; (@byte-write b)
;; (@byte-write (@+ b 1)))
;; 66)
;;(@byte-write ((fun (x) x) 68))
((fun (b) (@byte-write b)) 65)
((fun (b)
(@byte-write b)
(@byte-write (@+ b 1)))
66)
(@byte-write ((fun (x) x) 68))
;;(let ((compose (fun (f g)
;; (fun (x) (f (g x)))))
;; (succ (fun (x) (@+ x 1)))
;; (twice (fun (x) (@+ x x))))
;; (@byte-write ((compose succ twice) 34)))
(let ((compose (fun (f g)
(fun (x) (f (g x)))))
(succ (fun (x) (@+ x 1)))
(twice (fun (x) (@+ x x))))
(@byte-write ((compose succ twice) 34)))
(let
(
(compose (fun (f)
(fun (x) (f x)))
)
)
((compose 1)))
((fun (x y z) #u)
(@byte-write 70)
(@byte-write 71)
(@byte-write 72))
;;((fun (x y z) #u)
;; (@byte-write 70)
;; (@byte-write 71)
;; (@byte-write 72))
;;(let* ((fact (fun (self x)
;; (if (@= 0 x)
;; 1
;; (@* x (self self (@- x 1))))))
;; (fix (fun (f x)
;; (f f x))))
;; (if (@= (fix fact 5) 120)
;; (@byte-write 73)))
(let* ((fact (fun (self x)
(if (@= 0 x)
1
(@* x (self self (@- x 1))))))
(fix (fun (f x)
(f f x))))
(if (@= (fix fact 5) 120)
(@byte-write 73)))
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