typescript-to-lua
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -8,4 +8,11 @@ #!/usr/bin/env node | ||
var CommandLineParser_1 = require("./CommandLineParser"); | ||
var Transpiler_51_1 = require("./targets/Transpiler.51"); | ||
var Transpiler_52_1 = require("./targets/Transpiler.52"); | ||
var Transpiler_53_1 = require("./targets/Transpiler.53"); | ||
var Transpiler_JIT_1 = require("./targets/Transpiler.JIT"); | ||
var Transpiler_1 = require("./Transpiler"); | ||
function compile(fileNames, options) { | ||
if (!options.luaTarget) { | ||
options.luaTarget = Transpiler_1.LuaTarget.LuaJIT; | ||
} | ||
var program = ts.createProgram(fileNames, options); | ||
@@ -35,3 +42,3 @@ var checker = program.getTypeChecker(); | ||
// Transpile AST | ||
var lua = Transpiler_1.LuaTranspiler.transpileSourceFile(sourceFile, checker, options); | ||
var lua = createTranspiler(checker, options, sourceFile).transpileSourceFile(); | ||
var outPath = sourceFile.fileName; | ||
@@ -80,2 +87,24 @@ if (options.outDir !== options.rootDir) { | ||
exports.compile = compile; | ||
function createTranspiler(checker, options, sourceFile) { | ||
var luaTargetTranspiler; | ||
switch (options.luaTarget) { | ||
case Transpiler_1.LuaTarget.LuaJIT: | ||
luaTargetTranspiler = new Transpiler_JIT_1.LuaTranspilerJIT(checker, options, sourceFile); | ||
break; | ||
case Transpiler_1.LuaTarget.Lua51: | ||
luaTargetTranspiler = new Transpiler_51_1.LuaTranspiler51(checker, options, sourceFile); | ||
break; | ||
case Transpiler_1.LuaTarget.Lua52: | ||
luaTargetTranspiler = new Transpiler_52_1.LuaTranspiler52(checker, options, sourceFile); | ||
break; | ||
case Transpiler_1.LuaTarget.Lua53: | ||
luaTargetTranspiler = new Transpiler_53_1.LuaTranspiler53(checker, options, sourceFile); | ||
break; | ||
default: | ||
// should not happen | ||
throw Error("No luaTarget Specified please ensure a target is set!"); | ||
} | ||
return luaTargetTranspiler; | ||
} | ||
exports.createTranspiler = createTranspiler; | ||
function execCommandLine(argv) { | ||
@@ -82,0 +111,0 @@ argv = argv ? argv : process.argv.slice(2); |
@@ -41,2 +41,5 @@ "use strict"; | ||
}; | ||
TSHelper.isInDestructingAssignment = function (node) { | ||
return node.parent && ts.isVariableDeclaration(node.parent) && ts.isArrayBindingPattern(node.parent.name); | ||
}; | ||
TSHelper.isStringType = function (type) { | ||
@@ -49,3 +52,3 @@ return (type.flags & ts.TypeFlags.String) !== 0 | ||
var typeNode = checker.typeToTypeNode(type); | ||
return typeNode && typeNode.kind === ts.SyntaxKind.ArrayType; | ||
return typeNode && (typeNode.kind === ts.SyntaxKind.ArrayType || typeNode.kind === ts.SyntaxKind.TupleType); | ||
}; | ||
@@ -77,2 +80,11 @@ TSHelper.isTupleType = function (type, checker) { | ||
}; | ||
TSHelper.isTupleReturnCall = function (node, checker) { | ||
if (ts.isCallExpression(node)) { | ||
var type = checker.getTypeAtLocation(node.expression); | ||
return this.isTupleReturnFunction(type, checker); | ||
} | ||
else { | ||
return false; | ||
} | ||
}; | ||
TSHelper.isTupleReturnFunction = function (type, checker) { | ||
@@ -79,0 +91,0 @@ return type.symbol |
{ | ||
"name": "typescript-to-lua", | ||
"license": "MIT", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"repository": "https://github.com/Perryvw/TypescriptToLua", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -9,2 +9,3 @@ # TypescriptToLua | ||
[![Coverage](https://codecov.io/gh/perryvw/typescripttolua/branch/master/graph/badge.svg)](https://codecov.io/gh/perryvw/typescripttolua) | ||
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/TypescriptToLua/Lobby) | ||
@@ -11,0 +12,0 @@ ## Documentation |
Sorry, the diff of this file is too big to display
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
99049
12
1927
61