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

SCM Repository

[diderot] Diff of /trunk/src/compiler/IL/check-il-fn.sml
ViewVC logotype

Diff of /trunk/src/compiler/IL/check-il-fn.sml

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

revision 1231, Mon May 16 13:49:17 2011 UTC revision 1232, Mon May 16 23:37:52 2011 UTC
# Line 61  Line 61 
61          fun transfer (input, nd as IL.ND{kind, ...}) = (case kind          fun transfer (input, nd as IL.ND{kind, ...}) = (case kind
62                 of IL.NULL => raise Fail("unexpected " ^ IL.Node.toString nd)                 of IL.NULL => raise Fail("unexpected " ^ IL.Node.toString nd)
63                  | IL.JOIN{phis, ...} => let                  | IL.JOIN{phis, ...} => let
64                    (* add the lhs of the phi node, while removing the rhs variables *)                    (* add the lhs of the phi node.  We do not remove the rhs variables, since
65                      fun doPhi ((y, xs), vs) =                     * after value numbering, they may have further uses.
66                            VSet.add(                     *)
67                              VSet.difference(vs, VSet.fromList xs),                      fun doPhi ((y, _), vs) = VSet.add(vs, y)
68                              y)                      val output = List.foldl doPhi input (!phis)
69                      in                      in
70                        List.foldl doPhi input (!phis)                        output
71                      end                      end
72                  | IL.ASSIGN{stm=(y, _), ...} => VSet.add(input, y)                  | IL.ASSIGN{stm=(y, _), ...} => VSet.add(input, y)
73                  | _ => input                  | _ => input
# Line 85  Line 85 
85        end)        end)
86    
87      datatype token      datatype token
88        = NL | S of string | V of IL.var | VTYS of IL.var list | TY of Ty.ty | TYS of Ty.ty list        = NL | S of string | A of Atom.atom | V of IL.var | VTYS of IL.var list
89          | TY of Ty.ty | TYS of Ty.ty list
90    
91      fun error errBuf toks = let      fun error errBuf toks = let
92            fun tok2str NL = "\n  ** "            fun tok2str NL = "\n  ** "
93              | tok2str (S s) = s              | tok2str (S s) = s
94                | tok2str (A s) = Atom.toString s
95              | tok2str (V x) = V.toString x              | tok2str (V x) = V.toString x
96              | tok2str (VTYS xs) = tok2str(TYS(List.map V.ty xs))              | tok2str (VTYS xs) = tok2str(TYS(List.map V.ty xs))
97              | tok2str (TY ty) = Ty.toString ty              | tok2str (TY ty) = Ty.toString ty
# Line 238  Line 240 
240          (* the globals are those variables that are live at the exit of the global initialization *)          (* the globals are those variables that are live at the exit of the global initialization *)
241            val globals = IL.CFG.liveAtExit globalInit            val globals = IL.CFG.liveAtExit globalInit
242          (* check a strand definition *)          (* check a strand definition *)
243            fun checkStrand (IL.Strand{params, state, stateInit, methods, ...}) = let            fun checkStrand (IL.Strand{name, params, state, stateInit, methods}) = let
244                    val nStateVars = List.length state
245                  val extraVars = params @ globals                  val extraVars = params @ globals
246                  fun checkMethod (IL.Method{stateIn, body, ...}) =                  fun checkMethod (IL.Method{name, stateIn, body, ...}) = (
247                        checkCFG (extraVars@stateIn, body)                        if (nStateVars <> List.length stateIn)
248                            then errFn [
249                                S "method ", A name, S " has incorrect number of state variables", NL,
250                                S "expected ", S(Int.toString nStateVars), S ", but found ",
251                                S(Int.toString(List.length stateIn))
252                              ]
253                            else ();
254                          checkCFG (extraVars@stateIn, body))
255                  in                  in
256                    checkCFG (extraVars, stateInit);                    checkCFG (extraVars, stateInit);
257                      if (nStateVars <> List.length(IL.CFG.liveAtExit stateInit))
258                        then errFn [
259                            S "strand ", A name, S "'s initialization has incorrect number of state variables", NL,
260                            S "expected ", S(Int.toString nStateVars), S ", but found ",
261                            S(Int.toString(List.length(IL.CFG.liveAtExit stateInit)))
262                          ]
263                        else ();
264                    List.app checkMethod methods                    List.app checkMethod methods
265                  end                  end
266            in            in

Legend:
Removed from v.1231  
changed lines
  Added in v.1232

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