Simon Krajewski 6 лет назад
Родитель
Сommit
1df1daaca7
4 измененных файлов с 12 добавлено и 21 удалено
  1. 2 6
      src/compiler/main.ml
  2. 8 1
      src/context/commonCache.ml
  3. 1 7
      src/typing/macroContext.ml
  4. 1 7
      src/typing/typeload.ml

+ 2 - 6
src/compiler/main.ml

@@ -495,15 +495,11 @@ let create_typer_context ctx native_libs =
 let do_type tctx config_macros classes =
 	let com = tctx.Typecore.com in
 	let t = Timer.timer ["typing"] in
-	let add_signature desc =
-		Option.may (fun cs -> CommonCache.maybe_add_context_sign cs com desc) (CompilationServer.get ());
-	in
-	add_signature "before_init_macros";
+	Option.may (fun cs -> CommonCache.maybe_add_context_sign cs com "before_init_macros") (CompilationServer.get ());
 	com.stage <- CInitMacrosStart;
 	List.iter (MacroContext.call_init_macro tctx) (List.rev config_macros);
 	com.stage <- CInitMacrosDone;
-	com.cache <- (match CompilationServer.get() with None -> None | Some cs -> Some (CommonCache.get_cache cs com));
-	add_signature "after_init_macros";
+	CommonCache.lock_signature com "after_init_macros";
 	List.iter (fun f -> f ()) (List.rev com.callbacks#get_after_init_macros);
 	run_or_diagnose com (fun () ->
 		List.iter (fun cpath -> ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos)) (List.rev classes);

+ 8 - 1
src/context/commonCache.ml

@@ -74,4 +74,11 @@ let rec cache_context cs com =
 
 let maybe_add_context_sign cs com desc =
 	let sign = Define.get_signature com.defines in
-	ignore(cs#add_info sign desc com.platform com.class_path com.defines)
+	ignore(cs#add_info sign desc com.platform com.class_path com.defines)
+
+let lock_signature com name = match CompilationServer.get() with
+	| Some cs ->
+		maybe_add_context_sign cs com name;
+		com.cache <- Some (get_cache cs com)
+	| None ->
+		()

+ 1 - 7
src/typing/macroContext.ml

@@ -491,13 +491,7 @@ let get_macro_context ctx p =
 		let mctx = ctx.g.do_create com2 in
 		mctx.is_display_file <- false;
 		create_macro_interp ctx mctx;
-		begin match CompilationServer.get() with
-		| Some cs ->
-			CommonCache.maybe_add_context_sign cs com2 "get_macro_context";
-			com2.cache <- Some (CommonCache.get_cache cs com2)
-		| None ->
-			()
-		end;
+		CommonCache.lock_signature com2 "get_macro_context";
 		api, mctx
 
 let load_macro_module ctx cpath display p =

+ 1 - 7
src/typing/typeload.ml

@@ -741,13 +741,7 @@ let load_core_class ctx c =
 			if ctx.in_macro then Common.define com2 Define.Macro;
 			com2.class_path <- ctx.com.std_path;
 			if com2.display.dms_check_core_api then com2.display <- {com2.display with dms_check_core_api = false};
-			begin match CompilationServer.get() with
-			| Some cs ->
-				CommonCache.maybe_add_context_sign cs com2 "load_core_class";
-				com2.cache <- Some (CommonCache.get_cache cs com2)
-			| None ->
-				()
-			end;
+			CommonCache.lock_signature com2 "load_core_class";
 			let ctx2 = ctx.g.do_create com2 in
 			ctx.g.core_api <- Some ctx2;
 			ctx2