Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/high-il/rewrite-ein.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/high-il/rewrite-ein.sml

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

revision 2399, Sun Jul 7 02:22:44 2013 UTC revision 2400, Sun Jul 7 13:29:54 2013 UTC
# Line 6  Line 6 
6    
7  structure Rewrite : sig  structure Rewrite : sig
8    
   
   
9  (* should be  (* should be
10      val evalEinApp : Ein.ein * HighIL.var list -> (Ein.ein * HighIL.var list) option      val evalEinApp : Ein.ein * HighIL.var list -> (Ein.ein * HighIL.var list) option
11  *)  *)
    (* datatype arg  
       = Var of Var.var  
    | App of Ein.ein * Var.var list  
   
   
     val evalEinApp : Ein.ein * arg list -> Ein.ein * Var.var list  
 *)  
   
   
   
 end = struct  
   
 structure IL = HighIL  
   
12  datatype arg  datatype arg
13  = Var of IL.var list        = Var of VarEin.var
14  | App of Ein.ein * IL.var list        | App of Ein.ein * VarEin.var list
15    
16  (*val evalEinApp : Ein.ein * arg list -> Ein.ein * IL.var list      val evalEinApp : Ein.ein * arg list -> Ein.ein * VarEin.var list
 *)  
17    
18      end = struct
19    
20      structure VarMap = Var.Map      structure VarMap =  VarEin.Map
21    
22      fun mkAdd es = (      fun mkAdd es = (
23            case List.filter            case List.filter
# Line 46  Line 30 
30            (* end case *))            (* end case *))
31    
32      datatype arg      datatype arg
33        = Var of Var.var        = Var of  VarEin.var
34        | App of Ein.ein * Var.var list        | App of Ein.ein *  VarEin.var list
35    
36    (* apply a substitution to an ein_exp ID*)    (* apply a substitution to an ein_exp ID*)
37      fun instantiateIdx body ids = let      fun instantiateIdx body ids = let
# Line 120  Line 104 
104      fun evalEinApp (Ein.EIN{params, index, body}, args : arg list) = let      fun evalEinApp (Ein.EIN{params, index, body}, args : arg list) = let
105            fun renameVars ([], [], nT, nF, uniqueArgs) = (nT, nF, List.rev uniqueArgs)            fun renameVars ([], [], nT, nF, uniqueArgs) = (nT, nF, List.rev uniqueArgs)
106              | renameVars (param::params, arg::args, nT, nF, uniqueArgs) = let              | renameVars (param::params, arg::args, nT, nF, uniqueArgs) = let
107                  fun isUnique (x, uArgs) = not(List.exists (fn (y, _, _) => Var.same(x, y)) uArgs)                  fun isUnique (x, uArgs) = not(List.exists (fn (y, _, _) =>  VarEin.same(x, y)) uArgs)
108                  fun continue (nT, nF, uniqueArgs) = renameVars (params, args, nT, nF, uniqueArgs)                  fun continue (nT, nF, uniqueArgs) = renameVars (params, args, nT, nF, uniqueArgs)
109                  fun doVar (p, x, nT, nF, uArgs) = (case p                  fun doVar (p, x, nT, nF, uArgs) = (case p
110                         of Ein.TEN =>                         of Ein.TEN =>
# Line 163  Line 147 
147                    | SOME(Ein.FLD, id) => (                    | SOME(Ein.FLD, id) => (
148                        bindField(subst, nF, fn mx => Ein.Field(id, mx));                        bindField(subst, nF, fn mx => Ein.Field(id, mx));
149                        (nT, nF+1))                        (nT, nF+1))
150                    | NONE => raise Fail(concat["undefined argument variable \"", Var.name x, "\""])                    | NONE => raise Fail(concat["undefined argument variable \"",  VarEin.name x, "\""])
151                  (* end case *))                  (* end case *))
152          (* rewrite arguments and intialize the top-level substitution *)          (* rewrite arguments and intialize the top-level substitution *)
153            fun rewriteArgs ([], [], _, _) = ()            fun rewriteArgs ([], [], _, _) = ()

Legend:
Removed from v.2399  
changed lines
  Added in v.2400

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