Skip to content

Add the range statement to the constant resolver#612

Merged
ghaith merged 4 commits intomasterfrom
591-rangestatement-validation-in-case
Oct 27, 2022
Merged

Add the range statement to the constant resolver#612
ghaith merged 4 commits intomasterfrom
591-rangestatement-validation-in-case

Conversation

@ghaith
Copy link
Collaborator

@ghaith ghaith commented Oct 21, 2022

Fixes #591

@ghaith ghaith linked an issue Oct 21, 2022 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Oct 21, 2022

Codecov Report

Base: 93.66% // Head: 93.67% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (3664b51) compared to base (630ff16).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@ Coverage Diff @@ ## master #612 +/- ## ========================================== + Coverage 93.66% 93.67% +0.01%  ========================================== Files 44 44 Lines 16804 16815 +11 ========================================== + Hits 15740 15752 +12  + Misses 1064 1063 -1 
Impacted Files Coverage Δ
src/resolver/const_evaluator.rs 90.35% <100.00%> (+0.25%) ⬆️
src/validation.rs 96.38% <0.00%> (+0.32%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ghaith ghaith requested a review from riederm October 21, 2022 07:43
Copy link
Collaborator

@riederm riederm left a comment

Choose a reason for hiding this comment

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

I dont believe that ranges will work that easily
we would need to unroll it like:

case (3..10) --> needs to become case 3,4,5,6,7,8,9,10 or we need to rewrite the switch-statement to if-elseif-elseif-...-else

%DAYS_IN_MONTH = getelementptr inbounds %main, %main* %0, i32 0, i32 0
%SIXTY = getelementptr inbounds %main, %main* %0, i32 0, i32 1
%load_DAYS_IN_MONTH = load i32, i32* %DAYS_IN_MONTH, align 4
switch i32 %load_DAYS_IN_MONTH, label %else [
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this look correct? this switch does nothing but else, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also thought this was strange, I can add a correctness test with the constants, but we do have some that take care of the range

@ghaith
Copy link
Collaborator Author

ghaith commented Oct 25, 2022

I dont believe that ranges will work that easily we would need to unroll it like:

case (3..10) --> needs to become case 3,4,5,6,7,8,9,10 or we need to rewrite the switch-statement to if-elseif-elseif-...-else

This commit is only making sure the constants in the ranges are resolved.
The unroll functionality is already implemented, we have correctness tests for them as well (https://github.com/PLC-lang/rusty/blob/master/tests/correctness/control_flow.rs -> case_statement)

Copy link
Collaborator

@riederm riederm left a comment

Choose a reason for hiding this comment

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

yep I didnt look into the else thoroughly

@ghaith ghaith merged commit ac978b0 into master Oct 27, 2022
@ghaith ghaith deleted the 591-rangestatement-validation-in-case branch October 27, 2022 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants