-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimp.ml
More file actions
46 lines (38 loc) · 972 Bytes
/
imp.ml
File metadata and controls
46 lines (38 loc) · 972 Bytes
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
45
type binop =
| Add | Sub | Mul
| Lt | Le | Ge | Gt
| Eq | Neq
| And | Or
type unop = Neg | Not
type expression =
| Char of int
| Cst of int
| Bool of bool
| Var of string
| Unop of unop * expression
| Binop of binop * expression * expression
| Call of string * expression list
| DCall of expression * expression list
| Deref of expression * Op.mem_size
| Alloc of expression
| Addr of string
type instruction =
| Putchar of expression
| Set of string * expression
| If of expression * sequence * sequence
| While of expression * sequence
| Return of expression
| Expr of expression
| Write of expression * Op.mem_size * expression
and sequence = instruction list
type function_def = {
name: string;
params: string list;
locals: string list;
code: sequence;
}
type program = {
globals: string list;
static : Op.static list;
functions: function_def list;
}