Browse Source

[context] remove redundant string argument from load_extern_type callback

Simon Krajewski 6 years ago
parent
commit
47bde43dcb

+ 2 - 2
src/codegen/dotnet.ml

@@ -1170,7 +1170,7 @@ class net_library com name file_path std = object(self)
 			Hashtbl.add cache path None;
 			None
 
-	method build (path : path) (p : pos) : (string * Ast.package) option =
+	method build (path : path) (p : pos) : Ast.package option =
 		let p = { pfile = file_path ^ " @ " ^ s_type_path path; pmin = 0; pmax = 0; } in
 		let pack = match fst path with | ["haxe";"root"] -> [] | p -> p in
 		let cp = ref [] in
@@ -1203,7 +1203,7 @@ class net_library com name file_path std = object(self)
 		build path;
 		match !cp with
 			| [] -> None
-			| cp -> Some (file_path, (pack,cp))
+			| cp -> Some (pack,cp)
 
 	method get_data = ()
 

+ 3 - 3
src/codegen/java.ml

@@ -934,7 +934,7 @@ class virtual java_library com name file_path = object(self)
 				EAbstract { a with d_meta = add_meta (fst a.d_name) a.d_meta }
 			| d -> d
 
-	method build path (p : pos) : (string * Ast.package) option =
+	method build path (p : pos) : Ast.package option =
 		let rec build ctx path p types =
 			try
 				if List.mem path !types then
@@ -976,7 +976,7 @@ class virtual java_library com name file_path = object(self)
 									(if out <> Some ppath then
 										acc
 									else match build ctx path p types with
-										| Some(_,(_, classes)) ->
+										| Some(_, classes) ->
 											let base = snd ppath ^ "$" in
 											(List.map (fun (def,p) ->
 												self#replace_canonical_name p (fst ppath) base (snd ppath ^ ".") def, p) classes) @ acc
@@ -1044,7 +1044,7 @@ class virtual java_library com name file_path = object(self)
 								let inner = List.concat [!alias_list ; inner] in
 								let classes = List.map (fun t -> t,pos) (convert_java_class ctx pos cls) in
 								let imports, defs = List.partition (function | (EImport(_),_) -> true | _ -> false) (classes @ inner) in
-								let ret = Some ( real_path, (pack, imports @ defs) ) in
+								let ret = Some (pack, imports @ defs) in
 								ctx.jtparams <- old_types;
 								ret
 							end

+ 5 - 5
src/codegen/swfLoader.ml

@@ -132,10 +132,10 @@ let is_valid_path com pack name =
 	let rec loop = function
 		| [] ->
 			false
-		| (_,load) :: l ->
+		| (file,load) :: l ->
 			match load (pack,name) null_pos with
 			| None -> loop l
-			| Some (file,(_,a)) -> true
+			| Some (_,a) -> true
 	in
 	let file = Printf.sprintf "%s/%s.hx" (String.concat "/" pack) name in
 	loop com.load_extern_type || (try ignore(Common.find_file com file); true with Not_found -> false)
@@ -608,14 +608,14 @@ class swf_library com name file_path = object(self)
 	method close =
 		()
 
-	method build (path : path) (p : pos) : (string * Ast.package) option =
+	method build (path : path) (p : pos) : Ast.package option =
 		try
-			Some (file_path,Hashtbl.find haxe_classes path)
+			Some (Hashtbl.find haxe_classes path)
 		with Not_found -> try
 			let c = Hashtbl.find (self#extract) path in
 			let c = build_class com c file_path in
 			Hashtbl.add haxe_classes path c;
-			Some (file_path, c)
+			Some c
 		with Not_found ->
 			None
 

+ 2 - 2
src/compiler/server.ml

@@ -294,10 +294,10 @@ let rec wait_loop process_params verbose accept =
 						| [] ->
 							if verbose then print_endline ("No library file was found for " ^ s_type_path m.m_path); (* TODO *)
 							raise Not_found (* no extern registration *)
-						| (_,load) :: l ->
+						| (file,load) :: l ->
 							match load m.m_path p with
 							| None -> loop l
-							| Some (file,_) ->
+							| Some _ ->
 								if Path.unique_full_path file <> m.m_extra.m_file then begin
 									if verbose then print_endline ("Library file was changed for " ^ s_type_path m.m_path); (* TODO *)
 									raise Not_found;

+ 1 - 1
src/context/common.ml

@@ -188,7 +188,7 @@ type context = {
 	mutable warning : string -> pos -> unit;
 	mutable get_messages : unit -> compiler_message list;
 	mutable filter_messages : (compiler_message -> bool) -> unit;
-	mutable load_extern_type : (string * (path -> pos -> (string * Ast.package) option)) list; (* allow finding types which are not in sources *)
+	mutable load_extern_type : (string * (path -> pos -> Ast.package option)) list; (* allow finding types which are not in sources *)
 	callbacks : compiler_callbacks;
 	defines : Define.define;
 	mutable print : string -> unit;

+ 1 - 1
src/context/compilationServer.ml

@@ -18,7 +18,7 @@ type cached_directory = {
 
 type cached_native_lib = {
 	c_nl_mtime : float;
-	c_nl_files : (path,(string * Ast.package)) Hashtbl.t;
+	c_nl_files : (path,Ast.package) Hashtbl.t;
 }
 
 type cache = {

+ 1 - 1
src/context/display/displayToplevel.ml

@@ -419,7 +419,7 @@ let collect ctx tk with_type =
 		List.iter (fun file ->
 			try
 				let lib = Hashtbl.find cs.cache.c_native_libs file in
-				Hashtbl.iter (fun path (_,(pack,decls)) ->
+				Hashtbl.iter (fun path (pack,decls) ->
 					if process_decls pack (snd path) decls then check_package pack;
 				) lib.c_nl_files
 			with Not_found ->

+ 1 - 1
src/context/nativeLibraries.ml

@@ -33,7 +33,7 @@ class virtual ['a,'data] native_library (name : string) (file_path : string) = o
 	method get_name = name
 	method get_file_path = file_path
 
-	method virtual build : path -> pos -> (string * Ast.package) option
+	method virtual build : path -> pos -> Ast.package option
 	method virtual close : unit
 	method virtual list_modules : path list
 	method virtual load : unit

+ 1 - 1
src/typing/macroContext.ml

@@ -203,7 +203,7 @@ let make_macro_api ctx p =
 					None
 				else
 					let (pack,name),tdef,p = Interp.decode_type_def td in
-					Some (name,(pack,[tdef,p]))
+					Some (pack,[tdef,p])
 			];
 		);
 		MacroApi.parse_string = parse_expr_string;

+ 2 - 2
src/typing/typeloadModule.ml

@@ -964,10 +964,10 @@ let load_module ctx m p =
 				let rec loop = function
 					| [] ->
 						raise (Error (Module_not_found m,p))
-					| (_,load) :: l ->
+					| (file,load) :: l ->
 						match load m p with
 						| None -> loop l
-						| Some (file,(_,a)) -> file, a
+						| Some (_,a) -> file, a
 				in
 				is_extern := true;
 				loop ctx.com.load_extern_type