Skip to content

Add support for global constants to constant folder#1180

Merged
TristonianJones merged 1 commit intogoogle:masterfrom
zeitgeist87:add_identifier_support_for_constant_folding
Jun 20, 2025
Merged

Add support for global constants to constant folder#1180
TristonianJones merged 1 commit intogoogle:masterfrom
zeitgeist87:add_identifier_support_for_constant_folding

Conversation

@zeitgeist87
Copy link
Copy Markdown
Contributor

Global constants like enums are represented in the AST as identifiers. These identifiers can be looked up in the AST reference map. If the entry in the reference map has a value associated with it, we can treat it as a constant and attempt to turn it into a literal.

This reduces the size of the AST and unlocks more optimization opportunities.

@TristonianJones
Copy link
Copy Markdown
Collaborator

/gcbrun

Comment thread cel/folding_test.go
Comment thread cel/folding_test.go Outdated
@zeitgeist87 zeitgeist87 force-pushed the add_identifier_support_for_constant_folding branch 3 times, most recently from 85b2629 to cc30e3b Compare May 21, 2025 07:47
Comment thread cel/options.go Outdated
Global constants like enums are represented in the AST as identifiers. These
identifiers can be looked up in the AST reference map. If there is an entry
in the reference map, we can try to fold it as a constant and to turn it into
a literal.

This reduces the size of the AST and unlocks more optimization
opportunities.
@zeitgeist87 zeitgeist87 force-pushed the add_identifier_support_for_constant_folding branch from cc30e3b to fd56eca Compare May 22, 2025 17:54
@TristonianJones
Copy link
Copy Markdown
Collaborator

/gcbrun

@TristonianJones TristonianJones merged commit 66a441f into google:master Jun 20, 2025
2 checks passed
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