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 3260 - (download) (annotate)
Wed Sep 23 16:09:21 2015 UTC (3 years, 11 months ago) by cchiw
Original Path: branches/charisee/src/compiler/high-to-mid/handleEin.sml
File size: 2471 byte(s)
lift det field
(* Expands probe ein
 *
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *)

structure handleEin = struct

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

    val testinitial=0
    val testing=0
    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 toStringBind e= MidToString.toStringBind e

    fun expandEinOp bind00=let
               
        val star="************"
        val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",toStringBind 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 =>", toStringBind bind3]

        (* **************** split phase ************* *)
        val (newbies5)= Split.splitEinApp bind3
        val _ =testp["\n\n Returning \n\n =>",
            String.concatWith",\n\t"(List.map toStringBind 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))
            end 
        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*)

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

  end; (* local *)

end (* local *)

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