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

SCM Repository

[diderot] View of /branches/charisee/src/compiler/low-il/toString.sml
ViewVC logotype

View of /branches/charisee/src/compiler/low-il/toString.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2844 - (download) (annotate)
Tue Dec 9 18:05:29 2014 UTC (4 years, 11 months ago) by cchiw
File size: 2175 byte(s)
code cleanup
(*  *
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *Just created for debugging purpose 
 * 
 *)

structure toS =
  struct

    structure IL=LowIL
    structure Op=LowOps
    structure Ty = LowILTypes
    structure V = LowIL.Var
    structure StV = LowIL.StateVar

    fun rhsToString e=(case e
        of IL.STATE x => String.concat["State",StV.name x]
        | IL.VAR x =>  String.concat["var",V.name x]
        | IL.LIT lit =>"lit"
        | IL.OP(rator, args) =>"op"^Op.toString rator 
        | IL.APPLY(f, args) =>"apply"
        | IL.CONS(ty, a::args) => "cons"^V.name a
        | IL.EINAPP _=> "einapp"
    (*end case*))


    fun ASSIGNtoString(x,e)=String.concat[Ty.toString(V.ty x)," ",V.name x, "=ASN=",rhsToString e]
    fun SAVEtoString(x,e)=String.concat[StV.name x," =Save= ", V.name e]

    fun printNode x=(case x
        of IL.NULL      => "Null"
        | IL.JOIN  _     => "Join"
        | IL.COND _      =>"Cond"
        | IL.COM       _ =>"Comment"
        | IL.ASSIGN{pred,stm,succ}  =>String.concat["ASSIGN ",ASSIGNtoString stm]
        | IL.MASSIGN _   =>"MASSIGN"
        | IL.NEW  _    => "New"
        | IL.SAVE  _     => "Save"
        | IL.EXIT _       =>"Exit"
        | _=> "nothing"
    (*end x *))

    fun toStringRHS x  = (case V.binding x
        of vb => String.concat[
        "\n Found ", IL.vbToString vb,"\n"]
        (* end case *))


    fun toStringAssgn(IL.ASSGN (x,  A))=(case A
        of  IL.OP(opss,args)=> String.concat [(V.toString x),"==",Op.toString opss,
        " : ",(String.concatWith "," (List.map V.toString args))]
        | IL.LIT(Literal.Int d)=> String.concat[V.toString  x,"==...Literal",IntInf.toString( d)]
        | IL.CONS (ty, vars)=>  String.concat[(V.toString  x),"== Type:",Ty.toString ty,"--",
            (String.concatWith "," (List.map (fn e1=> V.toString e1) vars))]
        |  _ => String.concat[V.toString  x,"==","Etc",toStringRHS x]
        (*end case*))
    | toStringAssgn _ = raise Fail "Non-assignment operator"



    fun toStringAll(ty,rator)=
        String.concat(["\n",Ty.toString ty,"--", toStringAssgn rator] )

  end

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