typescript-to-lua 1.1.1 → 1.3.2
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 +28 -0
- package/dist/LuaAST.d.ts +1 -0
- package/dist/LuaAST.js +10 -2
- package/dist/LuaLib.d.ts +4 -3
- package/dist/LuaLib.js +6 -5
- package/dist/LuaPrinter.d.ts +11 -4
- package/dist/LuaPrinter.js +58 -15
- package/dist/lualib/ArrayFlat.lua +1 -1
- package/dist/lualib/ArrayFlatMap.lua +1 -1
- package/dist/lualib/ArrayIsArray.lua +1 -1
- package/dist/lualib/ArrayReduce.lua +7 -1
- package/dist/lualib/ArrayReduceRight.lua +7 -1
- package/dist/lualib/ArraySetLength.lua +1 -1
- package/dist/lualib/ArraySplice.lua +5 -5
- package/dist/lualib/Await.lua +21 -13
- package/dist/lualib/CloneDescriptor.lua +7 -7
- package/dist/lualib/Decorate.lua +1 -1
- package/dist/lualib/DelegatedYield.lua +1 -3
- package/dist/lualib/Delete.lua +6 -6
- package/dist/lualib/Error.lua +47 -44
- package/dist/lualib/Generator.lua +1 -5
- package/dist/lualib/InstanceOf.lua +1 -1
- package/dist/lualib/InstanceOfObject.lua +1 -1
- package/dist/lualib/Map.lua +130 -134
- package/dist/lualib/MathSign.lua +8 -0
- package/dist/lualib/Number.lua +1 -1
- package/dist/lualib/NumberIsFinite.lua +1 -1
- package/dist/lualib/NumberToString.lua +3 -5
- package/dist/lualib/ObjectDefineProperty.lua +40 -8
- package/dist/lualib/ParseFloat.lua +9 -5
- package/dist/lualib/ParseInt.lua +15 -3
- package/dist/lualib/Promise.lua +28 -24
- package/dist/lualib/Set.lua +119 -123
- package/dist/lualib/SetDescriptor.lua +7 -1
- package/dist/lualib/SourceMapTraceBack.lua +1 -1
- package/dist/lualib/SparseArrayNew.lua +5 -0
- package/dist/lualib/SparseArrayPush.lua +9 -0
- package/dist/lualib/SparseArraySpread.lua +4 -0
- package/dist/lualib/StringAccess.lua +1 -1
- package/dist/lualib/StringCharCodeAt.lua +1 -1
- package/dist/lualib/StringEndsWith.lua +2 -2
- package/dist/lualib/StringPadEnd.lua +2 -2
- package/dist/lualib/StringPadStart.lua +2 -2
- package/dist/lualib/StringReplace.lua +7 -1
- package/dist/lualib/StringSlice.lua +2 -2
- package/dist/lualib/StringSplit.lua +3 -3
- package/dist/lualib/StringStartsWith.lua +1 -1
- package/dist/lualib/StringSubstr.lua +1 -1
- package/dist/lualib/StringSubstring.lua +2 -2
- package/dist/lualib/Symbol.lua +3 -5
- package/dist/lualib/WeakMap.lua +40 -42
- package/dist/lualib/WeakSet.lua +36 -38
- package/dist/lualib/lualib_bundle.lua +804 -735
- package/dist/transformation/builtins/array.js +1 -2
- package/dist/transformation/builtins/function.js +6 -4
- package/dist/transformation/builtins/index.d.ts +1 -1
- package/dist/transformation/builtins/index.js +41 -6
- package/dist/transformation/builtins/math.js +7 -1
- package/dist/transformation/builtins/object.d.ts +2 -1
- package/dist/transformation/builtins/object.js +1 -2
- package/dist/transformation/builtins/string.js +1 -2
- package/dist/transformation/context/context.d.ts +12 -0
- package/dist/transformation/context/context.js +102 -3
- package/dist/transformation/utils/diagnostics.d.ts +9 -6
- package/dist/transformation/utils/diagnostics.js +4 -3
- package/dist/transformation/utils/language-extensions.d.ts +2 -0
- package/dist/transformation/utils/language-extensions.js +7 -1
- package/dist/transformation/utils/lua-ast.d.ts +0 -1
- package/dist/transformation/utils/lua-ast.js +14 -23
- package/dist/transformation/utils/preceding-statements.d.ts +3 -0
- package/dist/transformation/utils/preceding-statements.js +11 -0
- package/dist/transformation/utils/safe-names.d.ts +4 -2
- package/dist/transformation/utils/safe-names.js +11 -5
- package/dist/transformation/utils/scope.d.ts +3 -1
- package/dist/transformation/utils/scope.js +9 -1
- package/dist/transformation/utils/typescript/index.d.ts +1 -0
- package/dist/transformation/utils/typescript/index.js +16 -1
- package/dist/transformation/utils/typescript/types.d.ts +3 -1
- package/dist/transformation/utils/typescript/types.js +40 -13
- package/dist/transformation/visitors/access.d.ts +3 -0
- package/dist/transformation/visitors/access.js +63 -36
- package/dist/transformation/visitors/binary-expression/assignments.d.ts +3 -2
- package/dist/transformation/visitors/binary-expression/assignments.js +66 -57
- package/dist/transformation/visitors/binary-expression/compound.d.ts +5 -4
- package/dist/transformation/visitors/binary-expression/compound.js +66 -68
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.d.ts +2 -2
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +54 -25
- package/dist/transformation/visitors/binary-expression/index.d.ts +3 -1
- package/dist/transformation/visitors/binary-expression/index.js +65 -23
- package/dist/transformation/visitors/call.d.ts +3 -2
- package/dist/transformation/visitors/call.js +95 -141
- package/dist/transformation/visitors/class/index.js +5 -8
- package/dist/transformation/visitors/class/members/constructor.js +3 -1
- package/dist/transformation/visitors/class/new.js +4 -6
- package/dist/transformation/visitors/conditional.js +30 -37
- package/dist/transformation/visitors/delete.js +4 -0
- package/dist/transformation/visitors/errors.js +11 -9
- package/dist/transformation/visitors/expression-list.d.ts +7 -0
- package/dist/transformation/visitors/expression-list.js +120 -0
- package/dist/transformation/visitors/expression-statement.d.ts +3 -1
- package/dist/transformation/visitors/expression-statement.js +21 -19
- package/dist/transformation/visitors/function.d.ts +2 -0
- package/dist/transformation/visitors/function.js +63 -13
- package/dist/transformation/visitors/identifier.js +5 -0
- package/dist/transformation/visitors/language-extensions/index.d.ts +4 -0
- package/dist/transformation/visitors/language-extensions/index.js +17 -0
- package/dist/transformation/visitors/language-extensions/operators.d.ts +1 -1
- package/dist/transformation/visitors/language-extensions/operators.js +7 -2
- package/dist/transformation/visitors/language-extensions/pairsIterable.d.ts +5 -0
- package/dist/transformation/visitors/language-extensions/pairsIterable.js +53 -0
- package/dist/transformation/visitors/language-extensions/table.d.ts +1 -8
- package/dist/transformation/visitors/language-extensions/table.js +55 -53
- package/dist/transformation/visitors/literal.js +69 -16
- package/dist/transformation/visitors/loops/do-while.js +34 -8
- package/dist/transformation/visitors/loops/for-of.js +4 -0
- package/dist/transformation/visitors/loops/for.js +25 -5
- package/dist/transformation/visitors/loops/utils.d.ts +1 -0
- package/dist/transformation/visitors/loops/utils.js +19 -3
- package/dist/transformation/visitors/modules/export.js +1 -1
- package/dist/transformation/visitors/namespace.js +1 -1
- package/dist/transformation/visitors/optional-chaining.d.ts +16 -0
- package/dist/transformation/visitors/optional-chaining.js +172 -0
- package/dist/transformation/visitors/sourceFile.js +4 -1
- package/dist/transformation/visitors/spread.js +14 -7
- package/dist/transformation/visitors/switch.js +29 -9
- package/dist/transformation/visitors/template.js +5 -2
- package/dist/transformation/visitors/typeof.js +3 -1
- package/dist/transformation/visitors/variable-declaration.js +37 -8
- package/dist/transformation/visitors/void.d.ts +1 -4
- package/dist/transformation/visitors/void.js +7 -12
- package/dist/transpilation/transformers.js +4 -1
- package/dist/transpilation/utils.js +2 -1
- package/language-extensions/index.d.ts +11 -1
- package/package.json +5 -5
- package/dist/lualib/OptionalChainAccess.lua +0 -6
- package/dist/lualib/OptionalFunctionCall.lua +0 -6
- package/dist/lualib/OptionalMethodCall.lua +0 -11
- package/dist/transformation/utils/transform.d.ts +0 -8
- package/dist/transformation/utils/transform.js +0 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformCallExpression = exports.transformContextualCallExpression = exports.transformArguments = exports.
|
|
3
|
+
exports.transformCallExpression = exports.transformContextualCallExpression = exports.transformCallAndArguments = exports.transformArguments = exports.validateArguments = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const lua = require("../../LuaAST");
|
|
6
6
|
const builtins_1 = require("../builtins");
|
|
@@ -8,124 +8,103 @@ const annotations_1 = require("../utils/annotations");
|
|
|
8
8
|
const assignment_validation_1 = require("../utils/assignment-validation");
|
|
9
9
|
const function_context_1 = require("../utils/function-context");
|
|
10
10
|
const lua_ast_1 = require("../utils/lua-ast");
|
|
11
|
-
const lualib_1 = require("../utils/lualib");
|
|
12
11
|
const safe_names_1 = require("../utils/safe-names");
|
|
13
12
|
const typescript_1 = require("../utils/typescript");
|
|
14
13
|
const access_1 = require("./access");
|
|
15
14
|
const multi_1 = require("./language-extensions/multi");
|
|
16
|
-
const operators_1 = require("./language-extensions/operators");
|
|
17
|
-
const table_1 = require("./language-extensions/table");
|
|
18
15
|
const diagnostics_1 = require("../utils/diagnostics");
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (ts.isSpreadElement(expression)) {
|
|
34
|
-
chunks.push([expression]);
|
|
35
|
-
const next = expressions[index + 1];
|
|
36
|
-
if (next && !ts.isSpreadElement(next)) {
|
|
37
|
-
chunks.push([]);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
let lastChunk = chunks[chunks.length - 1];
|
|
42
|
-
if (!lastChunk) {
|
|
43
|
-
lastChunk = [];
|
|
44
|
-
chunks.push(lastChunk);
|
|
45
|
-
}
|
|
46
|
-
lastChunk.push(expression);
|
|
16
|
+
const expression_list_1 = require("./expression-list");
|
|
17
|
+
const preceding_statements_1 = require("../utils/preceding-statements");
|
|
18
|
+
const optional_chaining_1 = require("./optional-chaining");
|
|
19
|
+
const language_extensions_1 = require("./language-extensions");
|
|
20
|
+
function validateArguments(context, params, signature) {
|
|
21
|
+
if (!signature || signature.parameters.length < params.length) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
for (const [index, param] of params.entries()) {
|
|
25
|
+
const signatureParameter = signature.parameters[index];
|
|
26
|
+
const paramType = context.checker.getTypeAtLocation(param);
|
|
27
|
+
if (signatureParameter.valueDeclaration !== undefined) {
|
|
28
|
+
const signatureType = context.checker.getTypeAtLocation(signatureParameter.valueDeclaration);
|
|
29
|
+
(0, assignment_validation_1.validateAssignment)(context, param, paramType, signatureType, signatureParameter.name);
|
|
47
30
|
}
|
|
48
31
|
}
|
|
49
|
-
return chunks.map(chunk => (0, lua_ast_1.wrapInTable)(...chunk.map(expression => context.transformExpression(expression))));
|
|
50
32
|
}
|
|
51
|
-
|
|
52
|
-
const [preSpreadExpressions, postSpreadExpressions] = getExpressionsBeforeAndAfterFirstSpread(expressions);
|
|
53
|
-
const transformedPreSpreadExpressions = preSpreadExpressions.map(a => context.transformExpression(a));
|
|
54
|
-
// Nothing special required
|
|
55
|
-
if (postSpreadExpressions.length === 0) {
|
|
56
|
-
return transformedPreSpreadExpressions;
|
|
57
|
-
}
|
|
58
|
-
// Only one spread element at the end? Will work as expected
|
|
59
|
-
if (postSpreadExpressions.length === 1) {
|
|
60
|
-
return [...transformedPreSpreadExpressions, context.transformExpression(postSpreadExpressions[0])];
|
|
61
|
-
}
|
|
62
|
-
// Use Array.concat and unpack the result of that as the last Expression
|
|
63
|
-
const concatArguments = transformSpreadableExpressionsIntoArrayConcatArguments(context, postSpreadExpressions);
|
|
64
|
-
const lastExpression = (0, lua_ast_1.createUnpackCall)(context, (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayConcat, undefined, ...concatArguments));
|
|
65
|
-
return [...transformedPreSpreadExpressions, lastExpression];
|
|
66
|
-
}
|
|
67
|
-
exports.flattenSpreadExpressions = flattenSpreadExpressions;
|
|
33
|
+
exports.validateArguments = validateArguments;
|
|
68
34
|
function transformArguments(context, params, signature, callContext) {
|
|
69
|
-
|
|
70
|
-
|
|
35
|
+
validateArguments(context, params, signature);
|
|
36
|
+
return (0, expression_list_1.transformExpressionList)(context, callContext ? [callContext, ...params] : params);
|
|
37
|
+
}
|
|
38
|
+
exports.transformArguments = transformArguments;
|
|
39
|
+
function transformCallWithArguments(context, callExpression, transformedArguments, argPrecedingStatements, callContext) {
|
|
40
|
+
let call = context.transformExpression(callExpression);
|
|
41
|
+
let transformedContext;
|
|
71
42
|
if (callContext) {
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const paramType = context.checker.getTypeAtLocation(param);
|
|
78
|
-
if (signatureParameter.valueDeclaration !== undefined) {
|
|
79
|
-
const signatureType = context.checker.getTypeAtLocation(signatureParameter.valueDeclaration);
|
|
80
|
-
(0, assignment_validation_1.validateAssignment)(context, param, paramType, signatureType, signatureParameter.name);
|
|
81
|
-
}
|
|
43
|
+
transformedContext = context.transformExpression(callContext);
|
|
44
|
+
}
|
|
45
|
+
if (argPrecedingStatements.length > 0) {
|
|
46
|
+
if (transformedContext) {
|
|
47
|
+
transformedContext = (0, expression_list_1.moveToPrecedingTemp)(context, transformedContext, callContext);
|
|
82
48
|
}
|
|
49
|
+
call = (0, expression_list_1.moveToPrecedingTemp)(context, call, callExpression);
|
|
50
|
+
context.addPrecedingStatements(argPrecedingStatements);
|
|
83
51
|
}
|
|
84
|
-
|
|
52
|
+
if (transformedContext) {
|
|
53
|
+
transformedArguments.unshift(transformedContext);
|
|
54
|
+
}
|
|
55
|
+
return [call, transformedArguments];
|
|
85
56
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
57
|
+
function transformCallAndArguments(context, callExpression, params, signature, callContext) {
|
|
58
|
+
const [argPrecedingStatements, transformedArguments] = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => transformArguments(context, params, signature, callContext));
|
|
59
|
+
return transformCallWithArguments(context, callExpression, transformedArguments, argPrecedingStatements);
|
|
60
|
+
}
|
|
61
|
+
exports.transformCallAndArguments = transformCallAndArguments;
|
|
62
|
+
function transformElementAccessCall(context, left, transformedArguments, argPrecedingStatements) {
|
|
89
63
|
// Cache left-side if it has effects
|
|
90
|
-
//
|
|
64
|
+
// local ____self = context; return ____self[argument](parameters);
|
|
65
|
+
const selfIdentifier = lua.createIdentifier(context.createTempName("self"));
|
|
66
|
+
const callContext = context.transformExpression(left.expression);
|
|
67
|
+
const selfAssignment = lua.createVariableDeclarationStatement(selfIdentifier, callContext);
|
|
68
|
+
context.addPrecedingStatements(selfAssignment);
|
|
91
69
|
const argument = ts.isElementAccessExpression(left)
|
|
92
70
|
? (0, access_1.transformElementAccessArgument)(context, left)
|
|
93
71
|
: lua.createStringLiteral(left.name.text);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
72
|
+
let index = lua.createTableIndexExpression(selfIdentifier, argument);
|
|
73
|
+
if (argPrecedingStatements.length > 0) {
|
|
74
|
+
// Cache index in temp if args had preceding statements
|
|
75
|
+
index = (0, expression_list_1.moveToPrecedingTemp)(context, index);
|
|
76
|
+
context.addPrecedingStatements(argPrecedingStatements);
|
|
77
|
+
}
|
|
78
|
+
return lua.createCallExpression(index, [selfIdentifier, ...transformedArguments]);
|
|
100
79
|
}
|
|
101
80
|
function transformContextualCallExpression(context, node, args, signature) {
|
|
81
|
+
if (ts.isOptionalChain(node)) {
|
|
82
|
+
return (0, optional_chaining_1.transformOptionalChain)(context, node);
|
|
83
|
+
}
|
|
102
84
|
const left = ts.isCallExpression(node) ? node.expression : node.tag;
|
|
103
|
-
|
|
85
|
+
let [argPrecedingStatements, transformedArguments] = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => transformArguments(context, args, signature));
|
|
86
|
+
if (ts.isPropertyAccessExpression(left) &&
|
|
87
|
+
ts.isIdentifier(left.name) &&
|
|
88
|
+
(0, safe_names_1.isValidLuaIdentifier)(left.name.text, context.options) &&
|
|
89
|
+
argPrecedingStatements.length === 0) {
|
|
104
90
|
// table:name()
|
|
105
91
|
const table = context.transformExpression(left.expression);
|
|
106
|
-
|
|
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
|
-
...transformArguments(context, args, signature));
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
return lua.createMethodCallExpression(table, lua.createIdentifier(left.name.text, left.name), transformArguments(context, args, signature), node);
|
|
112
|
-
}
|
|
92
|
+
return lua.createMethodCallExpression(table, lua.createIdentifier(left.name.text, left.name), transformedArguments, node);
|
|
113
93
|
}
|
|
114
94
|
else if (ts.isElementAccessExpression(left) || ts.isPropertyAccessExpression(left)) {
|
|
115
95
|
if ((0, typescript_1.isExpressionWithEvaluationEffect)(left.expression)) {
|
|
116
|
-
return
|
|
96
|
+
return transformElementAccessCall(context, left, transformedArguments, argPrecedingStatements);
|
|
117
97
|
}
|
|
118
98
|
else {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return lua.createCallExpression(expression, [callContext, ...transformedArguments]);
|
|
99
|
+
let expression;
|
|
100
|
+
[expression, transformedArguments] = transformCallWithArguments(context, left, transformedArguments, argPrecedingStatements, left.expression);
|
|
101
|
+
return lua.createCallExpression(expression, transformedArguments, node);
|
|
123
102
|
}
|
|
124
103
|
}
|
|
125
104
|
else if (ts.isIdentifier(left)) {
|
|
126
105
|
const callContext = context.isStrict ? ts.factory.createNull() : ts.factory.createIdentifier("_G");
|
|
127
|
-
|
|
128
|
-
|
|
106
|
+
let expression;
|
|
107
|
+
[expression, transformedArguments] = transformCallWithArguments(context, left, transformedArguments, argPrecedingStatements, callContext);
|
|
129
108
|
return lua.createCallExpression(expression, transformedArguments, node);
|
|
130
109
|
}
|
|
131
110
|
else {
|
|
@@ -147,14 +126,8 @@ function transformPropertyCall(context, node) {
|
|
|
147
126
|
}
|
|
148
127
|
else {
|
|
149
128
|
// table.name()
|
|
150
|
-
const callPath = context.
|
|
151
|
-
|
|
152
|
-
if (ts.isOptionalChain(node)) {
|
|
153
|
-
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.OptionalFunctionCall, node, callPath, ...parameters);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
return lua.createCallExpression(callPath, parameters, node);
|
|
157
|
-
}
|
|
129
|
+
const [callPath, parameters] = transformCallAndArguments(context, node.expression, node.arguments, signature);
|
|
130
|
+
return lua.createCallExpression(callPath, parameters, node);
|
|
158
131
|
}
|
|
159
132
|
}
|
|
160
133
|
function transformElementCall(context, node) {
|
|
@@ -166,37 +139,26 @@ function transformElementCall(context, node) {
|
|
|
166
139
|
}
|
|
167
140
|
else {
|
|
168
141
|
// No context
|
|
169
|
-
const expression = context.
|
|
170
|
-
const parameters = transformArguments(context, node.arguments, signature);
|
|
142
|
+
const [expression, parameters] = transformCallAndArguments(context, node.expression, node.arguments, signature);
|
|
171
143
|
return lua.createCallExpression(expression, parameters);
|
|
172
144
|
}
|
|
173
145
|
}
|
|
174
146
|
const transformCallExpression = (node, context) => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (builtinResult) {
|
|
179
|
-
return wrapResultInTable ? (0, lua_ast_1.wrapInTable)(builtinResult) : builtinResult;
|
|
147
|
+
var _a;
|
|
148
|
+
if (ts.isOptionalChain(node)) {
|
|
149
|
+
return (0, optional_chaining_1.transformOptionalChain)(context, node);
|
|
180
150
|
}
|
|
151
|
+
const optionalContinuation = ts.isIdentifier(node.expression)
|
|
152
|
+
? (0, optional_chaining_1.getOptionalContinuationData)(node.expression)
|
|
153
|
+
: undefined;
|
|
154
|
+
const wrapResultInTable = (0, multi_1.isMultiReturnCall)(context, node) && (0, multi_1.shouldMultiReturnCallBeWrapped)(context, node);
|
|
181
155
|
if ((0, annotations_1.isTupleReturnCall)(context, node)) {
|
|
182
156
|
context.diagnostics.push((0, diagnostics_1.annotationRemoved)(node, annotations_1.AnnotationKind.TupleReturn));
|
|
183
157
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
}
|
|
191
|
-
if ((0, table_1.isTableGetCall)(context, node)) {
|
|
192
|
-
return (0, table_1.transformTableGetExpression)(context, node);
|
|
193
|
-
}
|
|
194
|
-
if ((0, table_1.isTableHasCall)(context, node)) {
|
|
195
|
-
return (0, table_1.transformTableHasExpression)(context, node);
|
|
196
|
-
}
|
|
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);
|
|
158
|
+
const builtinOrExtensionResult = (_a = (0, builtins_1.transformBuiltinCallExpression)(context, node, optionalContinuation !== undefined)) !== null && _a !== void 0 ? _a : (0, language_extensions_1.transformLanguageExtensionCallExpression)(context, node, optionalContinuation !== undefined);
|
|
159
|
+
if (builtinOrExtensionResult) {
|
|
160
|
+
// unsupportedOptionalCall diagnostic already present
|
|
161
|
+
return wrapResultInTable ? (0, lua_ast_1.wrapInTable)(builtinOrExtensionResult) : builtinOrExtensionResult;
|
|
200
162
|
}
|
|
201
163
|
if (ts.isPropertyAccessExpression(node.expression)) {
|
|
202
164
|
const ownerType = context.checker.getTypeAtLocation(node.expression.expression);
|
|
@@ -205,12 +167,11 @@ const transformCallExpression = (node, context) => {
|
|
|
205
167
|
context.diagnostics.push((0, diagnostics_1.annotationRemoved)(node, annotations_1.AnnotationKind.LuaTable));
|
|
206
168
|
}
|
|
207
169
|
const result = transformPropertyCall(context, node);
|
|
208
|
-
// transformPropertyCall already wraps optional so no need to do so here
|
|
209
170
|
return wrapResultInTable ? (0, lua_ast_1.wrapInTable)(result) : result;
|
|
210
171
|
}
|
|
211
172
|
if (ts.isElementAccessExpression(node.expression)) {
|
|
212
173
|
const result = transformElementCall(context, node);
|
|
213
|
-
return
|
|
174
|
+
return wrapResultInTable ? (0, lua_ast_1.wrapInTable)(result) : result;
|
|
214
175
|
}
|
|
215
176
|
const signature = context.checker.getResolvedSignature(node);
|
|
216
177
|
// Handle super calls properly
|
|
@@ -218,31 +179,24 @@ const transformCallExpression = (node, context) => {
|
|
|
218
179
|
const parameters = transformArguments(context, node.arguments, signature, ts.factory.createThis());
|
|
219
180
|
return lua.createCallExpression(lua.createTableIndexExpression(context.transformExpression(ts.factory.createSuper()), lua.createStringLiteral("____constructor")), parameters);
|
|
220
181
|
}
|
|
221
|
-
const callPath = context.transformExpression(node.expression);
|
|
222
182
|
const signatureDeclaration = signature === null || signature === void 0 ? void 0 : signature.getDeclaration();
|
|
223
|
-
let
|
|
224
|
-
|
|
225
|
-
|
|
183
|
+
let callPath;
|
|
184
|
+
let parameters;
|
|
185
|
+
const isContextualCall = !signatureDeclaration || (0, function_context_1.getDeclarationContextType)(context, signatureDeclaration) !== function_context_1.ContextType.Void;
|
|
186
|
+
if (!isContextualCall) {
|
|
187
|
+
[callPath, parameters] = transformCallAndArguments(context, node.expression, node.arguments, signature);
|
|
226
188
|
}
|
|
227
189
|
else {
|
|
228
|
-
|
|
229
|
-
|
|
190
|
+
// if is optionalContinuation, context will be handled by transformOptionalChain.
|
|
191
|
+
const useGlobalContext = !context.isStrict && optionalContinuation === undefined;
|
|
192
|
+
const callContext = useGlobalContext ? ts.factory.createIdentifier("_G") : ts.factory.createNull();
|
|
193
|
+
[callPath, parameters] = transformCallAndArguments(context, node.expression, node.arguments, signature, callContext);
|
|
230
194
|
}
|
|
231
195
|
const callExpression = lua.createCallExpression(callPath, parameters, node);
|
|
232
|
-
|
|
196
|
+
if (optionalContinuation && isContextualCall) {
|
|
197
|
+
optionalContinuation.contextualCall = callExpression;
|
|
198
|
+
}
|
|
199
|
+
return wrapResultInTable ? (0, lua_ast_1.wrapInTable)(callExpression) : callExpression;
|
|
233
200
|
};
|
|
234
201
|
exports.transformCallExpression = transformCallExpression;
|
|
235
|
-
function wrapIfRequired(context, shouldWrapInTable, shouldWrapOptional, call, node) {
|
|
236
|
-
const wrappedOptional = shouldWrapOptional ? wrapOptionalCall(context, call, node) : call;
|
|
237
|
-
return shouldWrapInTable ? (0, lua_ast_1.wrapInTable)(wrappedOptional) : wrappedOptional;
|
|
238
|
-
}
|
|
239
|
-
function wrapOptionalCall(context, call, node) {
|
|
240
|
-
if (lua.isMethodCallExpression(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
|
-
...call.params);
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.OptionalFunctionCall, node, call.expression, ...call.params);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
202
|
//# sourceMappingURL=call.js.map
|
|
@@ -9,7 +9,6 @@ const diagnostics_1 = require("../../utils/diagnostics");
|
|
|
9
9
|
const export_1 = require("../../utils/export");
|
|
10
10
|
const lua_ast_1 = require("../../utils/lua-ast");
|
|
11
11
|
const safe_names_1 = require("../../utils/safe-names");
|
|
12
|
-
const transform_1 = require("../../utils/transform");
|
|
13
12
|
const identifier_1 = require("../identifier");
|
|
14
13
|
const decorators_1 = require("./decorators");
|
|
15
14
|
const accessors_1 = require("./members/accessors");
|
|
@@ -33,10 +32,9 @@ exports.transformClassDeclaration = transformClassDeclaration;
|
|
|
33
32
|
const transformThisExpression = node => (0, lua_ast_1.createSelfIdentifier)(node);
|
|
34
33
|
exports.transformThisExpression = transformThisExpression;
|
|
35
34
|
function transformClassAsExpression(expression, context) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}, expression);
|
|
35
|
+
const { statements, name } = transformClassLikeDeclaration(expression, context);
|
|
36
|
+
context.addPrecedingStatements(statements);
|
|
37
|
+
return name;
|
|
40
38
|
}
|
|
41
39
|
exports.transformClassAsExpression = transformClassAsExpression;
|
|
42
40
|
const classSuperInfos = new WeakMap();
|
|
@@ -49,8 +47,7 @@ function transformClassLikeDeclaration(classDeclaration, context, nameOverride)
|
|
|
49
47
|
className = (0, identifier_1.transformIdentifier)(context, classDeclaration.name);
|
|
50
48
|
}
|
|
51
49
|
else {
|
|
52
|
-
|
|
53
|
-
className = lua.createAnonymousIdentifier();
|
|
50
|
+
className = lua.createIdentifier(context.createTempName("class"), classDeclaration);
|
|
54
51
|
}
|
|
55
52
|
const annotations = (0, annotations_1.getTypeAnnotations)(context.checker.getTypeAtLocation(classDeclaration));
|
|
56
53
|
if (annotations.has(annotations_1.AnnotationKind.Extension)) {
|
|
@@ -73,7 +70,7 @@ function transformClassLikeDeclaration(classDeclaration, context, nameOverride)
|
|
|
73
70
|
const instanceFields = properties.filter(prop => !(0, utils_2.isStaticNode)(prop));
|
|
74
71
|
const result = [];
|
|
75
72
|
let localClassName;
|
|
76
|
-
if ((0, safe_names_1.isUnsafeName)(className.text)) {
|
|
73
|
+
if ((0, safe_names_1.isUnsafeName)(className.text, context.options)) {
|
|
77
74
|
localClassName = lua.createIdentifier((0, safe_names_1.createSafeName)(className.text), undefined, className.symbolId, className.text);
|
|
78
75
|
lua.setNodePosition(localClassName, className);
|
|
79
76
|
}
|
|
@@ -4,6 +4,7 @@ exports.transformConstructorDeclaration = exports.createConstructorName = export
|
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const lua = require("../../../../LuaAST");
|
|
6
6
|
const lua_ast_1 = require("../../../utils/lua-ast");
|
|
7
|
+
const preceding_statements_1 = require("../../../utils/preceding-statements");
|
|
7
8
|
const scope_1 = require("../../../utils/scope");
|
|
8
9
|
const function_1 = require("../../function");
|
|
9
10
|
const identifier_1 = require("../../identifier");
|
|
@@ -29,7 +30,7 @@ function transformConstructorDeclaration(context, statement, className, instance
|
|
|
29
30
|
const bodyWithFieldInitializers = (0, function_1.transformFunctionBodyHeader)(context, scope, statement.parameters, restParamName);
|
|
30
31
|
// Check for field declarations in constructor
|
|
31
32
|
const constructorFieldsDeclarations = statement.parameters.filter(p => p.modifiers !== undefined);
|
|
32
|
-
const classInstanceFields = (0, fields_1.transformClassInstanceFields)(context, instanceFields);
|
|
33
|
+
const [fieldsPrecedingStatements, classInstanceFields] = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => (0, fields_1.transformClassInstanceFields)(context, instanceFields));
|
|
33
34
|
// If there are field initializers and the first statement is a super call,
|
|
34
35
|
// move super call between default assignments and initializers
|
|
35
36
|
if ((constructorFieldsDeclarations.length > 0 || classInstanceFields.length > 0) &&
|
|
@@ -54,6 +55,7 @@ function transformConstructorDeclaration(context, statement, className, instance
|
|
|
54
55
|
}
|
|
55
56
|
// else { TypeScript error: A parameter property may not be declared using a binding pattern }
|
|
56
57
|
}
|
|
58
|
+
bodyWithFieldInitializers.push(...fieldsPrecedingStatements);
|
|
57
59
|
bodyWithFieldInitializers.push(...classInstanceFields);
|
|
58
60
|
bodyWithFieldInitializers.push(...body);
|
|
59
61
|
const block = lua.createBlock(bodyWithFieldInitializers);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformNewExpression = exports.checkForLuaLibType = void 0;
|
|
4
|
+
const ts = require("typescript");
|
|
4
5
|
const lua = require("../../../LuaAST");
|
|
5
6
|
const annotations_1 = require("../../utils/annotations");
|
|
6
7
|
const diagnostics_1 = require("../../utils/diagnostics");
|
|
@@ -46,7 +47,7 @@ function checkForLuaLibType(context, type) {
|
|
|
46
47
|
}
|
|
47
48
|
exports.checkForLuaLibType = checkForLuaLibType;
|
|
48
49
|
const transformNewExpression = (node, context) => {
|
|
49
|
-
var _a;
|
|
50
|
+
var _a, _b;
|
|
50
51
|
const type = context.checker.getTypeAtLocation(node);
|
|
51
52
|
const annotations = (0, annotations_1.getTypeAnnotations)(type);
|
|
52
53
|
if (annotations.has(annotations_1.AnnotationKind.LuaTable)) {
|
|
@@ -56,15 +57,12 @@ const transformNewExpression = (node, context) => {
|
|
|
56
57
|
return lua.createTableExpression(undefined, node);
|
|
57
58
|
}
|
|
58
59
|
const signature = context.checker.getResolvedSignature(node);
|
|
59
|
-
const params = node.arguments
|
|
60
|
-
? (0, call_1.transformArguments)(context, node.arguments, signature)
|
|
61
|
-
: [lua.createBooleanLiteral(true)];
|
|
60
|
+
const [name, params] = (0, call_1.transformCallAndArguments)(context, node.expression, (_a = node.arguments) !== null && _a !== void 0 ? _a : [ts.factory.createTrue()], signature);
|
|
62
61
|
checkForLuaLibType(context, type);
|
|
63
|
-
const name = context.transformExpression(node.expression);
|
|
64
62
|
const customConstructorAnnotation = annotations.get(annotations_1.AnnotationKind.CustomConstructor);
|
|
65
63
|
if (customConstructorAnnotation) {
|
|
66
64
|
if (customConstructorAnnotation.args.length === 1) {
|
|
67
|
-
return lua.createCallExpression(lua.createIdentifier(customConstructorAnnotation.args[0]), (0, call_1.transformArguments)(context, (
|
|
65
|
+
return lua.createCallExpression(lua.createIdentifier(customConstructorAnnotation.args[0]), (0, call_1.transformArguments)(context, (_b = node.arguments) !== null && _b !== void 0 ? _b : []), node);
|
|
68
66
|
}
|
|
69
67
|
else {
|
|
70
68
|
context.diagnostics.push((0, diagnostics_1.annotationInvalidArgumentCount)(node, annotations_1.AnnotationKind.CustomConstructor, customConstructorAnnotation.args.length, 1));
|
|
@@ -3,47 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.transformIfStatement = exports.transformConditionalExpression = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const lua = require("../../LuaAST");
|
|
6
|
+
const preceding_statements_1 = require("../utils/preceding-statements");
|
|
6
7
|
const scope_1 = require("../utils/scope");
|
|
7
8
|
const block_1 = require("./block");
|
|
8
|
-
|
|
9
|
-
const strictNullChecks = context.options.strict === true || context.options.strictNullChecks === true;
|
|
10
|
-
const falsyFlags = ts.TypeFlags.Boolean |
|
|
11
|
-
ts.TypeFlags.BooleanLiteral |
|
|
12
|
-
ts.TypeFlags.Undefined |
|
|
13
|
-
ts.TypeFlags.Null |
|
|
14
|
-
ts.TypeFlags.Never |
|
|
15
|
-
ts.TypeFlags.Void |
|
|
16
|
-
ts.TypeFlags.Any;
|
|
17
|
-
if (type.flags & falsyFlags) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
else if (!strictNullChecks && !type.isLiteral()) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
else if (type.isUnion()) {
|
|
24
|
-
return type.types.some(subType => canBeFalsy(context, subType));
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function wrapInFunctionCall(expression) {
|
|
31
|
-
const returnStatement = lua.createReturnStatement([expression]);
|
|
32
|
-
return lua.createFunctionExpression(lua.createBlock([returnStatement]), undefined, undefined, lua.FunctionExpressionFlags.Inline);
|
|
33
|
-
}
|
|
9
|
+
const typescript_1 = require("../utils/typescript");
|
|
34
10
|
function transformProtectedConditionalExpression(context, expression) {
|
|
11
|
+
const tempVar = context.createTempNameForNode(expression.condition);
|
|
35
12
|
const condition = context.transformExpression(expression.condition);
|
|
36
|
-
const val1 = context.transformExpression(expression.whenTrue);
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
13
|
+
const [trueStatements, val1] = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => context.transformExpression(expression.whenTrue));
|
|
14
|
+
trueStatements.push(lua.createAssignmentStatement(lua.cloneIdentifier(tempVar), val1, expression.whenTrue));
|
|
15
|
+
const [falseStatements, val2] = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => context.transformExpression(expression.whenFalse));
|
|
16
|
+
falseStatements.push(lua.createAssignmentStatement(lua.cloneIdentifier(tempVar), val2, expression.whenFalse));
|
|
17
|
+
context.addPrecedingStatements([
|
|
18
|
+
lua.createVariableDeclarationStatement(tempVar, undefined, expression.condition),
|
|
19
|
+
lua.createIfStatement(condition, lua.createBlock(trueStatements, expression.whenTrue), lua.createBlock(falseStatements, expression.whenFalse), expression),
|
|
20
|
+
]);
|
|
21
|
+
return lua.cloneIdentifier(tempVar);
|
|
44
22
|
}
|
|
45
23
|
const transformConditionalExpression = (expression, context) => {
|
|
46
|
-
if (canBeFalsy(context, context.checker.getTypeAtLocation(expression.whenTrue))) {
|
|
24
|
+
if ((0, typescript_1.canBeFalsy)(context, context.checker.getTypeAtLocation(expression.whenTrue))) {
|
|
47
25
|
return transformProtectedConditionalExpression(context, expression);
|
|
48
26
|
}
|
|
49
27
|
const condition = context.transformExpression(expression.condition);
|
|
@@ -62,8 +40,23 @@ function transformIfStatement(statement, context) {
|
|
|
62
40
|
const ifBlock = lua.createBlock(statements);
|
|
63
41
|
if (statement.elseStatement) {
|
|
64
42
|
if (ts.isIfStatement(statement.elseStatement)) {
|
|
65
|
-
const
|
|
66
|
-
|
|
43
|
+
const tsElseStatement = statement.elseStatement;
|
|
44
|
+
const [precedingStatements, elseStatement] = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => transformIfStatement(tsElseStatement, context));
|
|
45
|
+
// If else-if condition generates preceding statements, we can't use elseif, we have to break it down:
|
|
46
|
+
// if conditionA then
|
|
47
|
+
// ...
|
|
48
|
+
// else
|
|
49
|
+
// conditionB's preceding statements
|
|
50
|
+
// if conditionB then
|
|
51
|
+
// end
|
|
52
|
+
// end
|
|
53
|
+
if (precedingStatements.length > 0) {
|
|
54
|
+
const elseBlock = lua.createBlock([...precedingStatements, elseStatement]);
|
|
55
|
+
return lua.createIfStatement(condition, ifBlock, elseBlock);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return lua.createIfStatement(condition, ifBlock, elseStatement);
|
|
59
|
+
}
|
|
67
60
|
}
|
|
68
61
|
else {
|
|
69
62
|
(0, scope_1.pushScope)(context, scope_1.ScopeType.Conditional);
|
|
@@ -7,7 +7,11 @@ const lualib_1 = require("../utils/lualib");
|
|
|
7
7
|
const diagnostics_1 = require("../utils/diagnostics");
|
|
8
8
|
const typescript_1 = require("../utils/typescript");
|
|
9
9
|
const lua_ast_1 = require("../utils/lua-ast");
|
|
10
|
+
const optional_chaining_1 = require("./optional-chaining");
|
|
10
11
|
const transformDeleteExpression = (node, context) => {
|
|
12
|
+
if (ts.isOptionalChain(node.expression)) {
|
|
13
|
+
return (0, optional_chaining_1.transformOptionalDeleteExpression)(context, node, node.expression);
|
|
14
|
+
}
|
|
11
15
|
let ownerExpression;
|
|
12
16
|
let propertyExpression;
|
|
13
17
|
if (ts.isPropertyAccessExpression(node.expression)) {
|
|
@@ -12,6 +12,7 @@ const identifier_1 = require("./identifier");
|
|
|
12
12
|
const multi_1 = require("./language-extensions/multi");
|
|
13
13
|
const return_1 = require("./return");
|
|
14
14
|
const transformTryStatement = (statement, context) => {
|
|
15
|
+
var _a;
|
|
15
16
|
const [tryBlock, tryScope] = (0, block_1.transformScopeBlock)(context, statement.tryBlock, scope_1.ScopeType.Try);
|
|
16
17
|
if (context.options.luaTarget === __1.LuaTarget.Lua51 && (0, typescript_1.isInAsyncFunction)(statement)) {
|
|
17
18
|
context.diagnostics.push((0, diagnostics_1.unsupportedForTarget)(statement, "try/catch inside async functions", __1.LuaTarget.Lua51));
|
|
@@ -34,24 +35,25 @@ const transformTryStatement = (statement, context) => {
|
|
|
34
35
|
const catchParameter = statement.catchClause.variableDeclaration
|
|
35
36
|
? (0, identifier_1.transformIdentifier)(context, statement.catchClause.variableDeclaration.name)
|
|
36
37
|
: undefined;
|
|
37
|
-
const
|
|
38
|
+
const catchFunction = lua.createFunctionExpression(catchBlock, catchParameter ? [lua.cloneIdentifier(catchParameter)] : []);
|
|
38
39
|
const catchIdentifier = lua.createIdentifier("____catch");
|
|
39
|
-
const catchFunction = lua.createFunctionExpression(catchBlock, catchParameters());
|
|
40
40
|
result.push(lua.createVariableDeclarationStatement(catchIdentifier, catchFunction));
|
|
41
|
+
const hasReturn = (_a = tryScope.functionReturned) !== null && _a !== void 0 ? _a : catchScope.functionReturned;
|
|
41
42
|
const tryReturnIdentifiers = [tryResultIdentifier]; // ____try
|
|
42
|
-
if (
|
|
43
|
-
tryReturnIdentifiers.push(returnedIdentifier); // ____returned
|
|
44
|
-
if (
|
|
43
|
+
if (hasReturn || statement.catchClause.variableDeclaration) {
|
|
44
|
+
tryReturnIdentifiers.push(returnedIdentifier); // ____returned
|
|
45
|
+
if (hasReturn) {
|
|
45
46
|
tryReturnIdentifiers.push(returnValueIdentifier); // ____returnValue
|
|
46
47
|
returnCondition = lua.cloneIdentifier(returnedIdentifier);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
result.push(lua.createVariableDeclarationStatement(tryReturnIdentifiers, tryCall));
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
51
|
+
const catchCall = lua.createCallExpression(catchIdentifier, statement.catchClause.variableDeclaration ? [lua.cloneIdentifier(returnedIdentifier)] : []);
|
|
52
|
+
const catchCallStatement = hasReturn
|
|
53
|
+
? lua.createAssignmentStatement([lua.cloneIdentifier(returnedIdentifier), lua.cloneIdentifier(returnValueIdentifier)], catchCall)
|
|
54
|
+
: lua.createExpressionStatement(catchCall);
|
|
53
55
|
const notTryCondition = lua.createUnaryExpression(tryResultIdentifier, lua.SyntaxKind.NotOperator);
|
|
54
|
-
result.push(lua.createIfStatement(notTryCondition, lua.createBlock([
|
|
56
|
+
result.push(lua.createIfStatement(notTryCondition, lua.createBlock([catchCallStatement])));
|
|
55
57
|
}
|
|
56
58
|
else if (tryScope.functionReturned) {
|
|
57
59
|
// try with return, but no catch
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import * as lua from "../../LuaAST";
|
|
3
|
+
import { TransformationContext } from "../context";
|
|
4
|
+
export declare function shouldMoveToTemp(context: TransformationContext, expression: lua.Expression, tsOriginal?: ts.Node): boolean;
|
|
5
|
+
export declare function moveToPrecedingTemp(context: TransformationContext, expression: lua.Expression, tsOriginal?: ts.Node): lua.Expression;
|
|
6
|
+
export declare function transformExpressionList(context: TransformationContext, expressions: readonly ts.Expression[]): lua.Expression[];
|
|
7
|
+
export declare function transformOrderedExpressions(context: TransformationContext, expressions: readonly ts.Expression[]): lua.Expression[];
|