]> Joshua Wise's Git repositories - snipe.git/blame - trans/label.sml
Code generation.
[snipe.git] / trans / label.sml
CommitLineData
6ade8b0a 1(* L3 Compiler
0a24e44d
JW
2 * Labeloraries
3 * Like temporaries, except more different
4 * Author: Joshua Wise <jwise@cs.cmu.edu>
5 *)
6
7signature LABEL =
8sig
9 type label
10
11 val reset : unit -> unit (* resets label numbering *)
12 val new : unit -> label (* returns a unique new label *)
13 val name : label -> string (* returns the name of a label *)
14 val compare : label * label -> order (* comparison function *)
15end
16
17structure Label :> LABEL =
18struct
19 type label = int
20
21 local
22 val counter = ref 1
23 in
24 (* warning: calling reset() may jeopardize uniqueness of labels! *)
25 fun reset () = ( counter := 1 )
26 fun new () = !counter before ( counter := !counter + 1 )
27 end
28
29 fun name t = ".L" ^ Int.toString t
30
31 fun compare (t1,t2) = Int.compare (t1,t2)
32end
This page took 0.029303 seconds and 4 git commands to generate.