|
@@ -309,11 +309,11 @@ let rec load_normal_type ctx t p allow_no_params =
|
|
| [TPType (_,t)] -> TDynamic (load_type ctx p t)
|
|
| [TPType (_,t)] -> TDynamic (load_type ctx p t)
|
|
| _ -> error "Too many parameters for Dynamic" p
|
|
| _ -> error "Too many parameters for Dynamic" p
|
|
else begin
|
|
else begin
|
|
- if List.length types <> List.length t.tparams then error ("Invalid number of type parameters for " ^ s_type_path path) p;
|
|
|
|
|
|
+ if List.length types <> List.length t.tparams then error ("Invalid number of type parameters for " ^ s_type_path path) p;
|
|
let tparams = List.map (fun t ->
|
|
let tparams = List.map (fun t ->
|
|
match t with
|
|
match t with
|
|
| TPConst c ->
|
|
| TPConst c ->
|
|
- let name = (match c with
|
|
|
|
|
|
+ let name = (match c with
|
|
| String s -> "S" ^ s
|
|
| String s -> "S" ^ s
|
|
| Int i -> "I" ^ i
|
|
| Int i -> "I" ^ i
|
|
| Float f -> "F" ^ f
|
|
| Float f -> "F" ^ f
|
|
@@ -437,7 +437,7 @@ and reverse_param (v,t) =
|
|
|
|
|
|
let extend_remoting ctx c t p async prot =
|
|
let extend_remoting ctx c t p async prot =
|
|
if c.cl_super <> None then error "Cannot extend several classes" p;
|
|
if c.cl_super <> None then error "Cannot extend several classes" p;
|
|
- if ctx.isproxy then
|
|
|
|
|
|
+ if ctx.isproxy then
|
|
() (* skip this proxy generation, we shouldn't need it anyway *)
|
|
() (* skip this proxy generation, we shouldn't need it anyway *)
|
|
else
|
|
else
|
|
let ctx2 = context ctx.error ctx.warn in
|
|
let ctx2 = context ctx.error ctx.warn in
|
|
@@ -735,7 +735,7 @@ let type_expr_with_type ctx e t =
|
|
ctx.param_type <- old;
|
|
ctx.param_type <- old;
|
|
e
|
|
e
|
|
with
|
|
with
|
|
- exc ->
|
|
|
|
|
|
+ exc ->
|
|
ctx.param_type <- old;
|
|
ctx.param_type <- old;
|
|
raise exc)
|
|
raise exc)
|
|
| _ ->
|
|
| _ ->
|
|
@@ -1387,10 +1387,10 @@ and type_switch ctx e cases def need_val p =
|
|
in
|
|
in
|
|
let enum = ref (match follow e.etype with
|
|
let enum = ref (match follow e.etype with
|
|
| TEnum (e,params) -> Some (e,params)
|
|
| TEnum (e,params) -> Some (e,params)
|
|
- | TMono r ->
|
|
|
|
|
|
+ | TMono r ->
|
|
(match lookup_enum (List.concat (List.map fst cases)) with
|
|
(match lookup_enum (List.concat (List.map fst cases)) with
|
|
| None -> None
|
|
| None -> None
|
|
- | Some (en,params) as k ->
|
|
|
|
|
|
+ | Some (en,params) as k ->
|
|
r := Some (TEnum (en,params));
|
|
r := Some (TEnum (en,params));
|
|
k)
|
|
k)
|
|
| _ -> None
|
|
| _ -> None
|
|
@@ -1399,7 +1399,7 @@ and type_switch ctx e cases def need_val p =
|
|
if need_val then begin
|
|
if need_val then begin
|
|
try
|
|
try
|
|
unify_raise ctx e.etype (!t) e.epos;
|
|
unify_raise ctx e.etype (!t) e.epos;
|
|
- with Error (Unify _,_) -> try
|
|
|
|
|
|
+ with Error (Unify _,_) -> try
|
|
unify_raise ctx (!t) e.etype e.epos;
|
|
unify_raise ctx (!t) e.etype e.epos;
|
|
t := e.etype;
|
|
t := e.etype;
|
|
with Error (Unify _,_) ->
|
|
with Error (Unify _,_) ->
|
|
@@ -1419,8 +1419,8 @@ and type_switch ctx e cases def need_val p =
|
|
let first_case = ref true in
|
|
let first_case = ref true in
|
|
let el = List.map (fun e1 ->
|
|
let el = List.map (fun e1 ->
|
|
let v = (match !enum with
|
|
let v = (match !enum with
|
|
- | Some en ->
|
|
|
|
- (try
|
|
|
|
|
|
+ | Some en ->
|
|
|
|
+ (try
|
|
CMatch (type_matching ctx en e1 ecases !first_case)
|
|
CMatch (type_matching ctx en e1 ecases !first_case)
|
|
with
|
|
with
|
|
Error _ when !first ->
|
|
Error _ when !first ->
|
|
@@ -1432,7 +1432,7 @@ and type_switch ctx e cases def need_val p =
|
|
first_case := false;
|
|
first_case := false;
|
|
first := false;
|
|
first := false;
|
|
v
|
|
v
|
|
- ) el in
|
|
|
|
|
|
+ ) el in
|
|
let e2 = type_expr ctx ~need_val e2 in
|
|
let e2 = type_expr ctx ~need_val e2 in
|
|
locals();
|
|
locals();
|
|
unify_val e2;
|
|
unify_val e2;
|
|
@@ -1473,7 +1473,7 @@ and type_switch ctx e cases def need_val p =
|
|
let exprs (el,e) =
|
|
let exprs (el,e) =
|
|
List.map (fun c ->
|
|
List.map (fun c ->
|
|
match c with
|
|
match c with
|
|
- | CExpr c -> c
|
|
|
|
|
|
+ | CExpr c -> c
|
|
| _ -> assert false
|
|
| _ -> assert false
|
|
) el , e
|
|
) el , e
|
|
in
|
|
in
|
|
@@ -1646,8 +1646,8 @@ and type_expr ctx ?(need_val=true) (e,p) =
|
|
in
|
|
in
|
|
let fields , types = List.fold_left loop ([],PMap.empty) fl in
|
|
let fields , types = List.fold_left loop ([],PMap.empty) fl in
|
|
mk (TObjectDecl fields) (mk_anon types) p
|
|
mk (TObjectDecl fields) (mk_anon types) p
|
|
- | EArrayDecl el ->
|
|
|
|
- let t = ref (mk_mono()) in
|
|
|
|
|
|
+ | EArrayDecl el ->
|
|
|
|
+ let t = ref (mk_mono()) in
|
|
let el = List.map (fun e ->
|
|
let el = List.map (fun e ->
|
|
let e = type_expr ctx e in
|
|
let e = type_expr ctx e in
|
|
(try
|
|
(try
|
|
@@ -1746,7 +1746,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
|
|
unify ctx e.etype (t_bool ctx) e.epos;
|
|
unify ctx e.etype (t_bool ctx) e.epos;
|
|
let e1 = type_expr ctx ~need_val e1 in
|
|
let e1 = type_expr ctx ~need_val e1 in
|
|
(match e2 with
|
|
(match e2 with
|
|
- | None ->
|
|
|
|
|
|
+ | None ->
|
|
mk (TIf (e,e1,if need_val then Some (null p) else None)) (t_void ctx) p
|
|
mk (TIf (e,e1,if need_val then Some (null p) else None)) (t_void ctx) p
|
|
| Some e2 ->
|
|
| Some e2 ->
|
|
let e2 = type_expr ctx ~need_val e2 in
|
|
let e2 = type_expr ctx ~need_val e2 in
|
|
@@ -1938,7 +1938,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
|
|
match follow t1 with
|
|
match follow t1 with
|
|
| TMono _ -> unify ctx t2 t1 p
|
|
| TMono _ -> unify ctx t2 t1 p
|
|
| _ -> ()
|
|
| _ -> ()
|
|
- ) args args2;
|
|
|
|
|
|
+ ) args args2;
|
|
| _ -> ());
|
|
| _ -> ());
|
|
let ft = TFun (args,rt) in
|
|
let ft = TFun (args,rt) in
|
|
let e , fargs = type_function ctx ft true false f p in
|
|
let e , fargs = type_function ctx ft true false f p in
|
|
@@ -1974,7 +1974,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
|
|
| TInst (c,_) -> c.cl_path
|
|
| TInst (c,_) -> c.cl_path
|
|
| TEnum (e,_) -> e.e_path
|
|
| TEnum (e,_) -> e.e_path
|
|
| _ -> assert false);
|
|
| _ -> assert false);
|
|
- | _ ->
|
|
|
|
|
|
+ | _ ->
|
|
error "Cast type must be a class" p
|
|
error "Cast type must be a class" p
|
|
) in
|
|
) in
|
|
let make_type (path,name) =
|
|
let make_type (path,name) =
|
|
@@ -2043,9 +2043,9 @@ let type_static_var ctx t e p =
|
|
|
|
|
|
let valid_redefinition ctx f t =
|
|
let valid_redefinition ctx f t =
|
|
let ft = field_type f in
|
|
let ft = field_type f in
|
|
- match follow ft , t with
|
|
|
|
- | TFun (args,r) , TFun (targs,tr) when f.cf_expr <> None && List.length args = List.length targs ->
|
|
|
|
- List.iter2 (fun (n,o1,a1) (_,o2,a2) ->
|
|
|
|
|
|
+ match follow ft , follow t with
|
|
|
|
+ | TFun (args,r) , TFun (targs,tr) when List.length args = List.length targs ->
|
|
|
|
+ List.iter2 (fun (n,o1,a1) (_,o2,a2) ->
|
|
if o1 <> o2 then raise (Unify_error [Not_matching_optional n]);
|
|
if o1 <> o2 then raise (Unify_error [Not_matching_optional n]);
|
|
type_eq EqStrict a1 a2
|
|
type_eq EqStrict a1 a2
|
|
) args targs;
|
|
) args targs;
|
|
@@ -2210,7 +2210,7 @@ let init_class ctx c p herits fields =
|
|
let stat = List.mem AStatic access in
|
|
let stat = List.mem AStatic access in
|
|
let constr = (name = "new") in
|
|
let constr = (name = "new") in
|
|
if c.cl_interface && not stat && (match f.f_expr with EBlock [] , _ -> false | _ -> true) then error "An interface method cannot have a body" p;
|
|
if c.cl_interface && not stat && (match f.f_expr with EBlock [] , _ -> false | _ -> true) then error "An interface method cannot have a body" p;
|
|
- if constr then (match f.f_type with
|
|
|
|
|
|
+ if constr then (match f.f_type with
|
|
| None | Some (TPNormal { tpackage = []; tname = "Void" }) -> ()
|
|
| None | Some (TPNormal { tpackage = []; tname = "Void" }) -> ()
|
|
| _ -> error "A class constructor can't have a return value" p
|
|
| _ -> error "A class constructor can't have a return value" p
|
|
);
|
|
);
|
|
@@ -2492,7 +2492,7 @@ let type_module ctx m tdecls loadp =
|
|
(match !r with
|
|
(match !r with
|
|
| None -> r := Some tt;
|
|
| None -> r := Some tt;
|
|
| Some _ -> assert false);
|
|
| Some _ -> assert false);
|
|
- | _ -> assert false);
|
|
|
|
|
|
+ | _ -> assert false);
|
|
) tdecls;
|
|
) tdecls;
|
|
(* PASS 3 : type checking, delayed until all modules and types are built *)
|
|
(* PASS 3 : type checking, delayed until all modules and types are built *)
|
|
ctx.delays := !delays :: !(ctx.delays);
|
|
ctx.delays := !delays :: !(ctx.delays);
|
|
@@ -2502,7 +2502,7 @@ let type_module ctx m tdecls loadp =
|
|
let rec f9path p = {
|
|
let rec f9path p = {
|
|
tpackage = (match p.tpackage with "flash" :: l -> "flash9" :: l | l -> l);
|
|
tpackage = (match p.tpackage with "flash" :: l -> "flash9" :: l | l -> l);
|
|
tname = p.tname;
|
|
tname = p.tname;
|
|
- tparams = List.map (fun c ->
|
|
|
|
|
|
+ tparams = List.map (fun c ->
|
|
match c with
|
|
match c with
|
|
| TPConst _ -> c
|
|
| TPConst _ -> c
|
|
| TPType (v,t) -> TPType (v,f9t t)
|
|
| TPType (v,t) -> TPType (v,f9t t)
|
|
@@ -2629,8 +2629,8 @@ type state =
|
|
| NotYet
|
|
| NotYet
|
|
|
|
|
|
let rec has_rtti c =
|
|
let rec has_rtti c =
|
|
- List.exists (function (t,pl) ->
|
|
|
|
- match t, pl with
|
|
|
|
|
|
+ List.exists (function (t,pl) ->
|
|
|
|
+ match t, pl with
|
|
| { cl_path = ["haxe";"rtti"],"Infos" },[] -> true
|
|
| { cl_path = ["haxe";"rtti"],"Infos" },[] -> true
|
|
| _ -> false
|
|
| _ -> false
|
|
) c.cl_implements || (match c.cl_super with None -> false | Some (c,_) -> has_rtti c)
|
|
) c.cl_implements || (match c.cl_super with None -> false | Some (c,_) -> has_rtti c)
|
|
@@ -2655,7 +2655,7 @@ let types ctx main excludes =
|
|
if List.mem c.cl_path excludes then begin
|
|
if List.mem c.cl_path excludes then begin
|
|
c.cl_extern <- true;
|
|
c.cl_extern <- true;
|
|
c.cl_init <- None;
|
|
c.cl_init <- None;
|
|
- end;
|
|
|
|
|
|
+ end;
|
|
if has_rtti c then begin
|
|
if has_rtti c then begin
|
|
let f = mk_field "__rtti" (t_string ctx) in
|
|
let f = mk_field "__rtti" (t_string ctx) in
|
|
let str = (!generate_meta_data) ctx t in
|
|
let str = (!generate_meta_data) ctx t in
|