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/normalize.sml
ViewVC logotype

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

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

revision 2869, Thu Feb 12 16:14:22 2015 UTC revision 2870, Wed Feb 25 21:47:43 2015 UTC
# Line 62  Line 62 
62          |_=>NONE          |_=>NONE
63      (* end case *))      (* end case *))
64    
65      val testing=0      val testing=1
66      fun testp e=(case testing      fun testp e=(case testing
67          of 1 => (print(String.concat e);1)          of 1 => (print(String.concat e);1)
68          | _ => 1          | _ => 1
# Line 71  Line 71 
71      (*doNormalize:EIN->EIN      (*doNormalize:EIN->EIN
72      * Orders EIN, normalizes it, then cleans the summation      * Orders EIN, normalizes it, then cleans the summation
73      *)      *)
74      fun doNormalize e=let      fun doNormalize(e,args)=let
75          val _ = testp ["\n in do Normalize"]          val _ = testp ["\n in do Normalize"]
76          val ordered=Order.orderfn e          val ordered=Order.orderfn e
77          val (n,change)=NE.normalize ordered          val (n,change)=NE.normalize(ordered,args)
78          val e'=S.cleanSummation n          val e'=S.cleanSummation n
79          val _  =testp ["original \n =>\n",P.printerE(e),"\n Ordered:\n",P.printerE(ordered),"\n normalized\n=>",P.printerE(n),"\n Move Sums \n =>", P.printerE(e')]          val _  =testp ["original \n =>\n",P.printerE(e),"\n Ordered:\n",P.printerE(ordered),"\n normalized\n=>",P.printerE(n),"\n Move Sums \n =>", P.printerE(e')]
80          in          in
# Line 89  Line 89 
89      fun foundEin(paramCount,place,change,newE,newArgs,done,newEinApp,orig,lhs)= (case (List.nth(paramCount, place))      fun foundEin(paramCount,place,change,newE,newArgs,done,newEinApp,orig,lhs)= (case (List.nth(paramCount, place))
90          of Ein.TEN(0,_)=> (change,orig, place+1,  done@[newEinApp])          of Ein.TEN(0,_)=> (change,orig, place+1,  done@[newEinApp])
91          | _ => let          | _ => let
92              val (c,subst)=App.app(orig,place,newE)              val rtnArgs=done@newArgs
93                val (c,subst)=App.app(orig,place,newE,newArgs,done)
94                val a=String.concatWith " , " (List.map V.toString newArgs)
95                val b=String.concatWith " , " (List.map V.toString done)
96                val r=String.concatWith " , " (List.map V.toString rtnArgs)
97    
98              val _ = testp["\n Apply at ", Int.toString(place),":--",P.printerE(newE),              val _ = testp["\n Apply at ", Int.toString(place),":--",P.printerE(newE),
99                    "\nArgs:",b,"\n newArgs:",a,"\nrtnArgs:",r,
100                      "\n","Subst Result:\t", P.printerE(subst), "\n"]                      "\n","Subst Result:\t", P.printerE(subst), "\n"]
101              in (case c              in (case c
102                  of 0 => (1,subst, place+length(newArgs), done@newArgs)                  of 0 => (1,subst, place+length(newArgs), rtnArgs)
103                  |_ => (use lhs;(*decUse e;*)(1,subst, place+length(newArgs), done@newArgs))                  |_ => (use lhs;(1,subst, place+length(newArgs), rtnArgs))
104                  (*end case*))                  (*end case*))
105              end              end
106          (*end case*))          (*end case*))
# Line 109  Line 115 
115      fun doRHS (lhs, IL.EINAPP (ein, args))=let      fun doRHS (lhs, IL.EINAPP (ein, args))=let
116          val _ = testp ["\n\n**************************\n\n\n",V.toString  lhs,"=="," ---Current: ", P.printerE(ein), (String.concatWith "," (List.map V.toString args))]          val _ = testp ["\n\n**************************\n\n\n",V.toString  lhs,"=="," ---Current: ", P.printerE(ein), (String.concatWith "," (List.map V.toString args))]
117          fun rewrite(0,_,_, [], _)= NONE          fun rewrite(0,_,_, [], _)= NONE
118              | rewrite(_,orig,_, [], args')= SOME[(lhs,IL.EINAPP((doNormalize orig), args'))]              | rewrite(_,orig,_, [], args')= SOME[(lhs,IL.EINAPP(doNormalize(orig,args'), args'))]
119              | rewrite(change,orig, place, e::es,args')=(case (isEin e)              | rewrite(change,orig, place, e::es,args')=(case (isEin e)
120                  of NONE => rewrite(change,orig, place+1, es, args'@[e])                  of NONE => rewrite(change,orig, place+1, es, args'@[e])
121                  | SOME(IL.EINAPP (newE,newA))=> let                  | SOME(IL.EINAPP (newE,newA))=> let
122    
123                      val Ein.EIN{params, index, body}=orig                      val Ein.EIN{params, index, body}=orig
124                      val (change',e',place',done')=foundEin(params,place,change,newE,newA,args',e,orig,lhs)                      val (change',e',place',done')=foundEin(params,place,change,newE,newA,args',e,orig,lhs)
125                      in rewrite(change',e',place',es,done')                      in rewrite(change',e',place',es,done')

Legend:
Removed from v.2869  
changed lines
  Added in v.2870

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