Jelajahi Sumber

[hxb] generate hxb on after_save callback

Rudy Ges 1 tahun lalu
induk
melakukan
26b9003774

+ 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 - 0
src/compiler/compiler.ml

@@ -365,6 +365,11 @@ let compile ctx actx callbacks =
 		let (tctx,display_file_dot_path) = do_type ctx mctx actx display_file_dot_path macro_cache_enabled in
 		DisplayProcessing.handle_display_after_typing ctx tctx display_file_dot_path;
 		finalize_typing ctx tctx;
+		com.callbacks#add_after_save (fun () ->
+			(* TODO use hxb cache for hxb output *)
+			callbacks.after_save ctx;
+			Generate.check_hxb_output com actx;
+		);
 		com.callbacks#add_before_save (fun () -> Generate.check_hxb_output com actx);
 		if is_diagnostics com then
 			filter ctx tctx (fun () -> DisplayProcessing.handle_display_after_finalization ctx tctx display_file_dot_path)

+ 5 - 2
src/compiler/server.ml

@@ -469,9 +469,11 @@ 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
+	ServerCompilationContext.after_compilation sctx ctx.com (has_error ctx)
 
 let mk_length_prefixed_communication allow_nonblock chin chout =
 	let sin = Unix.descr_of_in_channel chin in
@@ -622,6 +624,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;

+ 5 - 2
src/compiler/serverCompilationContext.ml

@@ -57,12 +57,15 @@ let reset sctx =
 	Hashtbl.clear Timer.htimers;
 	Helper.start_time := get_time()
 
-let maybe_cache_context sctx com =
-	if com.display.dms_full_typing && com.display.dms_populate_cache then 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);
 	end
 
+let after_compilation sctx com has_error =
+	()
+
 let ensure_macro_setup sctx =
 	if not sctx.macro_context_setup then begin
 		sctx.macro_context_setup <- true;