Browse Source

[typer] rename some things

Simon Krajewski 3 years ago
parent
commit
4843d39888

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

@@ -381,7 +381,7 @@ let collect ctx tk with_type sort =
 				()
 				()
 		in
 		in
 		List.iter enum_ctors ctx.m.curmod.m_types;
 		List.iter enum_ctors ctx.m.curmod.m_types;
-		List.iter enum_ctors (List.map fst ctx.m.module_types);
+		List.iter enum_ctors (List.map fst ctx.m.module_imports);
 
 
 		(* enum constructors of expected type *)
 		(* enum constructors of expected type *)
 		begin match with_type with
 		begin match with_type with
@@ -461,7 +461,7 @@ let collect ctx tk with_type sort =
 	List.iter add_type ctx.m.curmod.m_types;
 	List.iter add_type ctx.m.curmod.m_types;
 
 
 	(* module imports *)
 	(* module imports *)
-	List.iter add_type (List.rev_map fst ctx.m.module_types); (* reverse! *)
+	List.iter add_type (List.rev_map fst ctx.m.module_imports); (* reverse! *)
 
 
 	(* types from files *)
 	(* types from files *)
 	begin match !CompilationServer.instance with
 	begin match !CompilationServer.instance with

+ 2 - 2
src/context/typecore.ml

