Add the tiger source code bundle from the book site
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
915660c8a7
commit
33d8bac511
87 changed files with 3252 additions and 0 deletions
58
tiger/chap7/tree.sml
Normal file
58
tiger/chap7/tree.sml
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
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 | LSHIFT | RSHIFT | ARSHIFT | XOR
|
||||
|
||||
and relop = EQ | NE | LT | GT | LE | GE
|
||||
| ULT | ULE | UGT | UGE
|
||||
|
||||
val notRel : relop -> relop
|
||||
val commute: 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 | LSHIFT | RSHIFT | ARSHIFT | XOR
|
||||
|
||||
and relop = EQ | NE | LT | GT | LE | GE
|
||||
| ULT | ULE | UGT | UGE
|
||||
|
||||
end
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue