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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/cxx-util/tree-to-cxx.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/cxx-util/tree-to-cxx.sml

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

revision 3917, Sat May 28 16:41:39 2016 UTC revision 3918, Mon May 30 06:31:35 2016 UTC
# Line 37  Line 37 
37      structure Ty = TreeTypes      structure Ty = TreeTypes
38      structure V = TreeVar      structure V = TreeVar
39      structure Env = CodeGenEnv      structure Env = CodeGenEnv
40        structure RN = CxxNames
41    
42      fun trType (env, ty) = (case ty      fun trType (env, ty) = (case ty
43             of Ty.BoolTy => CL.boolTy             of Ty.BoolTy => CL.boolTy
# Line 270  Line 271 
271            (* end case *))            (* end case *))
272        | trMultiAssign (env, lhs, rhs) = raise Fail "bogus multi-assignment"        | trMultiAssign (env, lhs, rhs) = raise Fail "bogus multi-assignment"
273    
274        fun trPrintStm (outS, tys, args) = let
275              fun mkExp (lhs, [], []) = CL.mkBinOp(lhs, CL.#<<, CL.mkVar "std::end")
276                | mkExp (lhs, ty::tys, e::es) = let
277                  (* if necessary, wrap the argument so that the correct "<<" instance is used *)
278                    val e = (case ty
279                           of Ty.TensorTy shape => CL.mkApply(RN.tensorStruct shape, [e])
280                            | _ => e
281                          (* end case *))
282                    in
283                      mkExp (CL.mkBinOp(lhs, CL.#<<, e), tys, es)
284                    end
285                | mkExp _ = raise Fail "trPrintStm: arity mismatch"
286              in
287                CL.mkExpStm (mkExp (outS, tys, args))
288              end
289    
290      fun trStms (env, stms : TreeIR.stm list) = let      fun trStms (env, stms : TreeIR.stm list) = let
291            fun trStm (stm, (env, stms : CL.stm list)) = (case stm            fun trStm (stm, (env, stms : CL.stm list)) = (case stm
292                   of IR.S_Comment text => (env, CL.mkComment text :: stms)                   of IR.S_Comment text => (env, CL.mkComment text :: stms)
# Line 339  Line 356 
356                    | IR.S_Exit => (env, stms)                    | IR.S_Exit => (env, stms)
357                    | IR.S_Print(tys, args) => let                    | IR.S_Print(tys, args) => let
358                        val args = List.map (fn e => trExp(env, e)) args                        val args = List.map (fn e => trExp(env, e)) args
359                        val stm = GenPrint.genPrintStm (                        val stm = trPrintStm (
360                              CL.mkIndirect(CL.mkVar "wrld", "_output"),                              CL.mkIndirect(CL.mkVar "wrld", "_output"),
361                              tys, args)                              tys, args)
362                        in                        in

Legend:
Removed from v.3917  
changed lines
  Added in v.3918

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