]> Joshua Wise's Git repositories - snipe.git/blobdiff - trans/temp.sml
Initial import of l3c
[snipe.git] / trans / temp.sml
index 13411f1ab76e16c38a986059439f3a45802009a7..d370d99ccd470eb1c341697127bc7bf49e56996f 100644 (file)
@@ -1,4 +1,4 @@
-(* L2 Compiler
+(* L3 Compiler
  * Temporaries
  * Author: Kaustuv Chaudhuri <kaustuv+@cs.cmu.edu>
  * Modified: Alex Vaynberg <alv@andrew.cmu.edu>
@@ -10,24 +10,26 @@ sig
   type temp
 
   val reset : unit -> unit     (* resets temp numbering *)
-  val new : unit -> temp       (* returns a unique new temp *)
+  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
This page took 0.02646 seconds and 4 git commands to generate.