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

SCM Repository

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

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

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

revision 2038, Tue Oct 16 11:31:02 2012 UTC revision 2039, Wed Oct 17 16:10:37 2012 UTC
# Line 124  Line 124 
124             of PT.T_Mark m => checkTy(withContext(cxt, m))             of PT.T_Mark m => checkTy(withContext(cxt, m))
125              | PT.T_Bool => Ty.T_Bool              | PT.T_Bool => Ty.T_Bool
126              | PT.T_Int => Ty.T_Int              | PT.T_Int => Ty.T_Int
127          | PT.T_Strand n => Ty.T_Strand n          | PT.T_Strand n => Ty.T_StrandSequence
128              | PT.T_Real => Ty.realTy              | PT.T_Real => Ty.realTy
129              | PT.T_String => Ty.T_String              | PT.T_String => Ty.T_String
130              | PT.T_Vec n => (* NOTE: the parser guarantees that 2 <= n <= 4 *)              | PT.T_Vec n => (* NOTE: the parser guarantees that 2 <= n <= 4 *)
# Line 196  Line 196 
196                      | _ => err (cxt, [S "arguments to \"||\" must have bool type"])                      | _ => err (cxt, [S "arguments to \"||\" must have bool type"])
197                    (* end case *)                    (* end case *)
198                  end                  end
199          | PT.E_RadiusQuery e1 => let          | PT.E_SphereQuery e1 => let
200          val (e1',ty1) = checkExpr(env,cxt,e1)          val (e1',ty1) = checkExpr(env,cxt,e1)
201          in          in
202             case(ty1)             case(ty1)
203              of Ty.T_Int =>              of Ty.T_Int =>
204                  (AST.E_RadiusQuery(e1'), Ty.T_Function)                  (AST.E_SphereQuery(e1'), Ty.T_StrandSequence)
205              | _ =>  err (cxt, [S "argument to \"radius function\" must have int type"])              | _ =>  err (cxt, [S "argument to \"radius function\" must have int type"])
206              (* end case *)              (* end case *)
207          end          end
# Line 464  Line 464 
464    
465      fun checkVarDecl (env, cxt, kind, d) = (case d      fun checkVarDecl (env, cxt, kind, d) = (case d
466             of PT.VD_Mark m => checkVarDecl (env, (#1 cxt, #span m), kind, #tree m)             of PT.VD_Mark m => checkVarDecl (env, (#1 cxt, #span m), kind, #tree m)
467          | PT.VID_Decl(ty,x) => (case checkTy(cxt,ty)         (* | PT.VID_Decl(ty,x) => (case checkTy(cxt,ty)
468              of ty as Ty.T_Strand strandName => let              of ty as Ty.T_Strand strandName => let
469                   val x' = Var.new (x,kind,ty)                   val x' = Var.new (x,kind,ty)
470                   in                   in
# Line 482  Line 482 
482              S "needs to be a strand type\n",              S "needs to be a strand type\n",
483              S "but found: ", TY ty'])              S "but found: ", TY ty'])
484    
485           (*end of case *))           (*end of case *)) *)
486              | PT.VD_Decl(ty, x, e) => let              | PT.VD_Decl(ty, x, e) => let
487                  val ty = checkTy (cxt, ty)                  val ty = checkTy (cxt, ty)
488                  val x' = Var.new (x, kind, ty)                  val x' = Var.new (x, kind, ty)
# Line 532  Line 532 
532                    (* end case *);                    (* end case *);
533                    (AST.S_IfThenElse(e', s', AST.S_Block[]), env)                    (AST.S_IfThenElse(e', s', AST.S_Block[]), env)
534                  end                  end
535                  | PT.S_Foreach(vd,e,s) => let                  | PT.S_Foreach(vd,s) => let
536          val (x, x', _) = checkVarDecl (env, cxt, Var.StrandVar, vd)          val (x, x',e) = checkVarDecl (env, cxt, Var.StrandVar, vd)
                 val (e',ty) = checkExpr(env,cxt,e)  
537                  val (s',_)  = checkStmt(env,cxt,s)                  val (s',_)  = checkStmt(env,cxt,s)
538            val  sTy = (case vd
539                    of PT.VD_Decl(PT.T_Strand strandName,oldx,_) => Atom.toString(strandName)
540                     | _ => "" (*end of case *))
541                  in                  in
542                    checkForRedef(env,cxt,x);                    checkForRedef(env,cxt,x);
543                    (AST.S_Foreach(x',e',s'),insertLocal(env, cxt, x, x'))                    (AST.S_Foreach(x',e,s',sTy),insertLocal(env, cxt, x, x'))
544          end          end
545              | PT.S_IfThenElse(e, s1, s2) => let              | PT.S_IfThenElse(e, s1, s2) => let
546                  val (e', ty) = checkExpr (env, cxt, e)                  val (e', ty) = checkExpr (env, cxt, e)

Legend:
Removed from v.2038  
changed lines
  Added in v.2039

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