Bläddra i källkod

remove pf_can_init_member and always move every member initialization to the constructor (closes #2349)

Simon Krajewski 11 år sedan
förälder
incheckning
7b6dc8fdf9
2 ändrade filer med 2 tillägg och 19 borttagningar
  1. 1 18
      common.ml
  2. 1 1
      filters.ml

+ 1 - 18
common.ml

@@ -83,8 +83,6 @@ type platform_config = {
 	pf_captured_scope : bool;
 	(** generated locals must be absolutely unique wrt the current function *)
 	pf_unique_locals : bool;
-	(** which expressions can be generated to initialize member variables (or will be moved into the constructor *)
-	pf_can_init_member : tclass_field -> bool;
 	(** captured variables handling (see before) *)
 	pf_capture_policy : capture_policy;
 	(** when calling a method with optional args, do we replace the missing args with "null" constants *)
@@ -466,7 +464,6 @@ let default_config =
 		pf_locals_scope = true;
 		pf_captured_scope = true;
 		pf_unique_locals = false;
-		pf_can_init_member = (fun _ -> true);
 		pf_capture_policy = CPNone;
 		pf_pad_nulls = false;
 		pf_add_final_return = false;
@@ -488,7 +485,6 @@ let get_config com =
 			pf_locals_scope = com.flash_version > 6.;
 			pf_captured_scope = false;
 			pf_unique_locals = false;
-			pf_can_init_member = (fun _ -> true);
 			pf_capture_policy = CPLoopVars;
 			pf_pad_nulls = false;
 			pf_add_final_return = false;
@@ -504,7 +500,6 @@ let get_config com =
 			pf_locals_scope = false;
 			pf_captured_scope = false;
 			pf_unique_locals = false;
-			pf_can_init_member = (fun _ -> false);
 			pf_capture_policy = CPLoopVars;
 			pf_pad_nulls = false;
 			pf_add_final_return = false;
@@ -520,7 +515,6 @@ let get_config com =
 			pf_locals_scope = true;
 			pf_captured_scope = true;
 			pf_unique_locals = false;
-			pf_can_init_member = (fun _ -> false);
 			pf_capture_policy = CPNone;
 			pf_pad_nulls = true;
 			pf_add_final_return = false;
@@ -536,7 +530,6 @@ let get_config com =
 			pf_locals_scope = false;
 			pf_captured_scope = true;
 			pf_unique_locals = true;
-			pf_can_init_member = (fun _ -> true);
 			pf_capture_policy = CPLoopVars;
 			pf_pad_nulls = false;
 			pf_add_final_return = true;
@@ -552,7 +545,6 @@ let get_config com =
 			pf_locals_scope = true;
 			pf_captured_scope = true; (* handled by genSwf9 *)
 			pf_unique_locals = false;
-			pf_can_init_member = (fun _ -> false);
 			pf_capture_policy = CPLoopVars;
 			pf_pad_nulls = false;
 			pf_add_final_return = false;
@@ -568,12 +560,6 @@ let get_config com =
 			pf_locals_scope = false; (* some duplicate work is done in genPhp *)
 			pf_captured_scope = false;
 			pf_unique_locals = false;
-			pf_can_init_member = (fun cf ->
-				match cf.cf_kind, cf.cf_expr with
-				| Var { v_write = AccCall },	_ -> false
-				| _, Some { eexpr = TTypeExpr _ } -> false
-				| _ -> true
-			);
 			pf_capture_policy = CPNone;
 			pf_pad_nulls = true;
 			pf_add_final_return = false;
@@ -589,7 +575,6 @@ let get_config com =
 			pf_locals_scope = true;
 			pf_captured_scope = true;
 			pf_unique_locals = false;
-			pf_can_init_member = (fun _ -> false);
 			pf_capture_policy = CPWrapRef;
 			pf_pad_nulls = true;
 			pf_add_final_return = true;
@@ -605,7 +590,6 @@ let get_config com =
 			pf_locals_scope = false;
 			pf_captured_scope = true;
 			pf_unique_locals = true;
-			pf_can_init_member = (fun _ -> false);
 			pf_capture_policy = CPWrapRef;
 			pf_pad_nulls = true;
 			pf_add_final_return = false;
@@ -621,7 +605,6 @@ let get_config com =
 			pf_locals_scope = false;
 			pf_captured_scope = true;
 			pf_unique_locals = false;
-			pf_can_init_member = (fun _ -> false);
 			pf_capture_policy = CPWrapRef;
 			pf_pad_nulls = true;
 			pf_add_final_return = false;
@@ -855,7 +838,7 @@ let normalize_path p =
 
 let mem_size v =
 	Objsize.size_with_headers (Objsize.objsize v [] [])
-		
+
 (* ------------------------- TIMERS ----------------------------- *)
 
 type timer_infos = {

+ 1 - 1
filters.ml

@@ -936,7 +936,7 @@ let add_field_inits ctx t =
 		let inits,fields = List.fold_left (fun (inits,fields) cf ->
 			match cf.cf_kind,cf.cf_expr with
 			| Var _, Some _ ->
-				if ctx.com.config.pf_can_init_member cf then (inits, cf :: fields) else (cf :: inits, cf :: fields)
+				(cf :: inits, cf :: fields)
 			| Method MethDynamic, Some e when Common.defined ctx.com Define.As3 ->
 				(* TODO : this would have a better place in genSWF9 I think - NC *)
 				(* we move the initialization of dynamic functions to the constructor and also solve the