commit - 1254ececec090d507654c83649160818a242515a
commit + 2b2bebb21a0f7fe854a1a4647057b51ff5ce279d
blob - 6f04f56e44697153584a1dfa23f2cde8c39ba6da
blob + 19e46ee5cdc05c1695cb70ddd5264064efe6e4f2
--- bfc.hs
+++ bfc.hs
-- even if it's a SSA.
cell = 1
-compile' :: Int -> Int -> [AST] -> [[Instruction]] -> [Instruction]
+compile' :: Int -> Int -> [AST] -> [Int] -> [Instruction]
compile' n h ((x:xs):ys) trail =
case x of
Inc -> LoadL(n+1, cell) :
LoadW(n+2, n+1) :
Jnz(n+2, h+1, h+2) :
Label(h+1) :
- compile' (n+3) (h+3) (ast:(xs:ys)) newtrail
- where newtrail = ([Jmp(h), Label(h+2)]:trail)
-compile' n h ([]:ys) (t:ts) = t ++ (compile' n h ys ts)
+ compile' (n+3) (h+3) (ast:(xs:ys)) (h:trail)
+compile' n h ([]:ys) (t:ts) = Jmp(t) : Label(t+2) : compile' n h ys ts
compile' _ _ _ _ = []
compile ast = compile' 1 1 [ast] []