aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/functions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile/functions.rs')
-rw-r--r--src/makefile/functions.rs56
1 files changed, 46 insertions, 10 deletions
diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs
index 7bb0908..a16c268 100644
--- a/src/makefile/functions.rs
+++ b/src/makefile/functions.rs
@@ -6,7 +6,7 @@ use std::rc::Rc;
use eyre::{bail, Result, WrapErr};
use super::pattern::r#match;
-use super::r#macro::{Set as MacroSet, Source as MacroSource};
+use super::r#macro::{Macro, Set as MacroSet, Source as MacroSource};
use super::token::TokenString;
pub fn expand_call(
@@ -401,7 +401,15 @@ pub fn foreach(
let mut macros = macros.with_overlay();
let results = words
.map(|word| {
- macros.set(var.clone(), MacroSource::File, TokenString::text(word));
+ macros.set(
+ var.clone(),
+ Macro {
+ source: MacroSource::File,
+ text: TokenString::text(word),
+ #[cfg(feature = "full")]
+ eagerly_expanded: false,
+ },
+ );
macros.expand(text)
})
.collect::<Result<Vec<_>, _>>()?;
@@ -417,7 +425,15 @@ pub fn call<'a>(macros: &MacroSet, args: impl Iterator<Item = &'a TokenString>)
let mut macros = macros.with_overlay();
for (i, x) in args.into_iter().enumerate() {
- macros.set(i.to_string(), MacroSource::File, TokenString::text(x));
+ macros.set(
+ i.to_string(),
+ Macro {
+ source: MacroSource::File,
+ text: TokenString::text(x),
+ #[cfg(feature = "full")]
+ eagerly_expanded: false,
+ },
+ );
}
macros.expand(&TokenString::r#macro(function))
}
@@ -579,10 +595,22 @@ mod test {
let mut macros = MacroSet::new();
macros.set(
"test1".to_owned(),
- MacroSource::File,
- TokenString::text("something"),
+ Macro {
+ source: MacroSource::File,
+ text: TokenString::text("something"),
+ #[cfg(feature = "full")]
+ eagerly_expanded: false,
+ },
+ );
+ macros.set(
+ "test2".to_owned(),
+ Macro {
+ source: MacroSource::File,
+ text: TokenString::text(""),
+ #[cfg(feature = "full")]
+ eagerly_expanded: false,
+ },
);
- macros.set("test2".to_owned(), MacroSource::File, TokenString::text(""));
assert_eq!(
call(
@@ -668,8 +696,12 @@ mod test {
let mut macros = MacroSet::new();
macros.set(
"test".to_owned(),
- MacroSource::File,
- "worked for $(item).".parse()?,
+ Macro {
+ source: MacroSource::File,
+ text: "worked for $(item).".parse()?,
+ #[cfg(feature = "full")]
+ eagerly_expanded: false,
+ },
);
assert_eq!(
call(
@@ -691,8 +723,12 @@ mod test {
let mut macros = MacroSet::new();
macros.set(
"reverse".to_owned(),
- MacroSource::File,
- "$(2) $(1)".parse()?,
+ Macro {
+ source: MacroSource::File,
+ text: "$(2) $(1)".parse()?,
+ #[cfg(feature = "full")]
+ eagerly_expanded: false,
+ },
);
assert_eq!(
call(