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

SCM Repository

[smlnj] Diff of /sml/branches/SMLNJ/src/MLRISC/instructions/labels.sml
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/MLRISC/instructions/labels.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 428, Wed Sep 8 09:47:00 1999 UTC revision 429, Wed Sep 8 09:47:00 1999 UTC
# Line 6  Line 6 
6    
7  signature LABEL =  signature LABEL =
8    sig    sig
9      datatype label = Label of {id : int, addr : int ref, name:string option}      datatype label = Label of {id : int, addr : int ref, name:string}
10    
11      val newLabel : string -> label      val newLabel : string -> label
12      val nameOf   : label -> string      val nameOf   : label -> string
# Line 19  Line 19 
19    
20  structure Label : LABEL =  structure Label : LABEL =
21    struct    struct
22      datatype label = Label of {id:int, addr:int ref, name:string option}      datatype label = Label of {id:int, addr:int ref, name:string}
23    
24      val cnt                        = ref 0      val cnt                        = ref 0
25    
26      fun new name                   = Label{id= !cnt, addr=ref 0, name=name}      fun newLabel name =
27                                          before (cnt := !cnt + 1)      let val id = !cnt
28      fun newLabel ""                = new NONE      in  cnt := id + 1; Label{id=id, addr=ref ~1, name=name} end
29        | newLabel name              = new(SOME name)      fun nameOf(Label{id,name="",...})   = "LL" ^ Int.toString id
30      fun nameOf(Label{id,name=NONE,...})   = "LL" ^ Int.toString id        | nameOf(Label{name, ...}) = name
       | nameOf(Label{name=SOME lab, ...}) = lab  
31      fun id(Label{id,...})          = id      fun id(Label{id,...})          = id
32      fun addrOf(Label{addr,...})    = !addr      fun addrOf(Label{addr,...})    = !addr
33      fun setAddr(Label{addr,...},n) = addr := n      fun setAddr(Label{addr,...},n) = addr := n

Legend:
Removed from v.428  
changed lines
  Added in v.429

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