1module IRTS.CodegenC where
10cname :: Name -> String
11cname n = "_idris_" ++ concatMap cchar (show n)
12 where cchar x | isAlpha x || isDigit x = [x]
13 | otherwise = "_" ++ show (fromEnum x) ++ "_"
15indent i = take (i * 4) (repeat ' ')
18creg (L i) = "LOC(" ++ show i ++ ")"
19creg (T i) = "TOP(" ++ show i ++ ")"
21toDecl :: Name -> String
22toDecl f = "void " ++ cname f ++ "(VM*, VAL*);\n"
24toC :: Name -> [BC] -> String
26 = -- "/* " ++ show code ++ "*/\n\n" ++
27 "void " ++ cname f ++ "(VM* vm, VAL* oldbase) {" ++
28 concatMap (bcc 1) code ++ "}\n\n"
30bcc :: Int -> BC -> String
31bcc i (ASSIGN l r) = indent i ++ creg l ++ " = " ++ creg r ++ ";\n"
33bcc i _ = indent i ++ "// not done yet\n"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list