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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/simplify/util.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/simplify/util.sml

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

revision 4590, Mon Sep 19 23:13:56 2016 UTC revision 4591, Mon Sep 19 23:57:42 2016 UTC
# Line 23  Line 23 
23              mvs : SimpleTypes.meta_arg list     (* meta-variable arguments for primitive application *)              mvs : SimpleTypes.meta_arg list     (* meta-variable arguments for primitive application *)
24            }            }
25    
26    (* convert a block into a function by closing over its free variables *)    (* convert a block, which is the map part of a map-reduce, into a function by closing over
27      val makeFunction : string * Simple.block * SimpleTypes.ty -> Simple.func_def * Simple.var list     * its free variables.  The simple variable argument is the strand object, which should always
28       * be the first parameter (even if it is not referenced in the block).
29       *)
30        val makeFunction : string * Simple.var * Simple.block * SimpleTypes.ty
31              -> Simple.func_def * Simple.var list
32    
33    (* return true if an AST constant expression is "small" *)    (* return true if an AST constant expression is "small" *)
34      val isSmallExp : AST.expr -> bool      val isSmallExp : AST.expr -> bool
# Line 95  Line 99 
99                SimpleVar.new(name ^ Int.toString id, SimpleVar.FunVar, ty)                SimpleVar.new(name ^ Int.toString id, SimpleVar.FunVar, ty)
100              end              end
101      in      in
102      fun makeFunction (name, blk, resTy) = let      fun makeFunction (name, strand, blk, resTy) = let
103            val freeVars = ref []            val freeVars = ref []
104            fun cvtVar (env, x) = (case VMap.find(env, x)            fun cvtVar (env, x) = (case VMap.find(env, x)
105                   of SOME x' => (env, x')                   of SOME x' => (env, x')
# Line 262  Line 266 
266                          (env, S.E_InsideImage(pos', img', s))                          (env, S.E_InsideImage(pos', img', s))
267                        end                        end
268                  (* end case *))                  (* end case *))
269            val (env, blk) = cvtBlock (VMap.empty, blk)          (* the initial environment always includes the strand variable *)
270              val (env, _) = cvtVar (VMap.empty, strand)
271              val (env, blk) = cvtBlock (env, blk)
272            val (args, params) = ListPair.unzip (List.rev (! freeVars))            val (args, params) = ListPair.unzip (List.rev (! freeVars))
273            val f = SimpleFunc.new (name, resTy, List.map SimpleVar.typeOf params)            val f = SimpleFunc.new (name, resTy, List.map SimpleVar.typeOf params)
274            in            in

Legend:
Removed from v.4590  
changed lines
  Added in v.4591

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