File tree Expand file tree Collapse file tree 4 files changed +29
-4
lines changed
Expand file tree Collapse file tree 4 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 11* .js
22node_modules /
3+ yarn.lock
34
45coverage /
56.nyc *
Original file line number Diff line number Diff line change @@ -194,7 +194,7 @@ export abstract class LuaTranspiler {
194194 case ts . SyntaxKind . ThrowStatement :
195195 return this . transpileThrow ( node as ts . ThrowStatement ) ;
196196 case ts . SyntaxKind . ContinueStatement :
197- return this . transpileContinue ( ) ;
197+ return this . transpileContinue ( node as ts . ContinueStatement ) ;
198198 case ts . SyntaxKind . TypeAliasDeclaration :
199199 case ts . SyntaxKind . InterfaceDeclaration :
200200 case ts . SyntaxKind . EndOfFileToken :
@@ -316,8 +316,12 @@ export abstract class LuaTranspiler {
316316 }
317317 }
318318
319- public transpileContinue ( ) : string {
320- return this . indent + `goto __continue${ this . loopStack [ this . loopStack . length - 1 ] } \n` ;
319+ public transpileContinue ( node : ts . ContinueStatement ) : string {
320+ throw new TranspileError (
321+ `Unsupported continue statement, ` +
322+ `continue is not supported in Lua ${ this . options . luaTarget } .` ,
323+ node
324+ ) ;
321325 }
322326
323327 public transpileIf ( node : ts . IfStatement ) : string {
@@ -352,7 +356,6 @@ export abstract class LuaTranspiler {
352356 result += this . transpileStatement ( node . statement ) ;
353357 this . popIndent ( ) ;
354358 result += this . indent + "end\n" ;
355- result += this . indent + `::__continue${ this . loopStack . pop ( ) } ::\n` ;
356359 return result ;
357360 }
358361
Original file line number Diff line number Diff line change @@ -4,4 +4,5 @@ import { TSHelper as tsHelper } from "../TSHelper";
44import * as ts from "typescript" ;
55
66export class LuaTranspiler51 extends LuaTranspiler {
7+
78}
Original file line number Diff line number Diff line change @@ -4,5 +4,25 @@ import { LuaTranspiler51 } from "./Transpiler.51";
44import * as ts from "typescript" ;
55
66export class LuaTranspiler52 extends LuaTranspiler51 {
7+ public transpileLoopBody (
8+ node : ts . WhileStatement
9+ | ts . DoStatement
10+ | ts . ForStatement
11+ | ts . ForOfStatement
12+ | ts . ForInStatement
13+ ) : string {
14+ this . loopStack . push ( this . genVarCounter ) ;
15+ this . genVarCounter ++ ;
16+ let result = this . indent + "do\n" ;
17+ this . pushIndent ( ) ;
18+ result += this . transpileStatement ( node . statement ) ;
19+ this . popIndent ( ) ;
20+ result += this . indent + "end\n" ;
21+ result += this . indent + `::__continue${ this . loopStack . pop ( ) } ::\n` ;
22+ return result ;
23+ }
724
25+ public transpileContinue ( node : ts . ContinueStatement ) : string {
26+ return this . indent + `goto __continue${ this . loopStack [ this . loopStack . length - 1 ] } \n` ;
27+ }
828}
You can’t perform that action at this time.
0 commit comments