X-Git-Url: http://git.joshuawise.com/snipe.git/blobdiff_plain/12aa4087bee3e70f170d7457794921de4e385227..5c90fbb8681e975ccd0a1bc407b31daa1daef38a:/trans/temp.sml?ds=inline diff --git a/trans/temp.sml b/trans/temp.sml index 3f6c806..68de49c 100644 --- a/trans/temp.sml +++ b/trans/temp.sml @@ -1,4 +1,4 @@ -(* L1 Compiler +(* L3 Compiler * Temporaries * Author: Kaustuv Chaudhuri * Modified: Alex Vaynberg @@ -9,25 +9,27 @@ signature TEMP = sig type temp - val reset : unit -> unit (* resets temp numbering *) - val new : unit -> temp (* returns a unique new temp *) - val name : temp -> string (* returns the name of a temp *) + val reset : unit -> unit (* resets temp numbering *) + val new : string -> temp (* returns a unique new temp *) + val name : temp -> string (* returns the name of a temp *) val compare : temp * temp -> order (* comparison function *) + val eq : temp * temp -> bool end structure Temp :> TEMP = struct - type temp = int + type temp = int * string local val counter = ref 1 in (* warning: calling reset() may jeopardize uniqueness of temps! *) fun reset () = ( counter := 1 ) - fun new () = !counter before ( counter := !counter + 1 ) + fun new str = (!counter, str) before ( counter := !counter + 1 ) end - fun name t = "+t" ^ Int.toString t - - fun compare (t1,t2) = Int.compare (t1,t2) + fun name (t,s) = "+t" ^ Int.toString t ^ "[" ^ s ^ "]" + fun compare ((t1,_),(t2,_)) = Int.compare (t1,t2) + + fun eq ((t1,_), (t2,_)) = t1 = t2 end