-
Notifications
You must be signed in to change notification settings - Fork 1
/
tree.sml
66 lines (55 loc) · 1.59 KB
/
tree.sml
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
signature TREE =
sig
type label = Temp.label
type size
datatype stm = SEQ of stm * stm
| LABEL of label
| JUMP of exp * label list
| CJUMP of relop * exp * exp * label * label
| MOVE of exp * exp
| EXP of exp
and exp = BINOP of binop * exp * exp
| MEM of exp
| TEMP of Temp.temp
| ESEQ of stm * exp
| NAME of label
| CONST of int
| CALL of exp * exp list
and binop = PLUS | MINUS | MUL | DIV
| AND | OR | XOR | LSHIFT | RSHIFT | ARSHIFT
and relop = EQ | NE | LT | GT | LE | GE
| ULT | ULE | UGT | UGE
val notRel : relop -> relop
end
structure Tree : TREE =
struct
type label = Temp.label
type size = int
datatype stm = SEQ of stm * stm
| LABEL of label
| JUMP of exp * label list
| CJUMP of relop * exp * exp * label * label
| MOVE of exp * exp
| EXP of exp
and exp = BINOP of binop * exp * exp
| MEM of exp
| TEMP of Temp.temp
| ESEQ of stm * exp
| NAME of label
| CONST of int
| CALL of exp * exp list
and binop = PLUS | MINUS | MUL | DIV
| AND | OR | XOR | LSHIFT | RSHIFT | ARSHIFT
and relop = EQ | NE | LT | GT | LE | GE
| ULT | ULE | UGT | UGE
fun notRel EQ = NE
| notRel NE = EQ
| notRel LT = GE
| notRel GT = LE
| notRel LE = GT
| notRel GE = LT
| notRel ULT = UGE
| notRel ULE = UGT
| notRel UGT = ULE
| notRel UGE = ULT
end