ソースを参照

remove abstract reader

Simon Krajewski 1 年間 前
コミット
c97e6bee0d

+ 0 - 17
src/compiler/hxb/hxbAbstractReader.ml

@@ -1,17 +0,0 @@
-open HxbReaderApi
-open HxbData
-
-class virtual hxb_abstract_reader = object(self)
-	inherit hxb_reader_api
-
-	method read_hxb (path : Globals.path) (bytes : bytes) (stats : HxbReader.hxb_reader_stats) =
-		let reader = new HxbReader.hxb_reader path stats in
-		reader#read (self :> hxb_reader_api) bytes
-
-	method read_chunks (path : Globals.path) (chunks : cached_chunks) (stats : HxbReader.hxb_reader_stats) =
-		fst (self#read_chunks_until path chunks stats EOM)
-
-	method read_chunks_until (path : Globals.path) (chunks : cached_chunks) (stats : HxbReader.hxb_reader_stats) (until : HxbData.chunk_kind) =
-		let reader = new HxbReader.hxb_reader path stats in
-		reader#read_chunks_until (self :> hxb_reader_api) chunks until
-end

+ 3 - 4
src/compiler/server.ml

@@ -396,7 +396,6 @@ class hxb_reader_api_server
 	(ctx : Typecore.typer)
 	(cc : context_cache)
 = object(self)
-	inherit HxbAbstractReader.hxb_abstract_reader
 
 	method make_module (path : path) (file : string) =
 		let mc = cc#get_hxb_module path in
@@ -417,7 +416,8 @@ class hxb_reader_api_server
 			| GoodModule m ->
 				m
 			| BinaryModule mc ->
-				self#read_chunks mc.mc_path mc.mc_chunks ctx.com.hxb_reader_stats
+				let reader = new HxbReader.hxb_reader path ctx.com.hxb_reader_stats in
+				reader#read_chunks (self :> HxbReaderApi.hxb_reader_api) mc.mc_chunks
 			| BadModule reason ->
 				die (Printf.sprintf "Unexpected BadModule %s" (s_type_path path)) __LOC__
 			| NoModule ->
@@ -478,7 +478,6 @@ let rec add_modules sctx ctx (m : module_def) (from_binary : bool) (p : pos) =
 				handle_cache_bound_objects com m.m_extra.m_cache_bound_objects;
 				PMap.iter (fun _ (sign,mpath) ->
 					if sign = own_sign then begin
-						let cc = com.cs#get_context sign in
 						let m2 = try
 							com.module_lut#find mpath
 						with Not_found ->
@@ -489,7 +488,7 @@ let rec add_modules sctx ctx (m : module_def) (from_binary : bool) (p : pos) =
 							| GoodModule m ->
 								m
 							| BinaryModule mc ->
-								(new hxb_reader_api_server ctx cc)#read_chunks mc.mc_path mc.mc_chunks ctx.com.hxb_reader_stats
+								failwith (Printf.sprintf "Unexpectedly found unresolved binary module %s as a dependency of %s" (s_type_path mpath) (s_type_path m0.m_path))
 							| NoModule ->
 								failwith (Printf.sprintf "Unexpectedly could not find module %s as a dependency of %s" (s_type_path mpath) (s_type_path m0.m_path))
 							| BadModule reason ->

+ 2 - 3
src/context/display/displayJson.ml

@@ -109,8 +109,6 @@ class hxb_reader_api_com
 	(com : Common.context)
 	(cc : CompilationCache.context_cache)
 = object(self)
-	inherit HxbAbstractReader.hxb_abstract_reader
-
 	method make_module (path : path) (file : string) =
 		let mc = cc#get_hxb_module path in
 		{
@@ -137,7 +135,8 @@ class hxb_reader_api_com
 			cc#find_module m_path
 		with Not_found ->
 			let mc = cc#get_hxb_module m_path in
-			fst (self#read_chunks_until mc.mc_path mc.mc_chunks com.hxb_reader_stats (if headers_only then EOM else MTF))
+			let reader = new HxbReader.hxb_reader mc.mc_path com.hxb_reader_stats in
+			fst (reader#read_chunks_until (self :> HxbReaderApi.hxb_reader_api) mc.mc_chunks (if headers_only then EOM else MTF))
 
 	method basic_types =
 		com.basic

+ 3 - 1
src/context/display/displayTexpr.ml

@@ -176,7 +176,9 @@ let check_display_file ctx cs =
 				begin match !TypeloadModule.type_module_hook ctx path null_pos with
 				| NoModule | BadModule _ -> raise Not_found
 				| BinaryModule mc ->
-					let m = (TypeloadModule.get_reader ctx p)#read_chunks mc.mc_path mc.mc_chunks ctx.com.hxb_reader_stats in
+					let api = (new TypeloadModule.hxb_reader_api_typeload ctx TypeloadModule.load_module' p :> HxbReaderApi.hxb_reader_api) in
+					let reader = new HxbReader.hxb_reader path ctx.com.hxb_reader_stats in
+					let m = reader#read_chunks api mc.mc_chunks in
 					m
 				| GoodModule m ->
 					m

+ 4 - 7
src/typing/typeloadModule.ml

@@ -779,8 +779,6 @@ class hxb_reader_api_typeload
 	(load_module : typer -> path -> pos -> module_def)
 	(p : pos)
 = object(self)
-	inherit HxbAbstractReader.hxb_abstract_reader
-
 	method make_module (path : path) (file : string) =
 		let m = ModuleLevel.make_module ctx path file p in
 		m.m_extra.m_processed <- 1;
@@ -803,13 +801,12 @@ class hxb_reader_api_typeload
 		!uid
 end
 
-let rec get_reader ctx p =
-	new hxb_reader_api_typeload ctx load_module' p
-
-and load_hxb_module ctx path p =
+let rec load_hxb_module ctx path p =
 	let read file bytes =
 		try
-			let read = (get_reader ctx p)#read_hxb path bytes ctx.com.hxb_reader_stats in
+			let api = (new hxb_reader_api_typeload ctx load_module' p :> HxbReaderApi.hxb_reader_api) in
+			let reader = new HxbReader.hxb_reader path ctx.com.hxb_reader_stats in
+			let read = reader#read api bytes in
 			let m = read MTF in
 			delay ctx PBuildClass (fun () ->
 				ignore(read EOT);