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

SCM Repository

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

Diff of /branches/vis12-cl/src/compiler/c-util/gen-inputs-util.sml

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

revision 3087, Tue Mar 17 16:35:47 2015 UTC revision 3088, Tue Mar 17 18:27:27 2015 UTC
# Line 1  Line 1 
1  (* gen-inputs.sml  (* gen-inputs-util.sml
2   *   *
3   * COPYRIGHT (c) 2015 The Diderot Project (http://diderot-language.cs.uchicago.edu)   * COPYRIGHT (c) 2015 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4   * All rights reserved.   * All rights reserved.
# Line 76  Line 76 
76                    | ty => (trType ty, GVar.name gv)                    | ty => (trType ty, GVar.name gv)
77                  (* end case *))                  (* end case *))
78            in            in
79              [CL.D_StructDef(NONE, List.map mkField inputs, SOME(N.inputsTy tgt))]              [CL.D_StructDef(NONE, List.map mkField inputs, SOME(N.inputsTyName tgt))]
80            end            end
81    
82      local      local
# Line 111  Line 111 
111    (* generate code to initialize the default input values *)    (* generate code to initialize the default input values *)
112      fun genInitDefaults (tgt, inputs) = let      fun genInitDefaults (tgt, inputs) = let
113          (* the inputs pointer type *)          (* the inputs pointer type *)
114            val inputPtrTy = CL.T_Ptr(CL.T_Named(N.inputsTy tgt))            val inputPtrTy = N.inputsPtrTy tgt
115          (* some common variables *)          (* some common variables *)
116            val inpV = CL.mkVar "inp"            val inpV = CL.mkVar "inp"
117          (* initialize a given input *)          (* initialize a given input *)
# Line 132  Line 132 
132    (* generate code to register command-line options for setting the input variables *)    (* generate code to register command-line options for setting the input variables *)
133      fun genRegisterInputs (tgt, inputs) = let      fun genRegisterInputs (tgt, inputs) = let
134          (* the inputs pointer type *)          (* the inputs pointer type *)
135            val inputPtrTy = CL.T_Ptr(CL.T_Named(N.inputsTy tgt))            val inputPtrTy = N.inputsPtrTy tgt
136          (* some common variables *)          (* some common variables *)
137            val inpV = CL.mkVar "inp"            val inpV = CL.mkVar "inp"
138            val optsV = CL.mkVar "opts"            val optsV = CL.mkVar "opts"
139          (* register a given input *)          (* register a given input *)
140            fun registerInput (gv, name, desc, optDflt) = CL.mkCall(N.input(GVar.ty gv), [            fun registerInput (gv, name, desc, optDflt) = CL.mkCall(N.inputOpt(GVar.ty gv), [
141                    optsV, CL.mkStr name, CL.mkStr(Option.getOpt(desc, "")),                    optsV, CL.mkStr name, CL.mkStr(Option.getOpt(desc, "")),
142                    if TrTy.isCArrayTy(GVar.ty gv)                    if TrTy.isCArrayTy(GVar.ty gv)
143                      then CL.mkIndirect(inpV, GVar.name gv)                      then CL.mkIndirect(inpV, GVar.name gv)
# Line 147  Line 147 
147            in            in
148              CL.D_Func(              CL.D_Func(
149                ["static"], CL.voidTy, N.registerOpts,                ["static"], CL.voidTy, N.registerOpts,
150                [CL.PARAM([], inputPtrTy, "inp"), CL.PARAM([], CL.T_Ptr(CL.T_Named N.optionsTy), "opts")],                [CL.PARAM([], inputPtrTy, "inp"), CL.PARAM([], N.optionsPtrTy, "opts")],
151                CL.mkBlock(List.map registerInput inputs))                CL.mkBlock(List.map registerInput inputs))
152            end            end
153    
# Line 167  Line 167 
167        | genDefinedInpStruct (tgt : Properties.props, inputs) = let        | genDefinedInpStruct (tgt : Properties.props, inputs) = let
168            fun mkField (gv, _, _, _) = (CL.boolTy, GVar.name gv)            fun mkField (gv, _, _, _) = (CL.boolTy, GVar.name gv)
169            in            in
170              [CL.D_StructDef(NONE, List.map mkField inputs, SOME(N.definedInpTy tgt))]              [CL.D_StructDef(NONE, List.map mkField inputs, SOME(N.definedInpTyName tgt))]
171            end            end
172    
173    (* generate the function that initializes the defined-input flag struct. *)    (* generate the function that initializes the defined-input flag struct. *)
174      fun genDefineInp (tgt, inputs) = let      fun genDefineInp (tgt, inputs) = let
175          (* the world pointer type *)          (* the world pointer type *)
176            val worldPtrTy = CL.T_Ptr(CL.T_Named(N.worldTy tgt))            val worldPtrTy = N.worldPtrTy tgt
177            val wrldParam = CL.PARAM([], worldPtrTy, "wrld")            val wrldParam = CL.PARAM([], worldPtrTy, "wrld")
178            fun initFlag (gv, _, _, _) = CL.mkAssign(defined gv, CL.mkBool false)            fun initFlag (gv, _, _, _) = CL.mkAssign(defined gv, CL.mkBool false)
179            in            in

Legend:
Removed from v.3087  
changed lines
  Added in v.3088

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