Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate macro calls #455

Merged
merged 10 commits into from
Oct 6, 2021
Merged

Conversation

ZachSierp
Copy link
Contributor

Populate the macroCalls map in sourceInfo with macro expressions while parsing. For macro expressions nested in other macros, the map stores the argument ID of the nested macro for self reference instead of the full expression.

Storing the ID instead of the full argument reduces expression duplication in macroCalls and reduces overall size.

While iterating the AST, expression IDs can be looked up in macroCalls and continue from there. Nested macros can also be looked up by ID while iterating a macro in macroCalls.

This change covers cases where a macro is the target so some other macro such as has(a.b).filter(x, x > 0), and cases where macros are nested inside the arguments of subexpressions like x.filter(y, y.exists(z, has(z.a)) && y.exists(z, has(z.b)))

Fixes issue #292

@TristonianJones
Copy link
Collaborator

/gcbrun

parser/helper.go Outdated Show resolved Hide resolved
parser/helper.go Outdated Show resolved Hide resolved
parser/helper.go Outdated Show resolved Hide resolved
parser/options.go Show resolved Hide resolved
parser/parser_test.go Outdated Show resolved Hide resolved
parser/parser_test.go Outdated Show resolved Hide resolved
parser/parser_test.go Outdated Show resolved Hide resolved
parser/parser_test.go Outdated Show resolved Hide resolved
@TristonianJones
Copy link
Collaborator

/gcbrun

@TristonianJones TristonianJones merged commit 9630e6c into google:master Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants