Просмотр исходного кода

[typer] make m_deps hold a record

Simon Krajewski 1 год назад
Родитель
Сommit
1d7b7f93b9

+ 2 - 2
src/codegen/codegen.ml

@@ -388,8 +388,8 @@ module Dump = struct
 		let dep = Hashtbl.create 0 in
 		List.iter (fun m ->
 			print "%s:\n" (Path.UniqueKey.lazy_path m.m_extra.m_file);
-			PMap.iter (fun _ (sign,mpath) ->
-				let m2 = com.module_lut#find mpath in
+			PMap.iter (fun _ mdep ->
+				let m2 = com.module_lut#find mdep.md_path in
 				let file = Path.UniqueKey.lazy_path m2.m_extra.m_file in
 				print "\t%s\n" file;
 				let l = try Hashtbl.find dep file with Not_found -> [] in

+ 5 - 3
src/compiler/server.ml

@@ -316,7 +316,9 @@ let check_module sctx ctx m_path m_extra p =
 			((com.cs#get_context sign)#find_module mpath).m_extra
 		in
 		let check_dependencies () =
-			PMap.iter (fun _ (sign,mpath) ->
+			PMap.iter (fun _ mdep ->
+				let sign = mdep.md_sign in
+				let mpath = mdep.md_path in
 				let m2_extra = try
 					find_module_extra sign mpath
 				with Not_found ->
@@ -418,8 +420,8 @@ let add_modules sctx ctx m p =
 				) m.m_types;
 				TypeloadModule.ModuleLevel.add_module ctx m p;
 				handle_cache_bound_objects com m.m_extra.m_cache_bound_objects;
-				PMap.iter (fun _ (sign,mpath) ->
-					let m2 = (com.cs#get_context sign)#find_module mpath in
+				PMap.iter (fun _ mdep ->
+					let m2 = (com.cs#get_context mdep.md_sign)#find_module mdep.md_path in
 					add_modules (tabs ^ "  ") m0 m2
 				) m.m_extra.m_deps
 			)

+ 7 - 6
src/context/memory.ml

@@ -38,9 +38,10 @@ let rec scan_module_deps cs m h =
 		()
 	else begin
 		Hashtbl.add h m.m_id m;
-		PMap.iter (fun _ (sign,mpath) ->
-			let m = (cs#get_context sign)#find_module mpath in
-			scan_module_deps cs m h) m.m_extra.m_deps
+		PMap.iter (fun _ mdep ->
+			let m = (cs#get_context mdep.md_sign)#find_module mdep.md_path in
+			scan_module_deps cs m h
+		) m.m_extra.m_deps
 	end
 
 let module_sign key md =
@@ -274,9 +275,9 @@ let display_memory com =
 			());
 		if verbose then begin
 			print (Printf.sprintf "      %d total deps" (List.length deps));
-			PMap.iter (fun _ (sign,mpath) ->
-				let md = (com.cs#get_context sign)#find_module mpath in
-				print (Printf.sprintf "      dep %s%s" (s_type_path mpath) (module_sign key md));
+			PMap.iter (fun _ mdep ->
+				let md = (com.cs#get_context mdep.md_sign)#find_module mdep.md_path in
+				print (Printf.sprintf "      dep %s%s" (s_type_path mdep.md_path) (module_sign key md));
 			) m.m_extra.m_deps;
 		end;
 		flush stdout

+ 3 - 3
src/core/json/genjson.ml

@@ -712,10 +712,10 @@ let generate_module cs cc m =
 			| MSGood -> "Good"
 			| MSBad reason -> Printer.s_module_skip_reason reason
 			| MSUnknown -> "Unknown");
-		"dependencies",jarray (PMap.fold (fun (sign,mpath) acc ->
+		"dependencies",jarray (PMap.fold (fun mdep acc ->
 			(jobject [
-				"path",jstring (s_type_path mpath);
-				"sign",jstring (Digest.to_hex ((cs#get_context sign)#find_module mpath).m_extra.m_sign);
+				"path",jstring (s_type_path mdep.md_path);
+				"sign",jstring (Digest.to_hex ((cs#get_context mdep.md_sign)#find_module mdep.md_path).m_extra.m_sign);
 			]) :: acc
 		) m.m_extra.m_deps []);
 		"dependents",jarray (List.map (fun m -> (jobject [

+ 1 - 1
src/core/tFunctions.ml

@@ -291,7 +291,7 @@ let null_abstract = {
 
 let add_dependency ?(skip_postprocess=false) m mdep =
 	if m != null_module && mdep != null_module && (m.m_path != mdep.m_path || m.m_extra.m_sign != mdep.m_extra.m_sign) then begin
-		m.m_extra.m_deps <- PMap.add mdep.m_id (mdep.m_extra.m_sign, mdep.m_path) m.m_extra.m_deps;
+		m.m_extra.m_deps <- PMap.add mdep.m_id ({md_sign = mdep.m_extra.m_sign; md_path = mdep.m_path; md_kind = mdep.m_extra.m_kind}) m.m_extra.m_deps;
 		(* In case the module is cached, we'll have to run post-processing on it again (issue #10635) *)
 		if not skip_postprocess then m.m_extra.m_processed <- 0
 	end

+ 1 - 1
src/core/tPrinting.ml

@@ -641,7 +641,7 @@ module Printer = struct
 			"m_cache_state",s_module_cache_state me.m_cache_state;
 			"m_added",string_of_int me.m_added;
 			"m_checked",string_of_int me.m_checked;
-			"m_deps",s_pmap string_of_int (fun (_,m) -> snd m) me.m_deps;
+			"m_deps",s_pmap string_of_int (fun mdep -> snd mdep.md_path) me.m_deps;
 			"m_processed",string_of_int me.m_processed;
 			"m_kind",s_module_kind me.m_kind;
 			"m_binded_res",""; (* TODO *)

+ 7 - 1
src/core/tType.ml

@@ -401,6 +401,12 @@ and module_def_display = {
 	mutable m_import_positions : (pos,bool ref) PMap.t;
 }
 
+and module_dep = {
+	md_sign : Digest.t;
+	md_kind : module_kind;
+	md_path : path;
+}
+
 and module_def_extra = {
 	m_file : Path.UniqueKey.lazy_t;
 	m_sign : Digest.t;
@@ -411,7 +417,7 @@ and module_def_extra = {
 	mutable m_added : int;
 	mutable m_checked : int;
 	mutable m_processed : int;
-	mutable m_deps : (int,(Digest.t (* sign *) * path)) PMap.t;
+	mutable m_deps : (int,module_dep) PMap.t;
 	mutable m_kind : module_kind;
 	mutable m_cache_bound_objects : cache_bound_object DynArray.t;
 	mutable m_features : (string,bool) Hashtbl.t;