Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/instructions/labels.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/instructions/labels.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 430 - (view) (download)

1 : monnier 409 (* labels.sml
2 :     *
3 :     * COPYRIGHT (c) 1995 AT&T Bell Laboratories.
4 :     *
5 :     *)
6 :    
7 :     signature LABEL =
8 :     sig
9 : monnier 429 datatype label = Label of {id : int, addr : int ref, name:string}
10 : monnier 409
11 :     val newLabel : string -> label
12 :     val nameOf : label -> string
13 :     val id : label -> int
14 :     val addrOf : label -> int
15 :     val reset : unit -> unit
16 :     val setAddr : label * int -> unit
17 :     end
18 :    
19 :    
20 :     structure Label : LABEL =
21 :     struct
22 : monnier 429 datatype label = Label of {id:int, addr:int ref, name:string}
23 : monnier 409
24 :     val cnt = ref 0
25 :    
26 : monnier 429 fun newLabel name =
27 :     let val id = !cnt
28 :     in cnt := id + 1; Label{id=id, addr=ref ~1, name=name} end
29 :     fun nameOf(Label{id,name="",...}) = "LL" ^ Int.toString id
30 :     | nameOf(Label{name, ...}) = name
31 : monnier 409 fun id(Label{id,...}) = id
32 :     fun addrOf(Label{addr,...}) = !addr
33 :     fun setAddr(Label{addr,...},n) = addr := n
34 :     fun reset() = cnt := 0
35 :     end
36 :    
37 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0