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 3395 - (view) (download)

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

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