typescript-to-lua
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -19,2 +19,16 @@ "use strict"; | ||
} | ||
LuaTranspiler52.prototype.transpileLoopBody = function (node) { | ||
this.loopStack.push(this.genVarCounter); | ||
this.genVarCounter++; | ||
var 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; | ||
}; | ||
LuaTranspiler52.prototype.transpileContinue = function (node) { | ||
return this.indent + ("goto __continue" + this.loopStack[this.loopStack.length - 1] + "\n"); | ||
}; | ||
return LuaTranspiler52; | ||
@@ -21,0 +35,0 @@ }(Transpiler_51_1.LuaTranspiler51)); |
@@ -65,3 +65,3 @@ "use strict"; | ||
if (node && | ||
node.modifiers && | ||
node.modifiers && this.isModule && | ||
(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export)) { | ||
@@ -184,3 +184,3 @@ if (dummy) { | ||
case ts.SyntaxKind.ContinueStatement: | ||
return this.transpileContinue(); | ||
return this.transpileContinue(node); | ||
case ts.SyntaxKind.TypeAliasDeclaration: | ||
@@ -293,4 +293,5 @@ case ts.SyntaxKind.InterfaceDeclaration: | ||
}; | ||
LuaTranspiler.prototype.transpileContinue = function () { | ||
return this.indent + ("goto __continue" + this.loopStack[this.loopStack.length - 1] + "\n"); | ||
LuaTranspiler.prototype.transpileContinue = function (node) { | ||
throw new TranspileError("Unsupported continue statement, " + | ||
("continue is not supported in Lua " + this.options.luaTarget + "."), node); | ||
}; | ||
@@ -319,3 +320,2 @@ LuaTranspiler.prototype.transpileIf = function (node) { | ||
result += this.indent + "end\n"; | ||
result += this.indent + ("::__continue" + this.loopStack.pop() + "::\n"); | ||
return result; | ||
@@ -527,2 +527,3 @@ }; | ||
case ts.SyntaxKind.StringLiteral: | ||
case ts.SyntaxKind.NoSubstitutionTemplateLiteral: | ||
var text = node.text; | ||
@@ -570,2 +571,4 @@ return "\"" + text + "\""; | ||
return this.transpileExpression(node.expression); | ||
case ts.SyntaxKind.TypeOfExpression: | ||
return this.transpileTypeOfExpression(node); | ||
default: | ||
@@ -679,2 +682,5 @@ throw new TranspileError("Unsupported expression kind: " + TSHelper_1.TSHelper.enumName(node.kind, ts.SyntaxKind), node); | ||
break; | ||
case ts.SyntaxKind.InstanceOfKeyword: | ||
result = "TS_instanceof(" + lhs + ", " + rhs + ")"; | ||
break; | ||
default: | ||
@@ -735,3 +741,3 @@ throw new TranspileError("Unsupported binary operator kind: " + ts.tokenToString(node.operatorToken.kind), node); | ||
case ts.SyntaxKind.ExclamationToken: | ||
return "not " + operand; | ||
return "(not " + operand + ")"; | ||
case ts.SyntaxKind.MinusToken: | ||
@@ -1011,2 +1017,6 @@ return "-" + operand; | ||
}; | ||
LuaTranspiler.prototype.transpileTypeOfExpression = function (node) { | ||
var expression = this.transpileExpression(node.expression); | ||
return "(type(" + expression + ") == \"table\" and \"object\" or type(" + expression + "))"; | ||
}; | ||
// Transpile a variable statement | ||
@@ -1055,2 +1065,6 @@ LuaTranspiler.prototype.transpileVariableStatement = function (node) { | ||
LuaTranspiler.prototype.transpileFunctionDeclaration = function (node) { | ||
// Don't transpile functions without body (overload declarations) | ||
if (!node.body) { | ||
return ""; | ||
} | ||
var result = ""; | ||
@@ -1093,2 +1107,6 @@ var identifier = node.name; | ||
LuaTranspiler.prototype.transpileMethodDeclaration = function (node, callPath) { | ||
// Don't transpile methods without body (overload declarations) | ||
if (!node.body) { | ||
return ""; | ||
} | ||
var result = ""; | ||
@@ -1095,0 +1113,0 @@ var identifier = node.name; |
{ | ||
"name": "typescript-to-lua", | ||
"license": "MIT", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"repository": "https://github.com/Perryvw/TypescriptToLua", | ||
"scripts": { | ||
"build": "tsc -p tsconfig.json", | ||
"test": "tslint -p . && tsc -p ./test && node ./test/runner.js", | ||
"test": "tslint -p . && ts-node ./test/runner.ts", | ||
"coverage": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||
@@ -35,4 +35,5 @@ "coverage-html": "nyc npm test && nyc report --reporter=html", | ||
"nyc": "^11.7.1", | ||
"ts-node": "^7.0.0", | ||
"tslint": "^5.9.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100729
1959
9