aboutsummaryrefslogtreecommitdiff
path: root/Sjit/Compile.dcl
blob: 4bc1ed50c2dfc14860154bb614d8cdf798c9cc2c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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