소스 검색

prevent some types not being post-processed in macros (fixed issue #1126)

Nicolas Cannasse 13 년 전
부모
커밋
ea0ec82623
3개의 변경된 파일27개의 추가작업 그리고 25개의 파일을 삭제
  1. 23 23
      codegen.ml
  2. 2 1
      main.ml
  3. 2 1
      typer.ml

+ 23 - 23
codegen.ml

@@ -1149,32 +1149,32 @@ let check_local_vars_init e =
 
 let pp_counter = ref 1
 
-let post_process types filters =
+let post_process filters t =
 	(* ensure that we don't process twice the same (cached) module *)
-	List.iter (fun t ->
-		let m = (t_infos t).mt_module.m_extra in
-		if m.m_processed = 0 then m.m_processed <- !pp_counter;
-		if m.m_processed = !pp_counter then
-		match t with
-		| TClassDecl c ->
-			let process_field f =
-				match f.cf_expr with
-				| None -> ()
-				| Some e ->
-					f.cf_expr <- Some (List.fold_left (fun e f -> f e) e filters)
-			in
-			List.iter process_field c.cl_ordered_fields;
-			List.iter process_field c.cl_ordered_statics;
-			(match c.cl_constructor with
-			| None -> ()
-			| Some f -> process_field f);
-			(match c.cl_init with
+	let m = (t_infos t).mt_module.m_extra in
+	if m.m_processed = 0 then m.m_processed <- !pp_counter;
+	if m.m_processed = !pp_counter then
+	match t with
+	| TClassDecl c ->
+		let process_field f =
+			match f.cf_expr with
 			| None -> ()
 			| Some e ->
-				c.cl_init <- Some (List.fold_left (fun e f -> f e) e filters));
-		| TEnumDecl _ -> ()
-		| TTypeDecl _ -> ()
-	) types;
+				f.cf_expr <- Some (List.fold_left (fun e f -> f e) e filters)
+		in
+		List.iter process_field c.cl_ordered_fields;
+		List.iter process_field c.cl_ordered_statics;
+		(match c.cl_constructor with
+		| None -> ()
+		| Some f -> process_field f);
+		(match c.cl_init with
+		| None -> ()
+		| Some e ->
+			c.cl_init <- Some (List.fold_left (fun e f -> f e) e filters));
+	| TEnumDecl _ -> ()
+	| TTypeDecl _ -> ()
+
+let post_process_end() =
 	incr pp_counter
 
 (* -------------------------------------------------------------------------- *)

+ 2 - 1
main.ml

@@ -1032,7 +1032,8 @@ try
 			Codegen.captured_vars com;
 			Codegen.rename_local_vars com;
 		] in
-		Codegen.post_process com.types filters;
+		List.iter (Codegen.post_process filters) com.types;
+		Codegen.post_process_end();
 		Common.add_filter com (fun() -> List.iter (Codegen.on_generate tctx) com.types);
 		List.iter (fun f -> f()) (List.rev com.filters);
 		if ctx.has_error then raise Abort;

+ 2 - 1
typer.ml

@@ -2745,7 +2745,8 @@ let flush_macro_context mctx ctx =
 	ctx.com.types <- types;
 	ctx.com.Common.modules <- modules;
 	(* we should maybe ensure that all filters in Main are applied. Not urgent atm *)
-	Interp.add_types mctx types (fun t -> Codegen.post_process [t] [Codegen.captured_vars ctx.com; Codegen.rename_local_vars ctx.com])
+	Interp.add_types mctx types (Codegen.post_process [Codegen.captured_vars ctx.com; Codegen.rename_local_vars ctx.com]);
+	Codegen.post_process_end()
 
 let get_macro_context ctx p =
 	let api = make_macro_api ctx p in