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/gatien-branch/compiler/Elaborator/srcinfo/query.sml
ViewVC logotype

Diff of /sml/branches/gatien-branch/compiler/Elaborator/srcinfo/query.sml

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

revision 3131, Wed Jul 23 19:00:55 2008 UTC revision 3132, Wed Jul 23 20:20:58 2008 UTC
# Line 60  Line 60 
60    
61  open Ens_types2 Ens_var2  open Ens_types2 Ens_var2
62    
63  type occurrence = symbol * location  type occurrence = S.symbol * location
64  (*  (*
65  type subject = OCC of occurrence | SYM of symbol | ???  type subject = OCC of occurrence | SYM of symbol | ???
66    
# Line 86  Line 86 
86      S.eq (sym,name) andalso List.exists (fn (loc',_,_) => eqLocation(loc', loc)) (!usage)      S.eq (sym,name) andalso List.exists (fn (loc',_,_) => eqLocation(loc', loc)) (!usage)
87    
88  fun findUse(loc: location, usage: varUse list) : varUse option =  fun findUse(loc: location, usage: varUse list) : varUse option =
89      List.find (fn (loc',ty,acc) => eqLocation(loc,loc'))      List.find (fn (loc',ty,acc) => eqLocation(loc,loc')) usage
90    
91    
92  (* sample query functions *)  (* sample query functions *)
93    
94  (* find defining occurrence for a (variable?) applied occurrence *)  (* find defining occurrence for a (variable?) applied occurrence *)
95  fun varDefOcc (occ : occurrence) : location option =  fun varDefOcc (occ : occurrence) : location option =
96      case findVar (occIsVar occ)      case find_var (occIsVar occ)
97       of SOME{def,...} => SOME def       of SOME{def,...} => SOME def
98        | NONE => NONE        | NONE => NONE
99    
100  (* find type of a (variable?) applied occurrence *)  (* find type of a (variable?) applied occurrence *)
101  fun varTypOcc (occ as (sym,loc): occurrence) : ty' option =  fun varTypOcc (occ as (sym,loc): occurrence) : ty' option =
102      case findVar (occIsVar occ)      case find_var (occIsVar occ)
103       of SOME{def,usage} =>       of SOME{def,usage, ...} =>
104            let val (_,ty,_) =  findUse(loc,!usage)          ( case findUse(loc,!usage)
105             in SOME ty             of SOME (_,ty,_) => SOME ty
106            end              | NONE => NONE
107            )
108        | NONE => NONE        | NONE => NONE
109    
110  end (* structure Queries *)  end (* structure Queries *)

Legend:
Removed from v.3131  
changed lines
  Added in v.3132

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