|
@@ -594,38 +594,17 @@ let reduce_expression ctx e =
|
|
(* ELIMINATE DEAD CODE *)
|
|
(* ELIMINATE DEAD CODE *)
|
|
|
|
|
|
(*
|
|
(*
|
|
- if dead code elimination is on, any class without fields is eliminated from the output. Also inline members
|
|
|
|
- are eliminated unless marked as @:keep
|
|
|
|
|
|
+ if dead code elimination is on, any class without fields is eliminated from the output.
|
|
*)
|
|
*)
|
|
|
|
|
|
let filter_dead_code com =
|
|
let filter_dead_code com =
|
|
let s_class c = s_type_path c.cl_path in
|
|
let s_class c = s_type_path c.cl_path in
|
|
- let s_field c cf = (s_class c) ^ "." ^ cf.cf_name in
|
|
|
|
- let keep c cf = (has_meta ":core_api" c.cl_meta) || (has_meta ":keep" c.cl_meta) || (has_meta ":keep" cf.cf_meta) in
|
|
|
|
- let remove_inlines c =
|
|
|
|
- let remove_inline_fields lst =
|
|
|
|
- List.filter(fun cf ->
|
|
|
|
- match cf.cf_kind with
|
|
|
|
- | Var k when ((k.v_read = AccInline) && (not (keep c cf))) ->
|
|
|
|
- if com.verbose then print_endline ("Remove inline var " ^ s_field c cf);
|
|
|
|
- false;
|
|
|
|
- | Method k when ((k = MethInline) && (not (keep c cf))) ->
|
|
|
|
- if com.verbose then print_endline ("Remove inline method " ^ s_field c cf);
|
|
|
|
- false;
|
|
|
|
- | _ ->
|
|
|
|
- true;
|
|
|
|
- ) lst
|
|
|
|
- in
|
|
|
|
- c.cl_ordered_statics <- remove_inline_fields c.cl_ordered_statics;
|
|
|
|
- c.cl_ordered_fields <- remove_inline_fields c.cl_ordered_fields
|
|
|
|
- in
|
|
|
|
com.types <- List.filter (fun t ->
|
|
com.types <- List.filter (fun t ->
|
|
match t with
|
|
match t with
|
|
| TClassDecl c ->
|
|
| TClassDecl c ->
|
|
if (c.cl_extern or has_meta ":keep" c.cl_meta) then
|
|
if (c.cl_extern or has_meta ":keep" c.cl_meta) then
|
|
true
|
|
true
|
|
else (
|
|
else (
|
|
- remove_inlines c;
|
|
|
|
match (c.cl_ordered_statics, c.cl_ordered_fields, c.cl_constructor) with
|
|
match (c.cl_ordered_statics, c.cl_ordered_fields, c.cl_constructor) with
|
|
| ([], [], None) ->
|
|
| ([], [], None) ->
|
|
if com.verbose then print_endline ("Remove class " ^ s_class c);
|
|
if com.verbose then print_endline ("Remove class " ^ s_class c);
|