|
@@ -632,8 +632,9 @@ and gen_classes =
|
|
|
|
|
|
t_iterator : tdef;
|
|
|
|
|
|
- a_vector : tabstract;
|
|
|
- tvector : Type.t -> Type.t;
|
|
|
+ mutable nativearray_len : texpr -> pos -> texpr;
|
|
|
+ mutable nativearray_type : Type.t -> Type.t;
|
|
|
+ mutable nativearray : Type.t -> Type.t;
|
|
|
}
|
|
|
|
|
|
(* add here all reflection transformation additions *)
|
|
@@ -691,8 +692,9 @@ let new_ctx con =
|
|
|
|
|
|
t_iterator = get_tdef (get_type con.types ([], "Iterator"));
|
|
|
|
|
|
- a_vector = get_abstract (get_type con.types (["haxe";"ds"],"Vector"));
|
|
|
- tvector = (fun t -> TAbstract(gen.gclasses.a_vector,[t]));
|
|
|
+ nativearray = (fun _ -> assert false);
|
|
|
+ nativearray_type = (fun _ -> assert false);
|
|
|
+ nativearray_len = (fun _ -> assert false);
|
|
|
};
|
|
|
gtools = {
|
|
|
r_create_empty = (fun eclass t ->
|
|
@@ -1213,12 +1215,11 @@ let mk_temp gen name t =
|
|
|
let name = gen.gmk_internal_name "temp" (name ^ (string_of_int !tmp_count)) in
|
|
|
alloc_var name t
|
|
|
|
|
|
-let mk_vector_decl =
|
|
|
- let v_vector = alloc_var "__array__" t_dynamic in
|
|
|
- fun gen t el pos ->
|
|
|
+let v_nativearray = alloc_var "__array__" t_dynamic
|
|
|
+let mk_nativearray_decl gen t el pos =
|
|
|
{
|
|
|
- eexpr = TCall(mk_local v_vector pos, el);
|
|
|
- etype = gen.gclasses.tvector t;
|
|
|
+ eexpr = TCall(mk_local v_nativearray pos, el);
|
|
|
+ etype = gen.gclasses.nativearray t;
|
|
|
epos = pos;
|
|
|
}
|
|
|
|
|
@@ -6828,12 +6829,18 @@ struct
|
|
|
its only needed features is that it should return the index of the key if found, and the
|
|
|
complement of the index of where it should be inserted if not found (Ints).
|
|
|
|
|
|
- hash->hash_array->returning expression
|
|
|
+ hash->hash_array->length->returning expression
|
|
|
*)
|
|
|
- mutable rcf_hash_function : texpr->texpr->texpr;
|
|
|
+ mutable rcf_hash_function : texpr->texpr->texpr->texpr;
|
|
|
|
|
|
mutable rcf_lookup_function : texpr->texpr;
|
|
|
|
|
|
+ (* hash_array->length->pos->value *)
|
|
|
+ mutable rcf_insert_function : texpr->texpr->texpr->texpr->texpr;
|
|
|
+
|
|
|
+ (* hash_array->length->pos->value *)
|
|
|
+ mutable rcf_remove_function : texpr->texpr->texpr->texpr;
|
|
|
+
|
|
|
(*
|
|
|
class_cl is the real class for Class<> instances.
|
|
|
In the current implementation, due to some targets' limitations, (in particular, Java),
|
|
@@ -6862,7 +6869,7 @@ struct
|
|
|
mutable rcf_handle_statics : bool;
|
|
|
}
|
|
|
|
|
|
- let new_ctx gen ft object_iface optimize dynamic_getset_field dynamic_call_field hash_function lookup_function handle_statics =
|
|
|
+ let new_ctx gen ft object_iface optimize dynamic_getset_field dynamic_call_field hash_function lookup_function insert_function remove_function handle_statics =
|
|
|
{
|
|
|
rcf_gen = gen;
|
|
|
rcf_ft = ft;
|
|
@@ -6884,6 +6891,9 @@ struct
|
|
|
rcf_hash_function = hash_function;
|
|
|
rcf_lookup_function = lookup_function;
|
|
|
|
|
|
+ rcf_insert_function = insert_function;
|
|
|
+ rcf_remove_function = remove_function;
|
|
|
+
|
|
|
rcf_class_cl = None;
|
|
|
rcf_class_eager_creation = false;
|
|
|
|
|
@@ -7047,21 +7057,18 @@ struct
|
|
|
let basic = gen.gcon.basic in
|
|
|
let pos = cl.cl_pos in
|
|
|
|
|
|
- let vtmp = mk_temp gen "i" basic.tint in
|
|
|
- let vlen = mk_temp gen "len" basic.tint in
|
|
|
+ let vtmp = alloc_var "i" basic.tint in
|
|
|
|
|
|
- let mk_for arr =
|
|
|
+ let mk_for arr len =
|
|
|
let t = if ctx.rcf_optimize then basic.tint else basic.tstring in
|
|
|
let convert_str e = if ctx.rcf_optimize then ctx.rcf_lookup_function e else e in
|
|
|
- let lenlocal = mk_local vlen pos in
|
|
|
let tmpinc = { eexpr = TUnop(Ast.Increment, Ast.Postfix, mk_local vtmp pos); etype = basic.tint; epos = pos } in
|
|
|
{
|
|
|
eexpr = TBlock [
|
|
|
{ eexpr = TBinop(OpAssign, mk_local vtmp pos, mk_int ctx 0 pos); etype = basic.tint; epos = pos };
|
|
|
- { eexpr = TBinop(OpAssign, lenlocal, mk_field_access gen arr "length" pos); etype = basic.tint; epos = pos };
|
|
|
{
|
|
|
eexpr = TWhile (
|
|
|
- { eexpr = TBinop(Ast.OpLt, mk_local vtmp pos, lenlocal); etype = basic.tbool; epos = pos },
|
|
|
+ { eexpr = TBinop(Ast.OpLt, mk_local vtmp pos, len); etype = basic.tbool; epos = pos },
|
|
|
mk_block (when_found (convert_str { eexpr = TArray (arr, tmpinc); etype = t; epos = pos })),
|
|
|
Ast.NormalWhile
|
|
|
);
|
|
@@ -7077,18 +7084,16 @@ struct
|
|
|
let this_t = TInst(cl, List.map snd cl.cl_params) in
|
|
|
let this = { eexpr = TConst(TThis); etype = this_t; epos = pos } in
|
|
|
let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in
|
|
|
- [
|
|
|
- { eexpr = TVar (vtmp,None); etype = basic.tvoid; epos = pos };
|
|
|
- { eexpr = TVar (vlen,None); etype = basic.tvoid; epos = pos };
|
|
|
- ]
|
|
|
- @
|
|
|
+
|
|
|
+ { eexpr = TVar (vtmp,None); etype = basic.tvoid; epos = pos }
|
|
|
+ ::
|
|
|
if ctx.rcf_optimize then
|
|
|
[
|
|
|
- mk_for (mk_this (gen.gmk_internal_name "hx" "hashes") (basic.tarray basic.tint));
|
|
|
- mk_for (mk_this (gen.gmk_internal_name "hx" "hashes_f") (basic.tarray basic.tint));
|
|
|
+ mk_for (mk_this (gen.gmk_internal_name "hx" "hashes") (gen.gclasses.nativearray basic.tint)) (mk_this (gen.gmk_internal_name "hx" "length") basic.tint);
|
|
|
+ mk_for (mk_this (gen.gmk_internal_name "hx" "hashes_f") (gen.gclasses.nativearray basic.tint)) (mk_this (gen.gmk_internal_name "hx" "length_f") basic.tint);
|
|
|
] else [
|
|
|
- mk_for (mk_this (gen.gmk_internal_name "hx" "hashes") (basic.tarray basic.tstring));
|
|
|
- mk_for (mk_this (gen.gmk_internal_name "hx" "hashes_f") (basic.tarray basic.tstring));
|
|
|
+ mk_for (mk_this (gen.gmk_internal_name "hx" "hashes") (gen.gclasses.nativearray basic.tstring)) (mk_this (gen.gmk_internal_name "hx" "length") basic.tint);
|
|
|
+ mk_for (mk_this (gen.gmk_internal_name "hx" "hashes_f") (gen.gclasses.nativearray basic.tstring)) (mk_this (gen.gmk_internal_name "hx" "length_f") basic.tint);
|
|
|
]
|
|
|
|
|
|
(* *********************
|
|
@@ -7108,13 +7113,18 @@ struct
|
|
|
let basic = gen.gcon.basic in
|
|
|
let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in
|
|
|
let a_t = if ctx.rcf_optimize then basic.tint else basic.tstring in
|
|
|
- let hx_hashes = mk_this (gen.gmk_internal_name "hx" "hashes") (basic.tarray a_t) in
|
|
|
- let hx_hashes_f = mk_this (gen.gmk_internal_name "hx" "hashes_f") (basic.tarray a_t) in
|
|
|
- let hx_dynamics = mk_this (gen.gmk_internal_name "hx" "dynamics") (basic.tarray t_empty) in
|
|
|
- let hx_dynamics_f = mk_this (gen.gmk_internal_name "hx" "dynamics_f") (basic.tarray basic.tfloat) in
|
|
|
+ let hx_hashes = mk_this (gen.gmk_internal_name "hx" "hashes") (gen.gclasses.nativearray a_t) in
|
|
|
+ let hx_hashes_f = mk_this (gen.gmk_internal_name "hx" "hashes_f") (gen.gclasses.nativearray a_t) in
|
|
|
+ let hx_dynamics = mk_this (gen.gmk_internal_name "hx" "dynamics") (gen.gclasses.nativearray t_empty) in
|
|
|
+ let hx_dynamics_f = mk_this (gen.gmk_internal_name "hx" "dynamics_f") (gen.gclasses.nativearray basic.tfloat) in
|
|
|
+ let hx_length = mk_this (gen.gmk_internal_name "hx" "length") (basic.tint) in
|
|
|
+ let hx_length_f = mk_this (gen.gmk_internal_name "hx" "length_f") (basic.tint) in
|
|
|
let res = alloc_var "res" basic.tint in
|
|
|
- let fst_hash, snd_hash, fst_dynamics, snd_dynamics =
|
|
|
- if is_float then hx_hashes_f, hx_hashes, hx_dynamics_f, hx_dynamics else hx_hashes, hx_hashes_f, hx_dynamics, hx_dynamics_f
|
|
|
+ let fst_hash, snd_hash, fst_dynamics, snd_dynamics, fst_length, snd_length =
|
|
|
+ if is_float then
|
|
|
+ hx_hashes_f, hx_hashes, hx_dynamics_f, hx_dynamics, hx_length_f, hx_length
|
|
|
+ else
|
|
|
+ hx_hashes, hx_hashes_f, hx_dynamics, hx_dynamics_f, hx_length, hx_length_f
|
|
|
in
|
|
|
let res_local = mk_local res pos in
|
|
|
let gte = {
|
|
@@ -7122,12 +7132,10 @@ struct
|
|
|
etype = basic.tbool;
|
|
|
epos = pos;
|
|
|
} in
|
|
|
- let get_array_t t = match follow t with | TInst({ cl_path = ([],"Array") },[arrtype]) -> arrtype | _ -> assert false in
|
|
|
let mk_tarray arr idx =
|
|
|
- let t = get_array_t arr.etype in
|
|
|
{
|
|
|
eexpr = TArray(arr, idx);
|
|
|
- etype = t;
|
|
|
+ etype = gen.gclasses.nativearray_type arr.etype;
|
|
|
epos = pos;
|
|
|
}
|
|
|
in
|
|
@@ -7150,11 +7158,11 @@ struct
|
|
|
*)
|
|
|
let block =
|
|
|
[
|
|
|
- { eexpr = TVar(res, Some(ctx.rcf_hash_function hash_local fst_hash)); etype = basic.tvoid; epos = pos };
|
|
|
+ { eexpr = TVar(res, Some(ctx.rcf_hash_function hash_local fst_hash fst_length)); etype = basic.tvoid; epos = pos };
|
|
|
{ eexpr = TIf(gte, mk_return (mk_tarray fst_dynamics res_local), Some({
|
|
|
eexpr = TBlock(
|
|
|
[
|
|
|
- { eexpr = TBinop(Ast.OpAssign, res_local, ctx.rcf_hash_function hash_local snd_hash); etype = basic.tint; epos = pos };
|
|
|
+ { eexpr = TBinop(Ast.OpAssign, res_local, ctx.rcf_hash_function hash_local snd_hash snd_length); etype = basic.tint; epos = pos };
|
|
|
{ eexpr = TIf(gte, mk_return (mk_tarray snd_dynamics res_local), None); etype = ret_t; epos = pos }
|
|
|
]);
|
|
|
etype = ret_t;
|
|
@@ -7183,23 +7191,6 @@ struct
|
|
|
__hx_dynamics/_f.insert(~res, value_local);
|
|
|
return value_local;
|
|
|
*)
|
|
|
- let mk_splice arr at_pos = {
|
|
|
- eexpr = TCall(
|
|
|
- mk_field_access gen arr "spliceVoid" pos,
|
|
|
- [at_pos; { eexpr = TConst(TInt Int32.one); etype = basic.tint; epos = pos }]
|
|
|
- );
|
|
|
- etype = basic.tvoid;
|
|
|
- epos = pos
|
|
|
- } in
|
|
|
-
|
|
|
- let mk_insert arr at_pos value = {
|
|
|
- eexpr = TCall(
|
|
|
- mk_field_access gen arr "insert" pos,
|
|
|
- [at_pos; value]);
|
|
|
- etype = basic.tvoid;
|
|
|
- epos = pos
|
|
|
- } in
|
|
|
-
|
|
|
let neg_res = { eexpr = TUnop(Ast.NegBits, Ast.Prefix, res_local); etype = basic.tint; epos = pos } in
|
|
|
|
|
|
let res2 = alloc_var "res2" basic.tint in
|
|
@@ -7212,16 +7203,17 @@ struct
|
|
|
|
|
|
let block =
|
|
|
[
|
|
|
- { eexpr = TVar(res, Some(ctx.rcf_hash_function hash_local fst_hash)); etype = basic.tvoid; epos = pos };
|
|
|
+ { eexpr = TVar(res, Some(ctx.rcf_hash_function hash_local fst_hash fst_length)); etype = basic.tvoid; epos = pos };
|
|
|
{
|
|
|
eexpr = TIf(gte,
|
|
|
mk_return { eexpr = TBinop(Ast.OpAssign, mk_tarray fst_dynamics res_local, value_local); etype = value_local.etype; epos = pos },
|
|
|
Some({ eexpr = TBlock([
|
|
|
- { eexpr = TVar( res2, Some(ctx.rcf_hash_function hash_local snd_hash)); etype = basic.tvoid; epos = pos };
|
|
|
+ { eexpr = TVar( res2, Some(ctx.rcf_hash_function hash_local snd_hash snd_length)); etype = basic.tvoid; epos = pos };
|
|
|
{
|
|
|
eexpr = TIf(gte2, { eexpr = TBlock([
|
|
|
- mk_splice snd_hash res2_local;
|
|
|
- mk_splice snd_dynamics res2_local
|
|
|
+ ctx.rcf_remove_function snd_hash snd_length res2_local;
|
|
|
+ ctx.rcf_remove_function snd_dynamics snd_length res2_local;
|
|
|
+ mk (TUnop(Decrement,Postfix,snd_length)) basic.tint pos
|
|
|
]); etype = t_dynamic; epos = pos }, None);
|
|
|
etype = t_dynamic;
|
|
|
epos = pos;
|
|
@@ -7230,8 +7222,9 @@ struct
|
|
|
etype = t_dynamic;
|
|
|
epos = pos;
|
|
|
};
|
|
|
- mk_insert fst_hash neg_res hash_local;
|
|
|
- mk_insert fst_dynamics neg_res value_local;
|
|
|
+ ctx.rcf_insert_function fst_hash fst_length neg_res hash_local;
|
|
|
+ ctx.rcf_insert_function fst_dynamics fst_length neg_res value_local;
|
|
|
+ mk (TUnop(Increment,Postfix,fst_length)) basic.tint pos;
|
|
|
mk_return value_local
|
|
|
] in
|
|
|
block
|
|
@@ -7249,10 +7242,12 @@ struct
|
|
|
let body = if is_dynamic then begin
|
|
|
let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in
|
|
|
let a_t = if ctx.rcf_optimize then basic.tint else basic.tstring in
|
|
|
- let hx_hashes = mk_this (gen.gmk_internal_name "hx" "hashes") (basic.tarray a_t) in
|
|
|
- let hx_hashes_f = mk_this (gen.gmk_internal_name "hx" "hashes_f") (basic.tarray a_t) in
|
|
|
- let hx_dynamics = mk_this (gen.gmk_internal_name "hx" "dynamics") (basic.tarray t_empty) in
|
|
|
- let hx_dynamics_f = mk_this (gen.gmk_internal_name "hx" "dynamics_f") (basic.tarray basic.tfloat) in
|
|
|
+ let hx_hashes = mk_this (gen.gmk_internal_name "hx" "hashes") (gen.gclasses.nativearray a_t) in
|
|
|
+ let hx_hashes_f = mk_this (gen.gmk_internal_name "hx" "hashes_f") (gen.gclasses.nativearray a_t) in
|
|
|
+ let hx_dynamics = mk_this (gen.gmk_internal_name "hx" "dynamics") (gen.gclasses.nativearray t_empty) in
|
|
|
+ let hx_dynamics_f = mk_this (gen.gmk_internal_name "hx" "dynamics_f") (gen.gclasses.nativearray basic.tfloat) in
|
|
|
+ let hx_length = mk_this (gen.gmk_internal_name "hx" "length") (basic.tint) in
|
|
|
+ let hx_length_f = mk_this (gen.gmk_internal_name "hx" "length_f") (basic.tint) in
|
|
|
let res = alloc_var "res" basic.tint in
|
|
|
let res_local = mk_local res pos in
|
|
|
let gte = {
|
|
@@ -7260,14 +7255,6 @@ struct
|
|
|
etype = basic.tbool;
|
|
|
epos = pos;
|
|
|
} in
|
|
|
- let mk_splice arr at_pos = {
|
|
|
- eexpr = TCall(
|
|
|
- mk_field_access gen arr "spliceVoid" pos,
|
|
|
- [at_pos; { eexpr = TConst(TInt Int32.one); etype = basic.tint; epos = pos }]
|
|
|
- );
|
|
|
- etype = basic.tvoid;
|
|
|
- epos = pos
|
|
|
- } in
|
|
|
(*
|
|
|
var res = lookup(this.__hx_hashes, hash);
|
|
|
if (res >= 0)
|
|
@@ -7290,17 +7277,19 @@ struct
|
|
|
return false;
|
|
|
*)
|
|
|
[
|
|
|
- { eexpr = TVar(res,Some(ctx.rcf_hash_function local_switch_var hx_hashes)); etype = basic.tvoid; epos = pos };
|
|
|
+ { eexpr = TVar(res,Some(ctx.rcf_hash_function local_switch_var hx_hashes hx_length)); etype = basic.tvoid; epos = pos };
|
|
|
{
|
|
|
eexpr = TIf(gte, { eexpr = TBlock([
|
|
|
- mk_splice hx_hashes res_local;
|
|
|
- mk_splice hx_dynamics res_local;
|
|
|
+ ctx.rcf_remove_function hx_hashes hx_length res_local;
|
|
|
+ ctx.rcf_remove_function hx_dynamics hx_length res_local;
|
|
|
+ mk (TUnop(Decrement,Postfix,hx_length)) basic.tint pos;
|
|
|
mk_return { eexpr = TConst(TBool true); etype = basic.tbool; epos = pos }
|
|
|
]); etype = t_dynamic; epos = pos }, Some({ eexpr = TBlock([
|
|
|
- { eexpr = TBinop(Ast.OpAssign, res_local, ctx.rcf_hash_function local_switch_var hx_hashes_f); etype = basic.tint; epos = pos };
|
|
|
+ { eexpr = TBinop(Ast.OpAssign, res_local, ctx.rcf_hash_function local_switch_var hx_hashes_f hx_length_f); etype = basic.tint; epos = pos };
|
|
|
{ eexpr = TIf(gte, { eexpr = TBlock([
|
|
|
- mk_splice hx_hashes_f res_local;
|
|
|
- mk_splice hx_dynamics_f res_local;
|
|
|
+ ctx.rcf_remove_function hx_hashes_f hx_length_f res_local;
|
|
|
+ ctx.rcf_remove_function hx_dynamics_f hx_length_f res_local;
|
|
|
+ mk (TUnop(Decrement,Postfix,hx_length_f)) basic.tint pos;
|
|
|
mk_return { eexpr = TConst(TBool true); etype = basic.tbool; epos = pos }
|
|
|
]); etype = t_dynamic; epos = pos }, None); etype = t_dynamic; epos = pos }
|
|
|
]); etype = t_dynamic; epos = pos }));
|
|
@@ -7373,16 +7362,26 @@ struct
|
|
|
let basic = gen.gcon.basic in
|
|
|
let hasht = if ctx.rcf_optimize then basic.tint else basic.tstring in
|
|
|
|
|
|
+ let hashes_field = gen.gmk_internal_name "hx" "hashes", gen.gclasses.nativearray hasht in
|
|
|
+ let hashes_f_field = gen.gmk_internal_name "hx" "hashes_f", gen.gclasses.nativearray hasht in
|
|
|
+ let dynamics_field = gen.gmk_internal_name "hx" "dynamics", gen.gclasses.nativearray t_empty in
|
|
|
+ let dynamics_f_field = gen.gmk_internal_name "hx" "dynamics_f", gen.gclasses.nativearray basic.tfloat in
|
|
|
let fields =
|
|
|
[
|
|
|
- gen.gmk_internal_name "hx" "hashes", basic.tarray hasht;
|
|
|
- gen.gmk_internal_name "hx" "dynamics", basic.tarray t_empty;
|
|
|
- gen.gmk_internal_name "hx" "hashes_f", basic.tarray hasht;
|
|
|
- gen.gmk_internal_name "hx" "dynamics_f", basic.tarray basic.tfloat;
|
|
|
+ hashes_field;
|
|
|
+ dynamics_field;
|
|
|
+ hashes_f_field;
|
|
|
+ dynamics_f_field;
|
|
|
+ ] in
|
|
|
+
|
|
|
+ let hashes_var = alloc_var (fst hashes_field) (snd hashes_field) in
|
|
|
+ let hashes_f_var = alloc_var (fst hashes_f_field) (snd hashes_f_field) in
|
|
|
+ let tf_args = [
|
|
|
+ hashes_var, None;
|
|
|
+ alloc_var (fst dynamics_field) (snd dynamics_field), None;
|
|
|
+ hashes_f_var, None;
|
|
|
+ alloc_var (fst dynamics_f_field) (snd dynamics_f_field), None;
|
|
|
] in
|
|
|
- let tf_args = List.map (fun (name, t) ->
|
|
|
- alloc_var name t, None
|
|
|
- ) fields in
|
|
|
|
|
|
let this = { eexpr = TConst TThis; etype = TInst(cl, List.map snd cl.cl_params); epos = pos } in
|
|
|
let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in
|
|
@@ -7395,9 +7394,16 @@ struct
|
|
|
tf_type = basic.tvoid;
|
|
|
tf_expr =
|
|
|
{
|
|
|
- eexpr = TBlock(List.map (fun (v,_) ->
|
|
|
+ eexpr = TBlock(
|
|
|
+ List.map (fun (v,_) ->
|
|
|
{ eexpr = TBinop(Ast.OpAssign, mk_this v.v_name v.v_type, mk_local v pos); etype = v.v_type; epos = pos }
|
|
|
- ) tf_args);
|
|
|
+ ) tf_args
|
|
|
+ @
|
|
|
+ [
|
|
|
+ mk (TBinop(OpAssign, mk_this (gen.gmk_internal_name "hx" "length") basic.tint, gen.gclasses.nativearray_len (mk_local hashes_var pos) pos)) basic.tint pos;
|
|
|
+ mk (TBinop(OpAssign, mk_this (gen.gmk_internal_name "hx" "length_f") basic.tint, gen.gclasses.nativearray_len (mk_local hashes_f_var pos) pos)) basic.tint pos;
|
|
|
+ ]
|
|
|
+ );
|
|
|
etype = basic.tvoid;
|
|
|
epos = pos
|
|
|
}
|
|
@@ -7415,7 +7421,7 @@ struct
|
|
|
tf_args = [];
|
|
|
tf_expr = {
|
|
|
eexpr = TBlock(List.map (fun (f,t) ->
|
|
|
- { eexpr = TBinop(Ast.OpAssign, mk_this f t,{ eexpr = TArrayDecl([]); etype = t; epos = pos; }); etype = t; epos = pos }
|
|
|
+ { eexpr = TBinop(Ast.OpAssign, mk_this f t,{ eexpr = TCall(mk_local v_nativearray pos, []); etype = t; epos = pos; }); etype = t; epos = pos }
|
|
|
) fields);
|
|
|
etype = basic.tvoid;
|
|
|
epos = pos;
|
|
@@ -7477,14 +7483,13 @@ struct
|
|
|
|
|
|
let odecl, odecl_f = List.sort sort_fn odecl, List.sort sort_fn odecl_f in
|
|
|
|
|
|
- let mk_arrdecl el t = { eexpr = TArrayDecl(el); etype = t; epos = pos } in
|
|
|
let ret = {
|
|
|
e with eexpr = TNew(cl,[],
|
|
|
[
|
|
|
- mk_arrdecl (List.map fst odecl) (basic.tarray hasht);
|
|
|
- mk_arrdecl (List.map snd odecl) (basic.tarray t_empty);
|
|
|
- mk_arrdecl (List.map fst odecl_f) (basic.tarray hasht);
|
|
|
- mk_arrdecl (List.map snd odecl_f) (basic.tarray basic.tfloat)
|
|
|
+ mk_nativearray_decl gen hasht (List.map fst odecl) pos;
|
|
|
+ mk_nativearray_decl gen t_empty (List.map snd odecl) pos;
|
|
|
+ mk_nativearray_decl gen hasht (List.map fst odecl_f) pos;
|
|
|
+ mk_nativearray_decl gen basic.tfloat (List.map snd odecl_f) pos;
|
|
|
]);
|
|
|
} in
|
|
|
match !exprs_before with
|
|
@@ -7513,20 +7518,27 @@ struct
|
|
|
|
|
|
let new_fields =
|
|
|
[
|
|
|
- mk_class_field (gen.gmk_internal_name "hx" "hashes") (basic.tarray hasht) false pos (Var { v_read = AccNormal; v_write = AccNormal }) [];
|
|
|
- mk_class_field (gen.gmk_internal_name "hx" "dynamics") (basic.tarray t_empty) false pos (Var { v_read = AccNormal; v_write = AccNormal }) [];
|
|
|
- mk_class_field (gen.gmk_internal_name "hx" "hashes_f") (basic.tarray hasht) false pos (Var { v_read = AccNormal; v_write = AccNormal }) [];
|
|
|
- mk_class_field (gen.gmk_internal_name "hx" "dynamics_f") (basic.tarray basic.tfloat) false pos (Var { v_read = AccNormal; v_write = AccNormal }) [];
|
|
|
+ mk_class_field (gen.gmk_internal_name "hx" "hashes") (gen.gclasses.nativearray hasht) false pos (Var { v_read = AccNormal; v_write = AccNormal }) [];
|
|
|
+ mk_class_field (gen.gmk_internal_name "hx" "dynamics") (gen.gclasses.nativearray t_empty) false pos (Var { v_read = AccNormal; v_write = AccNormal }) [];
|
|
|
+ mk_class_field (gen.gmk_internal_name "hx" "hashes_f") (gen.gclasses.nativearray hasht) false pos (Var { v_read = AccNormal; v_write = AccNormal }) [];
|
|
|
+ mk_class_field (gen.gmk_internal_name "hx" "dynamics_f") (gen.gclasses.nativearray basic.tfloat) false pos (Var { v_read = AccNormal; v_write = AccNormal }) [];
|
|
|
] in
|
|
|
|
|
|
(if cl.cl_path <> (["haxe"; "lang"], "DynamicObject") then
|
|
|
- List.iter (fun cf -> cf.cf_expr <- Some { eexpr = TArrayDecl([]); etype = cf.cf_type; epos = cf.cf_pos }) new_fields
|
|
|
+ List.iter (fun cf -> cf.cf_expr <- Some { eexpr = TCall(mk_local v_nativearray pos, []); etype = cf.cf_type; epos = cf.cf_pos }) new_fields
|
|
|
);
|
|
|
|
|
|
let delete = get_delete_field ctx cl true in
|
|
|
+
|
|
|
+ let new_fields = new_fields @ [
|
|
|
+ mk_class_field (gen.gmk_internal_name "hx" "length") (basic.tint) false pos (Var { v_read = AccNormal; v_write = AccNormal }) [];
|
|
|
+ mk_class_field (gen.gmk_internal_name "hx" "length_f") (basic.tint) false pos (Var { v_read = AccNormal; v_write = AccNormal }) [];
|
|
|
+ delete;
|
|
|
+ ] in
|
|
|
+
|
|
|
List.iter (fun cf ->
|
|
|
cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields
|
|
|
- ) (delete :: new_fields);
|
|
|
+ ) new_fields;
|
|
|
|
|
|
(*
|
|
|
let rec last_ctor cl =
|
|
@@ -7543,10 +7555,10 @@ struct
|
|
|
This will consist of different parts:
|
|
|
Check if there are constructors. If not, create one and add initialization to it (calling super, ok)
|
|
|
If there are, add as first statement (or second if there is a super() call in the first)
|
|
|
- If class has @:$DynamicObject meta, also create another new() class with its parameters as constructor arguments
|
|
|
+ If class has @:dynamicObject meta, also create another new() class with its parameters as constructor arguments
|
|
|
*)
|
|
|
|
|
|
- cl.cl_ordered_fields <- cl.cl_ordered_fields @ (delete :: new_fields);
|
|
|
+ cl.cl_ordered_fields <- cl.cl_ordered_fields @ new_fields;
|
|
|
if is_override then cl.cl_overrides <- delete :: cl.cl_overrides
|
|
|
end
|
|
|
end else if not is_override then begin
|
|
@@ -9134,7 +9146,7 @@ struct
|
|
|
cf.cf_meta <- [];
|
|
|
|
|
|
let tf_args = List.map (fun (name,opt,t) -> (alloc_var name t, if opt then Some TNull else None) ) params in
|
|
|
- let arr_decl = mk_vector_decl gen t_dynamic (List.map (fun (v,_) -> mk_local v pos) tf_args) pos in
|
|
|
+ let arr_decl = mk_nativearray_decl gen t_dynamic (List.map (fun (v,_) -> mk_local v pos) tf_args) pos in
|
|
|
let expr = {
|
|
|
eexpr = TFunction({
|
|
|
tf_args = tf_args;
|
|
@@ -9153,7 +9165,7 @@ struct
|
|
|
in
|
|
|
let cf = mk_class_field name actual_t true pos (Var { v_read = AccNormal; v_write = AccNever }) [] in
|
|
|
let args = if has_params then
|
|
|
- [mk_int gen old_i pos; null (gen.gclasses.tvector t_dynamic) pos]
|
|
|
+ [mk_int gen old_i pos; null (gen.gclasses.nativearray t_dynamic) pos]
|
|
|
else
|
|
|
[mk_int gen old_i pos]
|
|
|
in
|
|
@@ -9168,9 +9180,9 @@ struct
|
|
|
cl.cl_statics <- PMap.add cf.cf_name cf cl.cl_statics;
|
|
|
cf
|
|
|
) en.e_names in
|
|
|
- let constructs_cf = mk_class_field "__hx_constructs" (gen.gclasses.tvector basic.tstring) true pos (Var { v_read = AccNormal; v_write = AccNever }) [] in
|
|
|
+ let constructs_cf = mk_class_field "__hx_constructs" (gen.gclasses.nativearray basic.tstring) true pos (Var { v_read = AccNormal; v_write = AccNever }) [] in
|
|
|
constructs_cf.cf_meta <- [Meta.ReadOnly,[],pos];
|
|
|
- constructs_cf.cf_expr <- Some (mk_vector_decl gen basic.tstring (List.map (fun s -> { eexpr = TConst(TString s); etype = basic.tstring; epos = pos }) en.e_names) pos);
|
|
|
+ constructs_cf.cf_expr <- Some (mk_nativearray_decl gen basic.tstring (List.map (fun s -> { eexpr = TConst(TString s); etype = basic.tstring; epos = pos }) en.e_names) pos);
|
|
|
|
|
|
cl.cl_ordered_statics <- constructs_cf :: cfs @ cl.cl_ordered_statics ;
|
|
|
cl.cl_statics <- PMap.add "__hx_constructs" constructs_cf cl.cl_statics;
|
|
@@ -9295,7 +9307,7 @@ struct
|
|
|
with Not_found ->
|
|
|
f
|
|
|
in
|
|
|
- let cond_array = { (mk_field_access gen f "params" f.epos) with etype = gen.gclasses.tvector t_dynamic } in
|
|
|
+ let cond_array = { (mk_field_access gen f "params" f.epos) with etype = gen.gclasses.nativearray t_dynamic } in
|
|
|
{ e with eexpr = TArray(cond_array, mk_int gen i cond_array.epos); }
|
|
|
| _ -> Type.map_expr run e
|
|
|
in
|