Przeglądaj źródła

[Swf9] Do not make constructor args optional unless Type.createEmptyInstance is used

Simon Krajewski 13 lat temu
rodzic
commit
f5bbe91568
1 zmienionych plików z 4 dodań i 2 usunięć
  1. 4 2
      genswf9.ml

+ 4 - 2
genswf9.ml

@@ -81,6 +81,7 @@ type context = {
 	swc : bool;
 	swc : bool;
 	boot : path;
 	boot : path;
 	swf_protected : bool;
 	swf_protected : bool;
+	need_ctor_skip : bool;
 	mutable cur_class : tclass;
 	mutable cur_class : tclass;
 	mutable debug : bool;
 	mutable debug : bool;
 	mutable last_line : int;
 	mutable last_line : int;
@@ -1744,7 +1745,7 @@ let generate_method ctx fdata stat fmeta =
 
 
 let generate_construct ctx fdata c =
 let generate_construct ctx fdata c =
 	(* make all args optional to allow no-param constructor *)
 	(* make all args optional to allow no-param constructor *)
-	let cargs = List.map (fun (v,c) ->
+	let cargs = if not ctx.need_ctor_skip then fdata.tf_args else List.map (fun (v,c) ->
 		let c = (match c with Some _ -> c | None ->
 		let c = (match c with Some _ -> c | None ->
 			Some (match classify ctx v.v_type with
 			Some (match classify ctx v.v_type with
 			| KInt | KUInt -> TInt 0l
 			| KInt | KUInt -> TInt 0l
@@ -1756,7 +1757,7 @@ let generate_construct ctx fdata c =
 	) fdata.tf_args in
 	) fdata.tf_args in
 	let f = begin_fun ctx cargs fdata.tf_type [ethis;fdata.tf_expr] false fdata.tf_expr.epos in
 	let f = begin_fun ctx cargs fdata.tf_type [ethis;fdata.tf_expr] false fdata.tf_expr.epos in
 	(* if skip_constructor, then returns immediatly *)
 	(* if skip_constructor, then returns immediatly *)
-	(match c.cl_kind with
+	if ctx.need_ctor_skip then (match c.cl_kind with
 	| KGenericInstance _ -> ()
 	| KGenericInstance _ -> ()
 	| _ when not (Codegen.constructor_side_effects fdata.tf_expr) -> ()
 	| _ when not (Codegen.constructor_side_effects fdata.tf_expr) -> ()
 	| _ ->
 	| _ ->
@@ -2359,6 +2360,7 @@ let generate_resource ctx name =
 let generate com boot_name =
 let generate com boot_name =
 	let ctx = {
 	let ctx = {
 		com = com;
 		com = com;
+		need_ctor_skip = Common.has_feature com "Type.createEmptyInstance";
 		debug = com.Common.debug;
 		debug = com.Common.debug;
 		cur_class = null_class;
 		cur_class = null_class;
 		boot = ([],boot_name);
 		boot = ([],boot_name);