typescript-to-lua 1.16.3 → 1.17.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.
|
@@ -50,7 +50,9 @@ export declare enum ExtensionKind {
|
|
|
50
50
|
TableSetType = "TableSet",
|
|
51
51
|
TableSetMethodType = "TableSetMethod",
|
|
52
52
|
TableAddKeyType = "TableAddKey",
|
|
53
|
-
TableAddKeyMethodType = "TableAddKeyMethod"
|
|
53
|
+
TableAddKeyMethodType = "TableAddKeyMethod",
|
|
54
|
+
TableIsEmptyType = "TableIsEmpty",
|
|
55
|
+
TableIsEmptyMethodType = "TableIsEmptyMethod"
|
|
54
56
|
}
|
|
55
57
|
export declare function getExtensionKindForType(context: TransformationContext, type: ts.Type): ExtensionKind | undefined;
|
|
56
58
|
export declare function getExtensionKindForNode(context: TransformationContext, node: ts.Node): ExtensionKind | undefined;
|
|
@@ -55,6 +55,8 @@ var ExtensionKind;
|
|
|
55
55
|
ExtensionKind["TableSetMethodType"] = "TableSetMethod";
|
|
56
56
|
ExtensionKind["TableAddKeyType"] = "TableAddKey";
|
|
57
57
|
ExtensionKind["TableAddKeyMethodType"] = "TableAddKeyMethod";
|
|
58
|
+
ExtensionKind["TableIsEmptyType"] = "TableIsEmpty";
|
|
59
|
+
ExtensionKind["TableIsEmptyMethodType"] = "TableIsEmptyMethod";
|
|
58
60
|
})(ExtensionKind || (exports.ExtensionKind = ExtensionKind = {}));
|
|
59
61
|
const extensionValues = new Set(Object.values(ExtensionKind));
|
|
60
62
|
function getExtensionKindForType(context, type) {
|
|
@@ -113,31 +115,7 @@ function getIterableExtensionKindForNode(context, node) {
|
|
|
113
115
|
return getIterableExtensionTypeForType(context, type);
|
|
114
116
|
}
|
|
115
117
|
exports.getIterableExtensionKindForNode = getIterableExtensionKindForNode;
|
|
116
|
-
exports.methodExtensionKinds = new Set(
|
|
117
|
-
ExtensionKind.AdditionOperatorMethodType,
|
|
118
|
-
ExtensionKind.SubtractionOperatorMethodType,
|
|
119
|
-
ExtensionKind.MultiplicationOperatorMethodType,
|
|
120
|
-
ExtensionKind.DivisionOperatorMethodType,
|
|
121
|
-
ExtensionKind.ModuloOperatorMethodType,
|
|
122
|
-
ExtensionKind.PowerOperatorMethodType,
|
|
123
|
-
ExtensionKind.FloorDivisionOperatorMethodType,
|
|
124
|
-
ExtensionKind.BitwiseAndOperatorMethodType,
|
|
125
|
-
ExtensionKind.BitwiseOrOperatorMethodType,
|
|
126
|
-
ExtensionKind.BitwiseExclusiveOrOperatorMethodType,
|
|
127
|
-
ExtensionKind.BitwiseLeftShiftOperatorMethodType,
|
|
128
|
-
ExtensionKind.BitwiseRightShiftOperatorMethodType,
|
|
129
|
-
ExtensionKind.ConcatOperatorMethodType,
|
|
130
|
-
ExtensionKind.LessThanOperatorMethodType,
|
|
131
|
-
ExtensionKind.GreaterThanOperatorMethodType,
|
|
132
|
-
ExtensionKind.NegationOperatorMethodType,
|
|
133
|
-
ExtensionKind.BitwiseNotOperatorMethodType,
|
|
134
|
-
ExtensionKind.LengthOperatorMethodType,
|
|
135
|
-
ExtensionKind.TableDeleteMethodType,
|
|
136
|
-
ExtensionKind.TableGetMethodType,
|
|
137
|
-
ExtensionKind.TableHasMethodType,
|
|
138
|
-
ExtensionKind.TableSetMethodType,
|
|
139
|
-
ExtensionKind.TableAddKeyMethodType,
|
|
140
|
-
]);
|
|
118
|
+
exports.methodExtensionKinds = new Set(Object.values(ExtensionKind).filter(key => key.endsWith("Method")));
|
|
141
119
|
function getNaryCallExtensionArgs(context, node, kind, numArgs) {
|
|
142
120
|
let expressions;
|
|
143
121
|
if (node.arguments.some(ts.isSpreadElement)) {
|
|
@@ -20,6 +20,8 @@ exports.tableExtensionTransformers = {
|
|
|
20
20
|
[language_extensions_1.ExtensionKind.TableSetMethodType]: transformTableSetExpression,
|
|
21
21
|
[language_extensions_1.ExtensionKind.TableAddKeyType]: transformTableAddKeyExpression,
|
|
22
22
|
[language_extensions_1.ExtensionKind.TableAddKeyMethodType]: transformTableAddKeyExpression,
|
|
23
|
+
[language_extensions_1.ExtensionKind.TableIsEmptyType]: transformTableIsEmptyExpression,
|
|
24
|
+
[language_extensions_1.ExtensionKind.TableIsEmptyMethodType]: transformTableIsEmptyExpression,
|
|
23
25
|
};
|
|
24
26
|
function transformTableDeleteExpression(context, node, extensionKind) {
|
|
25
27
|
const args = (0, language_extensions_1.getBinaryCallExtensionArgs)(context, node, extensionKind);
|
|
@@ -71,4 +73,13 @@ function transformTableAddKeyExpression(context, node, extensionKind) {
|
|
|
71
73
|
context.addPrecedingStatements(lua.createAssignmentStatement(lua.createTableIndexExpression(table, key), lua.createBooleanLiteral(true), node));
|
|
72
74
|
return lua.createNilLiteral();
|
|
73
75
|
}
|
|
76
|
+
function transformTableIsEmptyExpression(context, node, extensionKind) {
|
|
77
|
+
const args = (0, language_extensions_1.getUnaryCallExtensionArg)(context, node, extensionKind);
|
|
78
|
+
if (!args) {
|
|
79
|
+
return lua.createNilLiteral();
|
|
80
|
+
}
|
|
81
|
+
const table = context.transformExpression(args);
|
|
82
|
+
// next(arg0) == nil
|
|
83
|
+
return lua.createBinaryExpression(lua.createCallExpression(lua.createIdentifier("next"), [table], node), lua.createNilLiteral(), lua.SyntaxKind.EqualityOperator, node);
|
|
84
|
+
}
|
|
74
85
|
//# sourceMappingURL=table.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-to-lua",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!",
|
|
5
5
|
"repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",
|
|
6
6
|
"homepage": "https://typescripttolua.github.io/",
|