Browse Source

make sure that fields are marked as used when inlining is cancelled

Simon Krajewski 13 years ago
parent
commit
579bffa2d5
3 changed files with 5 additions and 3 deletions
  1. 2 0
      optimizer.ml
  2. 3 0
      typecore.ml
  3. 0 3
      typer.ml

+ 2 - 0
optimizer.ml

@@ -327,6 +327,8 @@ let rec type_inline ctx cf f ethis params tret p force =
 		This could be fixed with better post process code cleanup (planed)
 	*)
 	if !cancel_inlining || (Common.platform ctx.com Js && not force && (init <> None || !has_vars)) then begin
+		(* we have to make sure that we mark the field as used here so DCE does not remove it *)
+		mark_used_field ctx cf;
 		None
 	end else
 		let wrap e =

+ 3 - 0
typecore.ml

@@ -251,3 +251,6 @@ let feature_name = function
 
 let activate_feature ctx ft = Hashtbl.replace ctx.g.features (feature_name ft) ft
 let has_feature ctx s = Hashtbl.mem ctx.g.features s
+
+let mark_used_field ctx f =
+	if ctx.com.dead_code_elimination && not (has_meta ":?used" f.cf_meta) then f.cf_meta <- (":?used",[],f.cf_pos) :: f.cf_meta

+ 0 - 3
typer.ml

@@ -77,9 +77,6 @@ let rec mark_used_class ctx c =
 let mark_used_enum ctx e  =
 	if ctx.com.dead_code_elimination && not (has_meta ":?used" e.e_meta) then e.e_meta <- (":?used",[],e.e_pos) :: e.e_meta
 
-let mark_used_field ctx f =
-	if ctx.com.dead_code_elimination && not (has_meta ":?used" f.cf_meta) then f.cf_meta <- (":?used",[],f.cf_pos) :: f.cf_meta
-
 type type_class =
 	| KInt
 	| KFloat