C# IR: Add support for ContinueStmt - #1858
Merged
Merged
Conversation
ghost
self-requested a review
as a code owner
September 2, 2019 15:13
ContinueStmtContinueStmt
calumgrant
reviewed
Sep 11, 2019
calumgrant
left a comment
Contributor
There was a problem hiding this comment.
General approach looks very good. Nice to see how easy it is to add new constructs.
| then | ||
| if crtStmt instanceof ForStmt | ||
| then | ||
| result = getTranslatedStmt(crtStmt).(TranslatedForStmt).getUpdate(0).getFirstInstruction() |
Contributor
There was a problem hiding this comment.
What happens if there is no update? E.g.
for(;;) continue;
Author
There was a problem hiding this comment.
Thanks, missed that. Updated the code so that the instruction continue jumps to is the first instruction of the update sequence, if one exists, otherwise the first instruction of the condition, if that exists, otherwise the first instruction of the body.
| } | ||
|
|
||
| private Instruction getEnclosingLoopTargetInstruction(Stmt crtStmt) { | ||
| if crtStmt instanceof LoopStmt |
Contributor
There was a problem hiding this comment.
This logic might be better expressed as
if ... ForStmt
then ...
else if ... Loopstmt
then ...
else ...
added 2 commits
September 12, 2019 10:01
Added support for continue stmt. Minimal refactoring of the `TranslatedSpecificJump` classes. Added a new test file, `jumps.cs` and updated the expected output.
ghost
requested a review
from calumgrant
September 12, 2019 09:34
hvitved
requested changes
Sep 12, 2019
ghost
requested a review
from hvitved
September 12, 2019 12:10
hvitved
requested changes
Sep 12, 2019
ghost
requested a review
from hvitved
September 12, 2019 12:57
hvitved
approved these changes
Sep 12, 2019
calumgrant
approved these changes
Sep 12, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for the
ContinueStmtand contains some refactoring for the code that deals with jump stmts.Only the last commit should be reviewed, since the other one part of another PR.