summaryrefslogtreecommitdiff
path: root/src/macro_processor/macro_processor.rs
diff options
context:
space:
mode:
authorQrius <[email protected]>2024-09-26 00:11:05 +0200
committerQrius <[email protected]>2024-09-26 00:11:05 +0200
commitf26d572d52d822ca2d96d20124fe085c560cd604 (patch)
tree8b66c8c7d64f3ffff21c58ccd947f66a746379b3 /src/macro_processor/macro_processor.rs
parentee7facd1db22adb32b5f9077591e4cf2468e32c2 (diff)
downloadskaldpress-f26d572d52d822ca2d96d20124fe085c560cd604.tar.gz
skaldpress-f26d572d52d822ca2d96d20124fe085c560cd604.zip
Track macro invokations, only re-compile nesecarry files
Diffstat (limited to 'src/macro_processor/macro_processor.rs')
-rw-r--r--src/macro_processor/macro_processor.rs11
1 files changed, 10 insertions, 1 deletions
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<String, MacroType>,
+ /// All macro invocations that has happened
+ pub macro_invocations: Vec<(String, Vec<String>)>,
}
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();