From f26d572d52d822ca2d96d20124fe085c560cd604 Mon Sep 17 00:00:00 2001 From: Qrius Date: Thu, 26 Sep 2024 00:11:05 +0200 Subject: Track macro invokations, only re-compile nesecarry files --- src/macro_processor/macro_processor.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/macro_processor') diff --git a/src/macro_processor/macro_processor.rs b/src/macro_processor/macro_processor.rs index 93a86af..2e8675f 100644 --- a/src/macro_processor/macro_processor.rs +++ b/src/macro_processor/macro_processor.rs @@ -145,7 +145,7 @@ fn smp_builtin_include( } /// Include a new file verbatim, don't do ANY additional processing -fn smp_builtin_include_verbatim ( +fn smp_builtin_include_verbatim( smp: &mut MacroProcessor, macro_name: &str, args: &mut [String], @@ -264,12 +264,15 @@ enum ParserState { pub struct MacroProcessor { /// All currently defined macros in this MacroProcessor pub macros: HashMap, + /// All macro invocations that has happened + pub macro_invocations: Vec<(String, Vec)>, } impl MacroProcessor { pub fn new() -> Self { let mut smp = Self { macros: HashMap::new(), + macro_invocations: Vec::new(), }; smp.define_builtins(); smp @@ -373,6 +376,12 @@ impl MacroProcessor { return Ok(out); }; + // Log macro invokation + // The fact that we are here, does not ensure that the macro is actually expanded into + // something useful, just that it exists, and was invoked + self.macro_invocations + .push((macro_name.to_string(), args.to_vec())); + match macro_body { MacroType::String(body) => { let mut expanded = body.clone(); -- cgit v1.2.3