typescript-to-lua 1.6.3 → 1.7.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/dist/CompilerOptions.d.ts +1 -0
- package/dist/cli/parse.js +5 -0
- package/dist/lualib/ArraySlice.lua +10 -2
- package/dist/lualib/ArraySplice.lua +5 -1
- package/dist/lualib/Generator.lua +8 -1
- package/dist/lualib/ParseFloat.lua +5 -1
- package/dist/lualib/SparseArraySpread.lua +5 -1
- package/dist/lualib/StringCharCodeAt.lua +5 -1
- package/dist/lualib/lualib_bundle.lua +38 -7
- package/dist/lualib-build/plugin.js +1 -2
- package/dist/measure-performance.d.ts +15 -0
- package/dist/measure-performance.js +83 -0
- package/dist/transformation/builtins/array.js +2 -1
- package/dist/transformation/builtins/function.js +1 -1
- package/dist/transformation/builtins/global.d.ts +1 -1
- package/dist/transformation/builtins/global.js +13 -12
- package/dist/transformation/builtins/index.d.ts +2 -2
- package/dist/transformation/builtins/index.js +87 -89
- package/dist/transformation/builtins/object.d.ts +1 -1
- package/dist/transformation/builtins/object.js +4 -4
- package/dist/transformation/builtins/promise.js +4 -2
- package/dist/transformation/builtins/string.js +2 -0
- package/dist/transformation/context/context.d.ts +15 -0
- package/dist/transformation/context/context.js +66 -24
- package/dist/transformation/context/visitors.d.ts +1 -1
- package/dist/transformation/index.js +6 -5
- package/dist/transformation/utils/annotations.d.ts +1 -17
- package/dist/transformation/utils/annotations.js +48 -88
- package/dist/transformation/utils/assignment-validation.js +27 -23
- package/dist/transformation/utils/diagnostics.d.ts +1 -4
- package/dist/transformation/utils/diagnostics.js +2 -3
- package/dist/transformation/utils/function-context.d.ts +1 -1
- package/dist/transformation/utils/function-context.js +57 -51
- package/dist/transformation/utils/language-extensions.d.ts +57 -51
- package/dist/transformation/utils/language-extensions.js +99 -119
- package/dist/transformation/utils/lualib.d.ts +0 -1
- package/dist/transformation/utils/lualib.js +2 -8
- package/dist/transformation/utils/safe-names.d.ts +1 -1
- package/dist/transformation/utils/safe-names.js +3 -6
- package/dist/transformation/utils/scope.d.ts +0 -2
- package/dist/transformation/utils/scope.js +10 -27
- package/dist/transformation/utils/symbols.d.ts +1 -1
- package/dist/transformation/utils/symbols.js +7 -20
- package/dist/transformation/utils/typescript/index.d.ts +1 -0
- package/dist/transformation/utils/typescript/index.js +2 -1
- package/dist/transformation/utils/typescript/types.d.ts +2 -5
- package/dist/transformation/utils/typescript/types.js +27 -37
- package/dist/transformation/visitors/access.js +1 -4
- package/dist/transformation/visitors/block.js +4 -4
- package/dist/transformation/visitors/call.js +7 -18
- package/dist/transformation/visitors/class/index.js +8 -20
- package/dist/transformation/visitors/class/members/constructor.js +2 -2
- package/dist/transformation/visitors/class/new.js +2 -5
- package/dist/transformation/visitors/class/setup.d.ts +1 -1
- package/dist/transformation/visitors/class/setup.js +4 -4
- package/dist/transformation/visitors/class/utils.d.ts +1 -1
- package/dist/transformation/visitors/class/utils.js +2 -9
- package/dist/transformation/visitors/conditional.js +4 -4
- package/dist/transformation/visitors/function.d.ts +1 -1
- package/dist/transformation/visitors/function.js +8 -16
- package/dist/transformation/visitors/identifier.d.ts +1 -0
- package/dist/transformation/visitors/identifier.js +40 -44
- package/dist/transformation/visitors/language-extensions/call-extension.d.ts +10 -0
- package/dist/transformation/visitors/language-extensions/call-extension.js +23 -0
- package/dist/transformation/visitors/language-extensions/identifier.d.ts +5 -0
- package/dist/transformation/visitors/language-extensions/identifier.js +27 -0
- package/dist/transformation/visitors/language-extensions/iterable.d.ts +2 -3
- package/dist/transformation/visitors/language-extensions/iterable.js +21 -22
- package/dist/transformation/visitors/language-extensions/multi.d.ts +0 -1
- package/dist/transformation/visitors/language-extensions/multi.js +10 -24
- package/dist/transformation/visitors/language-extensions/operators.d.ts +2 -5
- package/dist/transformation/visitors/language-extensions/operators.js +89 -96
- package/dist/transformation/visitors/language-extensions/range.js +4 -2
- package/dist/transformation/visitors/language-extensions/table.d.ts +6 -3
- package/dist/transformation/visitors/language-extensions/table.js +46 -75
- package/dist/transformation/visitors/language-extensions/vararg.js +7 -3
- package/dist/transformation/visitors/literal.js +2 -23
- package/dist/transformation/visitors/loops/for-of.js +18 -18
- package/dist/transformation/visitors/loops/utils.js +5 -5
- package/dist/transformation/visitors/namespace.js +5 -14
- package/dist/transformation/visitors/return.js +2 -3
- package/dist/transformation/visitors/sourceFile.js +3 -4
- package/dist/transformation/visitors/spread.js +0 -5
- package/dist/transformation/visitors/switch.js +2 -2
- package/dist/transformation/visitors/variable-declaration.js +1 -1
- package/dist/transpilation/plugins.js +3 -0
- package/dist/transpilation/resolve.js +144 -161
- package/dist/transpilation/transpile.js +10 -0
- package/dist/transpilation/transpiler.d.ts +1 -0
- package/dist/transpilation/transpiler.js +18 -5
- package/dist/tstl.js +21 -0
- package/language-extensions/index.d.ts +156 -67
- package/package.json +2 -2
- package/dist/transformation/visitors/language-extensions/index.d.ts +0 -4
- package/dist/transformation/visitors/language-extensions/index.js +0 -17
- package/dist/transformation/visitors/language-extensions/pairsIterable.d.ts +0 -5
- package/dist/transformation/visitors/language-extensions/pairsIterable.js +0 -53
|
@@ -1,127 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.operatorExtensionTransformers = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const lua = require("../../../LuaAST");
|
|
6
|
-
const extensions = require("../../utils/language-extensions");
|
|
7
6
|
const utils_1 = require("../../../utils");
|
|
8
|
-
const typescript_1 = require("../../utils/typescript");
|
|
9
7
|
const CompilerOptions_1 = require("../../../CompilerOptions");
|
|
10
8
|
const diagnostics_1 = require("../../utils/diagnostics");
|
|
9
|
+
const language_extensions_1 = require("../../utils/language-extensions");
|
|
11
10
|
const binaryOperatorMappings = new Map([
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
11
|
+
[language_extensions_1.ExtensionKind.AdditionOperatorType, lua.SyntaxKind.AdditionOperator],
|
|
12
|
+
[language_extensions_1.ExtensionKind.AdditionOperatorMethodType, lua.SyntaxKind.AdditionOperator],
|
|
13
|
+
[language_extensions_1.ExtensionKind.SubtractionOperatorType, lua.SyntaxKind.SubtractionOperator],
|
|
14
|
+
[language_extensions_1.ExtensionKind.SubtractionOperatorMethodType, lua.SyntaxKind.SubtractionOperator],
|
|
15
|
+
[language_extensions_1.ExtensionKind.MultiplicationOperatorType, lua.SyntaxKind.MultiplicationOperator],
|
|
16
|
+
[language_extensions_1.ExtensionKind.MultiplicationOperatorMethodType, lua.SyntaxKind.MultiplicationOperator],
|
|
17
|
+
[language_extensions_1.ExtensionKind.DivisionOperatorType, lua.SyntaxKind.DivisionOperator],
|
|
18
|
+
[language_extensions_1.ExtensionKind.DivisionOperatorMethodType, lua.SyntaxKind.DivisionOperator],
|
|
19
|
+
[language_extensions_1.ExtensionKind.ModuloOperatorType, lua.SyntaxKind.ModuloOperator],
|
|
20
|
+
[language_extensions_1.ExtensionKind.ModuloOperatorMethodType, lua.SyntaxKind.ModuloOperator],
|
|
21
|
+
[language_extensions_1.ExtensionKind.PowerOperatorType, lua.SyntaxKind.PowerOperator],
|
|
22
|
+
[language_extensions_1.ExtensionKind.PowerOperatorMethodType, lua.SyntaxKind.PowerOperator],
|
|
23
|
+
[language_extensions_1.ExtensionKind.FloorDivisionOperatorType, lua.SyntaxKind.FloorDivisionOperator],
|
|
24
|
+
[language_extensions_1.ExtensionKind.FloorDivisionOperatorMethodType, lua.SyntaxKind.FloorDivisionOperator],
|
|
25
|
+
[language_extensions_1.ExtensionKind.BitwiseAndOperatorType, lua.SyntaxKind.BitwiseAndOperator],
|
|
26
|
+
[language_extensions_1.ExtensionKind.BitwiseAndOperatorMethodType, lua.SyntaxKind.BitwiseAndOperator],
|
|
27
|
+
[language_extensions_1.ExtensionKind.BitwiseOrOperatorType, lua.SyntaxKind.BitwiseOrOperator],
|
|
28
|
+
[language_extensions_1.ExtensionKind.BitwiseOrOperatorMethodType, lua.SyntaxKind.BitwiseOrOperator],
|
|
29
|
+
[language_extensions_1.ExtensionKind.BitwiseExclusiveOrOperatorType, lua.SyntaxKind.BitwiseExclusiveOrOperator],
|
|
30
|
+
[language_extensions_1.ExtensionKind.BitwiseExclusiveOrOperatorMethodType, lua.SyntaxKind.BitwiseExclusiveOrOperator],
|
|
31
|
+
[language_extensions_1.ExtensionKind.BitwiseLeftShiftOperatorType, lua.SyntaxKind.BitwiseLeftShiftOperator],
|
|
32
|
+
[language_extensions_1.ExtensionKind.BitwiseLeftShiftOperatorMethodType, lua.SyntaxKind.BitwiseLeftShiftOperator],
|
|
33
|
+
[language_extensions_1.ExtensionKind.BitwiseRightShiftOperatorType, lua.SyntaxKind.BitwiseRightShiftOperator],
|
|
34
|
+
[language_extensions_1.ExtensionKind.BitwiseRightShiftOperatorMethodType, lua.SyntaxKind.BitwiseRightShiftOperator],
|
|
35
|
+
[language_extensions_1.ExtensionKind.ConcatOperatorType, lua.SyntaxKind.ConcatOperator],
|
|
36
|
+
[language_extensions_1.ExtensionKind.ConcatOperatorMethodType, lua.SyntaxKind.ConcatOperator],
|
|
37
|
+
[language_extensions_1.ExtensionKind.LessThanOperatorType, lua.SyntaxKind.LessThanOperator],
|
|
38
|
+
[language_extensions_1.ExtensionKind.LessThanOperatorMethodType, lua.SyntaxKind.LessThanOperator],
|
|
39
|
+
[language_extensions_1.ExtensionKind.GreaterThanOperatorType, lua.SyntaxKind.GreaterThanOperator],
|
|
40
|
+
[language_extensions_1.ExtensionKind.GreaterThanOperatorMethodType, lua.SyntaxKind.GreaterThanOperator],
|
|
42
41
|
]);
|
|
43
42
|
const unaryOperatorMappings = new Map([
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
43
|
+
[language_extensions_1.ExtensionKind.NegationOperatorType, lua.SyntaxKind.NegationOperator],
|
|
44
|
+
[language_extensions_1.ExtensionKind.NegationOperatorMethodType, lua.SyntaxKind.NegationOperator],
|
|
45
|
+
[language_extensions_1.ExtensionKind.BitwiseNotOperatorType, lua.SyntaxKind.BitwiseNotOperator],
|
|
46
|
+
[language_extensions_1.ExtensionKind.BitwiseNotOperatorMethodType, lua.SyntaxKind.BitwiseNotOperator],
|
|
47
|
+
[language_extensions_1.ExtensionKind.LengthOperatorType, lua.SyntaxKind.LengthOperator],
|
|
48
|
+
[language_extensions_1.ExtensionKind.LengthOperatorMethodType, lua.SyntaxKind.LengthOperator],
|
|
50
49
|
]);
|
|
51
|
-
const operatorMapExtensions = [...binaryOperatorMappings.keys(), ...unaryOperatorMappings.keys()];
|
|
52
50
|
const bitwiseOperatorMapExtensions = new Set([
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
language_extensions_1.ExtensionKind.BitwiseAndOperatorType,
|
|
52
|
+
language_extensions_1.ExtensionKind.BitwiseAndOperatorMethodType,
|
|
53
|
+
language_extensions_1.ExtensionKind.BitwiseOrOperatorType,
|
|
54
|
+
language_extensions_1.ExtensionKind.BitwiseOrOperatorMethodType,
|
|
55
|
+
language_extensions_1.ExtensionKind.BitwiseExclusiveOrOperatorType,
|
|
56
|
+
language_extensions_1.ExtensionKind.BitwiseExclusiveOrOperatorMethodType,
|
|
57
|
+
language_extensions_1.ExtensionKind.BitwiseLeftShiftOperatorType,
|
|
58
|
+
language_extensions_1.ExtensionKind.BitwiseLeftShiftOperatorMethodType,
|
|
59
|
+
language_extensions_1.ExtensionKind.BitwiseRightShiftOperatorType,
|
|
60
|
+
language_extensions_1.ExtensionKind.BitwiseRightShiftOperatorMethodType,
|
|
61
|
+
language_extensions_1.ExtensionKind.BitwiseNotOperatorType,
|
|
62
|
+
language_extensions_1.ExtensionKind.BitwiseNotOperatorMethodType,
|
|
65
63
|
]);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
const requiresLua53 = new Set([
|
|
65
|
+
...bitwiseOperatorMapExtensions,
|
|
66
|
+
language_extensions_1.ExtensionKind.FloorDivisionOperatorType,
|
|
67
|
+
language_extensions_1.ExtensionKind.FloorDivisionOperatorMethodType,
|
|
68
|
+
]);
|
|
69
|
+
exports.operatorExtensionTransformers = {};
|
|
70
|
+
for (const kind of binaryOperatorMappings.keys()) {
|
|
71
|
+
exports.operatorExtensionTransformers[kind] = transformBinaryOperator;
|
|
72
|
+
}
|
|
73
|
+
for (const kind of unaryOperatorMappings.keys()) {
|
|
74
|
+
exports.operatorExtensionTransformers[kind] = transformUnaryOperator;
|
|
75
|
+
}
|
|
76
|
+
function transformBinaryOperator(context, node, kind) {
|
|
77
|
+
if (requiresLua53.has(kind))
|
|
78
|
+
checkHasLua53(context, node, kind);
|
|
79
|
+
let args = node.arguments;
|
|
80
|
+
if (args.length === 1 &&
|
|
81
|
+
(ts.isPropertyAccessExpression(node.expression) || ts.isElementAccessExpression(node.expression))) {
|
|
82
|
+
args = [node.expression.expression, ...args];
|
|
83
|
+
}
|
|
84
|
+
const luaOperator = binaryOperatorMappings.get(kind);
|
|
85
|
+
(0, utils_1.assert)(luaOperator);
|
|
86
|
+
return lua.createBinaryExpression(context.transformExpression(args[0]), context.transformExpression(args[1]), luaOperator);
|
|
69
87
|
}
|
|
70
|
-
function
|
|
71
|
-
if (
|
|
72
|
-
|
|
88
|
+
function transformUnaryOperator(context, node, kind) {
|
|
89
|
+
if (requiresLua53.has(kind))
|
|
90
|
+
checkHasLua53(context, node, kind);
|
|
91
|
+
let arg;
|
|
92
|
+
if (node.arguments.length === 0 &&
|
|
93
|
+
(ts.isPropertyAccessExpression(node.expression) || ts.isElementAccessExpression(node.expression))) {
|
|
94
|
+
arg = node.expression.expression;
|
|
73
95
|
}
|
|
74
96
|
else {
|
|
75
|
-
|
|
76
|
-
return operatorMapExtensions.some(extensionKind => extensions.isExtensionType(type, extensionKind));
|
|
97
|
+
arg = node.arguments[0];
|
|
77
98
|
}
|
|
99
|
+
const luaOperator = unaryOperatorMappings.get(kind);
|
|
100
|
+
(0, utils_1.assert)(luaOperator);
|
|
101
|
+
return lua.createUnaryExpression(context.transformExpression(arg), luaOperator);
|
|
78
102
|
}
|
|
79
|
-
|
|
80
|
-
function transformOperatorMappingExpression(context, node, isOptionalCall) {
|
|
81
|
-
const extensionKind = getOperatorMapExtensionKindForCall(context, node);
|
|
82
|
-
if (!extensionKind)
|
|
83
|
-
return undefined;
|
|
84
|
-
if (isOptionalCall) {
|
|
85
|
-
context.diagnostics.push((0, diagnostics_1.unsupportedBuiltinOptionalCall)(node));
|
|
86
|
-
return lua.createNilLiteral();
|
|
87
|
-
}
|
|
103
|
+
function checkHasLua53(context, node, kind) {
|
|
88
104
|
const isBefore53 = context.luaTarget === CompilerOptions_1.LuaTarget.Lua51 ||
|
|
89
105
|
context.luaTarget === CompilerOptions_1.LuaTarget.Lua52 ||
|
|
90
106
|
context.luaTarget === CompilerOptions_1.LuaTarget.LuaJIT ||
|
|
91
107
|
context.luaTarget === CompilerOptions_1.LuaTarget.Universal;
|
|
92
108
|
if (isBefore53) {
|
|
93
109
|
const luaTarget = context.luaTarget === CompilerOptions_1.LuaTarget.Universal ? CompilerOptions_1.LuaTarget.Lua51 : context.luaTarget;
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
else if (extensionKind === extensions.ExtensionKind.FloorDivisionOperatorType ||
|
|
98
|
-
extensionKind === extensions.ExtensionKind.FloorDivisionOperatorMethodType) {
|
|
110
|
+
if (kind === language_extensions_1.ExtensionKind.FloorDivisionOperatorType ||
|
|
111
|
+
kind === language_extensions_1.ExtensionKind.FloorDivisionOperatorMethodType) {
|
|
99
112
|
context.diagnostics.push((0, diagnostics_1.unsupportedForTarget)(node, "Floor division operator", luaTarget));
|
|
100
113
|
}
|
|
101
|
-
}
|
|
102
|
-
const args = node.arguments.slice();
|
|
103
|
-
if (binaryOperatorMappings.has(extensionKind)) {
|
|
104
|
-
if (args.length === 1 &&
|
|
105
|
-
(ts.isPropertyAccessExpression(node.expression) || ts.isElementAccessExpression(node.expression))) {
|
|
106
|
-
args.unshift(node.expression.expression);
|
|
107
|
-
}
|
|
108
|
-
const luaOperator = binaryOperatorMappings.get(extensionKind);
|
|
109
|
-
(0, utils_1.assert)(luaOperator);
|
|
110
|
-
return lua.createBinaryExpression(context.transformExpression(args[0]), context.transformExpression(args[1]), luaOperator);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
let arg;
|
|
114
|
-
if (args.length === 0 &&
|
|
115
|
-
(ts.isPropertyAccessExpression(node.expression) || ts.isElementAccessExpression(node.expression))) {
|
|
116
|
-
arg = node.expression.expression;
|
|
117
|
-
}
|
|
118
114
|
else {
|
|
119
|
-
|
|
115
|
+
// is bitwise operator
|
|
116
|
+
context.diagnostics.push((0, diagnostics_1.unsupportedForTarget)(node, "Native bitwise operations", luaTarget));
|
|
120
117
|
}
|
|
121
|
-
const luaOperator = unaryOperatorMappings.get(extensionKind);
|
|
122
|
-
(0, utils_1.assert)(luaOperator);
|
|
123
|
-
return lua.createUnaryExpression(context.transformExpression(arg), luaOperator);
|
|
124
118
|
}
|
|
125
119
|
}
|
|
126
|
-
exports.transformOperatorMappingExpression = transformOperatorMappingExpression;
|
|
127
120
|
//# sourceMappingURL=operators.js.map
|
|
@@ -9,13 +9,15 @@ const identifier_1 = require("../identifier");
|
|
|
9
9
|
const call_1 = require("../call");
|
|
10
10
|
const utils_2 = require("../../../utils");
|
|
11
11
|
const diagnostics_1 = require("../../utils/diagnostics");
|
|
12
|
+
const language_extensions_1 = require("../../utils/language-extensions");
|
|
12
13
|
function isRangeFunction(context, expression) {
|
|
13
14
|
return isRangeFunctionNode(context, expression.expression);
|
|
14
15
|
}
|
|
15
16
|
exports.isRangeFunction = isRangeFunction;
|
|
16
17
|
function isRangeFunctionNode(context, node) {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
return (ts.isIdentifier(node) &&
|
|
19
|
+
node.text === "$range" &&
|
|
20
|
+
(0, language_extensions_1.getExtensionKindForNode)(context, node) === extensions.ExtensionKind.RangeFunction);
|
|
19
21
|
}
|
|
20
22
|
exports.isRangeFunctionNode = isRangeFunctionNode;
|
|
21
23
|
function getControlVariable(context, statement) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as ts from "typescript";
|
|
2
|
-
import * as lua from "../../../LuaAST";
|
|
3
2
|
import { TransformationContext } from "../../context";
|
|
4
|
-
|
|
3
|
+
import { ExtensionKind } from "../../utils/language-extensions";
|
|
4
|
+
import { LanguageExtensionCallTransformer } from "./call-extension";
|
|
5
5
|
export declare function isTableNewCall(context: TransformationContext, node: ts.NewExpression): boolean;
|
|
6
|
-
export declare
|
|
6
|
+
export declare const tableNewExtensions: ExtensionKind[];
|
|
7
|
+
export declare const tableExtensionTransformers: {
|
|
8
|
+
[P in ExtensionKind]?: LanguageExtensionCallTransformer;
|
|
9
|
+
};
|
|
@@ -1,109 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.tableExtensionTransformers = exports.tableNewExtensions = exports.isTableNewCall = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const lua = require("../../../LuaAST");
|
|
6
|
-
const
|
|
7
|
-
const typescript_1 = require("../../utils/typescript");
|
|
6
|
+
const language_extensions_1 = require("../../utils/language-extensions");
|
|
8
7
|
const expression_list_1 = require("../expression-list");
|
|
9
|
-
const diagnostics_1 = require("../../utils/diagnostics");
|
|
10
|
-
const tableCallExtensions = [
|
|
11
|
-
extensions.ExtensionKind.TableDeleteType,
|
|
12
|
-
extensions.ExtensionKind.TableDeleteMethodType,
|
|
13
|
-
extensions.ExtensionKind.TableGetType,
|
|
14
|
-
extensions.ExtensionKind.TableGetMethodType,
|
|
15
|
-
extensions.ExtensionKind.TableHasType,
|
|
16
|
-
extensions.ExtensionKind.TableHasMethodType,
|
|
17
|
-
extensions.ExtensionKind.TableSetType,
|
|
18
|
-
extensions.ExtensionKind.TableSetMethodType,
|
|
19
|
-
];
|
|
20
|
-
const tableExtensions = [extensions.ExtensionKind.TableNewType, ...tableCallExtensions];
|
|
21
|
-
function getTableExtensionKindForCall(context, node, validExtensions) {
|
|
22
|
-
const type = (0, typescript_1.getFunctionTypeForCall)(context, node);
|
|
23
|
-
return type && validExtensions.find(extensionKind => extensions.isExtensionType(type, extensionKind));
|
|
24
|
-
}
|
|
25
|
-
function isTableExtensionIdentifier(context, node) {
|
|
26
|
-
const type = context.checker.getTypeAtLocation(node);
|
|
27
|
-
return tableExtensions.some(extensionKind => extensions.isExtensionType(type, extensionKind));
|
|
28
|
-
}
|
|
29
|
-
exports.isTableExtensionIdentifier = isTableExtensionIdentifier;
|
|
30
8
|
function isTableNewCall(context, node) {
|
|
31
|
-
|
|
32
|
-
return extensions.isExtensionType(type, extensions.ExtensionKind.TableNewType);
|
|
9
|
+
return (0, language_extensions_1.getExtensionKindForNode)(context, node.expression) === language_extensions_1.ExtensionKind.TableNewType;
|
|
33
10
|
}
|
|
34
11
|
exports.isTableNewCall = isTableNewCall;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
extensionType === extensions.ExtensionKind.TableGetMethodType) {
|
|
49
|
-
return transformTableGetExpression(context, node, extensionType);
|
|
50
|
-
}
|
|
51
|
-
if (extensionType === extensions.ExtensionKind.TableHasType ||
|
|
52
|
-
extensionType === extensions.ExtensionKind.TableHasMethodType) {
|
|
53
|
-
return transformTableHasExpression(context, node, extensionType);
|
|
54
|
-
}
|
|
55
|
-
if (extensionType === extensions.ExtensionKind.TableSetType ||
|
|
56
|
-
extensionType === extensions.ExtensionKind.TableSetMethodType) {
|
|
57
|
-
return transformTableSetExpression(context, node, extensionType);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.transformTableExtensionCall = transformTableExtensionCall;
|
|
12
|
+
exports.tableNewExtensions = [language_extensions_1.ExtensionKind.TableNewType];
|
|
13
|
+
exports.tableExtensionTransformers = {
|
|
14
|
+
[language_extensions_1.ExtensionKind.TableDeleteType]: transformTableDeleteExpression,
|
|
15
|
+
[language_extensions_1.ExtensionKind.TableDeleteMethodType]: transformTableDeleteExpression,
|
|
16
|
+
[language_extensions_1.ExtensionKind.TableGetType]: transformTableGetExpression,
|
|
17
|
+
[language_extensions_1.ExtensionKind.TableGetMethodType]: transformTableGetExpression,
|
|
18
|
+
[language_extensions_1.ExtensionKind.TableHasType]: transformTableHasExpression,
|
|
19
|
+
[language_extensions_1.ExtensionKind.TableHasMethodType]: transformTableHasExpression,
|
|
20
|
+
[language_extensions_1.ExtensionKind.TableSetType]: transformTableSetExpression,
|
|
21
|
+
[language_extensions_1.ExtensionKind.TableSetMethodType]: transformTableSetExpression,
|
|
22
|
+
[language_extensions_1.ExtensionKind.TableAddKeyType]: transformTableAddExpression,
|
|
23
|
+
[language_extensions_1.ExtensionKind.TableAddKeyMethodType]: transformTableAddExpression,
|
|
24
|
+
};
|
|
61
25
|
function transformTableDeleteExpression(context, node, extensionKind) {
|
|
62
26
|
const args = node.arguments.slice();
|
|
63
|
-
if (extensionKind ===
|
|
27
|
+
if (extensionKind === language_extensions_1.ExtensionKind.TableDeleteMethodType &&
|
|
64
28
|
(ts.isPropertyAccessExpression(node.expression) || ts.isElementAccessExpression(node.expression))) {
|
|
65
29
|
// In case of method (no table argument), push method owner to front of args list
|
|
66
30
|
args.unshift(node.expression.expression);
|
|
67
31
|
}
|
|
68
|
-
// arg0[arg1] = nil
|
|
69
32
|
const [table, accessExpression] = (0, expression_list_1.transformExpressionList)(context, args);
|
|
33
|
+
// arg0[arg1] = nil
|
|
70
34
|
context.addPrecedingStatements(lua.createAssignmentStatement(lua.createTableIndexExpression(table, accessExpression), lua.createNilLiteral(), node));
|
|
71
35
|
return lua.createBooleanLiteral(true);
|
|
72
36
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
(ts.isPropertyAccessExpression(node.expression) || ts.isElementAccessExpression(node.expression))) {
|
|
77
|
-
// In case of method (no table argument), push method owner to front of args list
|
|
78
|
-
args.unshift(node.expression.expression);
|
|
37
|
+
function transformWithTableArgument(context, node) {
|
|
38
|
+
if (ts.isPropertyAccessExpression(node.expression) || ts.isElementAccessExpression(node.expression)) {
|
|
39
|
+
return (0, expression_list_1.transformExpressionList)(context, [node.expression.expression, ...node.arguments]);
|
|
79
40
|
}
|
|
80
|
-
|
|
41
|
+
// todo: report diagnostic?
|
|
42
|
+
return [lua.createNilLiteral(), ...(0, expression_list_1.transformExpressionList)(context, node.arguments)];
|
|
43
|
+
}
|
|
44
|
+
function transformTableGetExpression(context, node, extensionKind) {
|
|
45
|
+
const args = extensionKind === language_extensions_1.ExtensionKind.TableGetMethodType
|
|
46
|
+
? transformWithTableArgument(context, node)
|
|
47
|
+
: (0, expression_list_1.transformExpressionList)(context, node.arguments);
|
|
48
|
+
const [table, accessExpression] = args;
|
|
81
49
|
// arg0[arg1]
|
|
82
50
|
return lua.createTableIndexExpression(table, accessExpression, node);
|
|
83
51
|
}
|
|
84
52
|
function transformTableHasExpression(context, node, extensionKind) {
|
|
85
|
-
const args =
|
|
86
|
-
|
|
87
|
-
(
|
|
88
|
-
|
|
89
|
-
args.unshift(node.expression.expression);
|
|
90
|
-
}
|
|
53
|
+
const args = extensionKind === language_extensions_1.ExtensionKind.TableHasMethodType
|
|
54
|
+
? transformWithTableArgument(context, node)
|
|
55
|
+
: (0, expression_list_1.transformExpressionList)(context, node.arguments);
|
|
56
|
+
const [table, accessExpression] = args;
|
|
91
57
|
// arg0[arg1]
|
|
92
|
-
const [table, accessExpression] = (0, expression_list_1.transformExpressionList)(context, args);
|
|
93
58
|
const tableIndexExpression = lua.createTableIndexExpression(table, accessExpression);
|
|
94
59
|
// arg0[arg1] ~= nil
|
|
95
60
|
return lua.createBinaryExpression(tableIndexExpression, lua.createNilLiteral(), lua.SyntaxKind.InequalityOperator, node);
|
|
96
61
|
}
|
|
97
62
|
function transformTableSetExpression(context, node, extensionKind) {
|
|
98
|
-
const args =
|
|
99
|
-
|
|
100
|
-
(
|
|
101
|
-
|
|
102
|
-
args.unshift(node.expression.expression);
|
|
103
|
-
}
|
|
63
|
+
const args = extensionKind === language_extensions_1.ExtensionKind.TableSetMethodType
|
|
64
|
+
? transformWithTableArgument(context, node)
|
|
65
|
+
: (0, expression_list_1.transformExpressionList)(context, node.arguments);
|
|
66
|
+
const [table, accessExpression, value] = args;
|
|
104
67
|
// arg0[arg1] = arg2
|
|
105
|
-
const [table, accessExpression, value] = (0, expression_list_1.transformExpressionList)(context, args);
|
|
106
68
|
context.addPrecedingStatements(lua.createAssignmentStatement(lua.createTableIndexExpression(table, accessExpression), value, node));
|
|
107
69
|
return lua.createNilLiteral();
|
|
108
70
|
}
|
|
71
|
+
function transformTableAddExpression(context, node, extensionKind) {
|
|
72
|
+
const args = extensionKind === language_extensions_1.ExtensionKind.TableAddKeyMethodType
|
|
73
|
+
? transformWithTableArgument(context, node)
|
|
74
|
+
: (0, expression_list_1.transformExpressionList)(context, node.arguments);
|
|
75
|
+
const [table, value] = args;
|
|
76
|
+
// arg0[arg1] = true
|
|
77
|
+
context.addPrecedingStatements(lua.createAssignmentStatement(lua.createTableIndexExpression(table, value), lua.createBooleanLiteral(true), node));
|
|
78
|
+
return lua.createNilLiteral();
|
|
79
|
+
}
|
|
109
80
|
//# sourceMappingURL=table.js.map
|
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isVarargConstantNode = exports.isGlobalVarargConstant = void 0;
|
|
4
4
|
const extensions = require("../../utils/language-extensions");
|
|
5
|
+
const language_extensions_1 = require("../../utils/language-extensions");
|
|
5
6
|
const scope_1 = require("../../utils/scope");
|
|
6
7
|
function isGlobalVarargConstant(context, symbol, scope) {
|
|
7
|
-
return
|
|
8
|
-
extensions.isExtensionValue(context, symbol, extensions.ExtensionKind.VarargConstant));
|
|
8
|
+
return scope.type === scope_1.ScopeType.File && isVarargConstantSymbol(context, symbol);
|
|
9
9
|
}
|
|
10
10
|
exports.isGlobalVarargConstant = isGlobalVarargConstant;
|
|
11
|
+
function isVarargConstantSymbol(context, symbol) {
|
|
12
|
+
return (symbol.getName() === "$vararg" &&
|
|
13
|
+
(0, language_extensions_1.getExtensionKindForSymbol)(context, symbol) === extensions.ExtensionKind.VarargConstant);
|
|
14
|
+
}
|
|
11
15
|
function isVarargConstantNode(context, node) {
|
|
12
16
|
const symbol = context.checker.getSymbolAtLocation(node);
|
|
13
|
-
return symbol
|
|
17
|
+
return symbol !== undefined && isVarargConstantSymbol(context, symbol);
|
|
14
18
|
}
|
|
15
19
|
exports.isVarargConstantNode = isVarargConstantNode;
|
|
16
20
|
//# sourceMappingURL=vararg.js.map
|
|
@@ -5,14 +5,12 @@ const ts = require("typescript");
|
|
|
5
5
|
const lua = require("../../LuaAST");
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const diagnostics_1 = require("../utils/diagnostics");
|
|
8
|
-
const export_1 = require("../utils/export");
|
|
9
8
|
const lualib_1 = require("../utils/lualib");
|
|
10
|
-
const safe_names_1 = require("../utils/safe-names");
|
|
11
9
|
const symbols_1 = require("../utils/symbols");
|
|
12
10
|
const typescript_1 = require("../utils/typescript");
|
|
13
11
|
const function_1 = require("./function");
|
|
14
12
|
const expression_list_1 = require("./expression-list");
|
|
15
|
-
const
|
|
13
|
+
const identifier_1 = require("./identifier");
|
|
16
14
|
// TODO: Move to object-literal.ts?
|
|
17
15
|
function transformPropertyName(context, node) {
|
|
18
16
|
if (ts.isComputedPropertyName(node)) {
|
|
@@ -30,21 +28,7 @@ function transformPropertyName(context, node) {
|
|
|
30
28
|
}
|
|
31
29
|
exports.transformPropertyName = transformPropertyName;
|
|
32
30
|
function createShorthandIdentifier(context, valueSymbol, propertyIdentifier) {
|
|
33
|
-
|
|
34
|
-
const isUnsafeName = valueSymbol
|
|
35
|
-
? (0, safe_names_1.hasUnsafeSymbolName)(context, valueSymbol, propertyIdentifier)
|
|
36
|
-
: (0, safe_names_1.hasUnsafeIdentifierName)(context, propertyIdentifier, false);
|
|
37
|
-
const name = isUnsafeName ? (0, safe_names_1.createSafeName)(propertyName) : propertyName;
|
|
38
|
-
let identifier = context.transformExpression(ts.factory.createIdentifier(name));
|
|
39
|
-
lua.setNodeOriginal(identifier, propertyIdentifier);
|
|
40
|
-
if (valueSymbol !== undefined && lua.isIdentifier(identifier)) {
|
|
41
|
-
identifier.symbolId = (0, symbols_1.getSymbolIdOfSymbol)(context, valueSymbol);
|
|
42
|
-
const exportScope = (0, export_1.getSymbolExportScope)(context, valueSymbol);
|
|
43
|
-
if (exportScope) {
|
|
44
|
-
identifier = (0, export_1.createExportedIdentifier)(context, identifier, exportScope);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return identifier;
|
|
31
|
+
return (0, identifier_1.transformIdentifierWithSymbol)(context, propertyIdentifier, valueSymbol);
|
|
48
32
|
}
|
|
49
33
|
exports.createShorthandIdentifier = createShorthandIdentifier;
|
|
50
34
|
const transformNumericLiteralExpression = expression => {
|
|
@@ -56,11 +40,6 @@ const transformNumericLiteralExpression = expression => {
|
|
|
56
40
|
return lua.createNumericLiteral(Number(expression.text), expression);
|
|
57
41
|
};
|
|
58
42
|
const transformObjectLiteralExpression = (expression, context) => {
|
|
59
|
-
const violations = (0, multi_1.findMultiAssignmentViolations)(context, expression);
|
|
60
|
-
if (violations.length > 0) {
|
|
61
|
-
context.diagnostics.push(...violations.map(e => (0, diagnostics_1.invalidMultiFunctionUse)(e)));
|
|
62
|
-
return lua.createNilLiteral(expression);
|
|
63
|
-
}
|
|
64
43
|
const properties = [];
|
|
65
44
|
const initializers = [];
|
|
66
45
|
const keyPrecedingStatements = [];
|
|
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.transformForOfStatement = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const lua = require("../../../LuaAST");
|
|
6
|
-
const annotations_1 = require("../../utils/annotations");
|
|
7
|
-
const diagnostics_1 = require("../../utils/diagnostics");
|
|
8
6
|
const lualib_1 = require("../../utils/lualib");
|
|
9
7
|
const typescript_1 = require("../../utils/typescript");
|
|
10
8
|
const iterable_1 = require("../language-extensions/iterable");
|
|
11
|
-
const pairsIterable_1 = require("../language-extensions/pairsIterable");
|
|
12
9
|
const range_1 = require("../language-extensions/range");
|
|
13
10
|
const utils_1 = require("./utils");
|
|
11
|
+
const language_extensions_1 = require("../../utils/language-extensions");
|
|
12
|
+
const utils_2 = require("../../../utils");
|
|
14
13
|
function transformForOfArrayStatement(context, statement, block) {
|
|
15
14
|
const valueVariable = (0, utils_1.transformForInitializer)(context, statement.initializer, block);
|
|
16
15
|
const ipairsCall = lua.createCallExpression(lua.createIdentifier("ipairs"), [
|
|
@@ -28,24 +27,25 @@ const transformForOfStatement = (node, context) => {
|
|
|
28
27
|
if (ts.isCallExpression(node.expression) && (0, range_1.isRangeFunction)(context, node.expression)) {
|
|
29
28
|
return (0, range_1.transformRangeStatement)(context, node, body);
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const iterableExtensionType = (0, language_extensions_1.getIterableExtensionKindForNode)(context, node.expression);
|
|
31
|
+
if (iterableExtensionType) {
|
|
32
|
+
if (iterableExtensionType === language_extensions_1.IterableExtensionKind.Iterable) {
|
|
33
|
+
return (0, iterable_1.transformForOfIterableStatement)(context, node, body);
|
|
34
|
+
}
|
|
35
|
+
else if (iterableExtensionType === language_extensions_1.IterableExtensionKind.Pairs) {
|
|
36
|
+
return (0, iterable_1.transformForOfPairsIterableStatement)(context, node, body);
|
|
37
|
+
}
|
|
38
|
+
else if (iterableExtensionType === language_extensions_1.IterableExtensionKind.PairsKey) {
|
|
39
|
+
return (0, iterable_1.transformForOfPairsKeyIterableStatement)(context, node, body);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
(0, utils_2.assertNever)(iterableExtensionType);
|
|
43
|
+
}
|
|
33
44
|
}
|
|
34
|
-
|
|
35
|
-
return (0, iterable_1.transformForOfIterableStatement)(context, node, body);
|
|
36
|
-
}
|
|
37
|
-
else if ((0, pairsIterable_1.isPairsIterableExpression)(context, node.expression)) {
|
|
38
|
-
return (0, pairsIterable_1.transformForOfPairsIterableStatement)(context, node, body);
|
|
39
|
-
}
|
|
40
|
-
else if ((0, annotations_1.isLuaIteratorType)(context, node.expression)) {
|
|
41
|
-
context.diagnostics.push((0, diagnostics_1.annotationRemoved)(node.expression, annotations_1.AnnotationKind.LuaIterator));
|
|
42
|
-
}
|
|
43
|
-
else if ((0, typescript_1.isArrayType)(context, context.checker.getTypeAtLocation(node.expression))) {
|
|
45
|
+
if ((0, typescript_1.isArrayType)(context, context.checker.getTypeAtLocation(node.expression))) {
|
|
44
46
|
return transformForOfArrayStatement(context, node, body);
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
return transformForOfIteratorStatement(context, node, body);
|
|
48
|
-
}
|
|
48
|
+
return transformForOfIteratorStatement(context, node, body);
|
|
49
49
|
};
|
|
50
50
|
exports.transformForOfStatement = transformForOfStatement;
|
|
51
51
|
//# sourceMappingURL=for-of.js.map
|
|
@@ -12,9 +12,9 @@ const block_1 = require("../block");
|
|
|
12
12
|
const identifier_1 = require("../identifier");
|
|
13
13
|
const variable_declaration_1 = require("../variable-declaration");
|
|
14
14
|
function transformLoopBody(context, loop) {
|
|
15
|
-
|
|
15
|
+
context.pushScope(scope_1.ScopeType.Loop);
|
|
16
16
|
const body = (0, scope_1.performHoisting)(context, (0, block_1.transformBlockOrStatement)(context, loop.statement));
|
|
17
|
-
const scope =
|
|
17
|
+
const scope = context.popScope();
|
|
18
18
|
const scopeId = scope.id;
|
|
19
19
|
if (!scope.loopContinued) {
|
|
20
20
|
return body;
|
|
@@ -35,7 +35,7 @@ function getVariableDeclarationBinding(context, node) {
|
|
|
35
35
|
exports.getVariableDeclarationBinding = getVariableDeclarationBinding;
|
|
36
36
|
function transformForInitializer(context, initializer, block) {
|
|
37
37
|
const valueVariable = lua.createIdentifier("____value");
|
|
38
|
-
|
|
38
|
+
context.pushScope(scope_1.ScopeType.LoopInitializer);
|
|
39
39
|
if (ts.isVariableDeclarationList(initializer)) {
|
|
40
40
|
// Declaration of new variable
|
|
41
41
|
const binding = getVariableDeclarationBinding(context, initializer);
|
|
@@ -45,7 +45,7 @@ function transformForInitializer(context, initializer, block) {
|
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
// Single variable declared in for loop
|
|
48
|
-
|
|
48
|
+
context.popScope();
|
|
49
49
|
return (0, identifier_1.transformIdentifier)(context, binding);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -55,7 +55,7 @@ function transformForInitializer(context, initializer, block) {
|
|
|
55
55
|
? (0, destructuring_assignments_1.transformAssignmentPattern)(context, initializer, valueVariable, false)
|
|
56
56
|
: (0, assignments_1.transformAssignment)(context, initializer, valueVariable)));
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
context.popScope();
|
|
59
59
|
return valueVariable;
|
|
60
60
|
}
|
|
61
61
|
exports.transformForInitializer = transformForInitializer;
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.transformModuleDeclaration = exports.createModuleLocalNameIdentifier = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const lua = require("../../LuaAST");
|
|
6
|
-
const annotations_1 = require("../utils/annotations");
|
|
7
|
-
const diagnostics_1 = require("../utils/diagnostics");
|
|
8
6
|
const export_1 = require("../utils/export");
|
|
9
7
|
const lua_ast_1 = require("../utils/lua-ast");
|
|
10
8
|
const safe_names_1 = require("../utils/safe-names");
|
|
@@ -33,16 +31,9 @@ function moduleHasEmittedBody(node) {
|
|
|
33
31
|
}
|
|
34
32
|
return false;
|
|
35
33
|
}
|
|
36
|
-
// Static context -> namespace dictionary keeping the current namespace for each transformation context
|
|
37
|
-
const currentNamespaces = new WeakMap();
|
|
38
34
|
const transformModuleDeclaration = (node, context) => {
|
|
39
35
|
var _a, _b;
|
|
40
|
-
const
|
|
41
|
-
// If phantom namespace elide the declaration and return the body
|
|
42
|
-
if (annotations.has(annotations_1.AnnotationKind.Phantom)) {
|
|
43
|
-
context.diagnostics.push((0, diagnostics_1.annotationRemoved)(node, annotations_1.AnnotationKind.Phantom));
|
|
44
|
-
}
|
|
45
|
-
const currentNamespace = currentNamespaces.get(context);
|
|
36
|
+
const currentNamespace = context.currentNamespaces;
|
|
46
37
|
const result = [];
|
|
47
38
|
const symbol = context.checker.getSymbolAtLocation(node.name);
|
|
48
39
|
const hasExports = symbol !== undefined && context.checker.getExportsOfModule(symbol).length > 0;
|
|
@@ -75,15 +66,15 @@ const transformModuleDeclaration = (node, context) => {
|
|
|
75
66
|
}
|
|
76
67
|
// Set current namespace for nested NS
|
|
77
68
|
// Keep previous namespace to reset after block transpilation
|
|
78
|
-
currentNamespaces
|
|
69
|
+
context.currentNamespaces = node;
|
|
79
70
|
// Transform moduleblock to block and visit it
|
|
80
71
|
if (moduleHasEmittedBody(node)) {
|
|
81
|
-
|
|
72
|
+
context.pushScope(scope_1.ScopeType.Block);
|
|
82
73
|
const statements = (0, scope_1.performHoisting)(context, context.transformStatements(ts.isModuleBlock(node.body) ? node.body.statements : node.body));
|
|
83
|
-
|
|
74
|
+
context.popScope();
|
|
84
75
|
result.push(lua.createDoStatement(statements));
|
|
85
76
|
}
|
|
86
|
-
currentNamespaces
|
|
77
|
+
context.currentNamespaces = currentNamespace;
|
|
87
78
|
return result;
|
|
88
79
|
};
|
|
89
80
|
exports.transformModuleDeclaration = transformModuleDeclaration;
|