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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/tree-il/tree-il-pp.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/tree-il/tree-il-pp.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2377, Mon Jun 3 19:41:56 2013 UTC revision 2690, Fri Aug 29 15:41:22 2014 UTC
# Line 28  Line 28 
28      fun prl (out, l) = pr(out, concat l)      fun prl (out, l) = pr(out, concat l)
29      fun prln (out, l) = (indent out; prl(out, l))      fun prln (out, l) = (indent out; prl(out, l))
30    
31        fun itos m = Int.toString m
32    
33      fun expToString e = let      fun expToString e = let
34            fun argsToS (lp, args, rp, l) = let            fun argsToS (shift, lp, args, rp, l) = let
35                  fun argToS ([], l) = l                  fun argToS ([], l) = l
36                    | argToS ([e], l) = toS (e, l)                    | argToS ([e], l) = toS (e, l)
37                    | argToS (e::es, l) = toS(e, "," :: argToS(es, l))                    | argToS (e::es, l) = toS(e, shift:: argToS(es, l))
38                  in                  in
39                    lp :: argToS(args, rp :: l)                    lp :: argToS(args, rp :: l)
40                  end                  end
41    
42            and toS (IL.E_State x, l) = IL.stateVarToString x :: l            and toS (IL.E_State x, l) = IL.stateVarToString x :: l
43              | toS (IL.E_Var x, l) = (case (Var.kind x)              | toS (IL.E_Var x, l) = (case (Var.kind x)
44                   of IL.VK_Local => Var.name x :: l                   of IL.VK_Local => Var.name x :: l
45                    | _ => "::" :: Var.name x :: l                    | _ => "::" :: Var.name x :: l
46                  (* end case *))                  (* end case *))
47              | toS (IL.E_Lit lit, l) = Literal.toString lit :: l              | toS (IL.E_Lit lit, l) = Literal.toString lit :: l
48              | toS (IL.E_Op(rator, args), l) = Op.toString rator :: argsToS ("(", args, ")", l)              | toS (IL.E_Op(rator, args), l) = Op.toString rator :: argsToS (",","(", args, ")", l)
49              | toS (IL.E_Apply(f, args), l) = MathFuns.toString f :: argsToS ("(", args, ")", l)              | toS (IL.E_Apply(f, args), l) = MathFuns.toString f :: argsToS (",","(", args, ")", l)
50              | toS (IL.E_Cons(ty, args), l) =              | toS (IL.E_Cons(ty, args), l) =
51                  "<" :: Ty.toString ty :: ">" :: argsToS ("{", args, "}", l)                  "<" :: Ty.toString ty :: ">" :: argsToS (",","{", args, "}", l)
52                | toS (IL.E_Mux(A,nSize,oSize, pieces, args),l) =
53                        "Mux<" ::itos nSize :: ":" :: itos oSize ::"[>\t ]"::argsToS (",","(", args, ")", l)
54    
55    
56                | toS (IL.E_LoadArr(A,tyNew, tyOrig, arg, offset), l) =
57                            "LdArr<" :: itos tyNew :: ":" :: itos tyOrig :: ">("
58                                :: argsToS (",", "(", [arg, offset], ")", l)
59            in            in
60              String.concat (toS (e, []))              String.concat (toS (e, []))
61            end            end
62    
63    
64      fun argsToString (prefix, es) = String.concat[      fun argsToString (prefix, es) = String.concat[
65              prefix, "(", String.concatWith "," (List.map expToString es), ")"              prefix, "(", String.concatWith "," (List.map expToString es), ")"
66            ]            ]
# Line 99  Line 110 
110                    List.app (fn s => prln(out, ["// ", s, "\n"])) text                    List.app (fn s => prln(out, ["// ", s, "\n"])) text
111                  end                  end
112              | IL.S_Assign([], e) => prln(out, [expToString e, ";\n"])              | IL.S_Assign([], e) => prln(out, [expToString e, ";\n"])
113              | IL.S_Assign([x], e) => prln(out, [Var.name x, " = ", expToString e, ";\n"])              | IL.S_Assign([x], e) => prln(out, [Var.name x, "=Assign= ", expToString e, ";\n"])
114              | IL.S_Assign(x::xs, e) => (              | IL.S_Assign(x::xs, e) => (
115                  prln(out, ["(", Var.name x]);                  prln(out, ["(", Var.name x]);
116                  List.app (fn x => prl(out, [",", Var.name x])) xs;                  List.app (fn x => prl(out, [",", Var.name x])) xs;
# Line 126  Line 137 
137              | IL.S_New(strand, args) =>              | IL.S_New(strand, args) =>
138                  prln (out, [argsToString("new "^Atom.toString strand, args), ";\n"])                  prln (out, [argsToString("new "^Atom.toString strand, args), ";\n"])
139              | IL.S_Save([x], rhs) =>              | IL.S_Save([x], rhs) =>
140                  prln (out, [IL.stateVarToString x, " = ", expToString rhs, ";\n"])                  prln (out, [IL.stateVarToString x, " =Save= ", expToString rhs, ";\n"])
141              | IL.S_Save(x::xs, e) => (              | IL.S_Save(x::xs, e) => (
142                  prln(out, ["(", IL.stateVarToString x]);                  prln(out, ["(", IL.stateVarToString x]);
143                  List.app (fn x => prl(out, [",", IL.stateVarToString x])) xs;                  List.app (fn x => prl(out, [",", IL.stateVarToString x])) xs;
# Line 151  Line 162 
162              | IL.S_Active => prln (out, ["active;\n"])              | IL.S_Active => prln (out, ["active;\n"])
163              | IL.S_Stabilize => prln (out, ["stabilize;\n"])              | IL.S_Stabilize => prln (out, ["stabilize;\n"])
164              | IL.S_Die => prln (out, ["die;\n"])              | IL.S_Die => prln (out, ["die;\n"])
165                | IL.S_StoreVec(x,A,nSize, oSize, pieces, args) =>
166                       prln(out, "StoreVectoArr1<" ::expToString x:: " = "::itos nSize :: ":" :: itos oSize ::[">\n\t" ])
167            (* end case *))            (* end case *))
168    
169      fun statement (outS, stm) = ppStm((outS, 0), stm)      fun statement (outS, stm) = ppStm((outS, 0), stm)
# Line 186  Line 199 
199              pr (out, "\n")              pr (out, "\n")
200            end            end
201    
202      fun program (outS, IL.Program{props, globals, inputInit, globalInit, strands, initially}) = let      fun program (outS, IL.Program{props,types,oprations, globals, inputInit, globalInit, strands, initially}) = let
203            val out = (outS, 0)            val out = (outS, 0)
204            val out' = incIndent out            val out' = incIndent out
205            in            in

Legend:
Removed from v.2377  
changed lines
  Added in v.2690

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