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

SCM Repository

[diderot] Annotation of /branches/charisee_dev/src/compiler/low-il/lowToString.sml
ViewVC logotype

Annotation of /branches/charisee_dev/src/compiler/low-il/lowToString.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3269 - (view) (download)

1 : cchiw 2845 (* *
2 :     * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
3 :     * All rights reserved.
4 :     *
5 :     * Just created for debugging purpose
6 :     *
7 :     *)
8 :    
9 :     structure LowToString =
10 :     struct
11 :    
12 :     structure IL=LowIL
13 :     structure Op=LowOps
14 :     structure Ty = LowILTypes
15 :     structure V = LowIL.Var
16 :     structure StV = LowIL.StateVar
17 :    
18 :     fun rhsToString e=(case e
19 :     of IL.STATE x => String.concat["State",StV.name x]
20 :     | IL.VAR x => String.concat["var",V.name x]
21 :     | IL.LIT lit =>"lit"
22 :     | IL.OP(rator, args) =>"op"^Op.toString rator
23 :     | IL.APPLY(f, args) =>"apply"
24 :     | IL.CONS(ty, a::args) => "cons"^V.name a
25 :     | IL.EINAPP _=> "einapp"
26 :     (*end case*))
27 :    
28 :     fun ASSIGNtoString(x,e)=String.concat[Ty.toString(V.ty x)," ",V.name x, "=ASN=",rhsToString e]
29 :     fun SAVEtoString(x,e)=String.concat[StV.name x," =Save= ", V.name e]
30 :    
31 :     fun printNode x=(case x
32 :     of IL.NULL => "Null"
33 :     | IL.JOIN _ => "Join"
34 :     | IL.COND _ => "Cond"
35 :     | IL.COM _ => "Comment"
36 :     | IL.ASSIGN{pred,stm,succ} => String.concat["ASSIGN ",ASSIGNtoString stm]
37 :     | IL.MASSIGN _ => "MASSIGN"
38 :     | IL.NEW _ => "New"
39 :     | IL.SAVE _ => "Save"
40 :     | IL.EXIT _ => "Exit"
41 :     | _ => "nothing"
42 :     (*end x *))
43 :    
44 :     fun toStringRHS x = (case V.binding x
45 :     of vb => String.concat[
46 :     "\n Found ", IL.vbToString vb,"\n"]
47 :     (* end case *))
48 :    
49 :     fun toStringAssgn(IL.ASSGN (x, A))=(case A
50 :     of IL.OP(opss,args)=> String.concat [(V.toString x),"==",Op.toString opss,
51 :     " : ",(String.concatWith "," (List.map V.toString args))]
52 :     | IL.LIT(Literal.Int d)=> String.concat[V.toString x,"==...Literal",IntInf.toString( d)]
53 :     | IL.CONS (ty, vars)=> String.concat[(V.toString x),"== Type:",Ty.toString ty,"--",
54 :     (String.concatWith "," (List.map (fn e1=> V.toString e1) vars))]
55 :     | _ => String.concat[V.toString x,"==","Etc",toStringRHS x]
56 :     (*end case*))
57 :     | toStringAssgn _ = raise Fail "Non-assignment operator"
58 :    
59 :     fun toStringAll(ty,rator)=
60 :     String.concat(["\n",Ty.toString ty,"--", toStringAssgn rator] )
61 :    
62 :     end

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