Browse Source

split MacroApi.module_dependency in two (since they do completely different things)

Dan Korostelev 8 years ago
parent
commit
0d05eb4978
2 changed files with 10 additions and 8 deletions
  1. 4 3
      src/macro/macroApi.ml
  2. 6 5
      src/typing/macroContext.ml

+ 4 - 3
src/macro/macroApi.ml

@@ -38,7 +38,8 @@ type 'value compiler_api = {
 	get_pattern_locals : Ast.expr -> Type.t -> (string,Type.tvar * Globals.pos) PMap.t;
 	define_type : 'value -> string option -> unit;
 	define_module : string -> 'value list -> ((string * Globals.pos) list * Ast.import_mode) list -> Ast.type_path list -> unit;
-	module_dependency : string -> string -> bool -> unit;
+	module_dependency : string -> string -> unit;
+	module_reuse_call : string -> string -> unit;
 	current_module : unit -> module_def;
 	on_reuse : (unit -> bool) -> unit;
 	mutable current_macro_module : unit -> module_def;
@@ -1833,11 +1834,11 @@ let macro_api ccom get_api =
 			vnull
 		);
 		"register_module_dependency", vfun2 (fun m file ->
-			(get_api()).module_dependency (decode_string m) (decode_string file) false;
+			(get_api()).module_dependency (decode_string m) (decode_string file);
 			vnull
 		);
 		"register_module_reuse_call", vfun2 (fun m mcall ->
-			(get_api()).module_dependency (decode_string m) (decode_string mcall) true;
+			(get_api()).module_reuse_call (decode_string m) (decode_string mcall);
 			vnull
 		);
 		"get_typed_expr", vfun1 (fun e ->

+ 6 - 5
src/typing/macroContext.ml

@@ -331,12 +331,13 @@ let make_macro_api ctx p =
 				add_dependency mnew ctx.m.curmod;
 			end
 		);
-		MacroApi.module_dependency = (fun mpath file ismacro ->
+		MacroApi.module_dependency = (fun mpath file ->
 			let m = typing_timer ctx false (fun() -> Typeload.load_module ctx (parse_path mpath) p) in
-			if ismacro then
-				m.m_extra.m_reuse_macro_calls <- file :: List.filter ((<>) file) m.m_extra.m_reuse_macro_calls
-			else
-				add_dependency m (create_fake_module ctx file);
+			add_dependency m (create_fake_module ctx file);
+		);
+		MacroApi.module_reuse_call = (fun mpath call ->
+			let m = typing_timer ctx false (fun() -> Typeload.load_module ctx (parse_path mpath) p) in
+			m.m_extra.m_reuse_macro_calls <- call :: List.filter ((<>) call) m.m_extra.m_reuse_macro_calls
 		);
 		MacroApi.current_module = (fun() ->
 			ctx.m.curmod