|
@@ -282,11 +282,23 @@ and field dce c n stat =
|
|
|
with Not_found ->
|
|
|
if dce.debug then prerr_endline ("[DCE] Field " ^ n ^ " not found on " ^ (s_type_path c.cl_path)) else ())
|
|
|
|
|
|
+and mark_really_used_class c =
|
|
|
+ if not (Meta.has Meta.ReallyUsed c.cl_meta) then
|
|
|
+ c.cl_meta <- (Meta.ReallyUsed,[],c.cl_pos) :: c.cl_meta
|
|
|
+
|
|
|
+and mark_really_used_mt mt =
|
|
|
+ match mt with
|
|
|
+ | TClassDecl c ->
|
|
|
+ mark_really_used_class c
|
|
|
+ | _ ->
|
|
|
+ ()
|
|
|
+
|
|
|
and expr dce e =
|
|
|
mark_t dce e.epos e.etype;
|
|
|
match e.eexpr with
|
|
|
| TNew(c,pl,el) ->
|
|
|
mark_class dce c;
|
|
|
+ mark_really_used_class c;
|
|
|
field dce c "new" false;
|
|
|
List.iter (expr dce) el;
|
|
|
List.iter (mark_t dce e.epos) pl;
|
|
@@ -296,9 +308,11 @@ and expr dce e =
|
|
|
| TCast(e, Some mt) ->
|
|
|
check_feature dce "typed_cast";
|
|
|
mark_mt dce mt;
|
|
|
+ mark_really_used_mt mt;
|
|
|
expr dce e;
|
|
|
| TTypeExpr mt ->
|
|
|
- mark_mt dce mt
|
|
|
+ mark_mt dce mt;
|
|
|
+ mark_really_used_mt mt;
|
|
|
| TTry(e, vl) ->
|
|
|
expr dce e;
|
|
|
List.iter (fun (v,e) ->
|
|
@@ -560,6 +574,15 @@ let run com main full =
|
|
|
| _ -> ()
|
|
|
) com.types;
|
|
|
|
|
|
+ (* mark extern classes as really used if they are extended by non-extern ones *)
|
|
|
+ List.iter (function
|
|
|
+ | TClassDecl ({cl_extern = false; cl_super = Some ({cl_extern = true} as csup, _)}) ->
|
|
|
+ mark_really_used_class csup
|
|
|
+ | TClassDecl ({cl_extern = false} as c) when c.cl_implements <> [] ->
|
|
|
+ List.iter (fun (iface,_) -> if (iface.cl_extern) then mark_really_used_class iface) c.cl_implements;
|
|
|
+ | _ -> ()
|
|
|
+ ) com.types;
|
|
|
+
|
|
|
(* cleanup added fields metadata - compatibility with compilation server *)
|
|
|
let rec remove_meta m = function
|
|
|
| [] -> []
|