|
@@ -108,6 +108,8 @@ type context = {
|
|
|
core_enum : tclass;
|
|
|
ref_abstract : tabstract;
|
|
|
cdebug_files : (string, string) lookup;
|
|
|
+ mutable ct_delayed : (unit -> unit) list;
|
|
|
+ mutable ct_depth : int;
|
|
|
}
|
|
|
|
|
|
(* --- *)
|
|
@@ -558,6 +560,7 @@ and class_type ?(tref=None) ctx c pl statics =
|
|
|
(match tref with
|
|
|
| None -> ()
|
|
|
| Some r -> r := Some t);
|
|
|
+ ctx.ct_depth <- ctx.ct_depth + 1;
|
|
|
ctx.cached_types <- PMap.add key_path t ctx.cached_types;
|
|
|
if c.cl_path = ([],"Array") then assert false;
|
|
|
if c == ctx.base_class then begin
|
|
@@ -573,23 +576,20 @@ and class_type ?(tref=None) ctx c pl statics =
|
|
|
| Some (HObj psup) ->
|
|
|
if psup.pnfields < 0 then assert false;
|
|
|
p.psuper <- Some psup;
|
|
|
- p.pfunctions <- psup.pfunctions;
|
|
|
- p.pinterfaces <- psup.pinterfaces;
|
|
|
psup.pnfields, psup.pvirtuals
|
|
|
| _ -> assert false
|
|
|
) in
|
|
|
let fa = DynArray.create() and pa = DynArray.create() and virtuals = DynArray.of_array virtuals in
|
|
|
- let todo = ref [] in
|
|
|
let add_field name get_t =
|
|
|
let fid = DynArray.length fa + start_field in
|
|
|
let str = if name = "" then 0 else alloc_string ctx name in
|
|
|
p.pindex <- PMap.add name (fid, HVoid) p.pindex;
|
|
|
DynArray.add fa (name, str, HVoid);
|
|
|
- todo := (fun() ->
|
|
|
+ ctx.ct_delayed <- (fun() ->
|
|
|
let t = get_t() in
|
|
|
p.pindex <- PMap.add name (fid, t) p.pindex;
|
|
|
Array.set p.pfields (fid - start_field) (name, str, t);
|
|
|
- ) :: !todo;
|
|
|
+ ) :: ctx.ct_delayed;
|
|
|
fid
|
|
|
in
|
|
|
List.iter (fun f ->
|
|
@@ -649,7 +649,12 @@ and class_type ?(tref=None) ctx c pl statics =
|
|
|
p.pfields <- DynArray.to_array fa;
|
|
|
p.pproto <- DynArray.to_array pa;
|
|
|
p.pvirtuals <- DynArray.to_array virtuals;
|
|
|
- List.iter (fun f -> f()) !todo;
|
|
|
+ ctx.ct_depth <- ctx.ct_depth - 1;
|
|
|
+ if ctx.ct_depth = 0 then begin
|
|
|
+ let todo = ctx.ct_delayed in
|
|
|
+ ctx.ct_delayed <- [];
|
|
|
+ List.iter (fun f -> f()) todo;
|
|
|
+ end;
|
|
|
if not statics && c != ctx.core_type && c != ctx.core_enum then p.pclassglobal <- Some (fst (class_global ctx (if statics then ctx.base_class else c)));
|
|
|
t
|
|
|
|
|
@@ -3737,6 +3742,8 @@ let create_context com is_macro dump =
|
|
|
method_wrappers = PMap.empty;
|
|
|
cdebug_files = new_lookup();
|
|
|
macro_typedefs = Hashtbl.create 0;
|
|
|
+ ct_delayed = [];
|
|
|
+ ct_depth = 0;
|
|
|
} in
|
|
|
ignore(alloc_string ctx "");
|
|
|
ignore(class_type ctx ctx.base_class [] false);
|