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

SCM Repository

[diderot] Annotation of /trunk/src/compiler/typechecker/typechecker.sml
ViewVC logotype

Annotation of /trunk/src/compiler/typechecker/typechecker.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 169 - (view) (download)

1 : jhr 69 (* typechecker.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     structure Typechecker : sig
8 :    
9 : jhr 88 exception Error
10 :    
11 : jhr 86 val check : Error.err_stream -> ParseTree.program -> AST.program
12 : jhr 69
13 :     end = struct
14 :    
15 : jhr 70 structure PT = ParseTree
16 : jhr 69 structure Ty = Types
17 : jhr 96 structure TU = TypeUtil
18 : jhr 81 structure U = Util
19 : jhr 69
20 : jhr 169 type env = {globalScope : bool, env : Env.env}
21 :    
22 : jhr 88 exception Error
23 :    
24 : jhr 86 type context = Error.err_stream * Error.span
25 :    
26 :     fun withContext ((errStrm, _), {span, tree}) =
27 :     ((errStrm, span), tree)
28 :     fun withEnvAndContext (env, (errStrm, _), {span, tree}) =
29 :     (env, (errStrm, span), tree)
30 :    
31 : jhr 88 fun error ((errStrm, span), msg) = (
32 :     Error.errorAt(errStrm, span, msg);
33 :     raise Error)
34 : jhr 86
35 : jhr 88 datatype token
36 :     = S of string | A of Atom.atom
37 :     | V of AST.var | TY of Types.ty | TYS of Types.ty list
38 :    
39 :     fun err (cxt, toks) = let
40 :     fun tok2str (S s) = s
41 :     | tok2str (A a) = Atom.toString a
42 :     | tok2str (V x) = Var.nameOf x
43 : jhr 96 | tok2str (TY ty) = TU.toString ty
44 : jhr 88 | tok2str (TYS []) = "()"
45 : jhr 96 | tok2str (TYS[ty]) = TU.toString ty
46 : jhr 88 | tok2str (TYS tys) = String.concat[
47 : jhr 96 "(", String.concatWith " * " (List.map TU.toString tys), ")"
48 : jhr 88 ]
49 :     in
50 :     error(cxt, List.map tok2str toks)
51 :     end
52 :    
53 : jhr 83 val realZero = AST.E_Lit(Literal.Float(FloatLit.zero true))
54 :    
55 : jhr 70 (* check a differentiation level, which muse be >= 0 *)
56 :     fun checkDiff (cxt, k) =
57 :     if (k < 0)
58 :     then raise Fail "differentiation must be >= 0"
59 : jhr 75 else Ty.DiffConst(IntInf.toInt k)
60 : jhr 70
61 :     (* check a dimension, which must be 2 or 3 *)
62 :     fun checkDim (cxt, d) =
63 : jhr 82 if (d <= 0)
64 :     then raise Fail "invalid dimension; must be > 0"
65 : jhr 75 else Ty.DimConst(IntInf.toInt d)
66 : jhr 70
67 :     (* check a shape *)
68 :     fun checkShape (cxt, shape) = let
69 :     fun chkDim d = if (d < 1)
70 :     then raise Fail "invalid shape dimension; must be >= 1"
71 : jhr 75 else Ty.DimConst(IntInf.toInt d)
72 : jhr 70 in
73 :     Ty.Shape(List.map chkDim shape)
74 :     end
75 :    
76 : jhr 69 (* check the well-formedness of a type and translate it to an AST type *)
77 : jhr 70 fun checkTy (cxt, ty) = (case ty
78 : jhr 86 of PT.T_Mark m => checkTy(withContext(cxt, m))
79 : jhr 70 | PT.T_Bool => Ty.T_Bool
80 :     | PT.T_Int => Ty.T_Int
81 :     | PT.T_Real => Ty.realTy
82 :     | PT.T_String => Ty.T_String
83 :     | PT.T_Vec n => (* NOTE: the parser guarantees that 2 <= n <= 4 *)
84 :     Ty.vecTy(IntInf.toInt n)
85 :     | PT.T_Kernel k => Ty.T_Kernel(checkDiff(cxt, k))
86 :     | PT.T_Field{diff, dim, shape} => Ty.T_Field{
87 :     diff = checkDiff (cxt, diff),
88 :     dim = checkDim (cxt, dim),
89 :     shape = checkShape (cxt, shape)
90 :     }
91 :     | PT.T_Tensor shape => Ty.T_Tensor(checkShape(cxt, shape))
92 :     | PT.T_Image{dim, shape} => Ty.T_Image{
93 :     dim = checkDim (cxt, dim),
94 :     shape = checkShape (cxt, shape)
95 :     }
96 : jhr 99 | PT.T_Array(ty, dims) => raise Fail "Array type not supported"
97 : jhr 69 (* end case *))
98 :    
99 : jhr 71 fun checkLit lit = (case lit
100 :     of (Literal.Int _) => (AST.E_Lit lit, Ty.T_Int)
101 :     | (Literal.Float _) => (AST.E_Lit lit, Ty.realTy)
102 :     | (Literal.String s) => (AST.E_Lit lit, Ty.T_String)
103 :     | (Literal.Bool _) => (AST.E_Lit lit, Ty.T_Bool)
104 :     (* end case *))
105 :    
106 : jhr 85 (* resolve overloading: we use a simple scheme that selects the first operator in the
107 :     * list that matches the argument types.
108 :     *)
109 : jhr 91 fun resolveOverload (cxt, rator, argTys, args, candidates) = let
110 :     fun tryCandidates [] = err(cxt, [
111 :     S "unable to resolve overloaded operator \"", A rator, S "\"\n",
112 :     S " argument type is: ", TYS argTys, S "\n"
113 : jhr 85 ])
114 :     | tryCandidates (x::xs) = let
115 :     val (tyArgs, Ty.T_Fun(domTy, rngTy)) = Util.instantiate(Var.typeOf x)
116 :     in
117 :     if U.tryMatchTypes(domTy, argTys)
118 :     then (AST.E_Apply(x, tyArgs, args, rngTy), rngTy)
119 :     else tryCandidates xs
120 :     end
121 :     in
122 :     tryCandidates candidates
123 :     end
124 :    
125 : jhr 70 (* typecheck an expression and translate it to AST *)
126 : jhr 169 fun checkExpr (env : env, cxt, e) = (case e
127 : jhr 86 of PT.E_Mark m => checkExpr (withEnvAndContext (env, cxt, m))
128 : jhr 169 | PT.E_Var x => (case Env.findVar (#env env, x)
129 : jhr 81 of SOME x' => let
130 :     val (args, ty) = Util.instantiate(Var.typeOf x')
131 :     in
132 :     (AST.E_Var(x', args, ty), ty)
133 :     end
134 : jhr 88 | NONE => err(cxt, [S "undeclared variable ", A x])
135 : jhr 71 (* end case *))
136 :     | PT.E_Lit lit => checkLit lit
137 : jhr 81 | PT.E_OrElse(e1, e2) => let
138 :     val (e1', ty1) = checkExpr(env, cxt, e1)
139 :     val (e2', ty2) = checkExpr(env, cxt, e2)
140 :     in
141 :     case (ty1, ty2)
142 :     of (Ty.T_Bool, Ty.T_Bool) =>
143 :     (AST.E_Cond(e1', AST.E_Lit(Literal.Bool true), e2'), Ty.T_Bool)
144 : jhr 99 | _ => err (cxt, [S "arguments to \"||\" must have bool type"])
145 : jhr 81 (* end case *)
146 :     end
147 :     | PT.E_AndAlso(e1, e2) => let
148 :     val (e1', ty1) = checkExpr(env, cxt, e1)
149 :     val (e2', ty2) = checkExpr(env, cxt, e2)
150 :     in
151 :     case (ty1, ty2)
152 :     of (Ty.T_Bool, Ty.T_Bool) =>
153 :     (AST.E_Cond(e1', e2', AST.E_Lit(Literal.Bool false)), Ty.T_Bool)
154 : jhr 99 | _ => err (cxt, [S "arguments to \"&&\" must have bool type"])
155 : jhr 81 (* end case *)
156 :     end
157 :     | PT.E_BinOp(e1, rator, e2) => let
158 :     val (e1', ty1) = checkExpr(env, cxt, e1)
159 :     val (e2', ty2) = checkExpr(env, cxt, e2)
160 :     in
161 :     case Basis.findOp rator
162 :     of [rator] => let
163 :     val (tyArgs, Ty.T_Fun(domTy, rngTy)) = Util.instantiate(Var.typeOf rator)
164 :     in
165 :     if U.matchTypes(domTy, [ty1, ty2])
166 :     then (AST.E_Apply(rator, tyArgs, [e1', e2'], rngTy), rngTy)
167 : jhr 89 else err (cxt, [
168 :     S "type error for binary operator \"", V rator, S "\"\n",
169 :     S " expected: ", TYS domTy, S "\n",
170 :     S " but found: ", TYS[ty1, ty2], S "\n"
171 : jhr 85 ])
172 : jhr 81 end
173 : jhr 91 | ovldList => resolveOverload (cxt, rator, [ty1, ty2], [e1', e2'], ovldList)
174 : jhr 81 (* end case *)
175 :     end
176 :     | PT.E_UnaryOp(rator, e) => let
177 :     val (e', ty) = checkExpr(env, cxt, e)
178 :     in
179 :     case Basis.findOp rator
180 :     of [rator] => let
181 :     val (tyArgs, Ty.T_Fun([domTy], rngTy)) = Util.instantiate(Var.typeOf rator)
182 :     in
183 :     if U.matchType(domTy, ty)
184 :     then (AST.E_Apply(rator, tyArgs, [e'], rngTy), rngTy)
185 : jhr 89 else err (cxt, [
186 :     S "type error for unary operator \"", V rator, S "\"\n",
187 :     S " expected: ", TY domTy, S "\n",
188 :     S " but found: ", TY ty, S "\n"
189 : jhr 85 ])
190 : jhr 81 end
191 : jhr 91 | ovldList => resolveOverload (cxt, rator, [ty], [e'], ovldList)
192 : jhr 81 (* end case *)
193 :     end
194 :     | PT.E_Tuple args => let
195 :     val (args, tys) = checkExprList (env, cxt, args)
196 :     in
197 :     raise Fail "E_Tuple not yet implemented"
198 :     end
199 :     | PT.E_Apply(f, args) => let
200 :     val (args, tys) = checkExprList (env, cxt, args)
201 :     in
202 : jhr 169 case Env.findFunc (#env env, f)
203 :     of SOME f =>
204 :     if (#globalScope env) orelse not(Basis.isRestricted f)
205 :     then (case Util.instantiate(Var.typeOf f)
206 :     of (tyArgs, Ty.T_Fun(domTy, rngTy)) =>
207 :     if U.matchTypes(domTy, tys)
208 :     then (AST.E_Apply(f, tyArgs, args, rngTy), rngTy)
209 :     else err(cxt, [
210 :     S "type error in application of ", V f, S "\n",
211 :     S " expected: ", TYS domTy, S "\n",
212 :     S " but found: ", TYS tys, S "\n"
213 :     ])
214 :     | _ => err(cxt, [S "application of non-function ", V f])
215 :     (* end case *))
216 :     else err(cxt, [S "use of restricted operation ", V f, S " in actor body"])
217 : jhr 99 | NONE => err(cxt, [S "unknown function ", A f])
218 : jhr 81 (* end case *)
219 :     end
220 : jhr 86 | PT.E_Cons args => let
221 :     val (args, ty::tys) = checkExprList (env, cxt, args)
222 : jhr 81 in
223 : jhr 96 case TU.pruneHead ty
224 : jhr 86 of Ty.T_Tensor shape => let
225 :     fun chkTy ty' = U.matchType(ty, ty')
226 :     val resTy = Ty.T_Tensor(Ty.shapeExt(shape, Ty.DimConst(List.length args)))
227 : jhr 83 in
228 : jhr 86 if List.all chkTy tys
229 :     then (AST.E_Cons args, resTy)
230 : jhr 99 else err(cxt, [S "arguments of tensor construction must have same type"])
231 : jhr 83 end
232 : jhr 99 | _ => err(cxt, [S "Invalid argument type for tensor construction"])
233 : jhr 83 (* end case *)
234 : jhr 81 end
235 : jhr 86 | PT.E_Real e => (case checkExpr (env, cxt, e)
236 :     of (e', Ty.T_Int) =>
237 :     (AST.E_Apply(BasisVars.i2r, [], [e'], Ty.realTy), Ty.realTy)
238 : jhr 99 | _ => err(cxt, [S "argument of real conversion must be int"])
239 : jhr 86 (* end case *))
240 : jhr 70 (* end case *))
241 :    
242 : jhr 81 (* typecheck a list of expressions returning a list of AST expressions and a list
243 :     * of types of the expressions.
244 :     *)
245 :     and checkExprList (env, cxt, exprs) = let
246 :     fun chk (e, (es, tys)) = let
247 :     val (e, ty) = checkExpr (env, cxt, e)
248 :     in
249 :     (e::es, ty::tys)
250 :     end
251 :     in
252 :     List.foldr chk ([], []) exprs
253 :     end
254 :    
255 : jhr 72 fun checkVarDecl (env, cxt, kind, d) = (case d
256 : jhr 86 of PT.VD_Mark m => checkVarDecl (env, (#1 cxt, #span m), kind, #tree m)
257 : jhr 72 | PT.VD_Decl(ty, x, e) => let
258 : jhr 81 val ty = checkTy (cxt, ty)
259 : jhr 72 val x' = Var.new (x, kind, ty)
260 :     val (e', ty') = checkExpr (env, cxt, e)
261 :     in
262 : jhr 99 (* FIXME: this check is not flexible enough; should allow lhs type to support
263 :     * fewer levels of differentiation than rhs provides.
264 :     *)
265 :     if U.matchType(ty, ty')
266 :     then (x, x', e')
267 :     else err(cxt, [
268 :     S "type of variable ", A x,
269 :     S " does not match type of initializer\n",
270 :     S " expected: ", TY ty, S "\n",
271 :     S " but found: ", TY ty', S "\n"
272 :     ])
273 : jhr 72 end
274 :     (* end case *))
275 :    
276 : jhr 169 fun checkGlobalExpr (env, cxt, exp) = checkExpr ({globalScope=true, env=env}, cxt, exp)
277 :     fun checkLocalExpr (env, cxt, exp) = checkExpr ({globalScope=false, env=env}, cxt, exp)
278 :     fun checkLocalExprList (env, cxt, exp) = checkExprList ({globalScope=false, env=env}, cxt, exp)
279 :    
280 : jhr 70 (* typecheck a statement and translate it to AST *)
281 : jhr 71 fun checkStmt (env, cxt, s) = (case s
282 : jhr 86 of PT.S_Mark m => checkStmt (withEnvAndContext (env, cxt, m))
283 : jhr 72 | PT.S_Block stms => let
284 :     fun chk (_, [], stms) = AST.S_Block(List.rev stms)
285 :     | chk (env, s::ss, stms) = let
286 :     val (s', env') = checkStmt (env, cxt, s)
287 :     in
288 : jhr 81 chk (env', ss, s'::stms)
289 : jhr 72 end
290 :     in
291 :     (chk (env, stms, []), env)
292 :     end
293 :     | PT.S_Decl vd => let
294 : jhr 169 val (x, x', e) = checkVarDecl ({globalScope=false, env=env}, cxt, Var.LocalVar, vd)
295 : jhr 72 in
296 : jhr 81 (AST.S_Decl(AST.VD_Decl(x', e)), Env.insertLocal(env, x, x'))
297 : jhr 72 end
298 :     | PT.S_IfThen(e, s) => let
299 : jhr 169 val (e', ty) = checkLocalExpr (env, cxt, e)
300 : jhr 81 val (s', _) = checkStmt (env, cxt, s)
301 : jhr 72 in
302 :     (* check that condition has bool type *)
303 :     case ty
304 :     of Ty.T_Bool => ()
305 : jhr 99 | _ => err(cxt, [S "condition not boolean type"])
306 : jhr 72 (* end case *);
307 :     (AST.S_IfThenElse(e', s', AST.S_Block[]), env)
308 :     end
309 :     | PT.S_IfThenElse(e, s1, s2) => let
310 : jhr 169 val (e', ty) = checkLocalExpr (env, cxt, e)
311 : jhr 81 val (s1', _) = checkStmt (env, cxt, s1)
312 :     val (s2', _) = checkStmt (env, cxt, s2)
313 : jhr 72 in
314 :     (* check that condition has bool type *)
315 :     case ty
316 :     of Ty.T_Bool => ()
317 : jhr 99 | _ => err(cxt, [S "condition not boolean type"])
318 : jhr 72 (* end case *);
319 :     (AST.S_IfThenElse(e', s1', s2'), env)
320 :     end
321 :     | PT.S_Assign(x, e) => (case Env.findVar (env, x)
322 : jhr 99 of NONE => err(cxt, [
323 :     S "undefined variable ", A x
324 :     ])
325 : jhr 72 | SOME x' => let
326 : jhr 99 (* FIXME: check for polymorphic variables *)
327 :     val ([], ty) = Var.typeOf x'
328 : jhr 169 val (e', ty') = checkLocalExpr (env, cxt, e)
329 : jhr 72 in
330 : jhr 99 if U.matchType(ty, ty')
331 :     then (x, x', e')
332 :     else err(cxt, [
333 :     S "type of assigned variable ", A x,
334 :     S " does not match type of rhs\n",
335 :     S " expected: ", TY ty, S "\n",
336 :     S " but found: ", TY ty', S "\n"
337 :     ]);
338 : jhr 72 (* check that x' is mutable *)
339 :     case Var.kindOf x'
340 :     of Var.ActorStateVar => ()
341 :     | Var.LocalVar => ()
342 : jhr 99 | _ => err(cxt, [
343 :     S "assignment to immutable variable ", A x
344 :     ])
345 : jhr 72 (* end case *);
346 :     (AST.S_Assign(x', e'), env)
347 :     end
348 :     (* end case *))
349 :     | PT.S_New(actor, args) => let
350 : jhr 169 val argsAndTys' = List.map (fn e => checkLocalExpr(env, cxt, e)) args
351 : jhr 81 val (args', tys') = ListPair.unzip argsAndTys'
352 : jhr 72 in
353 :     (* FIXME: check that actor is defined and has the argument types match *)
354 : jhr 81 (AST.S_New(actor, args'), env)
355 : jhr 72 end
356 :     | PT.S_Die => (AST.S_Die, env)
357 :     | PT.S_Stabilize => (AST.S_Stabilize, env)
358 : jhr 70 (* end case *))
359 :    
360 : jhr 82 fun checkParams (env, cxt, params) = let
361 :     fun chkParam (env, cxt, param) = (case param
362 : jhr 86 of PT.P_Mark m => chkParam (withEnvAndContext (env, cxt, m))
363 : jhr 82 | PT.P_Param(ty, x) => let
364 :     val x' = Var.new(x, AST.ActorParam, checkTy (cxt, ty))
365 :     in
366 :     (x', Env.insertLocal(env, x, x'))
367 :     end
368 :     (* end case *))
369 :     fun chk (param, (xs, env)) = let
370 :     val (x, env) = chkParam (env, cxt, param)
371 :     in
372 :     (x::xs, env)
373 :     end
374 :     in
375 :     (* FIXME: need to check for multiple occurences of the same parameter name! *)
376 :     List.foldr chk ([], env) params
377 :     end
378 :    
379 :     fun checkMethod (env, cxt, meth) = (case meth
380 : jhr 86 of PT.M_Mark m => checkMethod (withEnvAndContext (env, cxt, m))
381 : jhr 82 | PT.M_Method(name, body) => let
382 :     val (body, _) = checkStmt(env, cxt, body)
383 :     in
384 :     AST.M_Method(name, body)
385 :     end
386 :     (* end case *))
387 :    
388 :     fun checkActor (env, cxt, {name, params, state, methods}) = let
389 :     (* check the actor parameters *)
390 :     val (params, env) = checkParams (env, cxt, params)
391 :     (* check the actor state variable definitions *)
392 :     val (vds, env) = let
393 : jhr 164 fun checkStateVar ((isOut, vd), (vds, env)) = let
394 : jhr 169 val (x, x', e') = checkVarDecl ({globalScope=false, env=env}, cxt, AST.ActorStateVar, vd)
395 : jhr 82 in
396 : jhr 164 ((isOut, AST.VD_Decl(x', e'))::vds, Env.insertLocal(env, x, x'))
397 : jhr 82 end
398 :     val (vds, env) = List.foldl checkStateVar ([], env) state
399 :     in
400 :     (List.rev vds, env)
401 :     end
402 :     (* check the actor methods *)
403 :     val methods = List.map (fn m => checkMethod (env, cxt, m)) methods
404 :     in
405 :     AST.D_Actor{name = name, params = params, state = vds, methods = methods}
406 :     end
407 :    
408 : jhr 89 fun checkCreate (env, cxt, PT.C_Mark m) = checkCreate (withEnvAndContext (env, cxt, m))
409 :     | checkCreate (env, cxt, PT.C_Create(actor, args)) = let
410 : jhr 169 val (args, tys) = checkLocalExprList (env, cxt, args)
411 : jhr 89 in
412 :     (* FIXME: check against actor definition *)
413 :     AST.C_Create(actor, args)
414 :     end
415 :    
416 :     fun checkIter (env, cxt, PT.I_Mark m) = checkIter (withEnvAndContext (env, cxt, m))
417 :     | checkIter (env, cxt, PT.I_Range(x, e1, e2)) = let
418 : jhr 169 val (e1', ty1) = checkLocalExpr (env, cxt, e1)
419 :     val (e2', ty2) = checkLocalExpr (env, cxt, e2)
420 : jhr 89 val x' = Var.new(x, Var.LocalVar, Ty.T_Int)
421 :     val env' = Env.insertLocal(env, x, x')
422 :     in
423 :     case (ty1, ty2)
424 :     of (Ty.T_Int, Ty.T_Int) => (AST.I_Range(x', e1', e2'), env')
425 :     | _ => err(cxt, [
426 :     S "range expressions must have integer type\n",
427 :     S " but found: ", TY ty1, S " .. ", TY ty2, S "\n"
428 :     ])
429 :     (* end case *)
430 :     end
431 :    
432 :     fun checkIters (env, cxt, iters) = let
433 :     fun chk (env, [], iters) = (List.rev iters, env)
434 :     | chk (env, iter::rest, iters) = let
435 :     val (iter, env) = checkIter (env, cxt, iter)
436 :     in
437 :     chk (env, rest, iter::iters)
438 :     end
439 :     in
440 :     chk (env, iters, [])
441 :     end
442 :    
443 : jhr 71 fun checkDecl (env, cxt, d) = (case d
444 : jhr 86 of PT.D_Mark m => checkDecl (withEnvAndContext (env, cxt, m))
445 : jhr 72 | PT.D_Input(ty, x, optExp) => let
446 : jhr 71 val ty = checkTy(cxt, ty)
447 :     val x' = Var.new(x, Var.InputVar, ty)
448 :     val dcl = (case optExp
449 :     of NONE => AST.D_Input(x', NONE)
450 :     | SOME e => let
451 : jhr 169 val (e', ty') = checkGlobalExpr (env, cxt, e)
452 : jhr 71 in
453 : jhr 89 if U.matchType (ty, ty')
454 :     then AST.D_Input(x', SOME e')
455 :     else err(cxt, [
456 :     S "definition of ", V x', S " has wrong type\n",
457 :     S " expected: ", TY ty, S "\n",
458 :     S " but found: ", TY ty', S "\n"
459 :     ])
460 : jhr 71 end
461 :     (* end case *))
462 :     in
463 :     (dcl, Env.insertGlobal(env, x, x'))
464 :     end
465 : jhr 72 | PT.D_Var vd => let
466 : jhr 169 val (x, x', e') = checkVarDecl ({globalScope=true, env=env}, cxt, Var.GlobalVar, vd)
467 : jhr 72 in
468 : jhr 81 (AST.D_Var(AST.VD_Decl(x', e')), Env.insertGlobal(env, x, x'))
469 : jhr 72 end
470 : jhr 82 | PT.D_Actor arg => (checkActor(env, cxt, arg), env)
471 : jhr 89 | PT.D_InitialArray(create, iterators) => let
472 :     val (iterators, env') = checkIters (env, cxt, iterators)
473 :     val create = checkCreate (env', cxt, create)
474 :     in
475 :     (AST.D_InitialArray(create, iterators), env)
476 :     end
477 :     | PT.D_InitialCollection(create, iterators) => let
478 :     val (iterators, env') = checkIters (env, cxt, iterators)
479 :     val create = checkCreate (env', cxt, create)
480 :     in
481 :     (AST.D_InitialCollection(create, iterators), env)
482 :     end
483 : jhr 70 (* end case *))
484 :    
485 : jhr 86 fun check errStrm (PT.Program{span, tree}) = let
486 :     val cxt = (errStrm, span)
487 : jhr 81 fun chk (env, [], dcls') = AST.Program(List.rev dcls')
488 :     | chk (env, dcl::dcls, dcls') = let
489 : jhr 86 val (dcl', env) = checkDecl (env, cxt, dcl)
490 : jhr 81 in
491 :     chk (env, dcls, dcl'::dcls')
492 :     end
493 :     in
494 :     chk (Basis.env, tree, [])
495 :     end
496 : jhr 70
497 : jhr 69 end

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