]> Joshua Wise's Git repositories - snipe.git/blame_incremental - trans/temp.sml
Add cast syntax.
[snipe.git] / trans / temp.sml
... / ...
CommitLineData
1(* L3 Compiler
2 * Temporaries
3 * Author: Kaustuv Chaudhuri <kaustuv+@cs.cmu.edu>
4 * Modified: Alex Vaynberg <alv@andrew.cmu.edu>
5 * Modified: Frank Pfenning <fp@cs.cmu.edu>
6 *)
7
8signature TEMP =
9sig
10 type temp
11
12 val reset : unit -> unit (* resets temp numbering *)
13 val new : string -> temp (* returns a unique new temp *)
14 val name : temp -> string (* returns the name of a temp *)
15 val compare : temp * temp -> order (* comparison function *)
16 val eq : temp * temp -> bool
17end
18
19structure Temp :> TEMP =
20struct
21 type temp = int * string
22
23 local
24 val counter = ref 1
25 in
26 (* warning: calling reset() may jeopardize uniqueness of temps! *)
27 fun reset () = ( counter := 1 )
28 fun new str = (!counter, str) before ( counter := !counter + 1 )
29 end
30
31 fun name (t,s) = "+t" ^ Int.toString t ^ "[" ^ s ^ "]"
32 fun compare ((t1,_),(t2,_)) = Int.compare (t1,t2)
33
34 fun eq ((t1,_), (t2,_)) = t1 = t2
35end
This page took 0.025574 seconds and 4 git commands to generate.