فهرست منبع

[hxb] save cache on after_save instead of after_compilation

Rudy Ges 2 سال پیش
والد
کامیت
f909e29cc3

+ 1 - 0
src/compiler/compilationContext.ml

@@ -46,6 +46,7 @@ and compilation_context = {
 type compilation_callbacks = {
 	before_anything : compilation_context -> unit;
 	after_target_init : compilation_context -> unit;
+	after_save : compilation_context -> unit;
 	after_compilation : compilation_context -> unit;
 }
 

+ 5 - 1
src/compiler/compiler.ml

@@ -364,7 +364,11 @@ let compile ctx actx callbacks =
 		DisplayProcessing.handle_display_after_typing ctx tctx display_file_dot_path;
 		finalize_typing ctx tctx;
 		DisplayProcessing.handle_display_after_finalization ctx tctx display_file_dot_path;
-		com.callbacks#add_before_save (fun () -> Generate.check_hxb_output com actx);
+		com.callbacks#add_after_save (fun () ->
+			(* TODO use hxb cache for hxb output *)
+			callbacks.after_save ctx;
+			Generate.check_hxb_output com actx;
+		);
 		filter ctx tctx;
 		if ctx.has_error then raise Abort;
 		Generate.check_auxiliary_output com actx;

+ 1 - 1
src/compiler/hxb/hxbReader.ml

@@ -1121,7 +1121,7 @@ class hxb_reader
 			print_endline (Printf.sprintf "Error reading field expr for %s" cf.cf_name);
 			raise e
 		in
-		(* let expr_unoptimized = self#read_option (fun () -> self#read_texpr) in *)
+		let expr_unoptimized = self#read_option (fun () -> self#read_texpr) in
 
 		let l = self#read_uleb128 in
 		for i = 0 to l - 1 do

+ 4 - 0
src/compiler/server.ml

@@ -501,6 +501,9 @@ let after_target_init sctx ctx =
 		Hashtbl.add sctx.class_paths sign com.class_path;
 		()
 
+let after_save sctx ctx =
+	ServerCompilationContext.after_save sctx ctx.com (has_error ctx)
+
 let after_compilation sctx ctx =
 	(* if not (has_error ctx) then *)
 	(* 	maybe_cache_context sctx ctx.com *)
@@ -655,6 +658,7 @@ let rec process sctx comm args =
 		callbacks = {
 			before_anything = before_anything sctx;
 			after_target_init = after_target_init sctx;
+			after_save = after_save sctx;
 			after_compilation = after_compilation sctx;
 		};
 		init_wait_socket = init_wait_socket;

+ 7 - 7
src/compiler/serverCompilationContext.ml

@@ -57,17 +57,17 @@ let reset sctx =
 	Hashtbl.clear Timer.htimers;
 	Helper.start_time := get_time()
 
-let after_compilation sctx com has_error =
-	if has_error || not com.display.dms_full_typing || not com.display.dms_populate_cache then
-		CommonCache.clear_cache sctx.cs com
-	else begin
+let after_save sctx com has_error =
+	if not has_error && com.display.dms_full_typing && com.display.dms_populate_cache then begin
 		CommonCache.cache_context sctx.cs com;
 		ServerMessage.cached_modules com "" (List.length com.modules);
-
-		(* TEMP: Wipe server cache to force loading from hxb *)
-		CommonCache.clear_cache sctx.cs com;
 	end
 
+let after_compilation sctx com has_error =
+	(* if has_error || not com.display.dms_full_typing || not com.display.dms_populate_cache then *)
+	(* TEMP: Wipe server cache to force loading from hxb *)
+	CommonCache.clear_cache sctx.cs com
+
 let ensure_macro_setup sctx =
 	if not sctx.macro_context_setup then begin
 		sctx.macro_context_setup <- true;