1signature TEMP =
2sig
3  eqtype temp
4  val newtemp : unit -> temp
5  structure Table : TABLE sharing type Table.key = temp
6  val makestring: temp -> string
7  type label = Symbol.symbol
8  val newlabel : unit -> label
9  val namedlabel : string -> label
10end
11
12(* make this an abstraction sometime *)
13
14structure Temp : TEMP =
15struct
16    type temp = int
17    val temps = ref 100
18    fun newtemp() = let val t = !temps in temps := t+1; t end
19
20    structure Table = IntMapTable(type key = int
21                                  fun getInt n = n)
22
23    fun makestring t = "t" ^ Int.toString t
24
25    type label = Symbol.symbol
26
27    fun postinc x = let val i = !x in x := i+1; i end
28    val labs = ref 0
29
30    fun resetLabelIndex () = labs := 0
31
32    fun newlabel() = Symbol.newSymbol("L" ^ Int.toString (postinc labs))
33    val namedlabel = Symbol.newSymbol
34
35end
36