Skip to content

Commit

Permalink
Allow features with macros within macros (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
LindaGuiga committed Aug 14, 2024
1 parent c6d015b commit 0c2e771
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions evm_arithmetization/src/cpu/kernel/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ fn expand_macros(
expanded.extend(expand_macros(body.clone(), macros, macro_counter));
}
}
Item::ConditionalBlock(_, items) => {
expanded.extend(expand_macros(items.clone(), macros, macro_counter));
}
item => {
expanded.push(item);
}
Expand Down
14 changes: 13 additions & 1 deletion evm_arithmetization/src/cpu/kernel/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ mod tests {
#[test]
fn test_feature() {
let code = r#"
%macro bar_foo
#[cfg(feature = feature_1)]
{
%bar
PUSH 3
ADD
}
%endmacro
#[cfg(feature = feature_1)]
{
%macro bar
Expand All @@ -260,7 +268,7 @@ mod tests {
#[cfg(feature = feature_1)]
{
%bar
%bar_foo
PUSH 1
}
PUSH 3
Expand Down Expand Up @@ -291,6 +299,8 @@ mod tests {
%macro bar
PUSH 2
MUL
PUSH 3
ADD
%endmacro
global foo_1:
Expand Down Expand Up @@ -353,6 +363,8 @@ mod tests {
%macro bar
PUSH 2
MUL
PUSH 3
ADD
%endmacro
global foo_1:
Expand Down

0 comments on commit 0c2e771

Please sign in to comment.