Skip to content

C# IR: Add support for ContinueStmt - #1858

Merged
calumgrant merged 4 commits into
masterfrom
unknown repository
Sep 12, 2019
Merged

C# IR: Add support for ContinueStmt#1858
calumgrant merged 4 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Sep 2, 2019

Copy link
Copy Markdown

This PR adds support for the ContinueStmt and 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.

@ghost
ghost self-requested a review as a code owner September 2, 2019 15:13
@ghost ghost changed the title C# IR: Added support for ContinueStmt C# IR: Add support for ContinueStmt Sep 3, 2019
@ghost ghost closed this Sep 3, 2019
@ghost ghost reopened this Sep 3, 2019
@calumgrant calumgrant added the C# label Sep 9, 2019

@calumgrant calumgrant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if there is no update? E.g.

for(;;) continue;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This logic might be better expressed as

if ... ForStmt
then ...
else if ... Loopstmt
then ...
else ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Refactored the code.

AndreiDiaconu1 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
ghost requested a review from calumgrant September 12, 2019 09:34
@ghost
ghost requested a review from hvitved September 12, 2019 12:10
@ghost
ghost requested a review from hvitved September 12, 2019 12:57
@calumgrant
calumgrant merged commit b7db156 into github:master Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants