Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.js
node_modules/
yarn.lock

coverage/
.nyc*
Expand Down
11 changes: 7 additions & 4 deletions src/Transpiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export abstract class LuaTranspiler {
case ts.SyntaxKind.ThrowStatement:
return this.transpileThrow(node as ts.ThrowStatement);
case ts.SyntaxKind.ContinueStatement:
return this.transpileContinue();
return this.transpileContinue(node as ts.ContinueStatement);
case ts.SyntaxKind.TypeAliasDeclaration:
case ts.SyntaxKind.InterfaceDeclaration:
case ts.SyntaxKind.EndOfFileToken:
Expand Down Expand Up @@ -316,8 +316,12 @@ export abstract class LuaTranspiler {
}
}

public transpileContinue(): string {
return this.indent + `goto __continue${this.loopStack[this.loopStack.length - 1]}\n`;
public transpileContinue(node: ts.ContinueStatement): string {
throw new TranspileError(
`Unsupported continue statement, ` +
`continue is not supported in Lua ${this.options.luaTarget}.`,
node
);
}

public transpileIf(node: ts.IfStatement): string {
Expand Down Expand Up @@ -352,7 +356,6 @@ export abstract class LuaTranspiler {
result += this.transpileStatement(node.statement);
this.popIndent();
result += this.indent + "end\n";
result += this.indent + `::__continue${this.loopStack.pop()}::\n`;
return result;
}

Expand Down
1 change: 1 addition & 0 deletions src/targets/Transpiler.51.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import { TSHelper as tsHelper } from "../TSHelper";
import * as ts from "typescript";

export class LuaTranspiler51 extends LuaTranspiler {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unnecessary

}
20 changes: 20 additions & 0 deletions src/targets/Transpiler.52.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,25 @@ import { LuaTranspiler51 } from "./Transpiler.51";
import * as ts from "typescript";

export class LuaTranspiler52 extends LuaTranspiler51 {
public transpileLoopBody(
node: ts.WhileStatement
| ts.DoStatement
| ts.ForStatement
| ts.ForOfStatement
| ts.ForInStatement
): string {
this.loopStack.push(this.genVarCounter);
this.genVarCounter++;
let result = this.indent + "do\n";
this.pushIndent();
result += this.transpileStatement(node.statement);
this.popIndent();
result += this.indent + "end\n";
result += this.indent + `::__continue${this.loopStack.pop()}::\n`;
return result;
}

public transpileContinue(node: ts.ContinueStatement): string {
return this.indent + `goto __continue${this.loopStack[this.loopStack.length - 1]}\n`;
}
}