--- /dev/null
+(* L2 Compiler
+ * Labeloraries
+ * Like temporaries, except more different
+ * Author: Joshua Wise <jwise@cs.cmu.edu>
+ *)
+
+signature LABEL =
+sig
+ type label
+
+ val reset : unit -> unit (* resets label numbering *)
+ val new : unit -> label (* returns a unique new label *)
+ val name : label -> string (* returns the name of a label *)
+ val compare : label * label -> order (* comparison function *)
+end
+
+structure Label :> LABEL =
+struct
+ type label = int
+
+ local
+ val counter = ref 1
+ in
+ (* warning: calling reset() may jeopardize uniqueness of labels! *)
+ fun reset () = ( counter := 1 )
+ fun new () = !counter before ( counter := !counter + 1 )
+ end
+
+ fun name t = ".L" ^ Int.toString t
+
+ fun compare (t1,t2) = Int.compare (t1,t2)
+end