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

remove rewriteIndex, no longer needed

parent 2e2e0a17
......@@ -151,12 +151,14 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
case L3.BlockSet =>
val block = rewrite(x)
val value = rewrite(z)
rewriteIndex(y) {idx => L.LetP(n, CPS.BlockSet, Seq(block, idx, value), apply(body))}
tempLetP(CPS.ShiftRight, Seq(Left(y), Right(L.AtomL(1)))){idx =>
L.LetP(n, CPS.BlockSet, Seq(block, idx, value), apply(body))
}
case L3.BlockGet =>
val block = rewrite(x)
rewriteIndex(y){idx => L.LetP(n, CPS.BlockGet, Seq(block, idx), apply(body))}
tempLetP(CPS.ShiftRight, Seq(Left(y), Right(L.AtomL(1)))){
idx => L.LetP(n, CPS.BlockGet, Seq(block, idx), apply(body))
}
case L3.ByteRead =>
tempLetP(CPS.ByteRead, Seq()){ t1 =>
tempLetP(CPS.ShiftLeft, Seq(Right(t1), lAtomOne)) { t2 =>
......@@ -206,11 +208,4 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
L.AtomL(0x0a) // 01010
case H.AtomL(UnitLit) => L.AtomL(2)
}
private def rewriteIndex(idx: H.Atom)(cont: L.Atom => L.LetP): L.LetP = idx match {
case H.AtomN(n) =>
tempLetP(CPS.ShiftRight, Seq(Left(idx), Right(L.AtomL(1))))(cont)
case H.AtomL(IntLit(i)) => cont(L.AtomL(i.toInt))
case _ => throw new Exception(f"Cannot rewrite atom {idx} which is not Name or Int Literal")
}
}
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