@@ -60,11 +60,11 @@ type typer_pass =
 
 
 type typer_module = {
 type typer_module = {
 	curmod : module_def;
 	curmod : module_def;
-	mutable module_types : (module_type * pos) list;
+	mutable module_imports : (module_type * pos) list;
 	mutable module_using : (tclass * pos) list;
 	mutable module_using : (tclass * pos) list;
 	mutable module_globals : (string, (module_type * string * pos)) PMap.t;
 	mutable module_globals : (string, (module_type * string * pos)) PMap.t;
 	mutable wildcard_packages : (string list * pos) list;
 	mutable wildcard_packages : (string list * pos) list;
-	mutable module_imports : import list;
+	mutable import_statements : import list;
 }
 }
 
 
 type typer_globals = {
 type typer_globals = {

+ 0 - 1
src/typing/generic.ml

@@ -202,7 +202,6 @@ let rec build_generic ctx c p tl =
 		| _ -> typing_error ("Cannot specialize @:generic because the generated type name is already used: " ^ name) p
 		| _ -> typing_error ("Cannot specialize @:generic because the generated type name is already used: " ^ name) p
 	with Error(Module_not_found path,_) when path = (pack,name) ->
 	with Error(Module_not_found path,_) when path = (pack,name) ->
 		let m = (try Hashtbl.find ctx.g.modules (Hashtbl.find ctx.g.types_module c.cl_path) with Not_found -> die "" __LOC__) in
 		let m = (try Hashtbl.find ctx.g.modules (Hashtbl.find ctx.g.types_module c.cl_path) with Not_found -> die "" __LOC__) in
-		(* let ctx = { ctx with m = { ctx.m with module_types = m.m_types @ ctx.m.module_types } } in *)
 		ignore(c.cl_build()); (* make sure the super class is already setup *)
 		ignore(c.cl_build()); (* make sure the super class is already setup *)
 		let mg = {
 		let mg = {
 			m_id = alloc_mid();
 			m_id = alloc_mid();

+ 5 - 5
src/typing/macroContext.ml

@@ -273,7 +273,7 @@ let make_macro_api ctx p =
 			List.map fst ctx.m.module_using;
 			List.map fst ctx.m.module_using;
 		);
 		);
 		MacroApi.get_local_imports = (fun() ->
 		MacroApi.get_local_imports = (fun() ->
-			ctx.m.module_imports;
+			ctx.m.import_statements;
 		);
 		);
 		MacroApi.get_local_vars = (fun () ->
 		MacroApi.get_local_vars = (fun () ->
 			ctx.locals;
 			ctx.locals;
@@ -515,11 +515,11 @@ let load_macro_module ctx cpath display p =
 	api.MacroApi.current_macro_module <- (fun() -> mloaded);
 	api.MacroApi.current_macro_module <- (fun() -> mloaded);
 	mctx.m <- {
 	mctx.m <- {
 		curmod = mloaded;
 		curmod = mloaded;
-		module_types = [];
+		module_imports = [];
 		module_using = [];
 		module_using = [];
 		module_globals = PMap.empty;
 		module_globals = PMap.empty;
 		wildcard_packages = [];
 		wildcard_packages = [];
-		module_imports = [];
+		import_statements = [];
 	};
 	};
 	mloaded,(fun () -> mctx.com.display <- old)
 	mloaded,(fun () -> mctx.com.display <- old)
 
 
@@ -558,11 +558,11 @@ let load_macro' ctx display cpath f p =
 		Hashtbl.add mctx.com.cached_macros (cpath,f) meth;
 		Hashtbl.add mctx.com.cached_macros (cpath,f) meth;
 		mctx.m <- {
 		mctx.m <- {
 			curmod = null_module;
 			curmod = null_module;
-			module_types = [];
+			module_imports = [];
 			module_using = [];
 			module_using = [];
 			module_globals = PMap.empty;
 			module_globals = PMap.empty;
 			wildcard_packages = [];
 			wildcard_packages = [];
-			module_imports = [];
+			import_statements = [];
 		};
 		};
 		t();
 		t();
 		meth
 		meth

+ 3 - 3
src/typing/typeload.ml

@@ -126,7 +126,7 @@ let find_type_in_current_module_context ctx pack name =
 		List.find path_matches ctx.m.curmod.m_types
 		List.find path_matches ctx.m.curmod.m_types
 	with Not_found ->
 	with Not_found ->
 		(* Check the local imports *)
 		(* Check the local imports *)
-		let t,pi = List.find (fun (t2,pi) -> path_matches t2) ctx.m.module_types in
+		let t,pi = List.find (fun (t2,pi) -> path_matches t2) ctx.m.module_imports in
 		ImportHandling.mark_import_position ctx pi;
 		ImportHandling.mark_import_position ctx pi;
 		t
 		t
 
 
@@ -698,11 +698,11 @@ let hide_params ctx =
 	let old_deps = ctx.g.std.m_extra.m_deps in
 	let old_deps = ctx.g.std.m_extra.m_deps in
 	ctx.m <- {
 	ctx.m <- {
 		curmod = ctx.g.std;
 		curmod = ctx.g.std;
-		module_types = [];
+		module_imports = [];
 		module_using = [];
 		module_using = [];
 		module_globals = PMap.empty;
 		module_globals = PMap.empty;
 		wildcard_packages = [];
 		wildcard_packages = [];
-		module_imports = [];
+		import_statements = [];
 	};
 	};
 	ctx.type_params <- [];
 	ctx.type_params <- [];
 	(fun() ->
 	(fun() ->

+ 1 - 1
src/typing/typeloadCheck.ml

@@ -535,7 +535,7 @@ module Inheritance = struct
 					let lt = try
 					let lt = try
 						List.find path_matches ctx.m.curmod.m_types
 						List.find path_matches ctx.m.curmod.m_types
 					with Not_found ->
 					with Not_found ->
-						let t,pi = List.find (fun (lt,_) -> path_matches lt) ctx.m.module_types in
+						let t,pi = List.find (fun (lt,_) -> path_matches lt) ctx.m.module_imports in
 						ImportHandling.mark_import_position ctx pi;
 						ImportHandling.mark_import_position ctx pi;
 						t
 						t
 					in
 					in

+ 7 - 7
src/typing/typeloadModule.ml

@@ -479,7 +479,7 @@ let init_module_type ctx context_init (decl,p) =
 		try List.find (fun t -> snd (t_infos t).mt_path = name) ctx.m.curmod.m_types with Not_found -> die "" __LOC__
 		try List.find (fun t -> snd (t_infos t).mt_path = name) ctx.m.curmod.m_types with Not_found -> die "" __LOC__
 	in
 	in
 	let commit_import path mode p =
 	let commit_import path mode p =
-		ctx.m.module_imports <- (path,mode) :: ctx.m.module_imports;
+		ctx.m.import_statements <- (path,mode) :: ctx.m.import_statements;
 		if Filename.basename p.pfile <> "import.hx" then ImportHandling.add_import_position ctx p path;
 		if Filename.basename p.pfile <> "import.hx" then ImportHandling.add_import_position ctx p path;
 	in
 	in
 	let check_path_display path p =
 	let check_path_display path p =
@@ -551,7 +551,7 @@ let init_module_type ctx context_init (decl,p) =
 				| [] ->
 				| [] ->
 					(match name with
 					(match name with
 					| None ->
 					| None ->
-						ctx.m.module_types <- List.filter no_private (List.map (fun t -> t,p) types) @ ctx.m.module_types;
+						ctx.m.module_imports <- List.filter no_private (List.map (fun t -> t,p) types) @ ctx.m.module_imports;
 						Option.may (fun c ->
 						Option.may (fun c ->
 							context_init#add (fun () ->
 							context_init#add (fun () ->
 								ignore(c.cl_build());
 								ignore(c.cl_build());
@@ -562,13 +562,13 @@ let init_module_type ctx context_init (decl,p) =
 							);
 							);
 						) md.m_statics
 						) md.m_statics
 					| Some(newname,pname) ->
 					| Some(newname,pname) ->
-						ctx.m.module_types <- (rebind (get_type tname) newname pname,p) :: ctx.m.module_types);
+						ctx.m.module_imports <- (rebind (get_type tname) newname pname,p) :: ctx.m.module_imports);
 				| [tsub,p2] ->
 				| [tsub,p2] ->
 					let pu = punion p1 p2 in
 					let pu = punion p1 p2 in
 					(try
 					(try
 						let tsub = List.find (has_name tsub) types in
 						let tsub = List.find (has_name tsub) types in
 						chk_private tsub pu;
 						chk_private tsub pu;
-						ctx.m.module_types <- ((match name with None -> tsub | Some(n,pname) -> rebind tsub n pname),p) :: ctx.m.module_types
+						ctx.m.module_imports <- ((match name with None -> tsub | Some(n,pname) -> rebind tsub n pname),p) :: ctx.m.module_imports
 					with Not_found ->
 					with Not_found ->
 						(* this might be a static property, wait later to check *)
 						(* this might be a static property, wait later to check *)
 						let find_main_type_static () =
 						let find_main_type_static () =
@@ -647,7 +647,7 @@ let init_module_type ctx context_init (decl,p) =
 		check_path_display path p;
 		check_path_display path p;
 		let types,filter_classes = handle_using ctx path p in
 		let types,filter_classes = handle_using ctx path p in
 		(* do the import first *)
 		(* do the import first *)
-		ctx.m.module_types <- (List.map (fun t -> t,p) types) @ ctx.m.module_types;
+		ctx.m.module_imports <- (List.map (fun t -> t,p) types) @ ctx.m.module_imports;
 		context_init#add (fun() -> ctx.m.module_using <- filter_classes types @ ctx.m.module_using)
 		context_init#add (fun() -> ctx.m.module_using <- filter_classes types @ ctx.m.module_using)
 	| EClass d ->
 	| EClass d ->
 		let c = (match get_type (fst d.d_name) with TClassDecl c -> c | _ -> die "" __LOC__) in
 		let c = (match get_type (fst d.d_name) with TClassDecl c -> c | _ -> die "" __LOC__) in
@@ -962,11 +962,11 @@ let type_types_into_module ctx m tdecls p =
 		t = ctx.t;
 		t = ctx.t;
 		m = {
 		m = {
 			curmod = m;
 			curmod = m;
-			module_types = List.map (fun t -> t,null_pos) ctx.g.std.m_types;
+			module_imports = List.map (fun t -> t,null_pos) ctx.g.std.m_types;
 			module_using = [];
 			module_using = [];
 			module_globals = PMap.empty;
 			module_globals = PMap.empty;
 			wildcard_packages = [];
 			wildcard_packages = [];
-			module_imports = [];
+			import_statements = [];
 		};
 		};
 		is_display_file = (ctx.com.display.dms_kind <> DMNone && DisplayPosition.display_position#is_in_file (Path.UniqueKey.lazy_key m.m_extra.m_file));
 		is_display_file = (ctx.com.display.dms_kind <> DMNone && DisplayPosition.display_position#is_in_file (Path.UniqueKey.lazy_key m.m_extra.m_file));
 		bypass_accessor = 0;
 		bypass_accessor = 0;

+ 4 - 4
src/typing/typer.ml

@@ -412,7 +412,7 @@ let rec type_ident_raise ctx i p mode with_type =
 					with
 					with
 						Not_found -> loop l
 						Not_found -> loop l
 		in
 		in
-		(try loop (List.rev_map (fun t -> t,null_pos) ctx.m.curmod.m_types) with Not_found -> loop ctx.m.module_types)
+		(try loop (List.rev_map (fun t -> t,null_pos) ctx.m.curmod.m_types) with Not_found -> loop ctx.m.module_imports)
 	with Not_found ->
 	with Not_found ->
 		(* lookup imported globals *)
 		(* lookup imported globals *)
 		let t, name, pi = PMap.find i ctx.m.module_globals in
 		let t, name, pi = PMap.find i ctx.m.module_globals in
@@ -1978,11 +1978,11 @@ let rec create com =
 		};
 		};
 		m = {
 		m = {
 			curmod = null_module;
 			curmod = null_module;
-			module_types = [];
+			module_imports = [];
 			module_using = [];
 			module_using = [];
 			module_globals = PMap.empty;
 			module_globals = PMap.empty;
 			wildcard_packages = [];
 			wildcard_packages = [];
-			module_imports = [];
+			import_statements = [];
 		};
 		};
 		is_display_file = false;
 		is_display_file = false;
 		bypass_accessor = 0;
 		bypass_accessor = 0;
@@ -2027,7 +2027,7 @@ let rec create com =
 				typing_error "Standard library not found. You may need to set your `HAXE_STD_PATH` environment variable" null_pos
 				typing_error "Standard library not found. You may need to set your `HAXE_STD_PATH` environment variable" null_pos
 	);
 	);
 	(* We always want core types to be available so we add them as default imports (issue #1904 and #3131). *)
 	(* We always want core types to be available so we add them as default imports (issue #1904 and #3131). *)
-	ctx.m.module_types <- List.map (fun t -> t,null_pos) ctx.g.std.m_types;
+	ctx.m.module_imports <- List.map (fun t -> t,null_pos) ctx.g.std.m_types;
 	List.iter (fun t ->
 	List.iter (fun t ->
 		match t with
 		match t with
 		| TAbstractDecl a ->
 		| TAbstractDecl a ->