aboutsummaryrefslogtreecommitdiff
path: root/Sjit/Compile.dcl
diff options
context:
space:
mode:
Diffstat (limited to 'Sjit/Compile.dcl')
-rw-r--r--Sjit/Compile.dcl44
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