- Timestamp:
- 09/14/08 22:33:49 (3 months ago)
- Files:
-
- 1 modified
-
v6/smop/m0ld/M0ld.hs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
v6/smop/m0ld/M0ld.hs
r22244 r22245 272 272 ++ "})" 273 273 274 prettyPrintBytecode stmts = 274 prettyPrintConstant :: [Char] -> Value -> [Char] 275 prettyPrintConstant indent value = indent ++ case value of 276 StringConstant str -> (show str) ++ "\n" 277 IntegerConstant int -> (show int) ++ "\n" 278 None -> "" 279 Var name -> "¢" ++ name ++ "\n" 280 SubMold stmts -> "{\n" ++ (prettyPrintBytecode (" " ++ indent) stmts) ++ indent ++ "}\n" 281 prettyPrintBytecode indent stmts = 275 282 let labelsMap = mapLabels stmts 276 283 regMap = mapRegisters stmts 277 284 freeRegs = countRegister stmts 278 285 prettyPrintOp (Decl _ _) = "" 279 prettyPrintOp op = (joinStr " " $ ( map show (toBytecode op regMap labelsMap))) ++ "\n" 280 in concat $ map prettyPrintOp stmts 286 prettyPrintOp op = indent ++ (joinStr " " $ ( map show (toBytecode op regMap labelsMap))) ++ "\n" 287 decls = [prettyPrintConstant indent c | Decl reg c <- filter (not . isReg) stmts] 288 in (concat $ map (\(i,e) -> indent ++ "$" ++ (show i) ++ " = " ++ e) (zip [0..(length decls - 1)] decls)) ++ 289 (concat $ map prettyPrintOp stmts) 281 290 282 291 type ImplicitDecls = Map.Map Value [Char] … … 293 302 Left err -> error $ show err 294 303 Right (stmts,constants) -> do 295 if elem "print-bytecode" options then putStrLn $ prettyPrintBytecode $ (implicitDecls constants) ++ stmts304 if elem "print-bytecode" options then putStrLn $ prettyPrintBytecode "" $ (implicitDecls constants) ++ stmts 296 305 else putStrLn $ dumpToC $ (implicitDecls constants) ++ stmts
