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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/codegen/codegen-fn.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/codegen/codegen-fn.sml

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

revision 1031, Sun May 1 17:39:05 2011 UTC revision 1032, Sun May 1 17:39:37 2011 UTC
# Line 102  Line 102 
102            val env = T.Env.new prog            val env = T.Env.new prog
103          (* define the globals and initialize the environment *)          (* define the globals and initialize the environment *)
104            val env = let            val env = let
105                  fun gvar (x, env) = T.Env.bind(env, x, T.Var.global(prog, x))                (* produce a list of target variables for the globals, such that each global
106                   * has a unique name.
107                   *)
108                    fun genName (x, (cnt, globs)) = let
109                          val name = IL.Var.name x
110                          fun uniqueName (name, cnt) =
111                                if List.exists (fn (_, y) => (name = T.Var.name y)) globs
112                                  then uniqueName(name ^ Int.toString cnt, cnt+1)
113                                  else (name, cnt)
114                          val (name, cnt) = uniqueName (IL.Var.name x, cnt)
115                  in                  in
116                    List.foldl gvar (T.Env.scopeGlobal env) globals                          (cnt, (x, T.Var.global(prog, name, IL.Var.ty x))::globs)
117                          end
118                    val (_, globs) = List.foldl genName (0, []) globals
119                    fun gvar ((x, x'), env) = T.Env.bind(env, x, x')
120                    in
121                      List.foldl gvar (T.Env.scopeGlobal env) globs
122                  end                  end
123            in            in
124            (* global initialization *)            (* global initialization *)

Legend:
Removed from v.1031  
changed lines
  Added in v.1032

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