Browse Source

move module_cache to HxbData

That might not be the ideal place for it either but it's better than tType.ml
Simon Krajewski 1 year ago
parent
commit
84e09e7ea6

+ 2 - 1
src/compiler/compilationCache.ml

@@ -34,7 +34,7 @@ let get_module_name_of_cfile file cfile = match cfile.c_module_name with
 class context_cache (index : int) (sign : Digest.t) = object(self)
 	val files : (Path.UniqueKey.t,cached_file) Hashtbl.t = Hashtbl.create 0
 	val modules : (path,module_def) Hashtbl.t = Hashtbl.create 0
-	val binary_cache : (path,module_cache) Hashtbl.t = Hashtbl.create 0
+	val binary_cache : (path,HxbData.module_cache) Hashtbl.t = Hashtbl.create 0
 	val removed_files = Hashtbl.create 0
 	val mutable json = JNull
 	val mutable initialized = false
@@ -210,6 +210,7 @@ class cache = object(self)
 			Hashtbl.iter (fun _ m ->
 				if Path.UniqueKey.lazy_key m.m_extra.m_file = file_key then m.m_extra.m_cache_state <- MSBad (Tainted reason)
 			) cc#get_modules;
+			let open HxbData in
 			Hashtbl.iter (fun _ mc ->
 				if Path.UniqueKey.lazy_key mc.mc_extra.m_file = file_key then mc.mc_extra.m_cache_state <- MSBad (Tainted reason)
 			) cc#get_hxb

+ 1 - 0
src/compiler/generate.ml

@@ -22,6 +22,7 @@ let check_auxiliary_output com actx =
 	end
 
 let export_hxb com cc platform zip m =
+	let open HxbData in
 	match m.m_extra.m_kind with
 		| MCode | MMacro | MFake -> begin
 			(* Printf.eprintf "Export module %s\n" (s_type_path m.m_path); *)

+ 10 - 0
src/compiler/hxb/hxbData.ml

@@ -1,3 +1,6 @@
+open Globals
+open Type
+
 exception HxbFailure of string
 
 (* TEMP: Wipe server cache to force loading from hxb *)
@@ -30,6 +33,13 @@ type chunk_kind =
 	| AFLD (* abstract fields *)
 	| HEND (* the end *)
 
+type module_cache = {
+	mc_path : path;
+	mc_id : int;
+	mc_bytes : bytes;
+	mc_extra : module_def_extra;
+}
+
 let string_of_chunk_kind = function
 	| STRI -> "STRI"
 	| DOCS -> "DOCS"

+ 3 - 3
src/compiler/hxb/hxbReader.ml

@@ -123,9 +123,9 @@ class hxb_reader
 		)
 
 	method resolve_type pack mname tname =
-		try api#resolve_type pack mname tname with
-		| Bad_module (path, reason) -> raise (Bad_module (current_module.m_path, DependencyDirty (path, reason)))
-		| Not_found ->
+		try
+			api#resolve_type pack mname tname
+		with Not_found ->
 			dump_backtrace();
 			error (Printf.sprintf "Cannot resolve type %s" (s_type_path ((pack @ [mname]),tname)))
 

+ 1 - 0
src/compiler/server.ml

@@ -9,6 +9,7 @@ open Ipaddr
 open Json
 open CompilationContext
 open MessageReporting
+open HxbData
 
 exception Dirty of module_skip_reason
 exception ServerError of string

+ 1 - 0
src/context/display/displayJson.ml

@@ -323,6 +323,7 @@ let handler =
 		"server/modules", (fun hctx ->
 			let sign = Digest.from_hex (hctx.jsonrpc#get_string_param "signature") in
 			let cc = hctx.display#get_cs#get_context sign in
+			let open HxbData in
 			let l = Hashtbl.fold (fun _ m acc ->
 				if m.mc_extra.m_kind <> MFake then jstring (s_type_path m.mc_path) :: acc else acc
 			) cc#get_hxb [] in

+ 1 - 1
src/context/typecore.ml

@@ -214,7 +214,7 @@ type dot_path_part = {
 type find_module_result =
 	| GoodModule of module_def
 	| BadModule of module_skip_reason
-	| BinaryModule of module_cache
+	| BinaryModule of HxbData.module_cache
 	| NoModule
 
 let make_build_info kind path params extern apply = {

+ 0 - 9
src/core/tType.ml

@@ -43,8 +43,6 @@ type module_skip_reason =
 	| Shadowed of string
 	| LibraryChanged
 
-exception Bad_module of path * module_skip_reason
-
 type module_cache_state =
 	| MSGood
 	| MSBad of module_skip_reason
@@ -440,13 +438,6 @@ and module_def = {
 	mutable m_extra : module_def_extra;
 }
 
-and module_cache = {
-	mc_path : path;
-	mc_id : int;
-	mc_bytes : bytes;
-	mc_extra : module_def_extra;
-}
-
 and build_state =
 	| Built
 	| Building of tclass list