Changeset 4864
- Timestamp:
- Nov 10, 2015, 7:44:20 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
proto/pabloH/pabloc1.hs
r4863 r4864 5 5 import System.IO (stdout,stderr,hPutStr,hPutStrLn) 6 6 import Control.Monad 7 8 7 9 8 compileBinary :: (String, Int, PabloE, PabloE, Operator) -> (Int, [PabloInstruction], Operand) … … 40 39 IRvar(t4)) 41 40 41 replaceOrAssignTarget(targetVar, (n, [], v)) = (n, [IRassign(targetVar, v)]) 42 replaceOrAssignTarget(targetVar, (n, instrs, v)) = 43 case (last instrs) of 44 Binary(temp, op, e1, e2) -> (n-1, (init instrs) ++ [Binary(targetVar, op, e1, e2)]) 45 _ -> (n, instrs ++ [IRassign(targetVar, v)]) 46 42 47 compileAssigns :: (String, Int, [PabloS]) -> (Int, [PabloInstruction]) 43 48 compileAssigns (pfx, n, []) = (n, []) 44 49 compileAssigns (pfx, n, Assign(varname, e) : more) = 45 let (n1, instrs , v) = compileE(pfx, n, e)50 let (n1, instrs) = replaceOrAssignTarget(varname, compileE(pfx, n, e)) 46 51 (n2, moreInstrs) = compileAssigns(pfx, n1, more) 47 in (n2, instrs ++ (IRassign(varname, v) : moreInstrs))52 in (n2, instrs ++ moreInstrs) 48 53 49 54 isAssign (Assign(v,e)) = True … … 76 81 in (n4, block1 : block2 : (repeatIR ++ afterIR)) 77 82 78 79 83 compileMain stmts = 80 84 let (n, compiled) = compileStmts("tmp", 0, "entry", Ret, stmts)
Note: See TracChangeset
for help on using the changeset viewer.