diff options
author | Camil Staps | 2018-12-24 14:40:24 +0100 |
---|---|---|
committer | Camil Staps | 2018-12-24 14:40:24 +0100 |
commit | 4d24cd1e3c8a35df8ea872dda22f431b46c3c64f (patch) | |
tree | 5ed2940fe858ddf8d0f72e8a685ff0578de5f862 /Sjit/Compile.dcl | |
parent | Fix compilation for constant functions (allocate space for return value) (diff) |
Divide in modules
Diffstat (limited to 'Sjit/Compile.dcl')
-rw-r--r-- | Sjit/Compile.dcl | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Sjit/Compile.dcl b/Sjit/Compile.dcl new file mode 100644 index 0000000..4bc1ed5 --- /dev/null +++ b/Sjit/Compile.dcl @@ -0,0 +1,44 @@ +definition module Sjit.Compile + +from Data.Map import :: Map +from Data.Maybe import :: Maybe +from Sjit.Syntax import :: Function + +:: Instr + = PushRef !Int + | PushI !Int + | Put !Int + | Pop !Int + + | Call !Int + | Ret + | Halt + + | IAddRet + | IMulRet + | ISubRet + | IDivRet + +:: Program :== {!Instr} + +:: CompileState = + { vars :: !Map String Int + , funs :: !Map String Int + , sp :: !Int + , pc :: !Int + , blocks :: ![!Program!] + , jitst :: !JITState + } + +:: JITState = + { n_instr :: !Int + , code_start :: !Int + , code_len :: !Int + , code_ptr :: !Int + , mapping :: !Int + } + +appendProgram :: !Bool !Program !JITState -> JITState +bootstrap :: (!Program, !CompileState) +compile :: !Function !CompileState -> CompileState +compile_all :: !(Maybe CompileState) ![Function] -> CompileState |