2
0
Эх сурвалжийг харах

[dump] also skip mono ids if -D dump-ignore-var-ids

Rudy Ges 5 сар өмнө
parent
commit
5b3a2a38d2

+ 11 - 2
src/codegen/dump.ml

@@ -20,9 +20,17 @@ let create_dumpfile_from_path com path =
 	buf,close
 
 let dump_types com pretty =
+	let print_ids = not (Common.defined com Define.DumpIgnoreVarIds) in
+	let restore =
+		if not pretty then
+			let old = !TPrinting.MonomorphPrinting.show_mono_ids in
+			TPrinting.MonomorphPrinting.show_mono_ids := print_ids;
+			fun () -> TPrinting.MonomorphPrinting.show_mono_ids := old
+		else fun () -> ()
+	in
 	let s_type = s_type (Type.print_context()) in
 	let s_expr,s_type_param = if not pretty then
-		(Type.s_expr_ast (not (Common.defined com Define.DumpIgnoreVarIds)) "\t"),(Printer.s_type_param "")
+		(Type.s_expr_ast print_ids "\t"),(Printer.s_type_param "")
 	else
 		(Type.s_expr_pretty false "\t" true),(s_type_param s_type)
 	in
@@ -124,7 +132,8 @@ let dump_types com pretty =
 	in
 	Parallel.run_in_new_pool com.timer_ctx (fun pool ->
 		Parallel.ParallelArray.iter pool f (Array.of_list com.types)
-	)
+	);
+	restore()
 
 let dump_record com =
 	let f mt =

+ 2 - 2
src/core/tPrinting.ml

@@ -30,7 +30,7 @@ let s_module_type_kind = function
 
 
 module MonomorphPrinting = struct
-	let show_mono_ids = true
+	let show_mono_ids = ref true
 
 	let s_mono_constraint_kind s_type constr =
 		let rec loop = function
@@ -42,7 +42,7 @@ module MonomorphPrinting = struct
 		loop constr
 
 	let print_mono_name m id extra =
-		let s = if show_mono_ids then
+		let s = if !show_mono_ids then
 			Printf.sprintf "Unknown<%d>" id
 		else
 			"Unknown"