From f530b4ca0f7a4ef3773bf1542c72e3245396fc49 Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Thu, 29 Jun 2023 15:05:19 +0200 Subject: [PATCH] [hxb] cleanup --- src-json/define.json | 5 ----- src/compiler/args.ml | 21 ++++++------------- src/compiler/displayOutput.ml | 1 - src/compiler/tasks.ml | 2 +- src/typing/typeloadFields.ml | 1 - src/typing/typeloadModule.ml | 39 ++++++++++++++--------------------- src/typing/typeloadParse.ml | 1 - 7 files changed, 22 insertions(+), 48 deletions(-) diff --git a/src-json/define.json b/src-json/define.json index 1f2658c6151..1d575822d83 100644 --- a/src-json/define.json +++ b/src-json/define.json @@ -279,11 +279,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", diff --git a/src/compiler/args.ml b/src/compiler/args.ml index d9bf7db513f..5a1f8157dc3 100644 --- a/src/compiler/args.ml +++ b/src/compiler/args.ml @@ -121,9 +121,6 @@ let parse_args com = ("Target",["--run"],[], Arg.Unit (fun() -> raise (Arg.Bad "--run requires an argument: a Haxe module name") ), " [args...]","interpret a Haxe module with command line arguments"); - ("Target",["--hxb"],[], Arg.String (fun file -> - actx.hxb_out <- Some 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 ),"","add a directory to find source files"); @@ -132,18 +129,9 @@ let parse_args com = ),"","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 ),"","select startup class"); ("Compilation",["-L";"--library"],["-lib"],Arg.String (fun _ -> ()),"","use a haxelib library"); ("Compilation",["-D";"--define"],[],Arg.String (fun var -> @@ -277,6 +265,9 @@ let parse_args com = ("Services",["--json"],[],Arg.String (fun file -> actx.json_out <- Some file ),"","generate JSON types description"); + ("Services",["--hxb"],[], Arg.String (fun dir -> + actx.hxb_out <- Some dir; + ),"", "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 () -> diff --git a/src/compiler/displayOutput.ml b/src/compiler/displayOutput.ml index e46d7a9f10f..09e2c31aeef 100644 --- a/src/compiler/displayOutput.ml +++ b/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 in DisplayPath.TypePathHandler.complete_type_path_inner ctx p c cur_package is_import end with Common.Abort msg -> diff --git a/src/compiler/tasks.ml b/src/compiler/tasks.ml index b426782f42f..42d6ebcf4b6 100644 --- a/src/compiler/tasks.ml +++ b/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 \ No newline at end of file diff --git a/src/typing/typeloadFields.ml b/src/typing/typeloadFields.ml index 69682804da0..86bee7419da 100644 --- a/src/typing/typeloadFields.ml +++ b/src/typing/typeloadFields.ml @@ -1758,7 +1758,6 @@ let init_class ctx c p context_init 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); diff --git a/src/typing/typeloadModule.ml b/src/typing/typeloadModule.ml index 0d107bbf2bd..fd65afa99d1 100644 --- a/src/typing/typeloadModule.ml +++ b/src/typing/typeloadModule.ml @@ -791,29 +791,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 = @@ -842,18 +836,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(); diff --git a/src/typing/typeloadParse.ml b/src/typing/typeloadParse.ml index 557309fb89a..86595e5edff 100644 --- a/src/typing/typeloadParse.ml +++ b/src/typing/typeloadParse.ml @@ -298,7 +298,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