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

SCM Repository

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

Diff of /branches/vis15/src/compiler/tree-ir/tree-pp.sml

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

revision 3832, Fri May 6 15:08:12 2016 UTC revision 3833, Fri May 6 15:35:03 2016 UTC
# Line 21  Line 21 
21    end = struct    end = struct
22    
23      structure IR = TreeIR      structure IR = TreeIR
24      structure Op = IR.Op      structure Ty = TreeTypes
25      structure Var = IR.Var      structure Op = TreeOps
26      structure Ty = IR.Ty      structure Var = TreeVar
27        structure GVar = TreeGlobalVar
28        structure SVar = TreeStateVar
29    
30      fun indent (outS, i) = TextIO.output(outS, StringCvt.padLeft #" " i "")      fun indent (outS, i) = TextIO.output(outS, StringCvt.padLeft #" " i "")
31      fun incIndent (outS, i) = (outS, i+2)      fun incIndent (outS, i) = (outS, i+2)
# Line 43  Line 45 
45                  in                  in
46                    lp :: argToS(args, rp :: l)                    lp :: argToS(args, rp :: l)
47                  end                  end
48            and toS (IR.E_Global x, l) = "::" :: IR.GlobalVar.toString x :: l            and toS (IR.E_Global x, l) = "::" :: GVar.toString x :: l
49              | toS (IR.E_State x, l) = IR.StateVar.toString x :: l              | toS (IR.E_State x, l) = SVar.toString x :: l
50              | toS (IR.E_Var x, l) = Var.name x :: l              | toS (IR.E_Var x, l) = Var.name x :: l
51              | toS (IR.E_Lit lit, l) = Literal.toString lit :: l              | toS (IR.E_Lit lit, l) = Literal.toString lit :: l
52              | toS (IR.E_Op(rator, args), l) = Op.toString rator :: argsToS ("(", args, ")", l)              | toS (IR.E_Op(rator, args), l) = Op.toString rator :: argsToS ("(", args, ")", l)
# Line 53  Line 55 
55              | toS (IR.E_Seq(args, ty), l) =              | toS (IR.E_Seq(args, ty), l) =
56                  "<" :: Ty.toString ty :: ">" :: argsToS ("{", args, "}", l)                  "<" :: Ty.toString ty :: ">" :: argsToS ("{", args, "}", l)
57              | toS (IR.E_Pack es, l) = "PACK" :: argsToS ("(", es, ")", l)              | toS (IR.E_Pack es, l) = "PACK" :: argsToS ("(", es, ")", l)
58                | toS (IR.E_Select(e, i), l) = "SELECT_" :: Int.toString i :: "(" :: toS(e, ")" :: l)
59            in            in
60              String.concat (toS (e, []))              String.concat (toS (e, []))
61            end            end
# Line 62  Line 65 
65            ]            ]
66    
67      fun ppGlobalDecl out x = prln (out, [      fun ppGlobalDecl out x = prln (out, [
68              if IR.GlobalVar.isInput x then "input " else "",              if GVar.isInput x then "input " else "",
69              Ty.toString(IR.GlobalVar.ty x), " ", IR.GlobalVar.name x, ";\n"              Ty.toString(GVar.ty x), " ", GVar.name x, ";\n"
70            ])            ])
71    
72      fun ppVarDecl out x = prln (out, [Ty.toString(Var.ty x), " ", Var.name x, ";\n"])      fun ppVarDecl out x = prln (out, [Ty.toString(Var.ty x), " ", Var.name x, ";\n"])
# Line 76  Line 79 
79              | ppParams (x::r) = (              | ppParams (x::r) = (
80                  prl(out, [Ty.toString (Var.ty x), " ", Var.name x, ","]);                  prl(out, [Ty.toString (Var.ty x), " ", Var.name x, ","]);
81                  ppParams r)                  ppParams r)
82            fun ppSVarDecl (IR.SV{varying, output, name, ty, ...}) = let            fun ppSVarDecl sv = let
83                  val v = if varying then "varying " else ""                  val v = if SVar.isVarying sv then "varying " else ""
84                  val out = if output then "output " else ""                  val out = if SVar.isOutput sv then "output " else ""
85                  in                  in
86                    prln (out', [v, out, Ty.toString ty, " ", name, ";\n"])                    prln (out', [v, out, Ty.toString(SVar.ty sv), " ", SVar.name sv, ";\n"])
87                  end                  end
88            in            in
89              prln (out, ["strand ", Atom.toString name, " ("]);              prln (out, ["strand ", Atom.toString name, " ("]);
# Line 120  Line 123 
123                  List.app (fn x => prl(out, [",", Var.name x])) xs;                  List.app (fn x => prl(out, [",", Var.name x])) xs;
124                  prl (out, [") = UNPACK(", expToString e, ");\n"]))                  prl (out, [") = UNPACK(", expToString e, ");\n"]))
125              | IR.S_Assign(x, e) => prln(out, [Var.name x, " = ", expToString e, ";\n"])              | IR.S_Assign(x, e) => prln(out, [Var.name x, " = ", expToString e, ";\n"])
126              | IR.S_GAssign(x, e) => prln(out, [IR.GlobalVar.name x, " = ", expToString e, ";\n"])              | IR.S_GAssign(x, e) => prln(out, [GVar.name x, " = ", expToString e, ";\n"])
127              | IR.S_IfThen(cond, blk) => (              | IR.S_IfThen(cond, blk) => (
128                  prln (out, ["if (", expToString cond, ") "]);                  prln (out, ["if (", expToString cond, ") "]);
129                  ppBlock (out, blk);                  ppBlock (out, blk);
# Line 144  Line 147 
147                    ])                    ])
148              | IR.S_Input(x, name, desc, NONE) =>              | IR.S_Input(x, name, desc, NONE) =>
149                  prln (out, [                  prln (out, [
150                      IR.GlobalVar.name x, " = input<", Ty.toString(IR.GlobalVar.ty x), "> (\"",                      GVar.name x, " = input<", Ty.toString(GVar.ty x), "> (\"",
151                      String.toString name, "\",\"", descToString desc, "\");\n"                      String.toString name, "\",\"", descToString desc, "\");\n"
152                    ])                    ])
153              | IR.S_Input(x, name, desc, SOME dflt) =>              | IR.S_Input(x, name, desc, SOME dflt) =>
154                  prln (out, [                  prln (out, [
155                      IR.GlobalVar.name x, " = input<", Ty.toString(IR.GlobalVar.ty x), "> (\"",                      GVar.name x, " = input<", Ty.toString(GVar.ty x), "> (\"",
156                      String.toString name, "\",\"", descToString desc, "\",",                      String.toString name, "\",\"", descToString desc, "\",",
157                      expToString dflt, ");\n"                      expToString dflt, ");\n"
158                    ])                    ])
159              | IR.S_InputNrrd(x, name, desc, NONE) =>              | IR.S_InputNrrd(x, name, desc, NONE) =>
160                  prln (out, [                  prln (out, [
161                      IR.GlobalVar.name x, " = input-nrrd<", Ty.toString(IR.GlobalVar.ty x), "> (\"",                      GVar.name x, " = input-nrrd<", Ty.toString(GVar.ty x), "> (\"",
162                      String.toString name, "\",\"", descToString desc, "\");\n"                      String.toString name, "\",\"", descToString desc, "\");\n"
163                    ])                    ])
164              | IR.S_InputNrrd(x, name, desc, SOME dflt) =>              | IR.S_InputNrrd(x, name, desc, SOME dflt) =>
165                  prln (out, [                  prln (out, [
166                      IR.GlobalVar.name x, " = input-nrrd<", Ty.toString(IR.GlobalVar.ty x), "> (\"",                      GVar.name x, " = input-nrrd<", Ty.toString(GVar.ty x), "> (\"",
167                      String.toString name, "\",\"", descToString desc, "\",\"",                      String.toString name, "\",\"", descToString desc, "\",\"",
168                      String.toString dflt, "\");\n"                      String.toString dflt, "\");\n"
169                    ])                    ])
170              | IR.S_New(strand, args) =>              | IR.S_New(strand, args) =>
171                  prln (out, [argsToString("new "^Atom.toString strand, args), ";\n"])                  prln (out, [argsToString("new "^Atom.toString strand, args), ";\n"])
172              | IR.S_Save(x, rhs) =>              | IR.S_Save(x, rhs) =>
173                  prln (out, [IR.StateVar.toString x, " = ", expToString rhs, ";\n"])                  prln (out, [SVar.toString x, " = ", expToString rhs, ";\n"])
174              | IR.S_Exit es => prln (out, [argsToString("exit", es), ";\n"])              | IR.S_Exit es => prln (out, [argsToString("exit", es), ";\n"])
175              | IR.S_Print(_, es) => prln (out, [argsToString("print", es), ";\n"])              | IR.S_Print(_, es) => prln (out, [argsToString("print", es), ";\n"])
176            (* return functions for methods *)            (* return functions for methods *)

Legend:
Removed from v.3832  
changed lines
  Added in v.3833

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