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

SCM Repository

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

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

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

revision 3467, Sun Nov 29 20:45:59 2015 UTC revision 3499, Wed Dec 16 14:34:52 2015 UTC
# Line 69  Line 69 
69  (* FIXME: we could be more efficient by just checking for coercion matchs the first pass  (* FIXME: we could be more efficient by just checking for coercion matchs the first pass
70   * and remembering those that are not pure EQ matches.   * and remembering those that are not pure EQ matches.
71   *)   *)
72            (* build the result *)
73              fun done (rator, tyArgs, args, rngTy) = if Var.same(rator, BV.pow_si)
74                    then let (* check that the second argument is a constant expression *)
75                      val [e1, e2] = args
76                      in
77                        case CheckConst.eval (cxt, false, e2)
78                         of SOME e2' =>
79                              (AST.E_Prim(rator, tyArgs, [e1, ConstExpr.valueToExpr e2'], rngTy), rngTy)
80                          | NONE => err(cxt, [
81                                S "constant-integer exponent is required when lhs of '^' is a field"
82                              ])
83                      end
84                    else (AST.E_Prim(rator, tyArgs, args, rngTy), rngTy)
85          (* try to match candidates while allowing type coercions *)          (* try to match candidates while allowing type coercions *)
86            fun tryMatchCandidates [] = err(cxt, [            fun tryMatchCandidates [] = err(cxt, [
87                    S "unable to resolve overloaded operator ", A rator, S "\n",                    S "unable to resolve overloaded operator ", A rator, S "\n",
# Line 78  Line 91 
91                  val (tyArgs, Ty.T_Fun(domTy, rngTy)) = TU.instantiate(Var.typeOf x)                  val (tyArgs, Ty.T_Fun(domTy, rngTy)) = TU.instantiate(Var.typeOf x)
92                  in                  in
93                    case Unify.tryMatchArgs (domTy, args, argTys)                    case Unify.tryMatchArgs (domTy, args, argTys)
94                     of SOME args' => (AST.E_Prim(x, tyArgs, args', rngTy), rngTy)                     of SOME args' => done(x, tyArgs, args', rngTy)
95                      | NONE => tryMatchCandidates xs                      | NONE => tryMatchCandidates xs
96                    (* end case *)                    (* end case *)
97                  end                  end
98            (* try to match candidates without type coercions *)
99            fun tryCandidates [] = tryMatchCandidates candidates            fun tryCandidates [] = tryMatchCandidates candidates
100              | tryCandidates (x::xs) = let              | tryCandidates (x::xs) = let
101                  val (tyArgs, Ty.T_Fun(domTy, rngTy)) = TU.instantiate(Var.typeOf x)                  val (tyArgs, Ty.T_Fun(domTy, rngTy)) = TU.instantiate(Var.typeOf x)
102                  in                  in
103                    if Unify.tryEqualTypes(domTy, argTys)                    if Unify.tryEqualTypes(domTy, argTys)
104                      then (AST.E_Prim(x, tyArgs, args, rngTy), rngTy)                      then done(x, tyArgs, args, rngTy)
105                      else tryCandidates xs                      else tryCandidates xs
106                  end                  end
107            in            in

Legend:
Removed from v.3467  
changed lines
  Added in v.3499

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