|
@@ -1081,17 +1081,17 @@ let follow_module follow_func md = match md with
|
|
|
*)
|
|
|
let rec is_hxgen md =
|
|
|
match md with
|
|
|
- | TClassDecl cl -> has_meta ":hxgen" cl.cl_meta
|
|
|
- | TEnumDecl e -> has_meta ":hxgen" e.e_meta
|
|
|
- | TTypeDecl t -> has_meta ":hxgen" t.t_meta || ( match follow t.t_type with | TInst(cl,_) -> is_hxgen (TClassDecl cl) | TEnum(e,_) -> is_hxgen (TEnumDecl e) | _ -> false )
|
|
|
- | TAbstractDecl a -> has_meta ":hxgen" a.a_meta
|
|
|
+ | TClassDecl cl -> Meta.has Meta.HxGen cl.cl_meta
|
|
|
+ | TEnumDecl e -> Meta.has Meta.HxGen e.e_meta
|
|
|
+ | TTypeDecl t -> Meta.has Meta.HxGen t.t_meta || ( match follow t.t_type with | TInst(cl,_) -> is_hxgen (TClassDecl cl) | TEnum(e,_) -> is_hxgen (TEnumDecl e) | _ -> false )
|
|
|
+ | TAbstractDecl a -> Meta.has Meta.HxGen a.a_meta
|
|
|
|
|
|
let is_hxgen_t t =
|
|
|
match t with
|
|
|
- | TInst (cl, _) -> has_meta ":hxgen" cl.cl_meta
|
|
|
- | TEnum (e, _) -> has_meta ":hxgen" e.e_meta
|
|
|
- | TAbstract (a, _) -> has_meta ":hxgen" a.a_meta
|
|
|
- | TType (t, _) -> has_meta ":hxgen" t.t_meta
|
|
|
+ | TInst (cl, _) -> Meta.has Meta.HxGen cl.cl_meta
|
|
|
+ | TEnum (e, _) -> Meta.has Meta.HxGen e.e_meta
|
|
|
+ | TAbstract (a, _) -> Meta.has Meta.HxGen a.a_meta
|
|
|
+ | TType (t, _) -> Meta.has Meta.HxGen t.t_meta
|
|
|
| _ -> false
|
|
|
|
|
|
let mt_to_t_dyn md =
|
|
@@ -1131,7 +1131,7 @@ let mk_class_field name t public pos kind params =
|
|
|
cf_public = public;
|
|
|
cf_pos = pos;
|
|
|
cf_doc = None;
|
|
|
- cf_meta = [ ":$CompilerGenerated", [], Ast.null_pos ]; (* annotate that this class field was generated by the compiler *)
|
|
|
+ cf_meta = [ Meta.CompilerGenerated, [], Ast.null_pos ]; (* annotate that this class field was generated by the compiler *)
|
|
|
cf_kind = kind;
|
|
|
cf_params = params;
|
|
|
cf_expr = None;
|
|
@@ -1152,7 +1152,7 @@ let get_cl_t t =
|
|
|
|
|
|
let mk_class m path pos =
|
|
|
let cl = Type.mk_class m path pos in
|
|
|
- cl.cl_meta <- [ ":$CompilerGenerated", [], Ast.null_pos ];
|
|
|
+ cl.cl_meta <- [ Meta.CompilerGenerated, [], Ast.null_pos ];
|
|
|
cl
|
|
|
|
|
|
type tfield_access =
|
|
@@ -1359,15 +1359,15 @@ struct
|
|
|
| TClassDecl cl ->
|
|
|
let rec is_hxgen_class c =
|
|
|
if c.cl_extern then begin
|
|
|
- if has_meta ":hxgen" c.cl_meta then true else Option.map_default (fun (c,_) -> is_hxgen_class c) false c.cl_super
|
|
|
+ if Meta.has Meta.HxGen c.cl_meta then true else Option.map_default (fun (c,_) -> is_hxgen_class c) false c.cl_super
|
|
|
end else begin
|
|
|
- if has_meta ":nativegen" c.cl_meta then Option.map_default (fun (c, _) -> is_hxgen_class c) false c.cl_super else true
|
|
|
+ if Meta.has Meta.NativeGen c.cl_meta then Option.map_default (fun (c, _) -> is_hxgen_class c) false c.cl_super else true
|
|
|
end
|
|
|
in
|
|
|
|
|
|
is_hxgen_class cl
|
|
|
- | TEnumDecl e -> if e.e_extern then has_meta ":hxgen" e.e_meta else not (has_meta ":nativegen" e.e_meta)
|
|
|
- | TAbstractDecl a -> not (has_meta ":nativegen" a.a_meta)
|
|
|
+ | TEnumDecl e -> if e.e_extern then Meta.has Meta.HxGen e.e_meta else not (Meta.has Meta.NativeGen e.e_meta)
|
|
|
+ | TAbstractDecl a -> not (Meta.has Meta.NativeGen a.a_meta)
|
|
|
| TTypeDecl t -> (* TODO see when would we use this *)
|
|
|
false
|
|
|
|
|
@@ -1379,10 +1379,10 @@ struct
|
|
|
let filter md =
|
|
|
if is_hxgen_func md then begin
|
|
|
match md with
|
|
|
- | TClassDecl cl -> cl.cl_meta <- (":hxgen", [], cl.cl_pos) :: cl.cl_meta
|
|
|
- | TEnumDecl e -> e.e_meta <- (":hxgen", [], e.e_pos) :: e.e_meta
|
|
|
- | TTypeDecl t -> t.t_meta <- (":hxgen", [], t.t_pos) :: t.t_meta
|
|
|
- | TAbstractDecl a -> a.a_meta <- (":hxgen", [], a.a_pos) :: a.a_meta
|
|
|
+ | TClassDecl cl -> cl.cl_meta <- (Meta.HxGen, [], cl.cl_pos) :: cl.cl_meta
|
|
|
+ | TEnumDecl e -> e.e_meta <- (Meta.HxGen, [], e.e_pos) :: e.e_meta
|
|
|
+ | TTypeDecl t -> t.t_meta <- (Meta.HxGen, [], t.t_pos) :: t.t_meta
|
|
|
+ | TAbstractDecl a -> a.a_meta <- (Meta.HxGen, [], a.a_pos) :: a.a_meta
|
|
|
end
|
|
|
in
|
|
|
List.iter filter gen.gcon.types
|
|
@@ -1514,7 +1514,7 @@ struct
|
|
|
|
|
|
let cur_ctor =
|
|
|
match cl.cl_constructor with
|
|
|
- | Some ctor when has_meta ":skip_ctor" cl.cl_meta ->
|
|
|
+ | Some ctor when Meta.has Meta.SkipCtor cl.cl_meta ->
|
|
|
if not supports_ctor_inheritance then begin
|
|
|
do_empty_only false;
|
|
|
end;
|
|
@@ -3778,13 +3778,13 @@ struct
|
|
|
|
|
|
let is_hxgeneric = function
|
|
|
| TClassDecl(cl) ->
|
|
|
- not (has_meta ":$nativegeneric" cl.cl_meta)
|
|
|
+ not (Meta.has Meta.NativeGeneric cl.cl_meta)
|
|
|
| TEnumDecl(e) ->
|
|
|
- not (has_meta ":$nativegeneric" e.e_meta)
|
|
|
+ not (Meta.has Meta.NativeGeneric e.e_meta)
|
|
|
| TTypeDecl(t) ->
|
|
|
- not (has_meta ":$nativegeneric" t.t_meta)
|
|
|
+ not (Meta.has Meta.NativeGeneric t.t_meta)
|
|
|
| TAbstractDecl a ->
|
|
|
- not (has_meta ":$nativegeneric" a.a_meta)
|
|
|
+ not (Meta.has Meta.NativeGeneric a.a_meta)
|
|
|
|
|
|
let rec set_hxgeneric gen mds isfirst md =
|
|
|
let path = t_path md in
|
|
@@ -3806,12 +3806,12 @@ struct
|
|
|
match md with
|
|
|
| TClassDecl(cl) ->
|
|
|
(* first see if any meta is present (already processed) *)
|
|
|
- if has_meta ":$nativegeneric" cl.cl_meta then
|
|
|
+ if Meta.has Meta.NativeGeneric cl.cl_meta then
|
|
|
Some false
|
|
|
- else if has_meta ":$hxgeneric" cl.cl_meta then
|
|
|
+ else if Meta.has Meta.HaxeGeneric cl.cl_meta then
|
|
|
Some true
|
|
|
else if not (is_hxgen md) then
|
|
|
- (cl.cl_meta <- (":$nativegeneric", [], cl.cl_pos) :: cl.cl_meta;
|
|
|
+ (cl.cl_meta <- (Meta.NativeGeneric, [], cl.cl_pos) :: cl.cl_meta;
|
|
|
Some false)
|
|
|
else begin
|
|
|
(*
|
|
@@ -3821,14 +3821,14 @@ struct
|
|
|
(* on the first pass, our job is to find any evidence that makes it not be hxgeneric. Otherwise it will be hxgeneric *)
|
|
|
match cl.cl_super with
|
|
|
| Some (c,_) when is_false (set_hxgeneric gen mds isfirst (TClassDecl c)) ->
|
|
|
- cl.cl_meta <- (":$nativegeneric", [], cl.cl_pos) :: cl.cl_meta;
|
|
|
+ cl.cl_meta <- (Meta.NativeGeneric, [], cl.cl_pos) :: cl.cl_meta;
|
|
|
Some false
|
|
|
| _ ->
|
|
|
(* see if it's a generic class *)
|
|
|
match cl.cl_types with
|
|
|
| [] ->
|
|
|
(* if it's not, then it will be hxgeneric *)
|
|
|
- cl.cl_meta <- (":$hxgeneric", [], cl.cl_pos) :: cl.cl_meta;
|
|
|
+ cl.cl_meta <- (Meta.HaxeGeneric, [], cl.cl_pos) :: cl.cl_meta;
|
|
|
Some true
|
|
|
| _ ->
|
|
|
(* if it is, loop through all fields + statics and look for non-hxgeneric
|
|
@@ -3847,28 +3847,28 @@ struct
|
|
|
| _ -> loop cfs (* TAbstracts / Dynamics can't be generic *)
|
|
|
in
|
|
|
if loop cl.cl_ordered_fields then begin
|
|
|
- cl.cl_meta <- (":$nativegeneric", [], cl.cl_pos) :: cl.cl_meta;
|
|
|
+ cl.cl_meta <- (Meta.NativeGeneric, [], cl.cl_pos) :: cl.cl_meta;
|
|
|
Some false
|
|
|
end else if isfirst && !has_unresolved then
|
|
|
None
|
|
|
else begin
|
|
|
- cl.cl_meta <- (":$hxgeneric", [], cl.cl_pos) :: cl.cl_meta;
|
|
|
+ cl.cl_meta <- (Meta.HaxeGeneric, [], cl.cl_pos) :: cl.cl_meta;
|
|
|
Some true
|
|
|
end
|
|
|
end
|
|
|
| TEnumDecl e ->
|
|
|
- if has_meta ":$nativegeneric" e.e_meta then
|
|
|
+ if Meta.has Meta.NativeGeneric e.e_meta then
|
|
|
Some false
|
|
|
- else if has_meta ":$hxgeneric" e.e_meta then
|
|
|
+ else if Meta.has Meta.HaxeGeneric e.e_meta then
|
|
|
Some true
|
|
|
else if not (is_hxgen (TEnumDecl e)) then begin
|
|
|
- e.e_meta <- (":$nativegeneric", [], e.e_pos) :: e.e_meta;
|
|
|
+ e.e_meta <- (Meta.NativeGeneric, [], e.e_pos) :: e.e_meta;
|
|
|
Some false
|
|
|
end else begin
|
|
|
(* if enum is not generic, then it's hxgeneric *)
|
|
|
match e.e_types with
|
|
|
| [] ->
|
|
|
- e.e_meta <- (":$hxgeneric", [], e.e_pos) :: e.e_meta;
|
|
|
+ e.e_meta <- (Meta.HaxeGeneric, [], e.e_pos) :: e.e_meta;
|
|
|
Some true
|
|
|
| _ ->
|
|
|
let rec loop efs =
|
|
@@ -3896,12 +3896,12 @@ struct
|
|
|
in
|
|
|
let efs = PMap.fold (fun ef acc -> ef :: acc) e.e_constrs [] in
|
|
|
if loop efs then begin
|
|
|
- e.e_meta <- (":$nativegeneric", [], e.e_pos) :: e.e_meta;
|
|
|
+ e.e_meta <- (Meta.NativeGeneric, [], e.e_pos) :: e.e_meta;
|
|
|
Some false
|
|
|
end else if isfirst && !has_unresolved then
|
|
|
None
|
|
|
else begin
|
|
|
- e.e_meta <- (":$hxgeneric", [], e.e_pos) :: e.e_meta;
|
|
|
+ e.e_meta <- (Meta.HaxeGeneric, [], e.e_pos) :: e.e_meta;
|
|
|
Some true
|
|
|
end
|
|
|
end
|
|
@@ -4112,7 +4112,7 @@ struct
|
|
|
let iface = mk_class cl.cl_module cl.cl_path cl.cl_pos in
|
|
|
iface.cl_array_access <- Option.map (apply_params (cl.cl_types) (List.map (fun _ -> t_dynamic) cl.cl_types)) cl.cl_array_access;
|
|
|
iface.cl_module <- cl.cl_module;
|
|
|
- iface.cl_meta <- (":hxgen", [], cl.cl_pos) :: iface.cl_meta;
|
|
|
+ iface.cl_meta <- (Meta.HxGen, [], cl.cl_pos) :: iface.cl_meta;
|
|
|
Hashtbl.add ifaces cl.cl_path iface;
|
|
|
|
|
|
iface.cl_implements <- (base_generic, []) :: iface.cl_implements;
|
|
@@ -5827,7 +5827,7 @@ struct
|
|
|
let collect_fields cl (methods : bool option) (statics : bool option) =
|
|
|
let collected = Hashtbl.create 0 in
|
|
|
let collect cf acc =
|
|
|
- if has_meta ":$CompilerGenerated" cf.cf_meta || has_meta ":skipReflection" cf.cf_meta then
|
|
|
+ if Meta.has Meta.CompilerGenerated cf.cf_meta || Meta.has Meta.SkipReflection cf.cf_meta then
|
|
|
acc
|
|
|
else match methods, cf.cf_kind with
|
|
|
| None, _ when not (Hashtbl.mem collected cf.cf_name) -> Hashtbl.add collected cf.cf_name true; ([cf.cf_name], cf) :: acc
|
|
@@ -6798,7 +6798,7 @@ struct
|
|
|
|
|
|
let get_fields static =
|
|
|
let ret = collect_fields cl ( if is_float || is_set then Some (false) else None ) (Some static) in
|
|
|
- let ret = if is_set then List.filter (fun (_,cf) -> not (has_meta ":readonly" cf.cf_meta)) ret else ret in
|
|
|
+ let ret = if is_set then List.filter (fun (_,cf) -> not (Meta.has Meta.ReadOnly cf.cf_meta)) ret else ret in
|
|
|
if is_float then
|
|
|
List.filter (fun (_,cf) -> (* TODO: maybe really apply_params in cf.cf_type. The benefits would be limited, though *)
|
|
|
match follow (ctx.rcf_gen.greal_type (ctx.rcf_gen.gfollow#run_f cf.cf_type)) with
|
|
@@ -7119,7 +7119,7 @@ struct
|
|
|
|
|
|
(* setting it as DynamicObject makes getClass return null *)
|
|
|
let get_class =
|
|
|
- cl.cl_meta <- (":$DynamicObject", [], pos) :: cl.cl_meta
|
|
|
+ cl.cl_meta <- (Meta.DynamicObject, [], pos) :: cl.cl_meta
|
|
|
in
|
|
|
ignore get_class;
|
|
|
|
|
@@ -7226,7 +7226,7 @@ struct
|
|
|
let cls_dyn = TInst(tclass, [t_dynamic]) in
|
|
|
|
|
|
let expr, static_cfs =
|
|
|
- if has_meta ":$DynamicObject" cl.cl_meta then
|
|
|
+ if Meta.has Meta.DynamicObject cl.cl_meta then
|
|
|
mk_return (null t_dynamic pos), []
|
|
|
else
|
|
|
let cache_name = (gen.gmk_internal_name "hx" "class") in
|
|
@@ -7686,7 +7686,7 @@ struct
|
|
|
let process_cf static cf =
|
|
|
match cf.cf_kind with
|
|
|
| Var _ -> ()
|
|
|
- | _ when has_meta ":replaceReflection" cf.cf_meta ->
|
|
|
+ | _ when Meta.has Meta.ReplaceReflection cf.cf_meta ->
|
|
|
let name = if String.get cf.cf_name 0 = '_' then String.sub cf.cf_name 1 (String.length cf.cf_name - 1) else cf.cf_name in
|
|
|
let new_name = gen.gmk_internal_name "hx" name in
|
|
|
let new_cf = mk_class_field new_name cf.cf_type cf.cf_public cf.cf_pos cf.cf_kind cf.cf_params in
|
|
@@ -7755,7 +7755,7 @@ struct
|
|
|
let priority = min_dep +. 10.
|
|
|
|
|
|
let default_implementation gen baseclass baseinterface basedynamic =
|
|
|
- baseinterface.cl_meta <- (":$baseinterface", [], baseinterface.cl_pos) :: baseinterface.cl_meta;
|
|
|
+ baseinterface.cl_meta <- (Meta.BaseInterface, [], baseinterface.cl_pos) :: baseinterface.cl_meta;
|
|
|
let rec run md =
|
|
|
(if is_hxgen md then
|
|
|
match md with
|
|
@@ -7792,8 +7792,8 @@ struct
|
|
|
let configure ?slow_invoke ctx =
|
|
|
let gen = ctx.rcf_gen in
|
|
|
let run = (fun md -> match md with
|
|
|
- | TClassDecl cl when is_hxgen md && ( not cl.cl_interface || has_meta ":$baseinterface" cl.cl_meta ) ->
|
|
|
- (if has_meta ":replaceReflection" cl.cl_meta then replace_reflection ctx cl);
|
|
|
+ | TClassDecl cl when is_hxgen md && ( not cl.cl_interface || Meta.has Meta.BaseInterface cl.cl_meta ) ->
|
|
|
+ (if Meta.has Meta.ReplaceReflection cl.cl_meta then replace_reflection ctx cl);
|
|
|
(implement_dynamics ctx cl);
|
|
|
(if not (PMap.mem (gen.gmk_internal_name "hx" "lookupField") cl.cl_fields) then implement_final_lookup ctx cl);
|
|
|
(if not (PMap.mem (gen.gmk_internal_name "hx" "getField") cl.cl_fields) then implement_get_set ctx cl);
|
|
@@ -7909,7 +7909,7 @@ struct
|
|
|
let pmap_exists fn pmap = try PMap.iter (fun a b -> if fn a b then raise Exit) pmap; false with | Exit -> true
|
|
|
|
|
|
let has_any_meta en =
|
|
|
- let has_meta meta = List.exists (fun (name,_,_) -> (String.get name 0) <> ':') meta in
|
|
|
+ let has_meta meta = List.exists (fun (m,_,_) -> match m with Meta.Custom _ -> true | _ -> false) meta in
|
|
|
has_meta en.e_meta || pmap_exists (fun _ ef -> has_meta ef.ef_meta) en.e_constrs
|
|
|
|
|
|
let has_parameters e =
|
|
@@ -7938,9 +7938,9 @@ struct
|
|
|
cl.cl_super <- Some(base_class,[]);
|
|
|
cl.cl_extern <- en.e_extern;
|
|
|
en.e_extern <- true;
|
|
|
- en.e_meta <- (":$class", [], pos) :: en.e_meta;
|
|
|
+ en.e_meta <- (Meta.Class, [], pos) :: en.e_meta;
|
|
|
cl.cl_module <- en.e_module;
|
|
|
- cl.cl_meta <- ( ":$enum", [], pos ) :: cl.cl_meta;
|
|
|
+ cl.cl_meta <- ( Meta.Enum, [], pos ) :: cl.cl_meta;
|
|
|
let c_types =
|
|
|
if handle_type_params then
|
|
|
List.map (fun (s,t) -> (s, TInst (map_param (get_cl_t t), []))) en.e_types
|
|
@@ -8006,7 +8006,7 @@ struct
|
|
|
cf
|
|
|
in
|
|
|
cl.cl_statics <- PMap.add cf.cf_name cf cl.cl_statics;
|
|
|
- cf.cf_meta <- (":alias", [ EConst( String (string_of_int old_i) ), pos ], pos) :: [];
|
|
|
+ cf.cf_meta <- (Meta.Alias, [ EConst( String (string_of_int old_i) ), pos ], pos) :: [];
|
|
|
cf
|
|
|
) en.e_names in
|
|
|
let constructs_cf = mk_class_field "constructs" (basic.tarray basic.tstring) true pos (Var { v_read = AccNormal; v_write = AccNormal }) [] in
|
|
@@ -8021,7 +8021,7 @@ struct
|
|
|
cl.cl_statics <- PMap.add "constructs" constructs_cf cl.cl_statics;
|
|
|
|
|
|
(if should_be_hxgen then
|
|
|
- cl.cl_meta <- (":hxgen",[],cl.cl_pos) :: cl.cl_meta
|
|
|
+ cl.cl_meta <- (Meta.HxGen,[],cl.cl_pos) :: cl.cl_meta
|
|
|
else begin
|
|
|
(* create the constructor *)
|
|
|
let tf_args = [ alloc_var "index" basic.tint, None; alloc_var "params" (basic.tarray t_empty), None ] in
|
|
@@ -8070,7 +8070,7 @@ struct
|
|
|
convert e
|
|
|
else begin
|
|
|
(* take off the :hxgen meta from it, if there's any *)
|
|
|
- e.e_meta <- List.filter (fun (n,_,_) -> not (n = ":hxgen")) e.e_meta;
|
|
|
+ e.e_meta <- List.filter (fun (n,_,_) -> not (n = Meta.HxGen)) e.e_meta;
|
|
|
md
|
|
|
end
|
|
|
| _ -> md
|