|
@@ -109,7 +109,7 @@ let get_abstract_froms a pl =
|
|
|
let maybe_type_against_enum ctx f with_type iscall p =
|
|
|
try
|
|
|
begin match with_type with
|
|
|
- | WithType t ->
|
|
|
+ | WithType.WithType(t,_) ->
|
|
|
let rec loop stack t = match follow t with
|
|
|
| TEnum (en,_) ->
|
|
|
true,en.e_path,en.e_names,TEnumDecl en
|
|
@@ -488,7 +488,7 @@ let rec type_binop ctx op e1 e2 is_assign_op with_type p =
|
|
|
match op with
|
|
|
| OpAssign ->
|
|
|
let e1 = type_access ctx (fst e1) (snd e1) MSet in
|
|
|
- let tt = (match e1 with AKNo _ | AKInline _ | AKUsing _ | AKMacro _ | AKAccess _ -> Value | AKFieldSet(_,_,_,t) | AKSet(_,t,_) -> WithType t | AKExpr e -> WithType e.etype) in
|
|
|
+ let tt = (match e1 with AKNo _ | AKInline _ | AKUsing _ | AKMacro _ | AKAccess _ -> WithType.value | AKFieldSet(_,_,_,t) | AKSet(_,t,_) -> WithType.with_type t | AKExpr e -> WithType.with_type e.etype) in
|
|
|
let e2 = type_expr ctx e2 tt in
|
|
|
(match e1 with
|
|
|
| AKNo s -> error ("Cannot access field or identifier " ^ s ^ " for writing") p
|
|
@@ -635,7 +635,7 @@ let rec type_binop ctx op e1 e2 is_assign_op with_type p =
|
|
|
let ekey,ekey' = maybe_bind_to_temp ekey in
|
|
|
let ebase,ebase' = maybe_bind_to_temp ebase in
|
|
|
let eget = mk_array_get_call ctx (cf_get,tf_get,r_get,ekey,None) c ebase p in
|
|
|
- let eget = type_binop2 ctx op eget e2 true (WithType eget.etype) p in
|
|
|
+ let eget = type_binop2 ctx op eget e2 true (WithType.with_type eget.etype) p in
|
|
|
unify ctx eget.etype r_get p;
|
|
|
let cf_set,tf_set,r_set,ekey,eget = AbstractCast.find_array_access ctx a tl ekey (Some eget) p in
|
|
|
let eget = match eget with None -> assert false | Some e -> e in
|
|
@@ -643,7 +643,7 @@ let rec type_binop ctx op e1 e2 is_assign_op with_type p =
|
|
|
let e = match cf_set.cf_expr,cf_get.cf_expr with
|
|
|
| None,None ->
|
|
|
let ea = mk (TArray(ebase,ekey)) r_get p in
|
|
|
- mk (TBinop(OpAssignOp op,ea,type_expr ctx e2 (WithType r_get))) r_set p
|
|
|
+ mk (TBinop(OpAssignOp op,ea,type_expr ctx e2 (WithType.with_type r_get))) r_set p
|
|
|
| Some _,Some _ ->
|
|
|
let ef_set = mk (TField(et,(FStatic(c,cf_set)))) tf_set p in
|
|
|
let el = [make_call ctx ef_set [ebase;ekey;eget] r_set p] in
|
|
@@ -666,25 +666,25 @@ let rec type_binop ctx op e1 e2 is_assign_op with_type p =
|
|
|
(* If the with_type is an abstract which has exactly one applicable @:op method, we can promote it
|
|
|
to the individual arguments (issue #2786). *)
|
|
|
let wt = match with_type with
|
|
|
- | WithType t ->
|
|
|
+ | WithType.WithType(t,_) ->
|
|
|
begin match follow t with
|
|
|
| TAbstract(a,_) ->
|
|
|
begin match List.filter (fun (o,_) -> o = OpAssignOp(op) || o == op) a.a_ops with
|
|
|
| [_] -> with_type
|
|
|
- | _ -> Value
|
|
|
+ | _ -> WithType.value
|
|
|
end
|
|
|
| _ ->
|
|
|
- Value
|
|
|
+ WithType.value
|
|
|
end
|
|
|
| _ ->
|
|
|
- Value
|
|
|
+ WithType.value
|
|
|
in
|
|
|
let e1 = type_expr ctx e1 wt in
|
|
|
type_binop2 ctx op e1 e2 is_assign_op wt p
|
|
|
|
|
|
and type_binop2 ctx op (e1 : texpr) (e2 : Ast.expr) is_assign_op wt p =
|
|
|
let with_type = match op with
|
|
|
- | OpEq | OpNotEq | OpLt | OpLte | OpGt | OpGte -> WithType e1.etype
|
|
|
+ | OpEq | OpNotEq | OpLt | OpLte | OpGt | OpGte -> WithType.with_type e1.etype
|
|
|
| _ -> wt
|
|
|
in
|
|
|
let e2 = type_expr ctx e2 with_type in
|
|
@@ -1108,7 +1108,7 @@ and type_unop ctx op flag e p =
|
|
|
let eget = (EField ((EConst (Ident v.v_name),p),cf.cf_name),p) in
|
|
|
match flag with
|
|
|
| Prefix ->
|
|
|
- let get = type_binop ctx op eget one false Value p in
|
|
|
+ let get = type_binop ctx op eget one false WithType.value p in
|
|
|
unify ctx get.etype t p;
|
|
|
l();
|
|
|
mk (TBlock [
|
|
@@ -1118,8 +1118,8 @@ and type_unop ctx op flag e p =
|
|
|
| Postfix ->
|
|
|
let v2 = gen_local ctx t p in
|
|
|
let ev2 = mk (TLocal v2) t p in
|
|
|
- let get = type_expr ctx eget Value in
|
|
|
- let plusone = type_binop ctx op (EConst (Ident v2.v_name),p) one false Value p in
|
|
|
+ let get = type_expr ctx eget WithType.value in
|
|
|
+ let plusone = type_binop ctx op (EConst (Ident v2.v_name),p) one false WithType.value p in
|
|
|
unify ctx get.etype t p;
|
|
|
l();
|
|
|
mk (TBlock [
|
|
@@ -1348,7 +1348,7 @@ and handle_efield ctx e p mode =
|
|
|
(* if there was no module name part, last guess is that we're trying to get package completion *)
|
|
|
if ctx.in_display then begin
|
|
|
if ctx.com.json_out = None then raise (Parser.TypePath (List.map (fun (n,_,_) -> n) (List.rev acc),None,false,p))
|
|
|
- else raise_fields (DisplayToplevel.collect ctx TKType NoValue) CRTypeHint (Some p0);
|
|
|
+ else raise_fields (DisplayToplevel.collect ctx TKType WithType.no_value) CRTypeHint (Some p0);
|
|
|
end;
|
|
|
raise e)
|
|
|
in
|
|
@@ -1394,7 +1394,7 @@ and type_access ctx e p mode =
|
|
|
| EConst (Ident s) ->
|
|
|
type_ident ctx s p mode
|
|
|
| EField (e1,"new") ->
|
|
|
- let e1 = type_expr ctx e1 Value in
|
|
|
+ let e1 = type_expr ctx e1 WithType.value in
|
|
|
begin match e1.eexpr with
|
|
|
| TTypeExpr (TClassDecl c) ->
|
|
|
if mode = MSet then error "Cannot set constructor" p;
|
|
@@ -1428,11 +1428,11 @@ and type_access ctx e p mode =
|
|
|
| EArray (e1,e2) ->
|
|
|
type_array_access ctx e1 e2 p mode
|
|
|
| _ ->
|
|
|
- AKExpr (type_expr ctx (e,p) Value)
|
|
|
+ AKExpr (type_expr ctx (e,p) WithType.value)
|
|
|
|
|
|
and type_array_access ctx e1 e2 p mode =
|
|
|
- let e1 = type_expr ctx e1 Value in
|
|
|
- let e2 = type_expr ctx e2 Value in
|
|
|
+ let e1 = type_expr ctx e1 WithType.value in
|
|
|
+ let e2 = type_expr ctx e2 WithType.value in
|
|
|
let has_abstract_array_access = ref false in
|
|
|
try
|
|
|
(match follow e1.etype with
|
|
@@ -1481,7 +1481,7 @@ and type_vars ctx vl p =
|
|
|
let e = (match e with
|
|
|
| None -> None
|
|
|
| Some e ->
|
|
|
- let e = type_expr ctx e (WithType t) in
|
|
|
+ let e = type_expr ctx e (WithType.with_type t) in
|
|
|
let e = AbstractCast.cast_or_unify ctx t e p in
|
|
|
Some e
|
|
|
) in
|
|
@@ -1614,7 +1614,7 @@ and type_block ctx el with_type p =
|
|
|
let rec loop acc = function
|
|
|
| [] -> List.rev acc
|
|
|
| e :: l ->
|
|
|
- let acc = try merge acc (type_expr ctx e (if l = [] then with_type else NoValue)) with Error (e,p) -> check_error ctx e p; acc in
|
|
|
+ let acc = try merge acc (type_expr ctx e (if l = [] then with_type else WithType.no_value)) with Error (e,p) -> check_error ctx e p; acc in
|
|
|
loop acc l
|
|
|
in
|
|
|
let l = loop [] el in
|
|
@@ -1628,7 +1628,7 @@ and type_block ctx el with_type p =
|
|
|
and type_object_decl ctx fl with_type p =
|
|
|
let dynamic_parameter = ref None in
|
|
|
let a = (match with_type with
|
|
|
- | WithType t ->
|
|
|
+ | WithType.WithType(t,_) ->
|
|
|
let rec loop seen t =
|
|
|
match follow t with
|
|
|
| TAnon a -> ODKWithStructure a
|
|
@@ -1667,14 +1667,14 @@ and type_object_decl ctx fl with_type p =
|
|
|
if ctx.in_display && DisplayPosition.encloses_display_position pn then DisplayEmitter.display_field ctx Unknown CFSMember cf pn;
|
|
|
cf.cf_type
|
|
|
in
|
|
|
- let e = type_expr ctx e (WithType t) in
|
|
|
+ let e = type_expr ctx e (WithType.with_structure_field t n) in
|
|
|
let e = AbstractCast.cast_or_unify ctx t e e.epos in
|
|
|
let e = if is_null t && not (is_null e.etype) then mk (TCast(e,None)) (ctx.t.tnull e.etype) e.epos else e in
|
|
|
(try type_eq EqStrict e.etype t; e with Unify_error _ -> mk (TCast (e,None)) t e.epos)
|
|
|
with Not_found ->
|
|
|
if is_valid then
|
|
|
extra_fields := n :: !extra_fields;
|
|
|
- type_expr ctx e Value
|
|
|
+ type_expr ctx e WithType.value
|
|
|
in
|
|
|
if is_valid then begin
|
|
|
if starts_with n '$' then error "Field names starting with a dollar are not allowed" p;
|
|
@@ -1700,7 +1700,7 @@ and type_object_decl ctx fl with_type p =
|
|
|
let rec loop (l,acc) ((f,pf,qs),e) =
|
|
|
let is_valid = Lexer.is_valid_identifier f in
|
|
|
if PMap.mem f acc then error ("Duplicate field in object declaration : " ^ f) p;
|
|
|
- let e = type_expr ctx e Value in
|
|
|
+ let e = type_expr ctx e (WithType.named_structure_field f) in
|
|
|
(match follow e.etype with TAbstract({a_path=[],"Void"},_) -> error "Fields of type Void are not allowed in structures" e.epos | _ -> ());
|
|
|
let cf = mk_field f e.etype (punion pf e.epos) pf in
|
|
|
if ctx.in_display && DisplayPosition.encloses_display_position pf then DisplayEmitter.display_field ctx Unknown CFSMember cf pf;
|
|
@@ -1793,7 +1793,7 @@ and type_new ctx path el with_type p =
|
|
|
with Generic.Generic_Exception _ as exc ->
|
|
|
(* If we have an expected type, just use that (issue #3804) *)
|
|
|
begin match with_type with
|
|
|
- | WithType t ->
|
|
|
+ | WithType.WithType(t,_) ->
|
|
|
begin match follow t with
|
|
|
| TMono _ -> raise exc
|
|
|
| t -> t
|
|
@@ -1818,7 +1818,7 @@ and type_new ctx path el with_type p =
|
|
|
try begin match t with
|
|
|
| TInst ({cl_kind = KTypeParameter tl} as c,params) ->
|
|
|
if not (TypeloadCheck.is_generic_parameter ctx c) then error "Only generic type parameters can be constructed" p;
|
|
|
- let el = List.map (fun e -> type_expr ctx e Value) el in
|
|
|
+ let el = List.map (fun e -> type_expr ctx e WithType.value) el in
|
|
|
if not (has_constructible_constraint ctx tl el p) then raise_error (No_constructor (TClassDecl c)) p;
|
|
|
mk (TNew (c,params,el)) t p
|
|
|
| TAbstract({a_impl = Some c} as a,tl) when not (Meta.has Meta.MultiType a.a_meta) ->
|
|
@@ -1901,10 +1901,10 @@ and type_try ctx e1 catches with_type p =
|
|
|
((v,e) :: acc1),(e :: acc2)
|
|
|
) ([],[e1]) catches in
|
|
|
let t = match with_type with
|
|
|
- | NoValue -> ctx.t.tvoid
|
|
|
- | Value -> unify_min ctx el
|
|
|
- | WithType t when (match follow t with TMono _ -> true | _ -> false) -> unify_min ctx el
|
|
|
- | WithType t ->
|
|
|
+ | WithType.NoValue -> ctx.t.tvoid
|
|
|
+ | WithType.Value _ -> unify_min ctx el
|
|
|
+ | WithType.WithType(t,_) when (match follow t with TMono _ -> true | _ -> false) -> unify_min ctx el
|
|
|
+ | WithType.WithType(t,_) ->
|
|
|
List.iter (fun e -> unify ctx e.etype t e.epos) el;
|
|
|
t
|
|
|
in
|
|
@@ -1920,7 +1920,7 @@ and type_map_declaration ctx e1 el with_type p =
|
|
|
| _ -> mk_mono(),mk_mono(),false
|
|
|
in
|
|
|
match with_type with
|
|
|
- | WithType t -> get_map_params t
|
|
|
+ | WithType.WithType(t,_) -> get_map_params t
|
|
|
| _ -> (mk_mono(),mk_mono(),false)
|
|
|
in
|
|
|
let keys = Hashtbl.create 0 in
|
|
@@ -1939,19 +1939,19 @@ and type_map_declaration ctx e1 el with_type p =
|
|
|
) el in
|
|
|
let el_k,el_v,tkey,tval = if has_type then begin
|
|
|
let el_k,el_v = List.fold_left (fun (el_k,el_v) (e1,e2) ->
|
|
|
- let e1 = type_expr ctx e1 (WithType tkey) in
|
|
|
+ let e1 = type_expr ctx e1 (WithType.with_type tkey) in
|
|
|
check_key e1;
|
|
|
let e1 = AbstractCast.cast_or_unify ctx tkey e1 e1.epos in
|
|
|
- let e2 = type_expr ctx e2 (WithType tval) in
|
|
|
+ let e2 = type_expr ctx e2 (WithType.with_type tval) in
|
|
|
let e2 = AbstractCast.cast_or_unify ctx tval e2 e2.epos in
|
|
|
(e1 :: el_k,e2 :: el_v)
|
|
|
) ([],[]) el_kv in
|
|
|
el_k,el_v,tkey,tval
|
|
|
end else begin
|
|
|
let el_k,el_v = List.fold_left (fun (el_k,el_v) (e1,e2) ->
|
|
|
- let e1 = type_expr ctx e1 Value in
|
|
|
+ let e1 = type_expr ctx e1 WithType.value in
|
|
|
check_key e1;
|
|
|
- let e2 = type_expr ctx e2 Value in
|
|
|
+ let e2 = type_expr ctx e2 WithType.value in
|
|
|
(e1 :: el_k,e2 :: el_v)
|
|
|
) ([],[]) el_kv in
|
|
|
let unify_min_resume el = try
|
|
@@ -1983,7 +1983,7 @@ and type_local_function ctx name f with_type p =
|
|
|
let params = TypeloadFunction.type_function_params ctx f (match name with None -> "localfun" | Some (n,_) -> n) p in
|
|
|
if params <> [] then begin
|
|
|
if name = None then display_error ctx "Type parameters not supported in unnamed local functions" p;
|
|
|
- if with_type <> NoValue then error "Type parameters are not supported for rvalue functions" p
|
|
|
+ if with_type <> WithType.NoValue then error "Type parameters are not supported for rvalue functions" p
|
|
|
end;
|
|
|
List.iter (fun tp -> if tp.tp_constraints <> None then display_error ctx "Type parameter constraints are not supported for local functions" p) f.f_params;
|
|
|
let inline,v,pname = (match name with
|
|
@@ -2001,7 +2001,7 @@ and type_local_function ctx name f with_type p =
|
|
|
s, c, t
|
|
|
) f.f_args in
|
|
|
(match with_type with
|
|
|
- | WithType t ->
|
|
|
+ | WithType.WithType(t,_) ->
|
|
|
let rec loop t =
|
|
|
(match follow t with
|
|
|
| TFun (args2,tr) when List.length args2 = List.length args ->
|
|
@@ -2021,7 +2021,7 @@ and type_local_function ctx name f with_type p =
|
|
|
| _ -> ())
|
|
|
in
|
|
|
loop t
|
|
|
- | NoValue ->
|
|
|
+ | WithType.NoValue ->
|
|
|
if name = None then display_error ctx "Unnamed lvalue functions are not supported" p
|
|
|
| _ ->
|
|
|
());
|
|
@@ -2073,11 +2073,11 @@ and type_local_function ctx name f with_type p =
|
|
|
else
|
|
|
mk (TVar (v,Some e)) ctx.t.tvoid p
|
|
|
) in
|
|
|
- if with_type <> NoValue && not inline then mk (TBlock [decl;mk (TLocal v) v.v_type p]) v.v_type p else decl)
|
|
|
+ if with_type <> WithType.NoValue && not inline then mk (TBlock [decl;mk (TLocal v) v.v_type p]) v.v_type p else decl)
|
|
|
|
|
|
and type_array_decl ctx el with_type p =
|
|
|
let tp = (match with_type with
|
|
|
- | WithType t ->
|
|
|
+ | WithType.WithType(t,_) ->
|
|
|
let rec loop seen t =
|
|
|
(match follow t with
|
|
|
| TInst ({ cl_path = [],"Array" },[tp]) ->
|
|
@@ -2102,7 +2102,7 @@ and type_array_decl ctx el with_type p =
|
|
|
) in
|
|
|
(match tp with
|
|
|
| None ->
|
|
|
- let el = List.map (fun e -> type_expr ctx e Value) el in
|
|
|
+ let el = List.map (fun e -> type_expr ctx e WithType.value) el in
|
|
|
let t = try
|
|
|
unify_min_raise ctx.com.basic el
|
|
|
with Error (Unify l,p) ->
|
|
@@ -2114,7 +2114,7 @@ and type_array_decl ctx el with_type p =
|
|
|
mk (TArrayDecl el) (ctx.t.tarray t) p
|
|
|
| Some t ->
|
|
|
let el = List.map (fun e ->
|
|
|
- let e = type_expr ctx e (WithType t) in
|
|
|
+ let e = type_expr ctx e (WithType.with_type t) in
|
|
|
AbstractCast.cast_or_unify ctx t e p;
|
|
|
) el in
|
|
|
mk (TArrayDecl el) (ctx.t.tarray t) p)
|
|
@@ -2143,7 +2143,7 @@ and type_array_comprehension ctx e with_type p =
|
|
|
let e = map_compr e in
|
|
|
let ea = type_expr ctx !et with_type in
|
|
|
unify ctx v.v_type ea.etype p;
|
|
|
- let efor = type_expr ctx e NoValue in
|
|
|
+ let efor = type_expr ctx e WithType.NoValue in
|
|
|
mk (TBlock [
|
|
|
mk (TVar (v,Some ea)) ctx.t.tvoid p;
|
|
|
efor;
|
|
@@ -2158,7 +2158,7 @@ and type_return ctx e p =
|
|
|
mk (TReturn None) t_dynamic p
|
|
|
| Some e ->
|
|
|
try
|
|
|
- let e = type_expr ctx e (WithType ctx.ret) in
|
|
|
+ let e = type_expr ctx e (WithType.with_type ctx.ret) in
|
|
|
let e = AbstractCast.cast_or_unify ctx ctx.ret e p in
|
|
|
begin match follow e.etype with
|
|
|
| TAbstract({a_path=[],"Void"},_) ->
|
|
@@ -2206,10 +2206,10 @@ and type_cast ctx e t p =
|
|
|
error "Cast type must be a class or an enum" p
|
|
|
in
|
|
|
let texpr = loop t in
|
|
|
- mk (TCast (type_expr ctx e Value,Some texpr)) t p
|
|
|
+ mk (TCast (type_expr ctx e WithType.value,Some texpr)) t p
|
|
|
|
|
|
and type_if ctx e e1 e2 with_type p =
|
|
|
- let e = type_expr ctx e Value in
|
|
|
+ let e = type_expr ctx e WithType.value in
|
|
|
let e = AbstractCast.cast_or_unify ctx ctx.t.tbool e p in
|
|
|
let e1 = type_expr ctx (Expr.ensure_block e1) with_type in
|
|
|
(match e2 with
|
|
@@ -2218,10 +2218,10 @@ and type_if ctx e e1 e2 with_type p =
|
|
|
| Some e2 ->
|
|
|
let e2 = type_expr ctx (Expr.ensure_block e2) with_type in
|
|
|
let e1,e2,t = match with_type with
|
|
|
- | NoValue -> e1,e2,ctx.t.tvoid
|
|
|
- | Value -> e1,e2,unify_min ctx [e1; e2]
|
|
|
- | WithType t when (match follow t with TMono _ -> true | _ -> false) -> e1,e2,unify_min ctx [e1; e2]
|
|
|
- | WithType t ->
|
|
|
+ | WithType.NoValue -> e1,e2,ctx.t.tvoid
|
|
|
+ | WithType.Value _ -> e1,e2,unify_min ctx [e1; e2]
|
|
|
+ | WithType.WithType(t,_) when (match follow t with TMono _ -> true | _ -> false) -> e1,e2,unify_min ctx [e1; e2]
|
|
|
+ | WithType.WithType(t,_) ->
|
|
|
let e1 = AbstractCast.cast_or_unify ctx t e1 e1.epos in
|
|
|
let e2 = AbstractCast.cast_or_unify ctx t e2 e2.epos in
|
|
|
e1,e2,t
|
|
@@ -2272,7 +2272,7 @@ and type_meta ctx m e1 with_type p =
|
|
|
ctx.meta <- old;
|
|
|
e
|
|
|
|
|
|
-and type_call ctx e el (with_type:with_type) p =
|
|
|
+and type_call ctx e el (with_type:WithType.t) p =
|
|
|
let def () =
|
|
|
let e = maybe_type_against_enum ctx (fun () -> type_access ctx (fst e) (snd e) MCall) with_type true p in
|
|
|
let e = build_call ctx e el with_type p in
|
|
@@ -2287,8 +2287,8 @@ and type_call ctx e el (with_type:with_type) p =
|
|
|
let params = (match el with [] -> [] | _ -> [("customParams",null_pos,NoQuotes),(EArrayDecl (List.map mk_to_string_meta el) , p)]) in
|
|
|
let infos = mk_infos ctx p params in
|
|
|
if (platform ctx.com Js || platform ctx.com Python) && el = [] && has_dce ctx.com then
|
|
|
- let e = type_expr ctx e Value in
|
|
|
- let infos = type_expr ctx infos Value in
|
|
|
+ let e = type_expr ctx e WithType.value in
|
|
|
+ let infos = type_expr ctx infos WithType.value in
|
|
|
let e = match follow e.etype with
|
|
|
| TAbstract({a_impl = Some c},_) when PMap.mem "toString" c.cl_statics ->
|
|
|
call_to_string ctx e
|
|
@@ -2298,31 +2298,31 @@ and type_call ctx e el (with_type:with_type) p =
|
|
|
let e_trace = mk (TIdent "`trace") t_dynamic p in
|
|
|
mk (TCall (e_trace,[e;infos])) ctx.t.tvoid p
|
|
|
else
|
|
|
- type_expr ctx (ECall ((EField ((EField ((EConst (Ident "haxe"),p),"Log"),p),"trace"),p),[mk_to_string_meta e;infos]),p) NoValue
|
|
|
+ type_expr ctx (ECall ((EField ((EField ((EConst (Ident "haxe"),p),"Log"),p),"trace"),p),[mk_to_string_meta e;infos]),p) WithType.NoValue
|
|
|
| (EField ((EConst (Ident "super"),_),_),_), _ ->
|
|
|
def()
|
|
|
| (EField (e,"bind"),p), args ->
|
|
|
- let e = type_expr ctx e Value in
|
|
|
+ let e = type_expr ctx e WithType.value in
|
|
|
(match follow e.etype with
|
|
|
| TFun signature -> type_bind ctx e signature args p
|
|
|
| _ -> def ())
|
|
|
| (EConst (Ident "$type"),_) , [e] ->
|
|
|
- let e = type_expr ctx e Value in
|
|
|
+ let e = type_expr ctx e WithType.value in
|
|
|
ctx.com.warning (s_type (print_context()) e.etype) e.epos;
|
|
|
let e = Diagnostics.secure_generated_code ctx e in
|
|
|
e
|
|
|
| (EField(e,"match"),p), [epat] ->
|
|
|
- let et = type_expr ctx e Value in
|
|
|
+ let et = type_expr ctx e WithType.value in
|
|
|
(match follow et.etype with
|
|
|
| TEnum _ ->
|
|
|
- let e = Matcher.Match.match_expr ctx e [[epat],None,Some (EConst(Ident "true"),p),p] (Some (Some (EConst(Ident "false"),p),p)) (WithType ctx.t.tbool) p in
|
|
|
+ let e = Matcher.Match.match_expr ctx e [[epat],None,Some (EConst(Ident "true"),p),p] (Some (Some (EConst(Ident "false"),p),p)) (WithType.with_type ctx.t.tbool) p in
|
|
|
(* TODO: add that back *)
|
|
|
(* let locals = !get_pattern_locals_ref ctx epat t in
|
|
|
PMap.iter (fun _ (_,p) -> display_error ctx "Capture variables are not allowed" p) locals; *)
|
|
|
e
|
|
|
| _ -> def ())
|
|
|
| (EConst (Ident "__unprotect__"),_) , [(EConst (String _),_) as e] ->
|
|
|
- let e = type_expr ctx e Value in
|
|
|
+ let e = type_expr ctx e WithType.value in
|
|
|
if Common.platform ctx.com Flash then
|
|
|
let t = tfun [e.etype] e.etype in
|
|
|
let e_unprotect = mk (TIdent "__unprotect__") t p in
|
|
@@ -2351,7 +2351,7 @@ and type_call ctx e el (with_type:with_type) p =
|
|
|
| _ ->
|
|
|
def ()
|
|
|
|
|
|
-and type_expr ctx (e,p) (with_type:with_type) =
|
|
|
+and type_expr ctx (e,p) (with_type:WithType.t) =
|
|
|
match e with
|
|
|
| EField ((EConst (String s),ps),"code") ->
|
|
|
if UTF8.length s <> 1 then error "String must be a single UTF8 char" ps;
|
|
@@ -2359,7 +2359,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
|
| EField(_,n) when starts_with n '$' ->
|
|
|
error "Field names starting with $ are not allowed" p
|
|
|
| EConst (Ident s) ->
|
|
|
- if s = "super" && with_type <> NoValue && not ctx.in_display then error "Cannot use super as value" p;
|
|
|
+ if s = "super" && with_type <> WithType.NoValue && not ctx.in_display then error "Cannot use super as value" p;
|
|
|
let e = maybe_type_against_enum ctx (fun () -> type_ident ctx s p MGet) with_type false p in
|
|
|
acc_get ctx e p
|
|
|
| EField _
|
|
@@ -2376,7 +2376,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
|
Texpr.type_constant ctx.com.basic c p
|
|
|
| EBinop (op,e1,e2) ->
|
|
|
type_binop ctx op e1 e2 false with_type p
|
|
|
- | EBlock [] when with_type <> NoValue ->
|
|
|
+ | EBlock [] when with_type <> WithType.NoValue ->
|
|
|
type_expr ctx (EObjectDecl [],p) with_type
|
|
|
| EBlock l ->
|
|
|
let locals = save_locals ctx in
|
|
@@ -2404,18 +2404,18 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
|
type_if ctx e e1 e2 with_type p
|
|
|
| EWhile (cond,e,NormalWhile) ->
|
|
|
let old_loop = ctx.in_loop in
|
|
|
- let cond = type_expr ctx cond Value in
|
|
|
+ let cond = type_expr ctx cond WithType.value in
|
|
|
let cond = AbstractCast.cast_or_unify ctx ctx.t.tbool cond p in
|
|
|
ctx.in_loop <- true;
|
|
|
- let e = type_expr ctx (Expr.ensure_block e) NoValue in
|
|
|
+ let e = type_expr ctx (Expr.ensure_block e) WithType.NoValue in
|
|
|
ctx.in_loop <- old_loop;
|
|
|
mk (TWhile (cond,e,NormalWhile)) ctx.t.tvoid p
|
|
|
| EWhile (cond,e,DoWhile) ->
|
|
|
let old_loop = ctx.in_loop in
|
|
|
ctx.in_loop <- true;
|
|
|
- let e = type_expr ctx (Expr.ensure_block e) NoValue in
|
|
|
+ let e = type_expr ctx (Expr.ensure_block e) WithType.NoValue in
|
|
|
ctx.in_loop <- old_loop;
|
|
|
- let cond = type_expr ctx cond Value in
|
|
|
+ let cond = type_expr ctx cond WithType.value in
|
|
|
let cond = AbstractCast.cast_or_unify ctx ctx.t.tbool cond cond.epos in
|
|
|
mk (TWhile (cond,e,DoWhile)) ctx.t.tvoid p
|
|
|
| ESwitch (e1,cases,def) ->
|
|
@@ -2435,7 +2435,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
|
| ETry (e1,catches) ->
|
|
|
type_try ctx e1 catches with_type p
|
|
|
| EThrow e ->
|
|
|
- let e = type_expr ctx e Value in
|
|
|
+ let e = type_expr ctx e WithType.value in
|
|
|
mk (TThrow e) (mk_mono()) p
|
|
|
| ECall (e,el) ->
|
|
|
type_call ctx e el with_type p
|
|
@@ -2457,7 +2457,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
|
epos = e.epos;
|
|
|
}
|
|
|
| ECast (e,None) ->
|
|
|
- let e = type_expr ctx e Value in
|
|
|
+ let e = type_expr ctx e WithType.value in
|
|
|
mk (TCast (e,None)) (mk_mono()) p
|
|
|
| ECast (e, Some t) ->
|
|
|
type_cast ctx e t p
|
|
@@ -2467,7 +2467,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
|
|
|
assert false
|
|
|
| ECheckType (e,t) ->
|
|
|
let t = Typeload.load_complex_type ctx true t in
|
|
|
- let e = type_expr ctx e (WithType t) in
|
|
|
+ let e = type_expr ctx e (WithType.with_type t) in
|
|
|
let e = AbstractCast.cast_or_unify ctx t e p in
|
|
|
if e.etype == t then e else mk (TCast (e,None)) t p
|
|
|
| EMeta (m,e1) ->
|
|
@@ -2594,7 +2594,7 @@ let rec create com =
|
|
|
(match m.m_types with
|
|
|
| [TClassDecl c1;TClassDecl c2] -> ctx.g.global_using <- (c1,c1.cl_pos) :: (c2,c2.cl_pos) :: ctx.g.global_using
|
|
|
| [TClassDecl c1] ->
|
|
|
- let m = TypeloadModule.load_module ctx (["haxe"],"EnumValueTools") null_pos in
|
|
|
+ let m = TypeloadModule.load_module ctx (["haxe"],"EnumWithType.valueTools") null_pos in
|
|
|
(match m.m_types with
|
|
|
| [TClassDecl c2 ] -> ctx.g.global_using <- (c1,c1.cl_pos) :: (c2,c2.cl_pos) :: ctx.g.global_using
|
|
|
| _ -> assert false);
|