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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/typechecker/typechecker.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/typechecker/typechecker.sml

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

revision 2157, Mon Feb 18 17:02:32 2013 UTC revision 2158, Mon Feb 18 17:10:19 2013 UTC
# Line 42  Line 42 
42      type context = Error.err_stream * Error.span      type context = Error.err_stream * Error.span
43    
44    (* start a new scope *)    (* start a new scope *)
 (* QUESTION: do we want to restrict access to globals from a function? *)  
45      fun functionScope ({scope, bindings, env}, ty, f) =      fun functionScope ({scope, bindings, env}, ty, f) =
46            {scope=FunctionScope(ty, f), bindings=AtomMap.empty, env=env}            {scope=FunctionScope(ty, f), bindings=AtomMap.empty, env=env}
47      fun strandScope {scope, bindings, env} =      fun strandScope {scope, bindings, env} =
# Line 841  Line 840 
840    
841      fun checkStrand (env, cxt, {name, params, state, methods}) = let      fun checkStrand (env, cxt, {name, params, state, methods}) = let
842          (* check the strand parameters *)          (* check the strand parameters *)
843            val (params, env) = checkParams (env, cxt, params)            val (params, env) = checkParams (strandScope env, cxt, params)
844          (* check the strand state variable definitions *)          (* check the strand state variable definitions *)
845            val (vds, hasOutput, env) = let            val (vds, hasOutput, env) = let
846                  fun checkStateVar ((isOut, vd), (vds, hasOut, env)) = let                  fun checkStateVar ((isOut, vd), (vds, hasOut, env)) = let
# Line 959  Line 958 
958                  end                  end
959              | PT.D_Func(ty, f, params, body) => let              | PT.D_Func(ty, f, params, body) => let
960                  val ty' = checkTy(cxt, ty)                  val ty' = checkTy(cxt, ty)
961                  val (params', env') = checkParams (env, cxt, params)                  val env' = functionScope (env, ty', f)
962                    val (params', env') = checkParams (env', cxt, params)
963                  val body' = (case body                  val body' = (case body
964                         of PT.FB_Expr e => let                         of PT.FB_Expr e => let
965                              val (e', ty) = checkExpr (env', cxt, e)                              val (e', ty) = checkExpr (env', cxt, e)
# Line 973  Line 973 
973                                      ])                                      ])
974                                (* end case *)                                (* end case *)
975                              end                              end
976  (* FIXME: we need to check that there is a return on all control-flow paths *)                          | PT.FB_Stmt s => #1(checkStmt(env', cxt, s))
                         | PT.FB_Stmt s => #1(checkStmt(functionScope (env', ty', f), cxt, s))  
977                        (* end case *))                        (* end case *))
978                  val fnTy = Ty.T_Fun(List.map Var.monoTypeOf params', ty')                  val fnTy = Ty.T_Fun(List.map Var.monoTypeOf params', ty')
979                  val f' = Var.new (f, AST.FunVar, fnTy)                  val f' = Var.new (f, AST.FunVar, fnTy)
980                  in                  in
981  (* QUESTION: should we check for redefinition of the f? *)  (* QUESTION: should we check for redefinition of basis functions? *)
982                      checkForRedef (env, cxt, f);
983                    (AST.D_Func(f', params', body'), insertFunc(env, cxt, f, f'))                    (AST.D_Func(f', params', body'), insertFunc(env, cxt, f, f'))
984                  end                  end
985              | PT.D_Strand arg => (checkStrand(strandScope env, cxt, arg), env)              | PT.D_Strand arg => (checkStrand(env, cxt, arg), env)
986              | PT.D_InitialArray(create, iterators) => let              | PT.D_InitialArray(create, iterators) => let
987                  val env = initScope env                  val env = initScope env
988                  val (iterators, env') = checkIters (env, cxt, iterators)                  val (iterators, env') = checkIters (env, cxt, iterators)

Legend:
Removed from v.2157  
changed lines
  Added in v.2158

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