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
24
tiger/chap7/temp.sml
Normal file
24
tiger/chap7/temp.sml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
(* make this an abstraction sometime *)
|
||||
structure Temp : TEMP =
|
||||
struct
|
||||
type temp = int
|
||||
val temps = ref 100
|
||||
fun newtemp() = let val t = !temps in temps := t+1; t end
|
||||
|
||||
structure Table = IntMapTable(type key = int
|
||||
fun getInt n = n)
|
||||
|
||||
fun makestring t = "t" ^ Int.toString t
|
||||
|
||||
type label = Symbol.symbol
|
||||
|
||||
local structure F = Format
|
||||
fun postinc x = let val i = !x in x := i+1; i end
|
||||
val labs = ref 0
|
||||
in
|
||||
fun newlabel() = Symbol.symbol(F.format "L%d" [F.INT(postinc labs)])
|
||||
val namedlabel = Symbol.symbol
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue