Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/typechecker/check-expr.sml
 [diderot] / branches / vis15 / src / compiler / typechecker / check-expr.sml

# Diff of /branches/vis15/src/compiler/typechecker/check-expr.sml

revision 3431, Sat Nov 14 14:03:58 2015 UTC revision 3464, Sun Nov 29 17:38:34 2015 UTC
# Line 95  Line 95
95            end            end
96
97    (* check the type of a literal *)    (* check the type of a literal *)
98      fun checkLit lit = (case lit      fun checkLit lit = (AST.E_Lit lit, TypeOf.literal lit)
of (L.Int _) => (AST.E_Lit lit, Ty.T_Int)
| (L.Real _) => (AST.E_Lit lit, Ty.realTy)
| (L.String s) => (AST.E_Lit lit, Ty.T_String)
| (L.Bool _) => (AST.E_Lit lit, Ty.T_Bool)
(* end case *))
99
100    (* type check a dot product, which has the constraint:    (* type check a dot product, which has the constraint:
101     *     ALL[sigma1, d1, sigma2] . tensor[sigma1, d1] * tensor[d1, sigma2] -> tensor[sigma1, sigma2]     *     ALL[sigma1, d1, sigma2] . tensor[sigma1, d1] * tensor[d1, sigma2] -> tensor[sigma1, sigma2]
# Line 678  Line 673
673            val (e', ty) = check (env', cxt, e)            val (e', ty) = check (env', cxt, e)
674            val resTy = Ty.T_Sequence(ty, NONE)            val resTy = Ty.T_Sequence(ty, NONE)
675            in            in
676              (AST.E_Comprehension(e', iter', resTy), resTy)              case iter'
677                 of (x, AST.E_Var(xs, span)) =>
678                      if Basis.isStrandSet xs
679                      andalso not(Env.inGlobalInit env orelse Env.inGlobalUpdate env)
680                        then err (cxt, [
681                            S "use of strand set ", V xs,
682                            S " outside of global initialization or update"
683                          ])
684                        else (AST.E_ParallelMap(e', x, xs, resTy), resTy)
685                  | _ => (AST.E_Comprehension(e', iter', resTy), resTy)
686                (* end case *)
687            end            end
688        | chkComprehension _ = raise Fail "impossible"        | chkComprehension _ = raise Fail "impossible"
689
# Line 719  Line 724
724      and chkStringConstExpr (env, cxt, PT.E_Mark m) =      and chkStringConstExpr (env, cxt, PT.E_Mark m) =
725            chkStringConstExpr (E.withEnvAndContext (env, cxt, m))            chkStringConstExpr (E.withEnvAndContext (env, cxt, m))
726        | chkStringConstExpr (env, cxt, e) = (case checkAndPrune (env, cxt, e)        | chkStringConstExpr (env, cxt, e) = (case checkAndPrune (env, cxt, e)
727             of (e', Ty.T_String) => (case ConstExpr.eval (cxt, e')             of (e', Ty.T_String) => (case CheckConst.eval (cxt, false, e')
728                   of SOME(ConstExpr.String s) => SOME s                   of SOME(ConstExpr.String s) => SOME s
729                    | SOME(ConstExpr.Expr e) => raise Fail "FIXME"                    | SOME(ConstExpr.Expr e) => raise Fail "FIXME"
730                    | NONE => NONE                    | NONE => NONE
# Line 736  Line 741
741
742    (* check a dimension that is given by a constant expression *)    (* check a dimension that is given by a constant expression *)
743      and checkDim (env, cxt, dim) = (case checkAndPrune (env, cxt, dim)      and checkDim (env, cxt, dim) = (case checkAndPrune (env, cxt, dim)
744             of (e', Ty.T_Int) => (case ConstExpr.eval (cxt, e')             of (e', Ty.T_Int) => (case CheckConst.eval (cxt, false, e')
745                   of SOME(ConstExpr.Int d) => SOME d                   of SOME(ConstExpr.Int d) => SOME d
746                    | SOME(ConstExpr.Expr e) => (                    | SOME(ConstExpr.Expr e) => (
747                        TypeError.error (cxt, [S "unable to evaluate constant dimension expression"]);                        TypeError.error (cxt, [S "unable to evaluate constant dimension expression"]);

Legend:
 Removed from v.3431 changed lines Added in v.3464