Commit 67178875 authored by Sapphie's avatar Sapphie
Browse files

debugging and testing

parent e6899d1b
...@@ -37,13 +37,14 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) { ...@@ -37,13 +37,14 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
if (knownFuns.contains(fName)) { if (knownFuns.contains(fName)) {
val (wName, sName, fvs) = knownFuns(fName) val (wName, sName, fvs) = knownFuns(fName)
val newArgs = (args map rewrite) ++ (fvs map L.AtomN) val newArgs = (args map rewrite) ++ (fvs map L.AtomN)
L.AppF(L.AtomN(wName), retC, newArgs) val res = L.AppF(L.AtomN(wName), retC, newArgs)
res
} else { } else {
val f = Symbol.fresh("f") val f = Symbol.fresh("closure")
val newBody = L.AppF(L.AtomN(f), retC, rewrite(fun) +: args.map(rewrite)) val newBody = L.AppF(L.AtomN(f), retC, rewrite(fun) +: args.map(rewrite))
val newArgs = Seq(rewrite(fun), L.AtomL(0)) val newArgs = Seq(rewrite(fun), L.AtomL(0))
val res = L.LetP(f, CPS.BlockGet, newArgs, newBody) val res = L.LetP(f, CPS.BlockGet, newArgs, newBody)
println("satoeuhsoethu") println("aaaaaaaaaaaa")
println(fName) println(fName)
println(res) println(res)
res res
...@@ -358,7 +359,12 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) { ...@@ -358,7 +359,12 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
case L3.CharToInt => case L3.CharToInt =>
L.LetP(n, CPS.ShiftRight, Seq(rewrite(x), L.AtomL(2)), transform(body)) L.LetP(n, CPS.ShiftRight, Seq(rewrite(x), L.AtomL(2)), transform(body))
case L3.Id => case L3.Id =>
L.LetP(n, CPS.Id, Seq(rewrite(x)), transform(body)) val newKnownFuns = x match {
case H.AtomN(xName) if knownFuns contains xName =>
knownFuns.updated(n, knownFuns(xName))
case _ => knownFuns
}
L.LetP(n, CPS.Id, Seq(rewrite(x)), transform(body)(newKnownFuns))
case L3.IntToChar => case L3.IntToChar =>
tempLetP(CPS.ShiftLeft, Seq(Left(x), Right(L.AtomL(2)))){ t1 => tempLetP(CPS.ShiftLeft, Seq(Left(x), Right(L.AtomL(2)))){ t1 =>
......
...@@ -11,11 +11,19 @@ ...@@ -11,11 +11,19 @@
;; 66) ;; 66)
;;(@byte-write ((fun (x) x) 68)) ;;(@byte-write ((fun (x) x) 68))
(let ((compose (fun (f g) ;;(let ((compose (fun (f g)
(fun (x) (f (g x))))) ;; (fun (x) (f (g x)))))
(succ (fun (x) (@+ x 1))) ;; (succ (fun (x) (@+ x 1)))
(twice (fun (x) (@+ x x)))) ;; (twice (fun (x) (@+ x x))))
(@byte-write ((compose succ twice) 34))) ;; (@byte-write ((compose succ twice) 34)))
(let
(
(compose (fun (f)
(fun (x) (f x)))
)
)
((compose 1)))
;;((fun (x y z) #u) ;;((fun (x y z) #u)
;; (@byte-write 70) ;; (@byte-write 70)
......
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