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

SCM Repository

[diderot] Annotation of /branches/charisee/src/compiler/high-to-mid/handleEin.sml
ViewVC logotype

Annotation of /branches/charisee/src/compiler/high-to-mid/handleEin.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3567 - (view) (download)

1 : cchiw 2845 (* Expands probe ein
2 :     *
3 : jhr 3349 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     *
5 :     * COPYRIGHT (c) 2015 The University of Chicago
6 : cchiw 2845 * All rights reserved.
7 :     *)
8 :    
9 :     structure handleEin = struct
10 :    
11 :     local
12 :    
13 :     structure E = Ein
14 :     structure DstIL = MidIL
15 :     structure P=Printer
16 :     structure MidToS=MidToString
17 :     in
18 :    
19 : cchiw 3166 val testinitial=0
20 : cchiw 3259 val testing=0
21 : cchiw 2845 fun testp n=(case testing
22 :     of 0=> 1
23 :     | _ =>(print(String.concat n);1)
24 :     (*end case*))
25 : cchiw 3166 fun test0 n=(case testinitial
26 : cchiw 3203 of 0=>testp n
27 : cchiw 3166 | _ => (print(String.concat n);1))
28 : cchiw 3444 fun toStringBind e= MidToS.toStringBind e
29 :     fun useCount (HighIL.V{useCnt, ...}) = !useCnt
30 :     fun expandEinOp (srcy,bind00)=let
31 : cchiw 3033 val star="************"
32 : cchiw 3444 val _= ("\n Start"^star)
33 : cchiw 3260 val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",toStringBind bind00]
34 : cchiw 3203 val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=bind00
35 : cchiw 3033 (* ************* Sweep for 0's'*********** *)
36 : cchiw 3448 val _ =testp["Pre Sweep\n",P.printbody body,"\n"]
37 : cchiw 3203 val bodysweep=sweepEin.sweep body
38 : cchiw 3033 val ein1=Ein.EIN{params=params, index=index, body=bodysweep}
39 : cchiw 3448 val _ =testp["Post Sweep\n",P.printbody bodysweep,"\n"]
40 : cchiw 3567 (*
41 :     val ein1=Ein.EIN{params=params, index=index, body=body}*)
42 : cchiw 3203 (* ************** distribute and push Summation*********** *)
43 :     val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))
44 : cchiw 3260 val _ =testp["\n\n summation \n\n =>", toStringBind bind3]
45 : cchiw 3448 (* **************** split phase ************* *)
46 : cchiw 3033
47 : cchiw 3203 val (newbies5)= Split.splitEinApp bind3
48 : cchiw 3444 (**************** printing result ***************)
49 : cchiw 3203 val _ =testp["\n\n Returning \n\n =>",
50 : cchiw 3444 String.concatWith",\n\t"(List.map toStringBind newbies5)]
51 : cchiw 3448 val n =length(newbies5)
52 :     val _ = if (n > 10) then testp["\n **** SPLIT Length",Int.toString(n)] else 1
53 : cchiw 3166 (* ************** ProbeEIN *********** *)
54 : cchiw 3189 (*gives probeEIN the set. Could split into a sepearate step*)
55 : cchiw 3174 val fieldset= einSet.EinSet.empty
56 : cchiw 3444 val isField = ref 0
57 :     val isFieldR = ref 0
58 :     val isReplaced = ref 0
59 : cchiw 3174 fun iter([],_)=[]
60 :     | iter(e1::es,fieldset)= let
61 : cchiw 3444 val (e2,fieldset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset)
62 :     val rtn=[e2]@(iter(es,fieldset))
63 :     val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0
64 :     in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;
65 :     isFieldR:=(!isFieldR)+isFieldRt;rtn)
66 :     end
67 : cchiw 3174 val code=iter(newbies5, fieldset)
68 : cchiw 3444 val n= List.length(code)
69 : cchiw 3448 val _ =testp[HighIL.Var.name srcy ," Pieces",Int.toString (n),"\n"]
70 :     val flatcode= List.foldr op@ [] code
71 : cchiw 3048 (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)
72 : cchiw 3444 val _=(star^"end")
73 : cchiw 3033 in
74 :     List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode
75 :     end
76 :    
77 : cchiw 2845 end; (* local *)
78 :    
79 :     end (* local *)

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