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/src/compiler/FLINT/flint/flintutil.sml
ViewVC logotype

Diff of /sml/trunk/src/compiler/FLINT/flint/flintutil.sml

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

revision 423, Mon Sep 6 02:32:11 1999 UTC revision 489, Tue Nov 23 12:55:00 1999 UTC
# Line 214  Line 214 
214  fun freevars lexp = let  fun freevars lexp = let
215      val loop = freevars      val loop = freevars
216    
217        fun S_rmv(x, s) = S.delete(s, x) handle NotFound => s
218    
219      fun addv (s,F.VAR lv) = S.add(s, lv)      fun addv (s,F.VAR lv) = S.add(s, lv)
220        | addv (s,_) = s        | addv (s,_) = s
221      fun addvs (s,vs) = foldl (fn (v,s) => addv(s, v)) s vs      fun addvs (s,vs) = foldl (fn (v,s) => addv(s, v)) s vs
222      fun rmvs (s,lvs) = foldl (fn (l,s) => S.delete (s, l)) s lvs      fun rmvs (s,lvs) = foldl (fn (l,s) => S_rmv (l, s)) s lvs
223      fun singleton (F.VAR v) = S.singleton v      fun singleton (F.VAR v) = S.singleton v
224        | singleton _ = S.empty        | singleton _ = S.empty
225    
# Line 237  Line 239 
239                     (loop le) fdecs),                     (loop le) fdecs),
240              map #2 fdecs)              map #2 fdecs)
241       | F.APP (f,args) => addvs(S.empty, f::args)       | F.APP (f,args) => addvs(S.empty, f::args)
242       | F.TFN ((tfk,f,args,body),le) => S.union(S.delete(loop le, f), loop body)       | F.TFN ((tfk,f,args,body),le) => S.union(S_rmv(f, loop le), loop body)
243       | F.TAPP (f,args) => singleton f       | F.TAPP (f,args) => singleton f
244       | F.SWITCH (v,ac,arms,def) =>       | F.SWITCH (v,ac,arms,def) =>
245         let fun farm ((dc,le),fv) =         let fun farm ((dc,le),fv) =
246                 let val fvle = loop le                 let val fvle = loop le
247                 in S.union(fv,                 in S.union(fv,
248                            case dc                            case dc
249                             of F.DATAcon(dc,_,lv) => fdcon(S.delete(fvle, lv),dc)                             of F.DATAcon(dc,_,lv) => fdcon(S_rmv(lv, fvle),dc)
250                              | _ => fvle)                              | _ => fvle)
251                 end                 end
252             val fvs = case def of NONE => singleton v             val fvs = case def of NONE => singleton v
253                                 | SOME le => addv(loop le, v)                                 | SOME le => addv(loop le, v)
254         in foldl farm fvs arms         in foldl farm fvs arms
255         end         end
256       | F.CON (dc,tycs,v,lv,le) => fdcon(addv(S.delete(loop le, lv), v),dc)       | F.CON (dc,tycs,v,lv,le) => fdcon(addv(S_rmv(lv, loop le), v),dc)
257       | F.RECORD (rk,vs,lv,le) => addvs(S.delete(loop le, lv), vs)       | F.RECORD (rk,vs,lv,le) => addvs(S_rmv(lv, loop le), vs)
258       | F.SELECT (v,i,lv,le) => addv(S.delete(loop le, lv), v)       | F.SELECT (v,i,lv,le) => addv(S_rmv(lv, loop le), v)
259       | F.RAISE (v,ltys) => singleton v       | F.RAISE (v,ltys) => singleton v
260       | F.HANDLE (le,v) => addv(loop le, v)       | F.HANDLE (le,v) => addv(loop le, v)
261       | F.BRANCH (po,vs,le1,le2) => fpo(addvs(S.union(loop le1, loop le2), vs), po)       | F.BRANCH (po,vs,le1,le2) => fpo(addvs(S.union(loop le1, loop le2), vs), po)
262       | F.PRIMOP (po,vs,lv,le) => fpo(addvs(S.delete(loop le, lv), vs),po)       | F.PRIMOP (po,vs,lv,le) => fpo(addvs(S_rmv(lv, loop le), vs),po)
263  end  end
264    
265  end (* top-level local *)  end (* top-level local *)

Legend:
Removed from v.423  
changed lines
  Added in v.489

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