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

SCM Repository

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

View of /branches/charisee_dev/src/compiler/high-to-mid/handleEin.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 3203 - (download) (annotate)
Wed Jul 8 16:30:56 2015 UTC (5 years ago) by cchiw
Original Path: branches/charisee/src/compiler/high-to-mid/handleEin.sml
File size: 2470 byte(s)
some refactoring in tree-il, move sum function location
(* Expands probe ein
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.

structure handleEin = struct

    structure E = Ein
    structure DstIL = MidIL
    structure DstOp = MidOps
    structure P=Printer
    structure T=TransformEin
    structure MidToS=MidToString
    structure DstV  = DstIL.Var

    val testinitial=0
    val testing=1
    fun testp n=(case testing
        of 0=> 1
        | _ =>(print(String.concat n);1)
        (*end case*))
    fun test0 n=(case testinitial
        of 0=>testp n
        | _ => (print(String.concat n);1))
    fun printEINAPP e=MidToString.printEINAPP e

    fun expandEinOp bind00=let
        val star="************"
        val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",printEINAPP bind00]
        val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=bind00

        (* ************* Sweep for 0's'*********** *)
        val bodysweep=sweepEin.sweep body
        val ein1=Ein.EIN{params=params, index=index, body=bodysweep}
        val _=testp["Post Sweep\n",P.printbody bodysweep,"\n"]

        (* ************** distribute and push Summation*********** *)
        val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))
        val _ =testp["\n\n summation \n\n =>", printEINAPP bind3]

        (* **************** split phase ************* *)
        val (newbies5)= Split.splitEinApp bind3
        val _ =testp["\n\n Returning \n\n =>",
            String.concatWith",\n\t"(List.map printEINAPP newbies5)]

         (* ************** ProbeEIN *********** *)
        (*val code=List.map (fn e=>ProbeEin.expandEinOp e) (newbies5)*)

        (*gives probeEIN the set. Could split into a sepearate step*)
        val fieldset= einSet.EinSet.empty
        fun iter([],_)=[]
         | iter(e1::es,fieldset)= let
            val (e2,fieldset) = ProbeEin.expandEinOp(e1,fieldset)
            in [e2]@(iter(es,fieldset))
        val code=iter(newbies5, fieldset)
        (*val _ =print(String.concat[
            "\n",star,"Number of pieces now: ",Int.toString (List.length(code))])
        val flatcode= List.foldr op@ [] code
        (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)

            List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode

  end; (* local *)

end (* local *)

ViewVC Help
Powered by ViewVC 1.0.0