浏览代码

[hxb] cleanup

Rudy Ges 2 年之前
父节点
当前提交
d6fd491969

+ 0 - 5
src-json/define.json

@@ -300,11 +300,6 @@
 		"platforms": ["hl"],
 		"params": ["version"]
 	},
-  {
-    "name": "HxbOnly",
-    "define": "hxb.only",
-    "doc": "Only load types from hxb files (and cache)"
-  },
 	{
 		"name": "HxcppApiLevel",
 		"define": "hxcpp-api-level",

+ 6 - 15
src/compiler/args.ml

@@ -123,9 +123,6 @@ let parse_args com =
 		("Target",["--run"],[], Arg.Unit (fun() ->
 			raise (Arg.Bad "--run requires an argument: a Haxe module name")
 		), "<module> [args...]","interpret a Haxe module with command line arguments");
-		("Target",["--hxb"],[], Arg.String (fun file ->
-			actx.hxb_out <- Some file;
-		),"<file>", "generate haxe binary as target file");
 		("Compilation",["-p";"--class-path"],["-cp"],Arg.String (fun path ->
 			com.class_path <- Path.add_trailing_slash path :: com.class_path
 		),"<path>","add a directory to find source files");
@@ -134,18 +131,9 @@ let parse_args com =
 		),"<path>","add a directory to find binary source files");
 		("Compilation",["-m";"--main"],["-main"],Arg.String (fun cl ->
 			if com.main_class <> None then raise (Arg.Bad "Multiple --main classes specified");
-			begin match Path.file_extension cl with
-			| "hxb" ->
-				actx.pre_compilation <- (fun () ->
-					(* TODO: update hxb runner *)
-					(* HxbRunner.run com cl; *)
-					actx.did_something <- true
-				) :: actx.pre_compilation;
-			| _ ->
-				let cpath = Path.parse_type_path cl in
-				com.main_class <- Some cpath;
-				actx.classes <- cpath :: actx.classes
-			end
+			let cpath = Path.parse_type_path cl in
+			com.main_class <- Some cpath;
+			actx.classes <- cpath :: actx.classes
 		),"<class>","select startup class");
 		("Compilation",["-L";"--library"],["-lib"],Arg.String (fun _ -> ()),"<name[:ver]>","use a haxelib library");
 		("Compilation",["-D";"--define"],[],Arg.String (fun var ->
@@ -282,6 +270,9 @@ let parse_args com =
 		("Services",["--json"],[],Arg.String (fun file ->
 			actx.json_out <- Some file
 		),"<file>","generate JSON types description");
+		("Services",["--hxb"],[], Arg.String (fun dir ->
+			actx.hxb_out <- Some dir;
+		),"<directory>", "generate haxe binary representation in target directory");
 		("Optimization",["--no-output"],[], Arg.Unit (fun() -> actx.no_output <- true),"","compiles but does not generate any file");
 		("Debug",["--times"],[], Arg.Unit (fun() -> Timer.measure_times := true),"","measure compilation times");
 		("Optimization",["--no-inline"],[],Arg.Unit (fun () ->

+ 0 - 1
src/compiler/displayOutput.ml

@@ -344,7 +344,6 @@ let handle_type_path_exception ctx p c is_import pos =
 			| None ->
 				DisplayPath.TypePathHandler.complete_type_path com p
 			| Some (c,cur_package) ->
-				Printf.eprintf "=== [Display] create typer context ===\n";
 				let ctx = Typer.create com None in
 				DisplayPath.TypePathHandler.complete_type_path_inner ctx p c cur_package is_import
 		end with Error.Fatal_error err ->

+ 1 - 1
src/compiler/tasks.ml

@@ -64,4 +64,4 @@ class server_exploration_task (cs : CompilationCache.t) = object(self)
 
 	method private execute =
 		cs#iter_modules (fun m -> cs#add_task (new module_maintenance_task cs m))
-end
+end

+ 0 - 1
src/typing/typeloadFields.ml

@@ -1746,7 +1746,6 @@ let init_class ctx c p herits fields =
 	if cctx.is_class_debug then print_endline ("Created class context: " ^ dump_class_context cctx);
 	let fields = patch_class ctx c fields in
 	let fields = build_fields (ctx,cctx) c fields in
-	(* Triggers a second loading of many types.. *)
 	if cctx.is_core_api && ctx.com.display.dms_check_core_api then delay ctx PForce (fun() -> init_core_api ctx c);
 	if not cctx.is_lib then begin
 		delay ctx PForce (fun() -> check_overloads ctx c);

+ 15 - 24
src/typing/typeloadModule.ml

@@ -793,29 +793,23 @@ let type_module ctx mpath file ?(dont_check_path=false) ?(is_extern=false) tdecl
 
 let type_module_hook = ref (fun _ _ _ -> None)
 
-let indent = ref (-1)
-
 let rec get_reader ctx input mpath p =
-		let make_module path file =
-			(* Printf.eprintf "  \x1b[35m[typeloadModule]\x1b[0m make module %s\n" (s_type_path path); *)
-			let m = ModuleLevel.make_module ctx path file p in
-			m.m_extra.m_processed <- 1;
-			m
-		in
+	let make_module path file =
+		let m = ModuleLevel.make_module ctx path file p in
+		m.m_extra.m_processed <- 1;
+		m
+	in
 
-		let add_module m =
-			(* Printf.eprintf "  \x1b[35m[typeloadModule]\x1b[0m add module %s = %s\n" (s_type_path m.m_path) (s_type_path mpath); *)
-			ctx.com.module_lut#add m.m_path m in
+	let add_module m =
+		ctx.com.module_lut#add m.m_path m
+	in
 
-		let resolve_type pack mname tname =
-			(* Printf.eprintf "  \x1b[35m[typeloadModule]\x1b[0m resolve type %s\n" (s_type_path ((pack @ [mname]),tname)); *)
-			let m = try ctx.com.module_lut#find (pack,mname) with Not_found -> load_module' ctx ctx.g (pack,mname) p in
-			let t = List.find (fun t -> snd (t_path t) = tname) m.m_types in
-			(* Printf.eprintf "  \x1b[35m[typeloadModule]\x1b[0m resolved type %s\n" (s_type_path ((pack @ [mname]),tname)); *)
-			t
-		in
+	let resolve_type pack mname tname =
+		let m = try ctx.com.module_lut#find (pack,mname) with Not_found -> load_module' ctx ctx.g (pack,mname) p in
+		List.find (fun t -> snd (t_path t) = tname) m.m_types
+	in
 
-		new HxbReader.hxb_reader ctx.com input make_module add_module resolve_type
+	new HxbReader.hxb_reader ctx.com input make_module add_module resolve_type
 
 and load_hxb_module ctx path p =
 	let compose_path no_rename =
@@ -844,18 +838,15 @@ and load_hxb_module ctx path p =
 		raise e
 
 and load_module' ctx g m p =
-	(* Printf.eprintf "\x1b[45m[typeloadModule]\x1b[0m Load module %s\n" (s_type_path m); *)
 	try
 		(* Check current context *)
-		let m = ctx.com.module_lut#find m in
-		(* Printf.eprintf "\x1b[44m-- Retrieved %s from cache\x1b[0m\n" (snd m.m_path); *)
-		m
+		ctx.com.module_lut#find m
 	with Not_found ->
 		(* Check cache *)
 		match !type_module_hook ctx m p with
 		| Some m ->
 			m
-		(* Try loading from hxb first *)
+		(* Try loading from hxb first, then from source *)
 		| None -> try load_hxb_module ctx m p with Not_found ->
 			let raise_not_found () = raise_error_msg (Module_not_found m) p in
 			if ctx.com.module_nonexistent_lut#mem m then raise_not_found();

+ 0 - 1
src/typing/typeloadParse.ml

@@ -297,7 +297,6 @@ let parse_module' com m p =
 	file,remap,pack,decls
 
 let parse_module ctx m p =
-	if Common.defined ctx.com Define.HxbOnly then raise Not_found;
 	let file,remap,pack,decls = parse_module' ctx.com m p in
 	if pack <> !remap then begin
 		let spack m = if m = [] then "`package;`" else "`package " ^ (String.concat "." m) ^ ";`" in