X-Git-Url: http://git.joshuawise.com/snipe.git/blobdiff_plain/6ade8b0a3251e44b34c6bdbbd9403e36d6fd6231..1144856ba9d6018d9922c6ede7e97779a0fe6373:/trans/temp.sml diff --git a/trans/temp.sml b/trans/temp.sml index d370d99..1092dfc 100644 --- a/trans/temp.sml +++ b/trans/temp.sml @@ -10,26 +10,28 @@ sig type temp val reset : unit -> unit (* resets temp numbering *) - val new : string -> temp (* returns a unique new temp *) + val new : string -> int -> temp (* returns a unique new temp *) val name : temp -> string (* returns the name of a temp *) + val size : temp -> int (* returns the size of a temp *) val compare : temp * temp -> order (* comparison function *) val eq : temp * temp -> bool end structure Temp :> TEMP = struct - type temp = int * string + type temp = int * string * int local val counter = ref 1 in (* warning: calling reset() may jeopardize uniqueness of temps! *) fun reset () = ( counter := 1 ) - fun new str = (!counter, str) before ( counter := !counter + 1 ) + fun new str size = (!counter, str, size) before ( counter := !counter + 1 ) end - fun name (t,s) = "+t" ^ Int.toString t ^ "[" ^ s ^ "]" - fun compare ((t1,_),(t2,_)) = Int.compare (t1,t2) + fun name (t,s, sz) = "+t" ^ Int.toString t ^ "[" ^ s ^ "]" + fun size (t, s, sz) = sz + fun compare ((t1,_,_),(t2,_,_)) = Int.compare (t1,t2) - fun eq ((t1,_), (t2,_)) = t1 = t2 + fun eq ((t1,_,_), (t2,_,_)) = t1 = t2 end