typescript-to-lua 1.0.1 → 1.1.0
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/CHANGELOG.md +18 -0
- package/dist/CompilerOptions.d.ts +4 -3
- package/dist/LuaAST.js +4 -4
- package/dist/LuaLib.d.ts +1 -0
- package/dist/LuaLib.js +1 -0
- package/dist/LuaPrinter.d.ts +6 -2
- package/dist/LuaPrinter.js +25 -16
- package/dist/cli/diagnostics.js +2 -2
- package/dist/cli/report.js +1 -1
- package/dist/cli/tsconfig.js +4 -4
- package/dist/lualib/Await.lua +26 -10
- package/dist/lualib/Promise.lua +20 -6
- package/dist/lualib/SourceMapTraceBack.lua +18 -8
- package/dist/lualib/StringReplace.lua +8 -13
- package/dist/lualib/StringReplaceAll.lua +35 -0
- package/dist/lualib/lualib_bundle.lua +106 -35
- package/dist/transformation/builtins/array.js +29 -29
- package/dist/transformation/builtins/console.js +2 -2
- package/dist/transformation/builtins/function.js +9 -9
- package/dist/transformation/builtins/global.js +8 -8
- package/dist/transformation/builtins/index.js +33 -33
- package/dist/transformation/builtins/math.js +4 -4
- package/dist/transformation/builtins/number.js +7 -7
- package/dist/transformation/builtins/object.js +11 -11
- package/dist/transformation/builtins/promise.js +9 -9
- package/dist/transformation/builtins/string.js +32 -30
- package/dist/transformation/builtins/symbol.js +3 -3
- package/dist/transformation/context/context.js +5 -5
- package/dist/transformation/index.js +1 -1
- package/dist/transformation/utils/annotations.d.ts +1 -3
- package/dist/transformation/utils/annotations.js +0 -2
- package/dist/transformation/utils/assignment-validation.js +8 -7
- package/dist/transformation/utils/diagnostics.js +4 -4
- package/dist/transformation/utils/export.js +4 -4
- package/dist/transformation/utils/function-context.js +8 -8
- package/dist/transformation/utils/lua-ast.js +18 -19
- package/dist/transformation/utils/lualib.js +1 -1
- package/dist/transformation/utils/safe-names.js +5 -5
- package/dist/transformation/utils/scope.d.ts +6 -0
- package/dist/transformation/utils/scope.js +70 -40
- package/dist/transformation/utils/symbols.js +6 -6
- package/dist/transformation/utils/transform.js +3 -3
- package/dist/transformation/utils/typescript/nodes.d.ts +2 -0
- package/dist/transformation/utils/typescript/nodes.js +21 -1
- package/dist/transformation/visitors/access.js +16 -16
- package/dist/transformation/visitors/async-await.js +5 -4
- package/dist/transformation/visitors/binary-expression/assignments.js +29 -29
- package/dist/transformation/visitors/binary-expression/bit.js +4 -4
- package/dist/transformation/visitors/binary-expression/compound.js +18 -18
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +17 -17
- package/dist/transformation/visitors/binary-expression/index.js +21 -21
- package/dist/transformation/visitors/block.js +6 -6
- package/dist/transformation/visitors/break-continue.js +2 -2
- package/dist/transformation/visitors/call.js +35 -35
- package/dist/transformation/visitors/class/decorators.js +3 -3
- package/dist/transformation/visitors/class/index.js +34 -34
- package/dist/transformation/visitors/class/members/accessors.js +6 -6
- package/dist/transformation/visitors/class/members/constructor.js +7 -7
- package/dist/transformation/visitors/class/members/fields.js +6 -6
- package/dist/transformation/visitors/class/members/method.js +6 -6
- package/dist/transformation/visitors/class/new.js +12 -12
- package/dist/transformation/visitors/class/setup.js +11 -11
- package/dist/transformation/visitors/class/utils.js +2 -2
- package/dist/transformation/visitors/conditional.js +6 -6
- package/dist/transformation/visitors/delete.js +4 -4
- package/dist/transformation/visitors/enum.js +8 -8
- package/dist/transformation/visitors/errors.js +30 -30
- package/dist/transformation/visitors/expression-statement.js +10 -6
- package/dist/transformation/visitors/function.js +26 -26
- package/dist/transformation/visitors/identifier.js +22 -22
- package/dist/transformation/visitors/index.js +2 -2
- package/dist/transformation/visitors/language-extensions/iterable.js +7 -7
- package/dist/transformation/visitors/language-extensions/multi.d.ts +1 -1
- package/dist/transformation/visitors/language-extensions/multi.js +3 -3
- package/dist/transformation/visitors/language-extensions/operators.js +6 -6
- package/dist/transformation/visitors/language-extensions/range.js +6 -6
- package/dist/transformation/visitors/language-extensions/table.js +5 -5
- package/dist/transformation/visitors/literal.d.ts +1 -2
- package/dist/transformation/visitors/literal.js +19 -42
- package/dist/transformation/visitors/loops/do-while.js +2 -2
- package/dist/transformation/visitors/loops/for-in.js +4 -4
- package/dist/transformation/visitors/loops/for-of.js +13 -13
- package/dist/transformation/visitors/loops/for.js +3 -3
- package/dist/transformation/visitors/loops/utils.js +9 -9
- package/dist/transformation/visitors/modules/export.js +13 -13
- package/dist/transformation/visitors/modules/import.js +10 -10
- package/dist/transformation/visitors/namespace.js +13 -13
- package/dist/transformation/visitors/return.d.ts +1 -0
- package/dist/transformation/visitors/return.js +40 -26
- package/dist/transformation/visitors/sourceFile.js +8 -8
- package/dist/transformation/visitors/spread.js +11 -11
- package/dist/transformation/visitors/switch.js +34 -11
- package/dist/transformation/visitors/template.js +5 -5
- package/dist/transformation/visitors/typeof.js +2 -2
- package/dist/transformation/visitors/typescript.js +1 -1
- package/dist/transformation/visitors/unary-expression.js +9 -9
- package/dist/transformation/visitors/variable-declaration.js +28 -28
- package/dist/transformation/visitors/void.d.ts +6 -0
- package/dist/transformation/visitors/void.js +23 -0
- package/dist/transpilation/bundle.d.ts +3 -0
- package/dist/transpilation/bundle.js +52 -10
- package/dist/transpilation/diagnostics.js +3 -3
- package/dist/transpilation/index.js +2 -2
- package/dist/transpilation/output-collector.js +2 -2
- package/dist/transpilation/plugins.js +1 -1
- package/dist/transpilation/resolve.js +19 -12
- package/dist/transpilation/transformers.js +41 -24
- package/dist/transpilation/transpile.js +6 -6
- package/dist/transpilation/transpiler.js +8 -8
- package/dist/transpilation/utils.js +3 -2
- package/dist/tstl.js +8 -8
- package/dist/utils.js +2 -2
- package/package.json +15 -12
- package/dist/transformation/visitors/jsx/jsx.d.ts +0 -9
- package/dist/transformation/visitors/jsx/jsx.js +0 -237
- package/dist/transformation/visitors/jsx/xhtml.d.ts +0 -3
- package/dist/transformation/visitors/jsx/xhtml.js +0 -260
|
@@ -31,7 +31,7 @@ function transformBitOperatorToLuaOperator(context, node, operator) {
|
|
|
31
31
|
case ts.SyntaxKind.LessThanLessThanToken:
|
|
32
32
|
return lua.SyntaxKind.BitwiseLeftShiftOperator;
|
|
33
33
|
case ts.SyntaxKind.GreaterThanGreaterThanToken:
|
|
34
|
-
context.diagnostics.push(diagnostics_1.unsupportedRightShiftOperator(node));
|
|
34
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedRightShiftOperator)(node));
|
|
35
35
|
case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
|
|
36
36
|
return lua.SyntaxKind.BitwiseRightShiftOperator;
|
|
37
37
|
}
|
|
@@ -40,7 +40,7 @@ function transformBinaryBitOperation(context, node, left, right, operator) {
|
|
|
40
40
|
switch (context.luaTarget) {
|
|
41
41
|
case CompilerOptions_1.LuaTarget.Universal:
|
|
42
42
|
case CompilerOptions_1.LuaTarget.Lua51:
|
|
43
|
-
context.diagnostics.push(diagnostics_1.unsupportedForTarget(node, "Bitwise operations", CompilerOptions_1.LuaTarget.Lua51));
|
|
43
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedForTarget)(node, "Bitwise operations", CompilerOptions_1.LuaTarget.Lua51));
|
|
44
44
|
case CompilerOptions_1.LuaTarget.LuaJIT:
|
|
45
45
|
return transformBinaryBitLibOperation(node, left, right, operator, "bit");
|
|
46
46
|
case CompilerOptions_1.LuaTarget.Lua52:
|
|
@@ -58,7 +58,7 @@ function transformUnaryBitLibOperation(node, expression, operator, lib) {
|
|
|
58
58
|
bitFunction = "bnot";
|
|
59
59
|
break;
|
|
60
60
|
default:
|
|
61
|
-
utils_1.assertNever(operator);
|
|
61
|
+
(0, utils_1.assertNever)(operator);
|
|
62
62
|
}
|
|
63
63
|
return lua.createCallExpression(lua.createTableIndexExpression(lua.createIdentifier(lib), lua.createStringLiteral(bitFunction)), [expression], node);
|
|
64
64
|
}
|
|
@@ -66,7 +66,7 @@ function transformUnaryBitOperation(context, node, expression, operator) {
|
|
|
66
66
|
switch (context.luaTarget) {
|
|
67
67
|
case CompilerOptions_1.LuaTarget.Universal:
|
|
68
68
|
case CompilerOptions_1.LuaTarget.Lua51:
|
|
69
|
-
context.diagnostics.push(diagnostics_1.unsupportedForTarget(node, "Bitwise operations", CompilerOptions_1.LuaTarget.Lua51));
|
|
69
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedForTarget)(node, "Bitwise operations", CompilerOptions_1.LuaTarget.Lua51));
|
|
70
70
|
case CompilerOptions_1.LuaTarget.LuaJIT:
|
|
71
71
|
return transformUnaryBitLibOperation(node, expression, operator, "bit");
|
|
72
72
|
case CompilerOptions_1.LuaTarget.Lua52:
|
|
@@ -11,9 +11,9 @@ const assignments_1 = require("./assignments");
|
|
|
11
11
|
// If expression is property/element access with possible effects from being evaluated, returns separated object and index expressions.
|
|
12
12
|
function parseAccessExpressionWithEvaluationEffects(context, node) {
|
|
13
13
|
if (ts.isElementAccessExpression(node) &&
|
|
14
|
-
(typescript_1.isExpressionWithEvaluationEffect(node.expression) || typescript_1.isExpressionWithEvaluationEffect(node.argumentExpression))) {
|
|
14
|
+
((0, typescript_1.isExpressionWithEvaluationEffect)(node.expression) || (0, typescript_1.isExpressionWithEvaluationEffect)(node.argumentExpression))) {
|
|
15
15
|
const type = context.checker.getTypeAtLocation(node.expression);
|
|
16
|
-
if (typescript_1.isArrayType(context, type)) {
|
|
16
|
+
if ((0, typescript_1.isArrayType)(context, type)) {
|
|
17
17
|
// Offset arrays by one
|
|
18
18
|
const oneLit = ts.factory.createNumericLiteral("1");
|
|
19
19
|
const exp = ts.factory.createParenthesizedExpression(node.argumentExpression);
|
|
@@ -24,7 +24,7 @@ function parseAccessExpressionWithEvaluationEffects(context, node) {
|
|
|
24
24
|
return [node.expression, node.argumentExpression];
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
else if (ts.isPropertyAccessExpression(node) && typescript_1.isExpressionWithEvaluationEffect(node.expression)) {
|
|
27
|
+
else if (ts.isPropertyAccessExpression(node) && (0, typescript_1.isExpressionWithEvaluationEffect)(node.expression)) {
|
|
28
28
|
return [node.expression, ts.factory.createStringLiteral(node.name.text)];
|
|
29
29
|
}
|
|
30
30
|
return [];
|
|
@@ -52,7 +52,7 @@ exports.isCompoundAssignmentToken = isCompoundAssignmentToken;
|
|
|
52
52
|
const unwrapCompoundAssignmentToken = (token) => compoundToAssignmentTokens[token];
|
|
53
53
|
exports.unwrapCompoundAssignmentToken = unwrapCompoundAssignmentToken;
|
|
54
54
|
function transformCompoundAssignment(context, expression, lhs, rhs, operator, isPostfix) {
|
|
55
|
-
const left = utils_1.cast(context.transformExpression(lhs), lua.isAssignmentLeftHandSideExpression);
|
|
55
|
+
const left = (0, utils_1.cast)(context.transformExpression(lhs), lua.isAssignmentLeftHandSideExpression);
|
|
56
56
|
const right = context.transformExpression(rhs);
|
|
57
57
|
const [objExpression, indexExpression] = parseAccessExpressionWithEvaluationEffects(context, lhs);
|
|
58
58
|
if (objExpression && indexExpression) {
|
|
@@ -69,13 +69,13 @@ function transformCompoundAssignment(context, expression, lhs, rhs, operator, is
|
|
|
69
69
|
// local ____tmp = ____obj[____index];
|
|
70
70
|
// ____obj[____index] = ____tmp ${replacementOperator} ${right};
|
|
71
71
|
tmpDeclaration = lua.createVariableDeclarationStatement(tmp, accessExpression);
|
|
72
|
-
const operatorExpression = binary_expression_1.transformBinaryOperation(context, tmp, right, operator, expression);
|
|
72
|
+
const operatorExpression = (0, binary_expression_1.transformBinaryOperation)(context, tmp, right, operator, expression);
|
|
73
73
|
assignStatement = lua.createAssignmentStatement(accessExpression, operatorExpression);
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
// local ____tmp = ____obj[____index] ${replacementOperator} ${right};
|
|
77
77
|
// ____obj[____index] = ____tmp;
|
|
78
|
-
const operatorExpression = binary_expression_1.transformBinaryOperation(context, accessExpression, right, operator, expression);
|
|
78
|
+
const operatorExpression = (0, binary_expression_1.transformBinaryOperation)(context, accessExpression, right, operator, expression);
|
|
79
79
|
tmpDeclaration = lua.createVariableDeclarationStatement(tmp, operatorExpression);
|
|
80
80
|
assignStatement = lua.createAssignmentStatement(accessExpression, tmp);
|
|
81
81
|
}
|
|
@@ -89,8 +89,8 @@ function transformCompoundAssignment(context, expression, lhs, rhs, operator, is
|
|
|
89
89
|
// return ____tmp
|
|
90
90
|
const tmpIdentifier = lua.createIdentifier("____tmp");
|
|
91
91
|
const tmpDeclaration = lua.createVariableDeclarationStatement(tmpIdentifier, left);
|
|
92
|
-
const operatorExpression = binary_expression_1.transformBinaryOperation(context, tmpIdentifier, right, operator, expression);
|
|
93
|
-
const assignStatements = assignments_1.transformAssignment(context, lhs, operatorExpression);
|
|
92
|
+
const operatorExpression = (0, binary_expression_1.transformBinaryOperation)(context, tmpIdentifier, right, operator, expression);
|
|
93
|
+
const assignStatements = (0, assignments_1.transformAssignment)(context, lhs, operatorExpression);
|
|
94
94
|
return { statements: [tmpDeclaration, ...assignStatements], result: tmpIdentifier };
|
|
95
95
|
}
|
|
96
96
|
else if (ts.isPropertyAccessExpression(lhs) || ts.isElementAccessExpression(lhs)) {
|
|
@@ -99,9 +99,9 @@ function transformCompoundAssignment(context, expression, lhs, rhs, operator, is
|
|
|
99
99
|
// ${left} = ____tmp;
|
|
100
100
|
// return ____tmp
|
|
101
101
|
const tmpIdentifier = lua.createIdentifier("____tmp");
|
|
102
|
-
const operatorExpression = binary_expression_1.transformBinaryOperation(context, left, right, operator, expression);
|
|
102
|
+
const operatorExpression = (0, binary_expression_1.transformBinaryOperation)(context, left, right, operator, expression);
|
|
103
103
|
const tmpDeclaration = lua.createVariableDeclarationStatement(tmpIdentifier, operatorExpression);
|
|
104
|
-
const assignStatements = assignments_1.transformAssignment(context, lhs, tmpIdentifier);
|
|
104
|
+
const assignStatements = (0, assignments_1.transformAssignment)(context, lhs, tmpIdentifier);
|
|
105
105
|
if (isSetterSkippingCompoundAssignmentOperator(operator)) {
|
|
106
106
|
const statements = [
|
|
107
107
|
tmpDeclaration,
|
|
@@ -114,8 +114,8 @@ function transformCompoundAssignment(context, expression, lhs, rhs, operator, is
|
|
|
114
114
|
else {
|
|
115
115
|
// Simple expressions
|
|
116
116
|
// ${left} = ${right}; return ${right}
|
|
117
|
-
const operatorExpression = binary_expression_1.transformBinaryOperation(context, left, right, operator, expression);
|
|
118
|
-
const statements = assignments_1.transformAssignment(context, lhs, operatorExpression);
|
|
117
|
+
const operatorExpression = (0, binary_expression_1.transformBinaryOperation)(context, left, right, operator, expression);
|
|
118
|
+
const statements = (0, assignments_1.transformAssignment)(context, lhs, operatorExpression);
|
|
119
119
|
return { statements, result: left };
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -123,11 +123,11 @@ exports.transformCompoundAssignment = transformCompoundAssignment;
|
|
|
123
123
|
function transformCompoundAssignmentExpression(context, expression,
|
|
124
124
|
// TODO: Change type to ts.LeftHandSideExpression?
|
|
125
125
|
lhs, rhs, operator, isPostfix) {
|
|
126
|
-
return transform_1.transformToImmediatelyInvokedFunctionExpression(context, () => transformCompoundAssignment(context, expression, lhs, rhs, operator, isPostfix), expression);
|
|
126
|
+
return (0, transform_1.transformToImmediatelyInvokedFunctionExpression)(context, () => transformCompoundAssignment(context, expression, lhs, rhs, operator, isPostfix), expression);
|
|
127
127
|
}
|
|
128
128
|
exports.transformCompoundAssignmentExpression = transformCompoundAssignmentExpression;
|
|
129
129
|
function transformCompoundAssignmentStatement(context, node, lhs, rhs, operator) {
|
|
130
|
-
const left = utils_1.cast(context.transformExpression(lhs), lua.isAssignmentLeftHandSideExpression);
|
|
130
|
+
const left = (0, utils_1.cast)(context.transformExpression(lhs), lua.isAssignmentLeftHandSideExpression);
|
|
131
131
|
const right = context.transformExpression(rhs);
|
|
132
132
|
const [objExpression, indexExpression] = parseAccessExpressionWithEvaluationEffects(context, lhs);
|
|
133
133
|
if (objExpression && indexExpression) {
|
|
@@ -144,7 +144,7 @@ function transformCompoundAssignmentStatement(context, node, lhs, rhs, operator)
|
|
|
144
144
|
...transformSetterSkippingCompoundAssignment(context, accessExpression, operator, rhs, node),
|
|
145
145
|
];
|
|
146
146
|
}
|
|
147
|
-
const operatorExpression = binary_expression_1.transformBinaryOperation(context, accessExpression, right, operator, node);
|
|
147
|
+
const operatorExpression = (0, binary_expression_1.transformBinaryOperation)(context, accessExpression, right, operator, node);
|
|
148
148
|
const assignStatement = lua.createAssignmentStatement(accessExpression, operatorExpression);
|
|
149
149
|
return [objAndIndexDeclaration, assignStatement];
|
|
150
150
|
}
|
|
@@ -155,8 +155,8 @@ function transformCompoundAssignmentStatement(context, node, lhs, rhs, operator)
|
|
|
155
155
|
}
|
|
156
156
|
// Simple statements
|
|
157
157
|
// ${left} = ${left} ${replacementOperator} ${right}
|
|
158
|
-
const operatorExpression = binary_expression_1.transformBinaryOperation(context, left, right, operator, node);
|
|
159
|
-
return assignments_1.transformAssignment(context, lhs, operatorExpression);
|
|
158
|
+
const operatorExpression = (0, binary_expression_1.transformBinaryOperation)(context, left, right, operator, node);
|
|
159
|
+
return (0, assignments_1.transformAssignment)(context, lhs, operatorExpression);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
exports.transformCompoundAssignmentStatement = transformCompoundAssignmentStatement;
|
|
@@ -178,7 +178,7 @@ function transformSetterSkippingCompoundAssignment(context, lhs, operator, rhs,
|
|
|
178
178
|
condition = lua.createBinaryExpression(lhs, lua.createNilLiteral(), lua.SyntaxKind.EqualityOperator);
|
|
179
179
|
}
|
|
180
180
|
else {
|
|
181
|
-
utils_1.assertNever(operator);
|
|
181
|
+
(0, utils_1.assertNever)(operator);
|
|
182
182
|
}
|
|
183
183
|
// if condition then lhs = rhs end
|
|
184
184
|
return [
|
|
@@ -13,7 +13,7 @@ function isArrayLength(context, expression) {
|
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
const type = context.checker.getTypeAtLocation(expression.expression);
|
|
16
|
-
if (!typescript_1.isArrayType(context, type)) {
|
|
16
|
+
if (!(0, typescript_1.isArrayType)(context, type)) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
const name = ts.isPropertyAccessExpression(expression)
|
|
@@ -49,8 +49,8 @@ function transformArrayLiteralAssignmentPattern(context, node, root) {
|
|
|
49
49
|
const assignedVariable = lua.createIdentifier("____bindingAssignmentValue");
|
|
50
50
|
const assignedVariableDeclaration = lua.createVariableDeclarationStatement(assignedVariable, indexedRoot);
|
|
51
51
|
const nilCondition = lua.createBinaryExpression(assignedVariable, lua.createNilLiteral(), lua.SyntaxKind.EqualityOperator);
|
|
52
|
-
const defaultAssignmentStatements = assignments_1.transformAssignment(context, element.left, context.transformExpression(element.right));
|
|
53
|
-
const elseAssignmentStatements = assignments_1.transformAssignment(context, element.left, assignedVariable);
|
|
52
|
+
const defaultAssignmentStatements = (0, assignments_1.transformAssignment)(context, element.left, context.transformExpression(element.right));
|
|
53
|
+
const elseAssignmentStatements = (0, assignments_1.transformAssignment)(context, element.left, assignedVariable);
|
|
54
54
|
const ifBlock = lua.createBlock(defaultAssignmentStatements);
|
|
55
55
|
const elseBlock = lua.createBlock(elseAssignmentStatements);
|
|
56
56
|
const ifStatement = lua.createIfStatement(nilCondition, ifBlock, elseBlock, node);
|
|
@@ -58,14 +58,14 @@ function transformArrayLiteralAssignmentPattern(context, node, root) {
|
|
|
58
58
|
case ts.SyntaxKind.Identifier:
|
|
59
59
|
case ts.SyntaxKind.PropertyAccessExpression:
|
|
60
60
|
case ts.SyntaxKind.ElementAccessExpression:
|
|
61
|
-
return assignments_1.transformAssignment(context, element, indexedRoot);
|
|
61
|
+
return (0, assignments_1.transformAssignment)(context, element, indexedRoot);
|
|
62
62
|
case ts.SyntaxKind.SpreadElement:
|
|
63
63
|
if (index !== node.elements.length - 1) {
|
|
64
64
|
// TypeScript error
|
|
65
65
|
return [];
|
|
66
66
|
}
|
|
67
|
-
const restElements = lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArraySlice, undefined, root, lua.createNumericLiteral(index));
|
|
68
|
-
return assignments_1.transformAssignment(context, element.expression, restElements);
|
|
67
|
+
const restElements = (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArraySlice, undefined, root, lua.createNumericLiteral(index));
|
|
68
|
+
return (0, assignments_1.transformAssignment)(context, element.expression, restElements);
|
|
69
69
|
case ts.SyntaxKind.OmittedExpression:
|
|
70
70
|
return [];
|
|
71
71
|
default:
|
|
@@ -93,23 +93,23 @@ function transformObjectLiteralAssignmentPattern(context, node, root) {
|
|
|
93
93
|
// TypeScript error
|
|
94
94
|
break;
|
|
95
95
|
default:
|
|
96
|
-
utils_1.assertNever(property);
|
|
96
|
+
(0, utils_1.assertNever)(property);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
return result;
|
|
100
100
|
}
|
|
101
101
|
function transformShorthandPropertyAssignment(context, node, root) {
|
|
102
102
|
const result = [];
|
|
103
|
-
const assignmentVariableName = assignments_1.transformAssignmentLeftHandSideExpression(context, node.name);
|
|
103
|
+
const assignmentVariableName = (0, assignments_1.transformAssignmentLeftHandSideExpression)(context, node.name);
|
|
104
104
|
const extractionIndex = lua.createStringLiteral(node.name.text);
|
|
105
|
-
const variableExtractionAssignmentStatements = assignments_1.transformAssignment(context, node.name, lua.createTableIndexExpression(root, extractionIndex));
|
|
105
|
+
const variableExtractionAssignmentStatements = (0, assignments_1.transformAssignment)(context, node.name, lua.createTableIndexExpression(root, extractionIndex));
|
|
106
106
|
result.push(...variableExtractionAssignmentStatements);
|
|
107
107
|
const defaultInitializer = node.objectAssignmentInitializer
|
|
108
108
|
? context.transformExpression(node.objectAssignmentInitializer)
|
|
109
109
|
: undefined;
|
|
110
110
|
if (defaultInitializer) {
|
|
111
111
|
const nilCondition = lua.createBinaryExpression(assignmentVariableName, lua.createNilLiteral(), lua.SyntaxKind.EqualityOperator);
|
|
112
|
-
const assignmentStatements = assignments_1.transformAssignment(context, node.name, defaultInitializer);
|
|
112
|
+
const assignmentStatements = (0, assignments_1.transformAssignment)(context, node.name, defaultInitializer);
|
|
113
113
|
const ifBlock = lua.createBlock(assignmentStatements);
|
|
114
114
|
result.push(lua.createIfStatement(nilCondition, ifBlock, undefined, node));
|
|
115
115
|
}
|
|
@@ -117,8 +117,8 @@ function transformShorthandPropertyAssignment(context, node, root) {
|
|
|
117
117
|
}
|
|
118
118
|
function transformPropertyAssignment(context, node, root) {
|
|
119
119
|
const result = [];
|
|
120
|
-
if (typescript_1.isAssignmentPattern(node.initializer)) {
|
|
121
|
-
const propertyAccessString = literal_1.transformPropertyName(context, node.name);
|
|
120
|
+
if ((0, typescript_1.isAssignmentPattern)(node.initializer)) {
|
|
121
|
+
const propertyAccessString = (0, literal_1.transformPropertyName)(context, node.name);
|
|
122
122
|
const newRootAccess = lua.createTableIndexExpression(root, propertyAccessString);
|
|
123
123
|
if (ts.isObjectLiteralExpression(node.initializer)) {
|
|
124
124
|
return transformObjectLiteralAssignmentPattern(context, node.initializer, newRootAccess);
|
|
@@ -128,14 +128,14 @@ function transformPropertyAssignment(context, node, root) {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
const leftExpression = ts.isBinaryExpression(node.initializer) ? node.initializer.left : node.initializer;
|
|
131
|
-
const variableToExtract = literal_1.transformPropertyName(context, node.name);
|
|
131
|
+
const variableToExtract = (0, literal_1.transformPropertyName)(context, node.name);
|
|
132
132
|
const extractingExpression = lua.createTableIndexExpression(root, variableToExtract);
|
|
133
|
-
const destructureAssignmentStatements = assignments_1.transformAssignment(context, leftExpression, extractingExpression);
|
|
133
|
+
const destructureAssignmentStatements = (0, assignments_1.transformAssignment)(context, leftExpression, extractingExpression);
|
|
134
134
|
result.push(...destructureAssignmentStatements);
|
|
135
135
|
if (ts.isBinaryExpression(node.initializer)) {
|
|
136
136
|
const assignmentLeftHandSide = context.transformExpression(node.initializer.left);
|
|
137
137
|
const nilCondition = lua.createBinaryExpression(assignmentLeftHandSide, lua.createNilLiteral(), lua.SyntaxKind.EqualityOperator);
|
|
138
|
-
const ifBlock = lua.createBlock(assignments_1.transformAssignmentStatement(context, node.initializer));
|
|
138
|
+
const ifBlock = lua.createBlock((0, assignments_1.transformAssignmentStatement)(context, node.initializer));
|
|
139
139
|
result.push(lua.createIfStatement(nilCondition, ifBlock, undefined, node));
|
|
140
140
|
}
|
|
141
141
|
return result;
|
|
@@ -152,7 +152,7 @@ function transformSpreadAssignment(context, node, root, properties) {
|
|
|
152
152
|
usedProperties.push(lua.createTableFieldExpression(lua.createBooleanLiteral(true), name));
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
const extractingExpression = lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ObjectRest, undefined, root, lua.createTableExpression(usedProperties));
|
|
156
|
-
return assignments_1.transformAssignment(context, node.expression, extractingExpression);
|
|
155
|
+
const extractingExpression = (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ObjectRest, undefined, root, lua.createTableExpression(usedProperties));
|
|
156
|
+
return (0, assignments_1.transformAssignment)(context, node.expression, extractingExpression);
|
|
157
157
|
}
|
|
158
158
|
//# sourceMappingURL=destructuring-assignments.js.map
|
|
@@ -31,11 +31,11 @@ const simpleOperatorsToLua = {
|
|
|
31
31
|
[ts.SyntaxKind.ExclamationEqualsEqualsToken]: lua.SyntaxKind.InequalityOperator,
|
|
32
32
|
};
|
|
33
33
|
function transformBinaryOperation(context, left, right, operator, node) {
|
|
34
|
-
if (bit_1.isBitOperator(operator)) {
|
|
35
|
-
return bit_1.transformBinaryBitOperation(context, node, left, right, operator);
|
|
34
|
+
if ((0, bit_1.isBitOperator)(operator)) {
|
|
35
|
+
return (0, bit_1.transformBinaryBitOperation)(context, node, left, right, operator);
|
|
36
36
|
}
|
|
37
37
|
if (operator === ts.SyntaxKind.QuestionQuestionToken) {
|
|
38
|
-
utils_1.assert(ts.isBinaryExpression(node));
|
|
38
|
+
(0, utils_1.assert)(ts.isBinaryExpression(node));
|
|
39
39
|
return transformNullishCoalescingExpression(context, node, left, right);
|
|
40
40
|
}
|
|
41
41
|
let luaOperator = simpleOperatorsToLua[operator];
|
|
@@ -43,11 +43,11 @@ function transformBinaryOperation(context, left, right, operator, node) {
|
|
|
43
43
|
if (operator === ts.SyntaxKind.PlusToken && ts.isBinaryExpression(node)) {
|
|
44
44
|
const typeLeft = context.checker.getTypeAtLocation(node.left);
|
|
45
45
|
const typeRight = context.checker.getTypeAtLocation(node.right);
|
|
46
|
-
const isLeftString = typescript_1.isStringType(context, typeLeft);
|
|
47
|
-
const isRightString = typescript_1.isStringType(context, typeRight);
|
|
46
|
+
const isLeftString = (0, typescript_1.isStringType)(context, typeLeft);
|
|
47
|
+
const isRightString = (0, typescript_1.isStringType)(context, typeRight);
|
|
48
48
|
if (isLeftString || isRightString) {
|
|
49
|
-
left = isLeftString ? left : lua_ast_1.wrapInToStringForConcat(left);
|
|
50
|
-
right = isRightString ? right : lua_ast_1.wrapInToStringForConcat(right);
|
|
49
|
+
left = isLeftString ? left : (0, lua_ast_1.wrapInToStringForConcat)(left);
|
|
50
|
+
right = isRightString ? right : (0, lua_ast_1.wrapInToStringForConcat)(right);
|
|
51
51
|
luaOperator = lua.SyntaxKind.ConcatOperator;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -56,17 +56,17 @@ function transformBinaryOperation(context, left, right, operator, node) {
|
|
|
56
56
|
exports.transformBinaryOperation = transformBinaryOperation;
|
|
57
57
|
const transformBinaryExpression = (node, context) => {
|
|
58
58
|
const operator = node.operatorToken.kind;
|
|
59
|
-
const typeOfResult = typeof_1.transformTypeOfBinaryExpression(context, node);
|
|
59
|
+
const typeOfResult = (0, typeof_1.transformTypeOfBinaryExpression)(context, node);
|
|
60
60
|
if (typeOfResult) {
|
|
61
61
|
return typeOfResult;
|
|
62
62
|
}
|
|
63
|
-
if (compound_1.isCompoundAssignmentToken(operator)) {
|
|
64
|
-
const token = compound_1.unwrapCompoundAssignmentToken(operator);
|
|
65
|
-
return compound_1.transformCompoundAssignmentExpression(context, node, node.left, node.right, token, false);
|
|
63
|
+
if ((0, compound_1.isCompoundAssignmentToken)(operator)) {
|
|
64
|
+
const token = (0, compound_1.unwrapCompoundAssignmentToken)(operator);
|
|
65
|
+
return (0, compound_1.transformCompoundAssignmentExpression)(context, node, node.left, node.right, token, false);
|
|
66
66
|
}
|
|
67
67
|
switch (operator) {
|
|
68
68
|
case ts.SyntaxKind.EqualsToken:
|
|
69
|
-
return assignments_1.transformAssignmentExpression(context, node);
|
|
69
|
+
return (0, assignments_1.transformAssignmentExpression)(context, node);
|
|
70
70
|
case ts.SyntaxKind.InKeyword: {
|
|
71
71
|
const lhs = context.transformExpression(node.left);
|
|
72
72
|
const rhs = context.transformExpression(node.right);
|
|
@@ -77,13 +77,13 @@ const transformBinaryExpression = (node, context) => {
|
|
|
77
77
|
const lhs = context.transformExpression(node.left);
|
|
78
78
|
const rhs = context.transformExpression(node.right);
|
|
79
79
|
const rhsType = context.checker.getTypeAtLocation(node.right);
|
|
80
|
-
if (typescript_1.isStandardLibraryType(context, rhsType, "ObjectConstructor")) {
|
|
81
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.InstanceOfObject, node, lhs);
|
|
80
|
+
if ((0, typescript_1.isStandardLibraryType)(context, rhsType, "ObjectConstructor")) {
|
|
81
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.InstanceOfObject, node, lhs);
|
|
82
82
|
}
|
|
83
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.InstanceOf, node, lhs, rhs);
|
|
83
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.InstanceOf, node, lhs, rhs);
|
|
84
84
|
}
|
|
85
85
|
case ts.SyntaxKind.CommaToken: {
|
|
86
|
-
return transform_1.transformToImmediatelyInvokedFunctionExpression(context, () => ({
|
|
86
|
+
return (0, transform_1.transformToImmediatelyInvokedFunctionExpression)(context, () => ({
|
|
87
87
|
statements: context.transformStatements(ts.factory.createExpressionStatement(node.left)),
|
|
88
88
|
result: context.transformExpression(node.right),
|
|
89
89
|
}), node);
|
|
@@ -98,13 +98,13 @@ function transformBinaryExpressionStatement(context, node) {
|
|
|
98
98
|
if (!ts.isBinaryExpression(expression))
|
|
99
99
|
return;
|
|
100
100
|
const operator = expression.operatorToken.kind;
|
|
101
|
-
if (compound_1.isCompoundAssignmentToken(operator)) {
|
|
101
|
+
if ((0, compound_1.isCompoundAssignmentToken)(operator)) {
|
|
102
102
|
// +=, -=, etc...
|
|
103
|
-
const token = compound_1.unwrapCompoundAssignmentToken(operator);
|
|
104
|
-
return compound_1.transformCompoundAssignmentStatement(context, expression, expression.left, expression.right, token);
|
|
103
|
+
const token = (0, compound_1.unwrapCompoundAssignmentToken)(operator);
|
|
104
|
+
return (0, compound_1.transformCompoundAssignmentStatement)(context, expression, expression.left, expression.right, token);
|
|
105
105
|
}
|
|
106
106
|
else if (operator === ts.SyntaxKind.EqualsToken) {
|
|
107
|
-
return assignments_1.transformAssignmentStatement(context, expression);
|
|
107
|
+
return (0, assignments_1.transformAssignmentStatement)(context, expression);
|
|
108
108
|
}
|
|
109
109
|
else if (operator === ts.SyntaxKind.CommaToken) {
|
|
110
110
|
const statements = [
|
|
@@ -120,7 +120,7 @@ function transformNullishCoalescingExpression(context, node, transformedLeft, tr
|
|
|
120
120
|
// Check if we can take a shortcut to 'lhs or rhs' if the left-hand side cannot be 'false'.
|
|
121
121
|
const typeCanBeFalse = (type) => (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Boolean)) !== 0 ||
|
|
122
122
|
(type.flags & ts.TypeFlags.BooleanLiteral & ts.TypeFlags.PossiblyFalsy) !== 0;
|
|
123
|
-
if (typescript_1.typeCanSatisfy(context, lhsType, typeCanBeFalse)) {
|
|
123
|
+
if ((0, typescript_1.typeCanSatisfy)(context, lhsType, typeCanBeFalse)) {
|
|
124
124
|
// lhs can be false, transform to IIFE
|
|
125
125
|
const lhsIdentifier = lua.createIdentifier("____lhs");
|
|
126
126
|
const nilComparison = lua.createBinaryExpression(lua.cloneIdentifier(lhsIdentifier), lua.createNilLiteral(), lua.SyntaxKind.EqualityOperator);
|
|
@@ -9,16 +9,16 @@ function transformBlockOrStatement(context, statement) {
|
|
|
9
9
|
}
|
|
10
10
|
exports.transformBlockOrStatement = transformBlockOrStatement;
|
|
11
11
|
function transformScopeBlock(context, node, scopeType) {
|
|
12
|
-
scope_1.pushScope(context, scopeType);
|
|
13
|
-
const statements = scope_1.performHoisting(context, context.transformStatements(node.statements));
|
|
14
|
-
const scope = scope_1.popScope(context);
|
|
12
|
+
(0, scope_1.pushScope)(context, scopeType);
|
|
13
|
+
const statements = (0, scope_1.performHoisting)(context, context.transformStatements(node.statements));
|
|
14
|
+
const scope = (0, scope_1.popScope)(context);
|
|
15
15
|
return [lua.createBlock(statements, node), scope];
|
|
16
16
|
}
|
|
17
17
|
exports.transformScopeBlock = transformScopeBlock;
|
|
18
18
|
const transformBlock = (node, context) => {
|
|
19
|
-
scope_1.pushScope(context, scope_1.ScopeType.Block);
|
|
20
|
-
const statements = scope_1.performHoisting(context, context.transformStatements(node.statements));
|
|
21
|
-
scope_1.popScope(context);
|
|
19
|
+
(0, scope_1.pushScope)(context, scope_1.ScopeType.Block);
|
|
20
|
+
const statements = (0, scope_1.performHoisting)(context, context.transformStatements(node.statements));
|
|
21
|
+
(0, scope_1.popScope)(context);
|
|
22
22
|
return lua.createDoStatement(statements, node);
|
|
23
23
|
};
|
|
24
24
|
exports.transformBlock = transformBlock;
|
|
@@ -13,9 +13,9 @@ exports.transformBreakStatement = transformBreakStatement;
|
|
|
13
13
|
const transformContinueStatement = (statement, context) => {
|
|
14
14
|
var _a;
|
|
15
15
|
if (context.luaTarget === CompilerOptions_1.LuaTarget.Universal || context.luaTarget === CompilerOptions_1.LuaTarget.Lua51) {
|
|
16
|
-
context.diagnostics.push(diagnostics_1.unsupportedForTarget(statement, "Continue statement", CompilerOptions_1.LuaTarget.Lua51));
|
|
16
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedForTarget)(statement, "Continue statement", CompilerOptions_1.LuaTarget.Lua51));
|
|
17
17
|
}
|
|
18
|
-
const scope = scope_1.findScope(context, scope_1.ScopeType.Loop);
|
|
18
|
+
const scope = (0, scope_1.findScope)(context, scope_1.ScopeType.Loop);
|
|
19
19
|
if (scope) {
|
|
20
20
|
scope.loopContinued = true;
|
|
21
21
|
}
|
|
@@ -46,7 +46,7 @@ function transformSpreadableExpressionsIntoArrayConcatArguments(context, express
|
|
|
46
46
|
lastChunk.push(expression);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
return chunks.map(chunk => lua_ast_1.wrapInTable(...chunk.map(expression => context.transformExpression(expression))));
|
|
49
|
+
return chunks.map(chunk => (0, lua_ast_1.wrapInTable)(...chunk.map(expression => context.transformExpression(expression))));
|
|
50
50
|
}
|
|
51
51
|
function flattenSpreadExpressions(context, expressions) {
|
|
52
52
|
const [preSpreadExpressions, postSpreadExpressions] = getExpressionsBeforeAndAfterFirstSpread(expressions);
|
|
@@ -61,7 +61,7 @@ function flattenSpreadExpressions(context, expressions) {
|
|
|
61
61
|
}
|
|
62
62
|
// Use Array.concat and unpack the result of that as the last Expression
|
|
63
63
|
const concatArguments = transformSpreadableExpressionsIntoArrayConcatArguments(context, postSpreadExpressions);
|
|
64
|
-
const lastExpression = lua_ast_1.createUnpackCall(context, lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayConcat, undefined, ...concatArguments));
|
|
64
|
+
const lastExpression = (0, lua_ast_1.createUnpackCall)(context, (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayConcat, undefined, ...concatArguments));
|
|
65
65
|
return [...transformedPreSpreadExpressions, lastExpression];
|
|
66
66
|
}
|
|
67
67
|
exports.flattenSpreadExpressions = flattenSpreadExpressions;
|
|
@@ -77,7 +77,7 @@ function transformArguments(context, params, signature, callContext) {
|
|
|
77
77
|
const paramType = context.checker.getTypeAtLocation(param);
|
|
78
78
|
if (signatureParameter.valueDeclaration !== undefined) {
|
|
79
79
|
const signatureType = context.checker.getTypeAtLocation(signatureParameter.valueDeclaration);
|
|
80
|
-
assignment_validation_1.validateAssignment(context, param, paramType, signatureType, signatureParameter.name);
|
|
80
|
+
(0, assignment_validation_1.validateAssignment)(context, param, paramType, signatureType, signatureParameter.name);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -89,7 +89,7 @@ function transformElementAccessCall(context, left, args, signature) {
|
|
|
89
89
|
// Cache left-side if it has effects
|
|
90
90
|
// (function() local ____self = context; return ____self[argument](parameters); end)()
|
|
91
91
|
const argument = ts.isElementAccessExpression(left)
|
|
92
|
-
? access_1.transformElementAccessArgument(context, left)
|
|
92
|
+
? (0, access_1.transformElementAccessArgument)(context, left)
|
|
93
93
|
: lua.createStringLiteral(left.name.text);
|
|
94
94
|
const selfIdentifier = lua.createIdentifier("____self");
|
|
95
95
|
const callContext = context.transformExpression(left.expression);
|
|
@@ -100,11 +100,11 @@ function transformElementAccessCall(context, left, args, signature) {
|
|
|
100
100
|
}
|
|
101
101
|
function transformContextualCallExpression(context, node, args, signature) {
|
|
102
102
|
const left = ts.isCallExpression(node) ? node.expression : node.tag;
|
|
103
|
-
if (ts.isPropertyAccessExpression(left) && ts.isIdentifier(left.name) && safe_names_1.isValidLuaIdentifier(left.name.text)) {
|
|
103
|
+
if (ts.isPropertyAccessExpression(left) && ts.isIdentifier(left.name) && (0, safe_names_1.isValidLuaIdentifier)(left.name.text)) {
|
|
104
104
|
// table:name()
|
|
105
105
|
const table = context.transformExpression(left.expression);
|
|
106
106
|
if (ts.isOptionalChain(node)) {
|
|
107
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.OptionalMethodCall, node, table, lua.createStringLiteral(left.name.text, left.name), lua.createBooleanLiteral(node.questionDotToken !== undefined), // Require method is present if no ?.() call
|
|
107
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.OptionalMethodCall, node, table, lua.createStringLiteral(left.name.text, left.name), lua.createBooleanLiteral(node.questionDotToken !== undefined), // Require method is present if no ?.() call
|
|
108
108
|
...transformArguments(context, args, signature));
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
@@ -112,8 +112,8 @@ function transformContextualCallExpression(context, node, args, signature) {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
else if (ts.isElementAccessExpression(left) || ts.isPropertyAccessExpression(left)) {
|
|
115
|
-
if (typescript_1.isExpressionWithEvaluationEffect(left.expression)) {
|
|
116
|
-
return transform_1.transformToImmediatelyInvokedFunctionExpression(context, () => transformElementAccessCall(context, left, args, signature), node);
|
|
115
|
+
if ((0, typescript_1.isExpressionWithEvaluationEffect)(left.expression)) {
|
|
116
|
+
return (0, transform_1.transformToImmediatelyInvokedFunctionExpression)(context, () => transformElementAccessCall(context, left, args, signature), node);
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
119
119
|
const callContext = context.transformExpression(left.expression);
|
|
@@ -141,7 +141,7 @@ function transformPropertyCall(context, node) {
|
|
|
141
141
|
return lua.createCallExpression(context.transformExpression(node.expression), parameters);
|
|
142
142
|
}
|
|
143
143
|
const signatureDeclaration = signature === null || signature === void 0 ? void 0 : signature.getDeclaration();
|
|
144
|
-
if (!signatureDeclaration || function_context_1.getDeclarationContextType(context, signatureDeclaration) !== function_context_1.ContextType.Void) {
|
|
144
|
+
if (!signatureDeclaration || (0, function_context_1.getDeclarationContextType)(context, signatureDeclaration) !== function_context_1.ContextType.Void) {
|
|
145
145
|
// table:name()
|
|
146
146
|
return transformContextualCallExpression(context, node, node.arguments, signature);
|
|
147
147
|
}
|
|
@@ -150,7 +150,7 @@ function transformPropertyCall(context, node) {
|
|
|
150
150
|
const callPath = context.transformExpression(node.expression);
|
|
151
151
|
const parameters = transformArguments(context, node.arguments, signature);
|
|
152
152
|
if (ts.isOptionalChain(node)) {
|
|
153
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.OptionalFunctionCall, node, callPath, ...parameters);
|
|
153
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.OptionalFunctionCall, node, callPath, ...parameters);
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
156
156
|
return lua.createCallExpression(callPath, parameters, node);
|
|
@@ -160,7 +160,7 @@ function transformPropertyCall(context, node) {
|
|
|
160
160
|
function transformElementCall(context, node) {
|
|
161
161
|
const signature = context.checker.getResolvedSignature(node);
|
|
162
162
|
const signatureDeclaration = signature === null || signature === void 0 ? void 0 : signature.getDeclaration();
|
|
163
|
-
if (!signatureDeclaration || function_context_1.getDeclarationContextType(context, signatureDeclaration) !== function_context_1.ContextType.Void) {
|
|
163
|
+
if (!signatureDeclaration || (0, function_context_1.getDeclarationContextType)(context, signatureDeclaration) !== function_context_1.ContextType.Void) {
|
|
164
164
|
// A contextual parameter must be given to this call expression
|
|
165
165
|
return transformContextualCallExpression(context, node, node.arguments, signature);
|
|
166
166
|
}
|
|
@@ -172,41 +172,41 @@ function transformElementCall(context, node) {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
const transformCallExpression = (node, context) => {
|
|
175
|
-
const wrapResultInTable = multi_1.isMultiReturnCall(context, node) && multi_1.shouldMultiReturnCallBeWrapped(context, node);
|
|
175
|
+
const wrapResultInTable = (0, multi_1.isMultiReturnCall)(context, node) && (0, multi_1.shouldMultiReturnCallBeWrapped)(context, node);
|
|
176
176
|
const wrapResultInOptional = ts.isOptionalChain(node);
|
|
177
|
-
const builtinResult = builtins_1.transformBuiltinCallExpression(context, node);
|
|
177
|
+
const builtinResult = (0, builtins_1.transformBuiltinCallExpression)(context, node);
|
|
178
178
|
if (builtinResult) {
|
|
179
|
-
return wrapResultInTable ? lua_ast_1.wrapInTable(builtinResult) : builtinResult;
|
|
179
|
+
return wrapResultInTable ? (0, lua_ast_1.wrapInTable)(builtinResult) : builtinResult;
|
|
180
180
|
}
|
|
181
|
-
if (annotations_1.isTupleReturnCall(context, node)) {
|
|
182
|
-
context.diagnostics.push(diagnostics_1.annotationRemoved(node, annotations_1.AnnotationKind.TupleReturn));
|
|
181
|
+
if ((0, annotations_1.isTupleReturnCall)(context, node)) {
|
|
182
|
+
context.diagnostics.push((0, diagnostics_1.annotationRemoved)(node, annotations_1.AnnotationKind.TupleReturn));
|
|
183
183
|
}
|
|
184
|
-
if (operators_1.isOperatorMapping(context, node)) {
|
|
185
|
-
return operators_1.transformOperatorMappingExpression(context, node);
|
|
184
|
+
if ((0, operators_1.isOperatorMapping)(context, node)) {
|
|
185
|
+
return (0, operators_1.transformOperatorMappingExpression)(context, node);
|
|
186
186
|
}
|
|
187
|
-
if (table_1.isTableDeleteCall(context, node)) {
|
|
188
|
-
context.diagnostics.push(diagnostics_1.invalidTableDeleteExpression(node));
|
|
189
|
-
return transform_1.transformToImmediatelyInvokedFunctionExpression(context, () => ({ statements: table_1.transformTableDeleteExpression(context, node), result: lua.createNilLiteral() }), node);
|
|
187
|
+
if ((0, table_1.isTableDeleteCall)(context, node)) {
|
|
188
|
+
context.diagnostics.push((0, diagnostics_1.invalidTableDeleteExpression)(node));
|
|
189
|
+
return (0, transform_1.transformToImmediatelyInvokedFunctionExpression)(context, () => ({ statements: (0, table_1.transformTableDeleteExpression)(context, node), result: lua.createNilLiteral() }), node);
|
|
190
190
|
}
|
|
191
|
-
if (table_1.isTableGetCall(context, node)) {
|
|
192
|
-
return table_1.transformTableGetExpression(context, node);
|
|
191
|
+
if ((0, table_1.isTableGetCall)(context, node)) {
|
|
192
|
+
return (0, table_1.transformTableGetExpression)(context, node);
|
|
193
193
|
}
|
|
194
|
-
if (table_1.isTableHasCall(context, node)) {
|
|
195
|
-
return table_1.transformTableHasExpression(context, node);
|
|
194
|
+
if ((0, table_1.isTableHasCall)(context, node)) {
|
|
195
|
+
return (0, table_1.transformTableHasExpression)(context, node);
|
|
196
196
|
}
|
|
197
|
-
if (table_1.isTableSetCall(context, node)) {
|
|
198
|
-
context.diagnostics.push(diagnostics_1.invalidTableSetExpression(node));
|
|
199
|
-
return transform_1.transformToImmediatelyInvokedFunctionExpression(context, () => ({ statements: table_1.transformTableSetExpression(context, node), result: lua.createNilLiteral() }), node);
|
|
197
|
+
if ((0, table_1.isTableSetCall)(context, node)) {
|
|
198
|
+
context.diagnostics.push((0, diagnostics_1.invalidTableSetExpression)(node));
|
|
199
|
+
return (0, transform_1.transformToImmediatelyInvokedFunctionExpression)(context, () => ({ statements: (0, table_1.transformTableSetExpression)(context, node), result: lua.createNilLiteral() }), node);
|
|
200
200
|
}
|
|
201
201
|
if (ts.isPropertyAccessExpression(node.expression)) {
|
|
202
202
|
const ownerType = context.checker.getTypeAtLocation(node.expression.expression);
|
|
203
|
-
const annotations = annotations_1.getTypeAnnotations(ownerType);
|
|
203
|
+
const annotations = (0, annotations_1.getTypeAnnotations)(ownerType);
|
|
204
204
|
if (annotations.has(annotations_1.AnnotationKind.LuaTable)) {
|
|
205
|
-
context.diagnostics.push(diagnostics_1.annotationRemoved(node, annotations_1.AnnotationKind.LuaTable));
|
|
205
|
+
context.diagnostics.push((0, diagnostics_1.annotationRemoved)(node, annotations_1.AnnotationKind.LuaTable));
|
|
206
206
|
}
|
|
207
207
|
const result = transformPropertyCall(context, node);
|
|
208
208
|
// transformPropertyCall already wraps optional so no need to do so here
|
|
209
|
-
return wrapResultInTable ? lua_ast_1.wrapInTable(result) : result;
|
|
209
|
+
return wrapResultInTable ? (0, lua_ast_1.wrapInTable)(result) : result;
|
|
210
210
|
}
|
|
211
211
|
if (ts.isElementAccessExpression(node.expression)) {
|
|
212
212
|
const result = transformElementCall(context, node);
|
|
@@ -221,7 +221,7 @@ const transformCallExpression = (node, context) => {
|
|
|
221
221
|
const callPath = context.transformExpression(node.expression);
|
|
222
222
|
const signatureDeclaration = signature === null || signature === void 0 ? void 0 : signature.getDeclaration();
|
|
223
223
|
let parameters = [];
|
|
224
|
-
if (signatureDeclaration && function_context_1.getDeclarationContextType(context, signatureDeclaration) === function_context_1.ContextType.Void) {
|
|
224
|
+
if (signatureDeclaration && (0, function_context_1.getDeclarationContextType)(context, signatureDeclaration) === function_context_1.ContextType.Void) {
|
|
225
225
|
parameters = transformArguments(context, node.arguments, signature);
|
|
226
226
|
}
|
|
227
227
|
else {
|
|
@@ -234,15 +234,15 @@ const transformCallExpression = (node, context) => {
|
|
|
234
234
|
exports.transformCallExpression = transformCallExpression;
|
|
235
235
|
function wrapIfRequired(context, shouldWrapInTable, shouldWrapOptional, call, node) {
|
|
236
236
|
const wrappedOptional = shouldWrapOptional ? wrapOptionalCall(context, call, node) : call;
|
|
237
|
-
return shouldWrapInTable ? lua_ast_1.wrapInTable(wrappedOptional) : wrappedOptional;
|
|
237
|
+
return shouldWrapInTable ? (0, lua_ast_1.wrapInTable)(wrappedOptional) : wrappedOptional;
|
|
238
238
|
}
|
|
239
239
|
function wrapOptionalCall(context, call, node) {
|
|
240
240
|
if (lua.isMethodCallExpression(call)) {
|
|
241
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.OptionalMethodCall, node, call.prefixExpression, lua.createStringLiteral(call.name.text), lua.createBooleanLiteral(node.questionDotToken !== undefined), // Require method is present if no ?.() call
|
|
241
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.OptionalMethodCall, node, call.prefixExpression, lua.createStringLiteral(call.name.text), lua.createBooleanLiteral(node.questionDotToken !== undefined), // Require method is present if no ?.() call
|
|
242
242
|
...call.params);
|
|
243
243
|
}
|
|
244
244
|
else {
|
|
245
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.OptionalFunctionCall, node, call.expression, ...call.params);
|
|
245
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.OptionalFunctionCall, node, call.expression, ...call.params);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
//# sourceMappingURL=call.js.map
|
|
@@ -9,9 +9,9 @@ const lualib_1 = require("../../utils/lualib");
|
|
|
9
9
|
function transformDecoratorExpression(context, decorator) {
|
|
10
10
|
const expression = decorator.expression;
|
|
11
11
|
const type = context.checker.getTypeAtLocation(expression);
|
|
12
|
-
const callContext = function_context_1.getFunctionContextType(context, type);
|
|
12
|
+
const callContext = (0, function_context_1.getFunctionContextType)(context, type);
|
|
13
13
|
if (callContext === function_context_1.ContextType.Void) {
|
|
14
|
-
context.diagnostics.push(diagnostics_1.decoratorInvalidContext(decorator));
|
|
14
|
+
context.diagnostics.push((0, diagnostics_1.decoratorInvalidContext)(decorator));
|
|
15
15
|
}
|
|
16
16
|
return context.transformExpression(expression);
|
|
17
17
|
}
|
|
@@ -26,7 +26,7 @@ function createDecoratingExpression(context, kind, decorators, targetTableName,
|
|
|
26
26
|
kind === ts.SyntaxKind.SetAccessor;
|
|
27
27
|
trailingExpressions.push(isMethodOrAccessor ? lua.createBooleanLiteral(true) : lua.createNilLiteral());
|
|
28
28
|
}
|
|
29
|
-
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.Decorate, undefined, ...trailingExpressions);
|
|
29
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.Decorate, undefined, ...trailingExpressions);
|
|
30
30
|
}
|
|
31
31
|
exports.createDecoratingExpression = createDecoratingExpression;
|
|
32
32
|
//# sourceMappingURL=decorators.js.map
|