-
-
Notifications
You must be signed in to change notification settings - Fork 184
add support for continue statement #112
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bad7b96
add support for continue statement
InfiniteRain 37f844c
make us of lua goto; decrease code reusage; add tests
InfiniteRain 66cacc4
implement requested changes
InfiniteRain 08216d6
add continue translation tests; minor requested changes
InfiniteRain 78e8bc8
Merge branch 'master' of https://github.com/Perryvw/TypescriptToLua
61675ae
fix tupleArrayUses translation test
InfiniteRain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| local i = 0 | ||
| while(i<10) do | ||
| do | ||
| if i<5 then | ||
| goto __continue0 | ||
| end | ||
| end | ||
| ::__continue0:: | ||
| i=i+1 | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| local i = 0 | ||
| while(i<10) do | ||
| do | ||
| if i<5 then | ||
| goto __continue0 | ||
| end | ||
| if i==7 then | ||
| goto __continue0 | ||
| end | ||
| end | ||
| ::__continue0:: | ||
| i=i+1 | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| local i = 0 | ||
| while(i<5) do | ||
| do | ||
| if (i%2)==0 then | ||
| goto __continue0 | ||
| end | ||
| local j = 0 | ||
| while(j<2) do | ||
| do | ||
| if j==1 then | ||
| goto __continue1 | ||
| end | ||
| end | ||
| ::__continue1:: | ||
| j=j+1 | ||
| end | ||
| end | ||
| ::__continue0:: | ||
| i=i+1 | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| local i = 0 | ||
| while(i<5) do | ||
| do | ||
| if (i%2)==0 then | ||
| goto __continue0 | ||
| end | ||
| local j = 0 | ||
| while(j<2) do | ||
| do | ||
| if j==1 then | ||
| goto __continue1 | ||
| end | ||
| end | ||
| ::__continue1:: | ||
| j=j+1 | ||
| end | ||
| if i==4 then | ||
| goto __continue0 | ||
| end | ||
| end | ||
| ::__continue0:: | ||
| i=i+1 | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| local e = 10 | ||
|
|
||
| repeat | ||
| do | ||
| e=e-1 | ||
| end | ||
| ::__continue0:: | ||
| until not (e>0) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| local i = 1 | ||
| while(i<=100) do | ||
| do | ||
| end | ||
| ::__continue0:: | ||
| i=i+1 | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| for i, _ in pairs({a = 1,b = 2,c = 3,d = 4}) do | ||
| do | ||
| end | ||
| ::__continue0:: | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| for _, i in ipairs({1,2,3,4,5,6,7,8,9,10}) do | ||
| do | ||
| end | ||
| ::__continue0:: | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| for _, value in ipairs(tuple) do | ||
| do | ||
| end | ||
| ::__continue0:: | ||
| end | ||
| TS_forEach(tuple, function(v) | ||
| end | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| local d = 10 | ||
|
|
||
| while d>0 do | ||
| do | ||
| d=d-1 | ||
| end | ||
| ::__continue0:: | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| for (let i = 0; i < 10; i++) { | ||
| if (i < 5) { | ||
| continue; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| for (let i = 0; i < 10; i++) { | ||
| if (i < 5) { | ||
| continue; | ||
| } | ||
|
|
||
| if (i === 7) { | ||
| continue; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| for (let i = 0; i < 5; i++) { | ||
| if (i % 2 === 0) { | ||
| continue; | ||
| } | ||
|
|
||
| for (let j = 0; j < 2; j++) { | ||
| if (j === 1) { | ||
| continue; | ||
| } | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| for (let i = 0; i < 5; i++) { | ||
| if (i % 2 === 0) { | ||
| continue; | ||
| } | ||
|
|
||
| for (let j = 0; j < 2; j++) { | ||
| if (j === 1) { | ||
| continue; | ||
| } | ||
| } | ||
|
|
||
| if (i === 4) { | ||
| continue; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| let e = 10 | ||
| do { | ||
| e--; | ||
| } while (e > 0) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| for (let i = 1; i <= 100; i++) { | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| for (let i in { | ||
| a: 1, | ||
| b: 2, | ||
| c: 3, | ||
| d: 4 | ||
| }) { | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| for (let i of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) { | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| let d = 10; | ||
| while (d > 0) { | ||
| d--; | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can push the indent inside the transpileLoopBody function, this will reduce code reuse even more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with this. If you look at the regular for loop it translates the incrementor after the loop body but inside the indent. If you move the indent inside the loop body method this no longer works. You could ofcourse move only the push inside but I think that is bad form, push and pop should be obvious in the same context.