typescript-to-lua 1.25.2 → 1.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CompilerOptions.js +2 -2
- package/dist/LuaAST.js +76 -77
- package/dist/LuaLib.d.ts +1 -0
- package/dist/LuaLib.js +13 -12
- package/dist/LuaPrinter.js +2 -2
- package/dist/cli/information.js +2 -2
- package/dist/cli/parse.js +3 -3
- package/dist/cli/report.d.ts +4 -4
- package/dist/cli/report.js +2 -2
- package/dist/cli/tsconfig.js +3 -4
- package/dist/lualib/5.0/MathSign.lua +5 -4
- package/dist/lualib/5.0/MathTrunc.lua +6 -0
- package/dist/lualib/5.0/Set.lua +58 -0
- package/dist/lualib/5.0/lualib_bundle.lua +79 -12
- package/dist/lualib/5.0/lualib_module_info.json +13 -1
- package/dist/lualib/universal/MathSign.lua +5 -4
- package/dist/lualib/universal/MathTrunc.lua +6 -0
- package/dist/lualib/universal/Set.lua +58 -0
- package/dist/lualib/universal/lualib_bundle.lua +79 -12
- package/dist/lualib/universal/lualib_module_info.json +13 -1
- package/dist/lualib-build/plugin.d.ts +1 -1
- package/dist/lualib-build/util.js +8 -9
- package/dist/measure-performance.js +7 -8
- package/dist/transformation/builtins/array.js +3 -4
- package/dist/transformation/builtins/console.js +1 -2
- package/dist/transformation/builtins/function.js +2 -3
- package/dist/transformation/builtins/global.js +1 -2
- package/dist/transformation/builtins/index.js +4 -5
- package/dist/transformation/builtins/map.js +1 -2
- package/dist/transformation/builtins/math.js +5 -3
- package/dist/transformation/builtins/number.js +3 -4
- package/dist/transformation/builtins/object.js +2 -3
- package/dist/transformation/builtins/promise.js +4 -5
- package/dist/transformation/builtins/string.js +3 -4
- package/dist/transformation/builtins/symbol.js +1 -2
- package/dist/transformation/context/context.d.ts +0 -3
- package/dist/transformation/index.js +2 -3
- package/dist/transformation/pre-transformers/using-transformer.js +1 -2
- package/dist/transformation/utils/annotations.js +5 -5
- package/dist/transformation/utils/assignment-validation.js +1 -2
- package/dist/transformation/utils/export.js +14 -14
- package/dist/transformation/utils/function-context.js +3 -3
- package/dist/transformation/utils/language-extensions.js +10 -10
- package/dist/transformation/utils/lua-ast.js +12 -12
- package/dist/transformation/utils/lualib.js +3 -3
- package/dist/transformation/utils/preceding-statements.js +1 -2
- package/dist/transformation/utils/safe-names.js +3 -3
- package/dist/transformation/utils/scope.js +11 -11
- package/dist/transformation/utils/symbols.js +4 -5
- package/dist/transformation/utils/typescript/index.js +13 -14
- package/dist/transformation/utils/typescript/nodes.js +8 -9
- package/dist/transformation/utils/typescript/types.js +10 -11
- package/dist/transformation/visitors/access.js +4 -4
- package/dist/transformation/visitors/async-await.js +3 -3
- package/dist/transformation/visitors/binary-expression/assignments.js +5 -6
- package/dist/transformation/visitors/binary-expression/bit.js +3 -3
- package/dist/transformation/visitors/binary-expression/compound.js +3 -3
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +3 -4
- package/dist/transformation/visitors/binary-expression/index.js +4 -4
- package/dist/transformation/visitors/block.js +3 -3
- package/dist/transformation/visitors/call.js +6 -6
- package/dist/transformation/visitors/class/decorators.js +6 -7
- package/dist/transformation/visitors/class/index.js +14 -3
- package/dist/transformation/visitors/class/members/accessors.js +1 -2
- package/dist/transformation/visitors/class/members/constructor.js +3 -4
- package/dist/transformation/visitors/class/members/fields.js +2 -3
- package/dist/transformation/visitors/class/members/method.js +3 -4
- package/dist/transformation/visitors/class/setup.js +2 -3
- package/dist/transformation/visitors/class/utils.js +5 -6
- package/dist/transformation/visitors/conditional.js +3 -3
- package/dist/transformation/visitors/enum.js +2 -2
- package/dist/transformation/visitors/expression-list.js +4 -5
- package/dist/transformation/visitors/expression-statement.js +2 -2
- package/dist/transformation/visitors/function.js +9 -9
- package/dist/transformation/visitors/identifier.js +4 -4
- package/dist/transformation/visitors/language-extensions/call-extension.js +2 -2
- package/dist/transformation/visitors/language-extensions/identifier.js +2 -3
- package/dist/transformation/visitors/language-extensions/iterable.js +3 -4
- package/dist/transformation/visitors/language-extensions/multi.js +8 -9
- package/dist/transformation/visitors/language-extensions/range.js +3 -4
- package/dist/transformation/visitors/language-extensions/table.js +2 -2
- package/dist/transformation/visitors/language-extensions/vararg.js +2 -3
- package/dist/transformation/visitors/literal.js +3 -3
- package/dist/transformation/visitors/loops/utils.js +4 -5
- package/dist/transformation/visitors/modules/export.js +0 -3
- package/dist/transformation/visitors/modules/import.js +2 -2
- package/dist/transformation/visitors/namespace.js +3 -3
- package/dist/transformation/visitors/optional-chaining.js +6 -7
- package/dist/transformation/visitors/return.js +3 -3
- package/dist/transformation/visitors/spread.js +2 -2
- package/dist/transformation/visitors/typeof.js +2 -2
- package/dist/transformation/visitors/unary-expression.js +2 -2
- package/dist/transformation/visitors/variable-declaration.js +6 -6
- package/dist/transpilation/bundle.js +3 -3
- package/dist/transpilation/find-lua-requires.js +1 -2
- package/dist/transpilation/index.js +5 -6
- package/dist/transpilation/output-collector.js +1 -2
- package/dist/transpilation/plugins.js +1 -2
- package/dist/transpilation/resolve.js +1 -2
- package/dist/transpilation/transformers.js +2 -2
- package/dist/transpilation/transpile.js +1 -2
- package/dist/transpilation/transpiler.js +6 -6
- package/dist/transpilation/utils.js +2 -2
- package/dist/utils.js +9 -9
- package/package.json +6 -7
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNaN =
|
|
3
|
+
exports.createNaN = void 0;
|
|
4
|
+
exports.unwrapVisitorResult = unwrapVisitorResult;
|
|
5
|
+
exports.createSelfIdentifier = createSelfIdentifier;
|
|
6
|
+
exports.createExportsIdentifier = createExportsIdentifier;
|
|
7
|
+
exports.addToNumericExpression = addToNumericExpression;
|
|
8
|
+
exports.getNumberLiteralValue = getNumberLiteralValue;
|
|
9
|
+
exports.createUnpackCall = createUnpackCall;
|
|
10
|
+
exports.isUnpackCall = isUnpackCall;
|
|
11
|
+
exports.wrapInTable = wrapInTable;
|
|
12
|
+
exports.wrapInToStringForConcat = wrapInToStringForConcat;
|
|
13
|
+
exports.createHoistableVariableDeclarationStatement = createHoistableVariableDeclarationStatement;
|
|
14
|
+
exports.createLocalOrExportedOrGlobalDeclaration = createLocalOrExportedOrGlobalDeclaration;
|
|
4
15
|
const ts = require("typescript");
|
|
5
16
|
const CompilerOptions_1 = require("../../CompilerOptions");
|
|
6
17
|
const lua = require("../../LuaAST");
|
|
@@ -12,15 +23,12 @@ const LuaLib_1 = require("../../LuaLib");
|
|
|
12
23
|
function unwrapVisitorResult(result) {
|
|
13
24
|
return result === undefined ? [] : (0, utils_1.castArray)(result);
|
|
14
25
|
}
|
|
15
|
-
exports.unwrapVisitorResult = unwrapVisitorResult;
|
|
16
26
|
function createSelfIdentifier(tsOriginal) {
|
|
17
27
|
return lua.createIdentifier("self", tsOriginal, undefined, "this");
|
|
18
28
|
}
|
|
19
|
-
exports.createSelfIdentifier = createSelfIdentifier;
|
|
20
29
|
function createExportsIdentifier() {
|
|
21
30
|
return lua.createIdentifier("____exports");
|
|
22
31
|
}
|
|
23
|
-
exports.createExportsIdentifier = createExportsIdentifier;
|
|
24
32
|
function addToNumericExpression(expression, change) {
|
|
25
33
|
if (change === 0)
|
|
26
34
|
return expression;
|
|
@@ -41,7 +49,6 @@ function addToNumericExpression(expression, change) {
|
|
|
41
49
|
? lua.createBinaryExpression(expression, lua.createNumericLiteral(change), lua.SyntaxKind.AdditionOperator)
|
|
42
50
|
: lua.createBinaryExpression(expression, lua.createNumericLiteral(-change), lua.SyntaxKind.SubtractionOperator);
|
|
43
51
|
}
|
|
44
|
-
exports.addToNumericExpression = addToNumericExpression;
|
|
45
52
|
function getNumberLiteralValue(expression) {
|
|
46
53
|
if (!expression)
|
|
47
54
|
return undefined;
|
|
@@ -54,7 +61,6 @@ function getNumberLiteralValue(expression) {
|
|
|
54
61
|
}
|
|
55
62
|
return undefined;
|
|
56
63
|
}
|
|
57
|
-
exports.getNumberLiteralValue = getNumberLiteralValue;
|
|
58
64
|
function createUnpackCall(context, expression, tsOriginal) {
|
|
59
65
|
if (context.luaTarget === CompilerOptions_1.LuaTarget.Universal) {
|
|
60
66
|
return (0, lualib_1.transformLuaLibFunction)(context, LuaLib_1.LuaLibFeature.Unpack, tsOriginal, expression);
|
|
@@ -66,16 +72,13 @@ function createUnpackCall(context, expression, tsOriginal) {
|
|
|
66
72
|
: lua.createTableIndexExpression(lua.createIdentifier("table"), lua.createStringLiteral("unpack"));
|
|
67
73
|
return lua.setNodeFlags(lua.createCallExpression(unpack, [expression], tsOriginal), lua.NodeFlags.TableUnpackCall);
|
|
68
74
|
}
|
|
69
|
-
exports.createUnpackCall = createUnpackCall;
|
|
70
75
|
function isUnpackCall(node) {
|
|
71
76
|
return lua.isCallExpression(node) && (node.flags & lua.NodeFlags.TableUnpackCall) !== 0;
|
|
72
77
|
}
|
|
73
|
-
exports.isUnpackCall = isUnpackCall;
|
|
74
78
|
function wrapInTable(...expressions) {
|
|
75
79
|
const fields = expressions.map(e => lua.createTableFieldExpression(e));
|
|
76
80
|
return lua.createTableExpression(fields);
|
|
77
81
|
}
|
|
78
|
-
exports.wrapInTable = wrapInTable;
|
|
79
82
|
function wrapInToStringForConcat(expression) {
|
|
80
83
|
if (lua.isStringLiteral(expression) ||
|
|
81
84
|
lua.isNumericLiteral(expression) ||
|
|
@@ -84,7 +87,6 @@ function wrapInToStringForConcat(expression) {
|
|
|
84
87
|
}
|
|
85
88
|
return lua.createCallExpression(lua.createIdentifier("tostring"), [expression]);
|
|
86
89
|
}
|
|
87
|
-
exports.wrapInToStringForConcat = wrapInToStringForConcat;
|
|
88
90
|
function createHoistableVariableDeclarationStatement(context, identifier, initializer, tsOriginal) {
|
|
89
91
|
const declaration = lua.createVariableDeclarationStatement(identifier, initializer, tsOriginal);
|
|
90
92
|
if (identifier.symbolId !== undefined) {
|
|
@@ -94,7 +96,6 @@ function createHoistableVariableDeclarationStatement(context, identifier, initia
|
|
|
94
96
|
}
|
|
95
97
|
return declaration;
|
|
96
98
|
}
|
|
97
|
-
exports.createHoistableVariableDeclarationStatement = createHoistableVariableDeclarationStatement;
|
|
98
99
|
function hasMultipleReferences(scope, identifiers) {
|
|
99
100
|
const scopeSymbols = scope.referencedSymbols;
|
|
100
101
|
if (!scopeSymbols) {
|
|
@@ -180,7 +181,6 @@ function createLocalOrExportedOrGlobalDeclaration(context, lhs, rhs, tsOriginal,
|
|
|
180
181
|
return [];
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
|
-
exports.createLocalOrExportedOrGlobalDeclaration = createLocalOrExportedOrGlobalDeclaration;
|
|
184
184
|
/**
|
|
185
185
|
* Apply JSDoc comments to the newly-created Lua statement, if present.
|
|
186
186
|
* https://stackoverflow.com/questions/47429792/is-it-possible-to-get-comments-as-nodes-in-the-ast-using-the-typescript-compiler
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LuaLibFeature = void 0;
|
|
4
|
+
exports.importLuaLibFeature = importLuaLibFeature;
|
|
5
|
+
exports.transformLuaLibFunction = transformLuaLibFunction;
|
|
4
6
|
const lua = require("../../LuaAST");
|
|
5
7
|
const LuaLib_1 = require("../../LuaLib");
|
|
6
8
|
Object.defineProperty(exports, "LuaLibFeature", { enumerable: true, get: function () { return LuaLib_1.LuaLibFeature; } });
|
|
7
9
|
function importLuaLibFeature(context, feature) {
|
|
8
10
|
context.usedLuaLibFeatures.add(feature);
|
|
9
11
|
}
|
|
10
|
-
exports.importLuaLibFeature = importLuaLibFeature;
|
|
11
12
|
function transformLuaLibFunction(context, feature, tsParent, ...params) {
|
|
12
13
|
importLuaLibFeature(context, feature);
|
|
13
14
|
const functionIdentifier = lua.createIdentifier(`__TS__${feature}`);
|
|
14
15
|
return lua.createCallExpression(functionIdentifier, params, tsParent);
|
|
15
16
|
}
|
|
16
|
-
exports.transformLuaLibFunction = transformLuaLibFunction;
|
|
17
17
|
//# sourceMappingURL=lualib.js.map
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformInPrecedingStatementScope =
|
|
3
|
+
exports.transformInPrecedingStatementScope = transformInPrecedingStatementScope;
|
|
4
4
|
function transformInPrecedingStatementScope(context, transformer) {
|
|
5
5
|
context.pushPrecedingStatements();
|
|
6
6
|
const statementOrStatements = transformer();
|
|
7
7
|
const precedingStatements = context.popPrecedingStatements();
|
|
8
8
|
return { precedingStatements, result: statementOrStatements };
|
|
9
9
|
}
|
|
10
|
-
exports.transformInPrecedingStatementScope = transformInPrecedingStatementScope;
|
|
11
10
|
//# sourceMappingURL=preceding-statements.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSafeName = exports.
|
|
3
|
+
exports.createSafeName = exports.isUnsafeName = exports.luaKeywords = exports.isValidLuaIdentifier = exports.shouldAllowUnicode = void 0;
|
|
4
|
+
exports.hasUnsafeSymbolName = hasUnsafeSymbolName;
|
|
5
|
+
exports.hasUnsafeIdentifierName = hasUnsafeIdentifierName;
|
|
4
6
|
const __1 = require("../..");
|
|
5
7
|
const diagnostics_1 = require("./diagnostics");
|
|
6
8
|
const export_1 = require("./export");
|
|
@@ -79,14 +81,12 @@ function hasUnsafeSymbolName(context, symbol, tsOriginal) {
|
|
|
79
81
|
// only unsafe when non-ambient and not exported
|
|
80
82
|
return (0, exports.isUnsafeName)(symbol.name, context.options) && !isAmbient && !(0, export_1.isSymbolExported)(context, symbol);
|
|
81
83
|
}
|
|
82
|
-
exports.hasUnsafeSymbolName = hasUnsafeSymbolName;
|
|
83
84
|
function hasUnsafeIdentifierName(context, identifier, symbol) {
|
|
84
85
|
if (symbol) {
|
|
85
86
|
return hasUnsafeSymbolName(context, symbol, identifier);
|
|
86
87
|
}
|
|
87
88
|
return checkName(context, identifier.text, identifier);
|
|
88
89
|
}
|
|
89
|
-
exports.hasUnsafeIdentifierName = hasUnsafeIdentifierName;
|
|
90
90
|
const fixInvalidLuaIdentifier = (name) => name.replace(/[^a-zA-Z0-9_]/g, c => `_${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
91
91
|
const createSafeName = (name) => "____" + fixInvalidLuaIdentifier(name);
|
|
92
92
|
exports.createSafeName = createSafeName;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LoopContinued = exports.ScopeType = void 0;
|
|
4
|
+
exports.walkScopesUp = walkScopesUp;
|
|
5
|
+
exports.markSymbolAsReferencedInCurrentScopes = markSymbolAsReferencedInCurrentScopes;
|
|
6
|
+
exports.peekScope = peekScope;
|
|
7
|
+
exports.findScope = findScope;
|
|
8
|
+
exports.addScopeVariableDeclaration = addScopeVariableDeclaration;
|
|
9
|
+
exports.hasReferencedUndefinedLocalFunction = hasReferencedUndefinedLocalFunction;
|
|
10
|
+
exports.hasReferencedSymbol = hasReferencedSymbol;
|
|
11
|
+
exports.isFunctionScopeWithDefinition = isFunctionScopeWithDefinition;
|
|
12
|
+
exports.separateHoistedStatements = separateHoistedStatements;
|
|
13
|
+
exports.performHoisting = performHoisting;
|
|
4
14
|
const ts = require("typescript");
|
|
5
15
|
const lua = require("../../LuaAST");
|
|
6
16
|
const utils_1 = require("../../utils");
|
|
@@ -30,7 +40,6 @@ function* walkScopesUp(context) {
|
|
|
30
40
|
yield scope;
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
|
-
exports.walkScopesUp = walkScopesUp;
|
|
34
43
|
function markSymbolAsReferencedInCurrentScopes(context, symbolId, identifier) {
|
|
35
44
|
for (const scope of context.scopeStack) {
|
|
36
45
|
if (!scope.referencedSymbols) {
|
|
@@ -40,14 +49,12 @@ function markSymbolAsReferencedInCurrentScopes(context, symbolId, identifier) {
|
|
|
40
49
|
references.push(identifier);
|
|
41
50
|
}
|
|
42
51
|
}
|
|
43
|
-
exports.markSymbolAsReferencedInCurrentScopes = markSymbolAsReferencedInCurrentScopes;
|
|
44
52
|
function peekScope(context) {
|
|
45
53
|
const scopeStack = context.scopeStack;
|
|
46
54
|
const scope = scopeStack[scopeStack.length - 1];
|
|
47
55
|
(0, utils_1.assert)(scope);
|
|
48
56
|
return scope;
|
|
49
57
|
}
|
|
50
|
-
exports.peekScope = peekScope;
|
|
51
58
|
function findScope(context, scopeTypes) {
|
|
52
59
|
for (let i = context.scopeStack.length - 1; i >= 0; --i) {
|
|
53
60
|
const scope = context.scopeStack[i];
|
|
@@ -56,14 +63,12 @@ function findScope(context, scopeTypes) {
|
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
|
-
exports.findScope = findScope;
|
|
60
66
|
function addScopeVariableDeclaration(scope, declaration) {
|
|
61
67
|
if (!scope.variableDeclarations) {
|
|
62
68
|
scope.variableDeclarations = [];
|
|
63
69
|
}
|
|
64
70
|
scope.variableDeclarations.push(declaration);
|
|
65
71
|
}
|
|
66
|
-
exports.addScopeVariableDeclaration = addScopeVariableDeclaration;
|
|
67
72
|
function isHoistableFunctionDeclaredInScope(symbol, scopeNode) {
|
|
68
73
|
var _a;
|
|
69
74
|
return (_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(d => ts.isFunctionDeclaration(d) && (0, typescript_1.findFirstNodeAbove)(d, (n) => n === scopeNode));
|
|
@@ -85,7 +90,6 @@ function hasReferencedUndefinedLocalFunction(context, scope) {
|
|
|
85
90
|
}
|
|
86
91
|
return false;
|
|
87
92
|
}
|
|
88
|
-
exports.hasReferencedUndefinedLocalFunction = hasReferencedUndefinedLocalFunction;
|
|
89
93
|
function hasReferencedSymbol(context, scope, symbol) {
|
|
90
94
|
if (!scope.referencedSymbols) {
|
|
91
95
|
return;
|
|
@@ -97,11 +101,9 @@ function hasReferencedSymbol(context, scope, symbol) {
|
|
|
97
101
|
}
|
|
98
102
|
return false;
|
|
99
103
|
}
|
|
100
|
-
exports.hasReferencedSymbol = hasReferencedSymbol;
|
|
101
104
|
function isFunctionScopeWithDefinition(scope) {
|
|
102
105
|
return scope.node !== undefined && ts.isFunctionLike(scope.node);
|
|
103
106
|
}
|
|
104
|
-
exports.isFunctionScopeWithDefinition = isFunctionScopeWithDefinition;
|
|
105
107
|
function separateHoistedStatements(context, statements) {
|
|
106
108
|
const scope = peekScope(context);
|
|
107
109
|
const allHoistedStatments = [];
|
|
@@ -119,7 +121,6 @@ function separateHoistedStatements(context, statements) {
|
|
|
119
121
|
hoistedIdentifiers: allHoistedIdentifiers,
|
|
120
122
|
};
|
|
121
123
|
}
|
|
122
|
-
exports.separateHoistedStatements = separateHoistedStatements;
|
|
123
124
|
function performHoisting(context, statements) {
|
|
124
125
|
const result = separateHoistedStatements(context, statements);
|
|
125
126
|
const modifiedStatements = [...result.hoistedStatements, ...result.statements];
|
|
@@ -128,7 +129,6 @@ function performHoisting(context, statements) {
|
|
|
128
129
|
}
|
|
129
130
|
return modifiedStatements;
|
|
130
131
|
}
|
|
131
|
-
exports.performHoisting = performHoisting;
|
|
132
132
|
function shouldHoistSymbol(context, symbolId, scope) {
|
|
133
133
|
// Always hoist in top-level of switch statements
|
|
134
134
|
if (scope.type === ScopeType.Switch) {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getSymbolInfo = getSymbolInfo;
|
|
4
|
+
exports.getSymbolIdOfSymbol = getSymbolIdOfSymbol;
|
|
5
|
+
exports.trackSymbolReference = trackSymbolReference;
|
|
6
|
+
exports.getIdentifierSymbolId = getIdentifierSymbolId;
|
|
4
7
|
const spread_1 = require("../visitors/spread");
|
|
5
8
|
const scope_1 = require("./scope");
|
|
6
9
|
function getSymbolInfo(context, symbolId) {
|
|
7
10
|
return context.symbolInfoMap.get(symbolId);
|
|
8
11
|
}
|
|
9
|
-
exports.getSymbolInfo = getSymbolInfo;
|
|
10
12
|
function getSymbolIdOfSymbol(context, symbol) {
|
|
11
13
|
return context.symbolIdMaps.get(symbol);
|
|
12
14
|
}
|
|
13
|
-
exports.getSymbolIdOfSymbol = getSymbolIdOfSymbol;
|
|
14
15
|
function trackSymbolReference(context, symbol, identifier) {
|
|
15
16
|
// Track first time symbols are seen
|
|
16
17
|
let symbolId = context.symbolIdMaps.get(symbol);
|
|
@@ -26,11 +27,9 @@ function trackSymbolReference(context, symbol, identifier) {
|
|
|
26
27
|
}
|
|
27
28
|
return symbolId;
|
|
28
29
|
}
|
|
29
|
-
exports.trackSymbolReference = trackSymbolReference;
|
|
30
30
|
function getIdentifierSymbolId(context, identifier, symbol) {
|
|
31
31
|
if (symbol) {
|
|
32
32
|
return trackSymbolReference(context, symbol, identifier);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
exports.getIdentifierSymbolId = getIdentifierSymbolId;
|
|
36
35
|
//# sourceMappingURL=symbols.js.map
|
|
@@ -14,7 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.hasExportEquals = hasExportEquals;
|
|
18
|
+
exports.findFirstNodeAbove = findFirstNodeAbove;
|
|
19
|
+
exports.findFirstNonOuterParent = findFirstNonOuterParent;
|
|
20
|
+
exports.expressionResultIsUsed = expressionResultIsUsed;
|
|
21
|
+
exports.getFirstDeclarationInFile = getFirstDeclarationInFile;
|
|
22
|
+
exports.isStandardLibraryDeclaration = isStandardLibraryDeclaration;
|
|
23
|
+
exports.isStandardLibraryType = isStandardLibraryType;
|
|
24
|
+
exports.hasStandardLibrarySignature = hasStandardLibrarySignature;
|
|
25
|
+
exports.inferAssignedType = inferAssignedType;
|
|
26
|
+
exports.getAllCallSignatures = getAllCallSignatures;
|
|
27
|
+
exports.isExpressionWithEvaluationEffect = isExpressionWithEvaluationEffect;
|
|
28
|
+
exports.getFunctionTypeForCall = getFunctionTypeForCall;
|
|
29
|
+
exports.isConstIdentifier = isConstIdentifier;
|
|
18
30
|
const ts = require("typescript");
|
|
19
31
|
__exportStar(require("./nodes"), exports);
|
|
20
32
|
__exportStar(require("./types"), exports);
|
|
@@ -22,7 +34,6 @@ __exportStar(require("./types"), exports);
|
|
|
22
34
|
function hasExportEquals(sourceFile) {
|
|
23
35
|
return sourceFile.statements.some(node => ts.isExportAssignment(node) && node.isExportEquals);
|
|
24
36
|
}
|
|
25
|
-
exports.hasExportEquals = hasExportEquals;
|
|
26
37
|
/**
|
|
27
38
|
* Search up until finding a node satisfying the callback
|
|
28
39
|
*/
|
|
@@ -37,7 +48,6 @@ function findFirstNodeAbove(node, callback) {
|
|
|
37
48
|
}
|
|
38
49
|
}
|
|
39
50
|
}
|
|
40
|
-
exports.findFirstNodeAbove = findFirstNodeAbove;
|
|
41
51
|
function findFirstNonOuterParent(node) {
|
|
42
52
|
let current = ts.getOriginalNode(node).parent;
|
|
43
53
|
while (ts.isOuterExpression(current)) {
|
|
@@ -45,18 +55,15 @@ function findFirstNonOuterParent(node) {
|
|
|
45
55
|
}
|
|
46
56
|
return current;
|
|
47
57
|
}
|
|
48
|
-
exports.findFirstNonOuterParent = findFirstNonOuterParent;
|
|
49
58
|
function expressionResultIsUsed(node) {
|
|
50
59
|
return !ts.isExpressionStatement(findFirstNonOuterParent(node));
|
|
51
60
|
}
|
|
52
|
-
exports.expressionResultIsUsed = expressionResultIsUsed;
|
|
53
61
|
function getFirstDeclarationInFile(symbol, sourceFile) {
|
|
54
62
|
var _a, _b;
|
|
55
63
|
const originalSourceFile = (_a = ts.getParseTreeNode(sourceFile)) !== null && _a !== void 0 ? _a : sourceFile;
|
|
56
64
|
const declarations = ((_b = symbol.getDeclarations()) !== null && _b !== void 0 ? _b : []).filter(d => d.getSourceFile() === originalSourceFile);
|
|
57
65
|
return declarations.length > 0 ? declarations.reduce((p, c) => (p.pos < c.pos ? p : c)) : undefined;
|
|
58
66
|
}
|
|
59
|
-
exports.getFirstDeclarationInFile = getFirstDeclarationInFile;
|
|
60
67
|
function isStandardLibraryDeclaration(context, declaration) {
|
|
61
68
|
var _a;
|
|
62
69
|
const parseTreeNode = (_a = ts.getParseTreeNode(declaration)) !== null && _a !== void 0 ? _a : declaration;
|
|
@@ -66,7 +73,6 @@ function isStandardLibraryDeclaration(context, declaration) {
|
|
|
66
73
|
}
|
|
67
74
|
return context.program.isSourceFileDefaultLibrary(sourceFile);
|
|
68
75
|
}
|
|
69
|
-
exports.isStandardLibraryDeclaration = isStandardLibraryDeclaration;
|
|
70
76
|
function isStandardLibraryType(context, type, name) {
|
|
71
77
|
const symbol = type.getSymbol();
|
|
72
78
|
if (!symbol || (name ? symbol.name !== name : symbol.name === "__type")) {
|
|
@@ -79,26 +85,21 @@ function isStandardLibraryType(context, type, name) {
|
|
|
79
85
|
}
|
|
80
86
|
return isStandardLibraryDeclaration(context, declaration);
|
|
81
87
|
}
|
|
82
|
-
exports.isStandardLibraryType = isStandardLibraryType;
|
|
83
88
|
function hasStandardLibrarySignature(context, callExpression) {
|
|
84
89
|
const signature = context.checker.getResolvedSignature(callExpression);
|
|
85
90
|
return (signature === null || signature === void 0 ? void 0 : signature.declaration) ? isStandardLibraryDeclaration(context, signature.declaration) : false;
|
|
86
91
|
}
|
|
87
|
-
exports.hasStandardLibrarySignature = hasStandardLibrarySignature;
|
|
88
92
|
function inferAssignedType(context, expression) {
|
|
89
93
|
var _a;
|
|
90
94
|
return (_a = context.checker.getContextualType(expression)) !== null && _a !== void 0 ? _a : context.checker.getTypeAtLocation(expression);
|
|
91
95
|
}
|
|
92
|
-
exports.inferAssignedType = inferAssignedType;
|
|
93
96
|
function getAllCallSignatures(type) {
|
|
94
97
|
return type.isUnion() ? type.types.flatMap(getAllCallSignatures) : type.getCallSignatures();
|
|
95
98
|
}
|
|
96
|
-
exports.getAllCallSignatures = getAllCallSignatures;
|
|
97
99
|
// Returns true for expressions that may have effects when evaluated
|
|
98
100
|
function isExpressionWithEvaluationEffect(node) {
|
|
99
101
|
return !(ts.isLiteralExpression(node) || ts.isIdentifier(node) || node.kind === ts.SyntaxKind.ThisKeyword);
|
|
100
102
|
}
|
|
101
|
-
exports.isExpressionWithEvaluationEffect = isExpressionWithEvaluationEffect;
|
|
102
103
|
function getFunctionTypeForCall(context, node) {
|
|
103
104
|
const signature = context.checker.getResolvedSignature(node);
|
|
104
105
|
if (!(signature === null || signature === void 0 ? void 0 : signature.declaration)) {
|
|
@@ -110,7 +111,6 @@ function getFunctionTypeForCall(context, node) {
|
|
|
110
111
|
}
|
|
111
112
|
return context.checker.getTypeFromTypeNode(typeDeclaration.type);
|
|
112
113
|
}
|
|
113
|
-
exports.getFunctionTypeForCall = getFunctionTypeForCall;
|
|
114
114
|
function isConstIdentifier(context, node) {
|
|
115
115
|
let identifier = node;
|
|
116
116
|
if (ts.isComputedPropertyName(identifier)) {
|
|
@@ -125,5 +125,4 @@ function isConstIdentifier(context, node) {
|
|
|
125
125
|
}
|
|
126
126
|
return symbol.declarations.some(d => ts.isVariableDeclarationList(d.parent) && (d.parent.flags & ts.NodeFlags.Const) !== 0);
|
|
127
127
|
}
|
|
128
|
-
exports.isConstIdentifier = isConstIdentifier;
|
|
129
128
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isAssignmentPattern = isAssignmentPattern;
|
|
4
|
+
exports.isDestructuringAssignment = isDestructuringAssignment;
|
|
5
|
+
exports.isAmbientNode = isAmbientNode;
|
|
6
|
+
exports.isInDestructingAssignment = isInDestructingAssignment;
|
|
7
|
+
exports.isInAsyncFunction = isInAsyncFunction;
|
|
8
|
+
exports.isInGeneratorFunction = isInGeneratorFunction;
|
|
9
|
+
exports.getSymbolOfNode = getSymbolOfNode;
|
|
10
|
+
exports.isFirstDeclaration = isFirstDeclaration;
|
|
4
11
|
const ts = require("typescript");
|
|
5
12
|
const _1 = require(".");
|
|
6
13
|
function isAssignmentPattern(node) {
|
|
7
14
|
return ts.isObjectLiteralExpression(node) || ts.isArrayLiteralExpression(node);
|
|
8
15
|
}
|
|
9
|
-
exports.isAssignmentPattern = isAssignmentPattern;
|
|
10
16
|
function isDestructuringAssignment(node) {
|
|
11
17
|
return (ts.isBinaryExpression(node) &&
|
|
12
18
|
node.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
|
|
13
19
|
isAssignmentPattern(node.left));
|
|
14
20
|
}
|
|
15
|
-
exports.isDestructuringAssignment = isDestructuringAssignment;
|
|
16
21
|
function isAmbientNode(node) {
|
|
17
22
|
return (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Ambient) !== 0;
|
|
18
23
|
}
|
|
19
|
-
exports.isAmbientNode = isAmbientNode;
|
|
20
24
|
function isInDestructingAssignment(node) {
|
|
21
25
|
return (node.parent &&
|
|
22
26
|
((ts.isVariableDeclaration(node.parent) && ts.isArrayBindingPattern(node.parent.name)) ||
|
|
23
27
|
(ts.isBinaryExpression(node.parent) && ts.isArrayLiteralExpression(node.parent.left))));
|
|
24
28
|
}
|
|
25
|
-
exports.isInDestructingAssignment = isInDestructingAssignment;
|
|
26
29
|
function isInAsyncFunction(node) {
|
|
27
30
|
var _a, _b;
|
|
28
31
|
// Check if node is in function declaration with `async`
|
|
@@ -37,7 +40,6 @@ function isInAsyncFunction(node) {
|
|
|
37
40
|
return false;
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
|
-
exports.isInAsyncFunction = isInAsyncFunction;
|
|
41
43
|
function isInGeneratorFunction(node) {
|
|
42
44
|
// Check if node is in function declaration with `async`
|
|
43
45
|
const declaration = (0, _1.findFirstNodeAbove)(node, ts.isFunctionDeclaration);
|
|
@@ -46,7 +48,6 @@ function isInGeneratorFunction(node) {
|
|
|
46
48
|
}
|
|
47
49
|
return declaration.asteriskToken !== undefined;
|
|
48
50
|
}
|
|
49
|
-
exports.isInGeneratorFunction = isInGeneratorFunction;
|
|
50
51
|
/**
|
|
51
52
|
* Quite hacky, avoid unless absolutely necessary!
|
|
52
53
|
*/
|
|
@@ -54,10 +55,8 @@ function getSymbolOfNode(context, node) {
|
|
|
54
55
|
var _a;
|
|
55
56
|
return (_a = node.symbol) !== null && _a !== void 0 ? _a : context.checker.getSymbolAtLocation(node);
|
|
56
57
|
}
|
|
57
|
-
exports.getSymbolOfNode = getSymbolOfNode;
|
|
58
58
|
function isFirstDeclaration(context, node) {
|
|
59
59
|
const symbol = getSymbolOfNode(context, node);
|
|
60
60
|
return symbol ? symbol.valueDeclaration === node : true;
|
|
61
61
|
}
|
|
62
|
-
exports.isFirstDeclaration = isFirstDeclaration;
|
|
63
62
|
//# sourceMappingURL=nodes.js.map
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.typeAlwaysHasSomeOfFlags = typeAlwaysHasSomeOfFlags;
|
|
4
|
+
exports.typeCanHaveSomeOfFlags = typeCanHaveSomeOfFlags;
|
|
5
|
+
exports.isStringType = isStringType;
|
|
6
|
+
exports.isNumberType = isNumberType;
|
|
7
|
+
exports.forTypeOrAnySupertype = forTypeOrAnySupertype;
|
|
8
|
+
exports.isArrayType = isArrayType;
|
|
9
|
+
exports.isAlwaysArrayType = isAlwaysArrayType;
|
|
10
|
+
exports.isFunctionType = isFunctionType;
|
|
11
|
+
exports.canBeFalsy = canBeFalsy;
|
|
12
|
+
exports.canBeFalsyWhenNotNull = canBeFalsyWhenNotNull;
|
|
4
13
|
const ts = require("typescript");
|
|
5
14
|
function typeAlwaysHasSomeOfFlags(context, type, flags) {
|
|
6
15
|
const baseConstraint = context.checker.getBaseConstraintOfType(type);
|
|
@@ -18,7 +27,6 @@ function typeAlwaysHasSomeOfFlags(context, type, flags) {
|
|
|
18
27
|
}
|
|
19
28
|
return false;
|
|
20
29
|
}
|
|
21
|
-
exports.typeAlwaysHasSomeOfFlags = typeAlwaysHasSomeOfFlags;
|
|
22
30
|
function typeCanHaveSomeOfFlags(context, type, flags) {
|
|
23
31
|
const baseConstraint = context.checker.getBaseConstraintOfType(type);
|
|
24
32
|
if (!baseConstraint) {
|
|
@@ -40,15 +48,12 @@ function typeCanHaveSomeOfFlags(context, type, flags) {
|
|
|
40
48
|
}
|
|
41
49
|
return false;
|
|
42
50
|
}
|
|
43
|
-
exports.typeCanHaveSomeOfFlags = typeCanHaveSomeOfFlags;
|
|
44
51
|
function isStringType(context, type) {
|
|
45
52
|
return typeAlwaysHasSomeOfFlags(context, type, ts.TypeFlags.StringLike);
|
|
46
53
|
}
|
|
47
|
-
exports.isStringType = isStringType;
|
|
48
54
|
function isNumberType(context, type) {
|
|
49
55
|
return typeAlwaysHasSomeOfFlags(context, type, ts.TypeFlags.NumberLike);
|
|
50
56
|
}
|
|
51
|
-
exports.isNumberType = isNumberType;
|
|
52
57
|
function isExplicitArrayType(context, type) {
|
|
53
58
|
if (context.checker.isArrayType(type) || context.checker.isTupleType(type))
|
|
54
59
|
return true;
|
|
@@ -92,19 +97,15 @@ function forTypeOrAnySupertype(context, type, predicate) {
|
|
|
92
97
|
return false;
|
|
93
98
|
return baseTypes.some(superType => forTypeOrAnySupertype(context, superType, predicate));
|
|
94
99
|
}
|
|
95
|
-
exports.forTypeOrAnySupertype = forTypeOrAnySupertype;
|
|
96
100
|
function isArrayType(context, type) {
|
|
97
101
|
return forTypeOrAnySupertype(context, type, t => isExplicitArrayType(context, t));
|
|
98
102
|
}
|
|
99
|
-
exports.isArrayType = isArrayType;
|
|
100
103
|
function isAlwaysArrayType(context, type) {
|
|
101
104
|
return forTypeOrAnySupertype(context, type, t => isAlwaysExplicitArrayType(context, t));
|
|
102
105
|
}
|
|
103
|
-
exports.isAlwaysArrayType = isAlwaysArrayType;
|
|
104
106
|
function isFunctionType(type) {
|
|
105
107
|
return type.getCallSignatures().length > 0;
|
|
106
108
|
}
|
|
107
|
-
exports.isFunctionType = isFunctionType;
|
|
108
109
|
function canBeFalsy(context, type) {
|
|
109
110
|
const strictNullChecks = context.options.strict === true || context.options.strictNullChecks === true;
|
|
110
111
|
if (!strictNullChecks && !type.isLiteral())
|
|
@@ -119,7 +120,6 @@ function canBeFalsy(context, type) {
|
|
|
119
120
|
ts.TypeFlags.Null;
|
|
120
121
|
return typeCanHaveSomeOfFlags(context, type, falsyFlags);
|
|
121
122
|
}
|
|
122
|
-
exports.canBeFalsy = canBeFalsy;
|
|
123
123
|
function canBeFalsyWhenNotNull(context, type) {
|
|
124
124
|
const falsyFlags = ts.TypeFlags.Boolean |
|
|
125
125
|
ts.TypeFlags.BooleanLiteral |
|
|
@@ -129,5 +129,4 @@ function canBeFalsyWhenNotNull(context, type) {
|
|
|
129
129
|
ts.TypeFlags.Any;
|
|
130
130
|
return typeCanHaveSomeOfFlags(context, type, falsyFlags);
|
|
131
131
|
}
|
|
132
|
-
exports.canBeFalsyWhenNotNull = canBeFalsyWhenNotNull;
|
|
133
132
|
//# sourceMappingURL=types.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformQualifiedName = exports.
|
|
3
|
+
exports.transformQualifiedName = exports.transformPropertyAccessExpression = exports.transformElementAccessExpression = void 0;
|
|
4
|
+
exports.transformElementAccessArgument = transformElementAccessArgument;
|
|
5
|
+
exports.transformElementAccessExpressionWithCapture = transformElementAccessExpressionWithCapture;
|
|
6
|
+
exports.transformPropertyAccessExpressionWithCapture = transformPropertyAccessExpressionWithCapture;
|
|
4
7
|
const ts = require("typescript");
|
|
5
8
|
const lua = require("../../LuaAST");
|
|
6
9
|
const builtins_1 = require("../builtins");
|
|
@@ -29,7 +32,6 @@ function transformElementAccessArgument(context, node) {
|
|
|
29
32
|
const index = context.transformExpression(node.argumentExpression);
|
|
30
33
|
return addOneToArrayAccessArgument(context, node, index);
|
|
31
34
|
}
|
|
32
|
-
exports.transformElementAccessArgument = transformElementAccessArgument;
|
|
33
35
|
const transformElementAccessExpression = (node, context) => transformElementAccessExpressionWithCapture(context, node, undefined).expression;
|
|
34
36
|
exports.transformElementAccessExpression = transformElementAccessExpression;
|
|
35
37
|
function transformElementAccessExpressionWithCapture(context, node, thisValueCapture) {
|
|
@@ -73,7 +75,6 @@ function transformElementAccessExpressionWithCapture(context, node, thisValueCap
|
|
|
73
75
|
}
|
|
74
76
|
return { expression: lua.createTableIndexExpression(table, updatedAccessExpression, node) };
|
|
75
77
|
}
|
|
76
|
-
exports.transformElementAccessExpressionWithCapture = transformElementAccessExpressionWithCapture;
|
|
77
78
|
const transformPropertyAccessExpression = (node, context) => transformPropertyAccessExpressionWithCapture(context, node, undefined).expression;
|
|
78
79
|
exports.transformPropertyAccessExpression = transformPropertyAccessExpression;
|
|
79
80
|
function transformPropertyAccessExpressionWithCapture(context, node, thisValueCapture) {
|
|
@@ -145,7 +146,6 @@ function transformPropertyAccessExpressionWithCapture(context, node, thisValueCa
|
|
|
145
146
|
}
|
|
146
147
|
return { expression: lua.createTableIndexExpression(table, lua.createStringLiteral(property), node) };
|
|
147
148
|
}
|
|
148
|
-
exports.transformPropertyAccessExpressionWithCapture = transformPropertyAccessExpressionWithCapture;
|
|
149
149
|
const transformQualifiedName = (node, context) => {
|
|
150
150
|
const right = lua.createStringLiteral(node.right.text, node.right);
|
|
151
151
|
const left = context.transformExpression(node.left);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.transformAwaitExpression = void 0;
|
|
4
|
+
exports.isAsyncFunction = isAsyncFunction;
|
|
5
|
+
exports.wrapInAsyncAwaiter = wrapInAsyncAwaiter;
|
|
4
6
|
const ts = require("typescript");
|
|
5
7
|
const lua = require("../../LuaAST");
|
|
6
8
|
const diagnostics_1 = require("../utils/diagnostics");
|
|
@@ -19,7 +21,6 @@ function isAsyncFunction(declaration) {
|
|
|
19
21
|
var _a, _b;
|
|
20
22
|
return (_b = (_a = declaration.modifiers) === null || _a === void 0 ? void 0 : _a.some(m => m.kind === ts.SyntaxKind.AsyncKeyword)) !== null && _b !== void 0 ? _b : false;
|
|
21
23
|
}
|
|
22
|
-
exports.isAsyncFunction = isAsyncFunction;
|
|
23
24
|
function wrapInAsyncAwaiter(context, statements, includeResolveParameter = true) {
|
|
24
25
|
(0, lualib_1.importLuaLibFeature)(context, lualib_1.LuaLibFeature.Await);
|
|
25
26
|
const parameters = includeResolveParameter ? [lua.createIdentifier("____awaiter_resolve")] : [];
|
|
@@ -27,5 +28,4 @@ function wrapInAsyncAwaiter(context, statements, includeResolveParameter = true)
|
|
|
27
28
|
lua.createFunctionExpression(lua.createBlock(statements), parameters),
|
|
28
29
|
]);
|
|
29
30
|
}
|
|
30
|
-
exports.wrapInAsyncAwaiter = wrapInAsyncAwaiter;
|
|
31
31
|
//# sourceMappingURL=async-await.js.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.transformAssignmentLeftHandSideExpression = transformAssignmentLeftHandSideExpression;
|
|
4
|
+
exports.transformAssignment = transformAssignment;
|
|
5
|
+
exports.transformAssignmentWithRightPrecedingStatements = transformAssignmentWithRightPrecedingStatements;
|
|
6
|
+
exports.transformAssignmentExpression = transformAssignmentExpression;
|
|
7
|
+
exports.transformAssignmentStatement = transformAssignmentStatement;
|
|
4
8
|
const ts = require("typescript");
|
|
5
9
|
const typescript_1 = require("typescript");
|
|
6
10
|
const lua = require("../../../LuaAST");
|
|
@@ -43,7 +47,6 @@ function transformAssignmentLeftHandSideExpression(context, node, rightHasPreced
|
|
|
43
47
|
return lua.createAnonymousIdentifier();
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
|
-
exports.transformAssignmentLeftHandSideExpression = transformAssignmentLeftHandSideExpression;
|
|
47
50
|
function transformAssignment(context,
|
|
48
51
|
// TODO: Change type to ts.LeftHandSideExpression?
|
|
49
52
|
lhs, right, rightHasPrecedingStatements, parent) {
|
|
@@ -82,14 +85,12 @@ lhs, right, rightHasPrecedingStatements, parent) {
|
|
|
82
85
|
}),
|
|
83
86
|
];
|
|
84
87
|
}
|
|
85
|
-
exports.transformAssignment = transformAssignment;
|
|
86
88
|
function transformAssignmentWithRightPrecedingStatements(context, lhs, right, rightPrecedingStatements, parent) {
|
|
87
89
|
return [
|
|
88
90
|
...rightPrecedingStatements,
|
|
89
91
|
...transformAssignment(context, lhs, right, rightPrecedingStatements.length > 0, parent),
|
|
90
92
|
];
|
|
91
93
|
}
|
|
92
|
-
exports.transformAssignmentWithRightPrecedingStatements = transformAssignmentWithRightPrecedingStatements;
|
|
93
94
|
function transformDestructuredAssignmentExpression(context, expression) {
|
|
94
95
|
let { precedingStatements: rightPrecedingStatements, result: right } = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => context.transformExpression(expression.right));
|
|
95
96
|
context.addPrecedingStatements(rightPrecedingStatements);
|
|
@@ -131,7 +132,6 @@ function transformAssignmentExpression(context, expression) {
|
|
|
131
132
|
return left;
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
|
-
exports.transformAssignmentExpression = transformAssignmentExpression;
|
|
135
135
|
const canBeTransformedToLuaAssignmentStatement = (context, node) => ts.isArrayLiteralExpression(node.left) &&
|
|
136
136
|
node.left.elements.every(element => {
|
|
137
137
|
if ((0, destructuring_assignments_1.isArrayLength)(context, element)) {
|
|
@@ -179,5 +179,4 @@ function transformAssignmentStatement(context, expression) {
|
|
|
179
179
|
return transformAssignmentWithRightPrecedingStatements(context, expression.left, right, precedingStatements);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
exports.transformAssignmentStatement = transformAssignmentStatement;
|
|
183
182
|
//# sourceMappingURL=assignments.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isBitOperator = void 0;
|
|
4
|
+
exports.transformBinaryBitOperation = transformBinaryBitOperation;
|
|
5
|
+
exports.transformUnaryBitOperation = transformUnaryBitOperation;
|
|
4
6
|
const ts = require("typescript");
|
|
5
7
|
const CompilerOptions_1 = require("../../../CompilerOptions");
|
|
6
8
|
const lua = require("../../../LuaAST");
|
|
@@ -53,7 +55,6 @@ function transformBinaryBitOperation(context, node, left, right, operator) {
|
|
|
53
55
|
return lua.createBinaryExpression(left, right, luaOperator, node);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
|
-
exports.transformBinaryBitOperation = transformBinaryBitOperation;
|
|
57
58
|
function transformUnaryBitLibOperation(node, expression, operator, lib) {
|
|
58
59
|
let bitFunction;
|
|
59
60
|
switch (operator) {
|
|
@@ -80,5 +81,4 @@ function transformUnaryBitOperation(context, node, expression, operator) {
|
|
|
80
81
|
return lua.createUnaryExpression(expression, operator, node);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
exports.transformUnaryBitOperation = transformUnaryBitOperation;
|
|
84
84
|
//# sourceMappingURL=bit.js.map
|