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 2826, Mon Nov 10 21:06:46 2014 UTC revision 2827, Tue Nov 11 00:18:38 2014 UTC
# Line 69  Line 69 
69      (* end case *))      (* end case *))
70    
71    
72  val testing=1  val testing=0
73    fun testp e=(case testing
74        of 1 => (print(String.concat e);1)
75        | _ => 1
76    (*end case*))
77    
78    
79  fun doNormalize e=let  fun doNormalize e=let
80      val _ =print "\n in do Normalize"      val _ = testp ["\n in do Normalize"]
81      val ordered=Order.orderfn(e)      val ordered=Order.orderfn e
82      val (n,change)=NE.normalize(ordered)      val (n,change)=NE.normalize ordered
83      val e'=S.cleanSummation(n)      val e'=S.cleanSummation n
84      in (case testing      val _  =testp ["\n Ordered:\n",P.printerE(ordered),"\n =>",P.printerE(n),"\n Move Sums \n =>", P.printerE(e')]
85          of 0 => e'      in
86          | _  => (print(String.concat ["\n Ordered:\n",P.printerE(ordered),"\n =>",P.printerE(n),"\n Move Sums \n =>", P.printerE(e')]);e')          e'
         (*end case*))  
87      end      end
88    
89  fun foundEin(paramCount,place,change,newE,newArgs,done,newEinApp,orig,lhs)= (case (List.nth(paramCount, place),testing)  fun foundEin(paramCount,place,change,newE,newArgs,done,newEinApp,orig,lhs)= (case (List.nth(paramCount, place),testing)
# Line 90  Line 94 
94          (*end case*))          (*end case*))
95      | (_,_)=> let      | (_,_)=> let
96          val (c,subst)=App.app(orig,place,newE)          val (c,subst)=App.app(orig,place,newE)
97          val _ = print(String.concat["\n Apply at ", Int.toString(place),":--",P.printerE(newE),          val _ = testp["\n Apply at ", Int.toString(place),":--",P.printerE(newE),
98                  "\n","Subst Result:\t", P.printerE(subst), "\n"])                  "\n","Subst Result:\t", P.printerE(subst), "\n"]
99          in (case c          in (case c
100              of 0 => (1,subst, place+length(newArgs), done@newArgs)              of 0 => (1,subst, place+length(newArgs), done@newArgs)
101              |_ => (incUse lhs;(*decUse e;*)(1,subst, place+length(newArgs), done@newArgs))              |_ => (incUse lhs;(*decUse e;*)(1,subst, place+length(newArgs), done@newArgs))
# Line 103  Line 107 
107    
108    
109  fun doRHS (lhs, IL.EINAPP (ein, args))=let  fun doRHS (lhs, IL.EINAPP (ein, args))=let
110        val _ = testp [V.toString  lhs,"=="," ---Current: ", P.printerE(ein), (String.concatWith "," (List.map V.toString args))]
      val _ =print "\n do rhs"  
     val _ =(case testing  
         of 0=> 0  
         | _ => (print(String.concat[V.toString  lhs,"=="," ---Current: ", P.printerE(ein), (String.concatWith "," (List.map V.toString args))]);1)  
         (*end case*))  
   
111      fun rewrite(0,_,_, [], _)= NONE      fun rewrite(0,_,_, [], _)= NONE
112          | rewrite(_,orig,_, [], done)= SOME[(lhs,IL.EINAPP((doNormalize orig), done))]          | rewrite(_,orig,_, [], done)= SOME[(lhs,IL.EINAPP((doNormalize orig), done))]
113          | rewrite(change,orig, place, e::es,done)=(case (isEin e)          | rewrite(change,orig, place, e::es,done)=(case (isEin e)
# Line 123  Line 121 
121              (* end case *))              (* end case *))
122      in rewrite(0,ein, 0,args,[])      in rewrite(0,ein, 0,args,[])
123      end      end
124    | doRHS _ = NONE
 | doRHS _ = (print "non einapp";NONE)  
125    
126      structure Rewrite = RewriteFn (      structure Rewrite = RewriteFn (
127        struct        struct

Legend:
Removed from v.2826  
changed lines
  Added in v.2827

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