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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/c-util/output-util.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/c-util/output-util.sml

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

revision 2832, Tue Nov 18 22:47:05 2014 UTC revision 2833, Wed Nov 19 15:01:38 2014 UTC
# Line 24  Line 24 
24     *)     *)
25      val maybeAlloc : CLang.exp * CLang.var * int -> CLang.stm      val maybeAlloc : CLang.exp * CLang.var * int -> CLang.stm
26    
27    (* return true if the program produces just a single output file *)    (* generate code to register command-line options for redirecting the output in standalone
28      val singleOutput : (TreeIL.Ty.ty * string) list -> bool     * executables.  This function returns a list consisting of the global C variables that hold
29       * the option values and the registration function.
30       *)
31        val genRegisterOutputOpts : (TreeIL.Ty.ty * string) list -> CLang.decl list
32    
33      val genOutput : Properties.props * (TreeIL.Ty.ty * string) list -> CLang.decl list      val genOutput : Properties.props * (TreeIL.Ty.ty * string) list -> CLang.decl list
34    
# Line 103  Line 106 
106                ]                ]
107            (* endif*))            (* endif*))
108    
109    (* return true if the program produces just a single output file *)    (* generate code to register command-line options for redirecting the output in standalone
110      fun singleOutput [(Ty.DynSeqTy _, _)] = false     * executables.
111        | singleOutput [_] = true     *)
112        | singleOutput _ = false      fun genRegisterOutputOpts outputs = let
113            (* global variable names *)
114              val outfile = "Outfile"
115              fun outstem name = "OutStem_" ^ name
116            (* some common variables *)
117              val optsV = CL.mkVar "opts"
118            (* make a global variable declaration *)
119              fun mkDecl (name, value) = CL.D_Var([], CL.charPtr, name, SOME(CL.I_Exp(CL.mkStr value)))
120            (* register a flag for a given output *)
121              fun registerOutput (_, name) = let
122                    val optName = "redirect-" ^ name
123                    in
124                      CL.mkCall("Diderot_OptAddString", [
125                          optsV, CL.mkStr("o-" ^ name), CL.mkStr("specify output-file stem for " ^ name),
126                          CL.mkUnOp(CL.%&, CL.mkVar(outstem name)),
127                          CL.mkBool true
128                        ])
129                    end
130              val stms = List.map registerOutput outputs
131              val dcls = List.map (fn (_, name) => mkDecl (outstem name, name)) outputs
132              val (stms, dcls) = (case outputs
133                     of [(Ty.DynSeqTy _, _)] => (stms, dcls) (* two ouput files *)
134                      | [(_, name)] => let (* one output file, so add redirect option *)
135                          val stm = CL.mkCall("Diderot_OptAddString", [
136                              optsV, CL.mkStr "o", CL.mkStr("specify output-file file"),
137                              CL.mkUnOp(CL.%&, CL.mkVar outfile),
138                              CL.mkBool true
139                            ])
140                          val dcl = mkDecl (outfile, name ^ ".nrrd")
141                          in
142                            (stm :: stms, dcl :: dcls)
143                          end
144                      | _ => (stms, dcls)
145                    (* end case *))
146              val registerFn = CL.D_Func(
147                    ["static"], CL.voidTy, N.registerOutputOpts,
148                    [CL.PARAM([], CL.T_Ptr(CL.T_Named N.optionsTy), "opts")],
149                    CL.mkBlock stms)
150              in
151                dcls @ [registerFn]
152              end
153    
154    (* generate the nrrd-file output and print functions used by standalone executables *)    (* generate the nrrd-file output and print functions used by standalone executables *)
155      fun genOutput (tgt : Properties.props, outputs) = let      fun genOutput (tgt : Properties.props, outputs) = let

Legend:
Removed from v.2832  
changed lines
  Added in v.2833

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