]> Joshua Wise's Git repositories - snipe.git/blame - trans/temp.sml
Initial import of l4c
[snipe.git] / trans / temp.sml
CommitLineData
6ade8b0a 1(* L3 Compiler
12aa4087
JW
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 *)
1144856b 13 val new : string -> int -> temp (* returns a unique new temp *)
12aa4087 14 val name : temp -> string (* returns the name of a temp *)
1144856b 15 val size : temp -> int (* returns the size of a temp *)
12aa4087 16 val compare : temp * temp -> order (* comparison function *)
6ade8b0a 17 val eq : temp * temp -> bool
12aa4087
JW
18end
19
20structure Temp :> TEMP =
21struct
1144856b 22 type temp = int * string * int
12aa4087
JW
23
24 local
25 val counter = ref 1
26 in
27 (* warning: calling reset() may jeopardize uniqueness of temps! *)
28 fun reset () = ( counter := 1 )
1144856b 29 fun new str size = (!counter, str, size) before ( counter := !counter + 1 )
12aa4087
JW
30 end
31
1144856b
JW
32 fun name (t,s, sz) = "+t" ^ Int.toString t ^ "[" ^ s ^ "]"
33 fun size (t, s, sz) = sz
34 fun compare ((t1,_,_),(t2,_,_)) = Int.compare (t1,t2)
6ade8b0a 35
1144856b 36 fun eq ((t1,_,_), (t2,_,_)) = t1 = t2
12aa4087 37end
This page took 0.026096 seconds and 4 git commands to generate.