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

Simplify constant-fold method #3805

Merged
merged 1 commit into from
Jan 9, 2023
Merged

Conversation

rst0git
Copy link
Member

@rst0git rst0git commented Dec 23, 2022

This pull request aims to follow up on #3794 to simplify DoConstantFolding::postorder(IR::Member* e) by removing unnecessary if-else statements.

Signed-off-by: Radostin Stoyanov <[email protected]>
@rst0git rst0git marked this pull request as ready for review December 23, 2022 04:12
auto structType = type->to<IR::Type_StructLike>();
if (structType == nullptr) BUG("Expected a struct type, got %1%", type);

if (auto list = expr->to<IR::ListExpression>()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether this is still necessary; the type checker will convert list expressions to structexpressions when needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Mihai for the code review! To avoid the risk of breaking something, I would leave it as is for the time being.

@rst0git rst0git merged commit da17b29 into p4lang:main Jan 9, 2023
@rst0git rst0git deleted the constantfolding branch January 9, 2023 07:33
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