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/trunk/compiler/FLINT/main/literals.sml
ViewVC logotype

Diff of /sml/trunk/compiler/FLINT/main/literals.sml

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

revision 251, Mon Apr 19 02:55:26 1999 UTC revision 422, Sun Sep 5 22:49:38 1999 UTC
# Line 184  Line 184 
184    
185  exception LitInfo  exception LitInfo
186    
187  datatype rlit = RLIT of string * int  datatype rlit = RLIT of string * word
188  fun toRlit s = RLIT(s, StrgHash.hashString s)  fun toRlit s = RLIT(s, HashString.hashString s)
189  fun fromRlit (RLIT(s, _)) = s  fun fromRlit (RLIT(s, _)) = s
190  fun rlitcmp (RLIT(s1,i1), RLIT(s2,i2)) =  fun rlitcmp (RLIT(s1,i1), RLIT(s2,i2)) =
191    if i1 < i2 then LESS    if i1 < i2 then LESS
192    else if i1 > i2 then GREATER else String.compare(s1, s2)    else if i1 > i2 then GREATER else String.compare(s1, s2)
193  structure RlitDict = BinaryDict(struct type ord_key = rlit  structure RlitDict = BinaryMapFn(struct type ord_key = rlit
194                                         val cmpKey = rlitcmp                                         val compare = rlitcmp
195                                  end)                                  end)
196    
197  (* lifting all literals from a CPS program *)  (* lifting all literals from a CPS program *)
# Line 219  Line 219 
219        (* register a string literal *)        (* register a string literal *)
220        local val strs : string list ref = ref []        local val strs : string list ref = ref []
221              val strsN : int ref = ref 0              val strsN : int ref = ref 0
222              val sdict = ref (RlitDict.mkDict())              val sdict = ref (RlitDict.empty)
223              val srtv = mkv()              val srtv = mkv()
224              val srtval = VAR srtv              val srtval = VAR srtv
225        in        in
# Line 228  Line 228 
228              val sd = !sdict              val sd = !sdict
229              val rlit = toRlit s              val rlit = toRlit s
230              val n =              val n =
231                (case RlitDict.peek(sd, rlit)                (case RlitDict.find(sd, rlit)
232                  of SOME k => k                  of SOME k => k
233                   | _ => let val _ = (strs := (s :: (!strs)))                   | _ => let val _ = (strs := (s :: (!strs)))
234                              val k = !strsN                              val k = !strsN
# Line 266  Line 266 
266        (** a special treatment of real constants *)        (** a special treatment of real constants *)
267        local val reals : string list ref = ref []        local val reals : string list ref = ref []
268              val realsN : int ref = ref 0              val realsN : int ref = ref 0
269              val rdict = ref (RlitDict.mkDict())              val rdict = ref (RlitDict.empty)
270              val rrtv = mkv()              val rrtv = mkv()
271              val rrtval = VAR rrtv              val rrtval = VAR rrtv
272        in        in
# Line 275  Line 275 
275              val rd = !rdict              val rd = !rdict
276              val rlit = toRlit s              val rlit = toRlit s
277              val n =              val n =
278                (case RlitDict.peek(rd, rlit)                (case RlitDict.find(rd, rlit)
279                  of SOME k => k                  of SOME k => k
280                   | _ => let val _ = (reals := (s :: (!reals)))                   | _ => let val _ = (reals := (s :: (!reals)))
281                              val k = !realsN                              val k = !realsN
# Line 467  Line 467 
467  end (* toplevel local *)  end (* toplevel local *)
468  end (* Literals *)  end (* Literals *)
469    
 (*  
  * $Log$  
  *)  
   

Legend:
Removed from v.251  
changed lines
  Added in v.422

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