@tilua/compiler 1.0.0 → 1.0.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/dist/{chunk-S5C4VH6A.js → chunk-QSRDDIU4.js} +1 -31
- package/dist/cli.cjs +1 -31
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -31
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -709,36 +709,6 @@ var Lowerer = class {
|
|
|
709
709
|
for (let i = 0; i < locals.length; i += 100) declarations.push(local(locals.slice(i, i + 100), []));
|
|
710
710
|
return [...declarations, ...hoisted, ...requires, ...body];
|
|
711
711
|
}
|
|
712
|
-
/** Is `expression` a table iterated directly — not an iterator function
|
|
713
|
-
* such as `pairs(t)` or `string.gmatch(s, p)`? Known from its type. */
|
|
714
|
-
iteratesTable(expression) {
|
|
715
|
-
const types = this.options.types;
|
|
716
|
-
const type = types?.typeOf.get(expression);
|
|
717
|
-
if (!types || !type) return false;
|
|
718
|
-
const seen = /* @__PURE__ */ new Set();
|
|
719
|
-
const table2 = (t) => {
|
|
720
|
-
if (seen.has(t)) return false;
|
|
721
|
-
seen.add(t);
|
|
722
|
-
switch (t.kind) {
|
|
723
|
-
case "array":
|
|
724
|
-
case "tuple":
|
|
725
|
-
return true;
|
|
726
|
-
case "object":
|
|
727
|
-
return !t.class;
|
|
728
|
-
case "union":
|
|
729
|
-
return t.types.every((m) => m.kind === "primitive" && m.name === "nil" || table2(m));
|
|
730
|
-
case "intersection":
|
|
731
|
-
return t.types.some(table2);
|
|
732
|
-
case "genericRef": {
|
|
733
|
-
const alias = types.aliases.get(t.name);
|
|
734
|
-
return alias !== void 0 && table2(alias);
|
|
735
|
-
}
|
|
736
|
-
default:
|
|
737
|
-
return false;
|
|
738
|
-
}
|
|
739
|
-
};
|
|
740
|
-
return table2(type);
|
|
741
|
-
}
|
|
742
712
|
isRewritten(node) {
|
|
743
713
|
const binding = this.bindingByDeclaration.get(node);
|
|
744
714
|
return binding !== void 0 && this.rewrites.has(binding.id);
|
|
@@ -962,7 +932,7 @@ var Lowerer = class {
|
|
|
962
932
|
prelude.push(...this.destructure(target, identifier(temp), "declare"));
|
|
963
933
|
return temp;
|
|
964
934
|
});
|
|
965
|
-
if (variables.length === 1 &&
|
|
935
|
+
if (variables.length === 1 && this.options.types?.iteratesValues.has(node)) {
|
|
966
936
|
variables.unshift(this.names.fresh("_"));
|
|
967
937
|
}
|
|
968
938
|
return [genericFor(
|
package/dist/cli.cjs
CHANGED
|
@@ -721,36 +721,6 @@ var Lowerer = class {
|
|
|
721
721
|
for (let i = 0; i < locals.length; i += 100) declarations.push(local(locals.slice(i, i + 100), []));
|
|
722
722
|
return [...declarations, ...hoisted, ...requires, ...body];
|
|
723
723
|
}
|
|
724
|
-
/** Is `expression` a table iterated directly — not an iterator function
|
|
725
|
-
* such as `pairs(t)` or `string.gmatch(s, p)`? Known from its type. */
|
|
726
|
-
iteratesTable(expression) {
|
|
727
|
-
const types = this.options.types;
|
|
728
|
-
const type = types?.typeOf.get(expression);
|
|
729
|
-
if (!types || !type) return false;
|
|
730
|
-
const seen = /* @__PURE__ */ new Set();
|
|
731
|
-
const table2 = (t) => {
|
|
732
|
-
if (seen.has(t)) return false;
|
|
733
|
-
seen.add(t);
|
|
734
|
-
switch (t.kind) {
|
|
735
|
-
case "array":
|
|
736
|
-
case "tuple":
|
|
737
|
-
return true;
|
|
738
|
-
case "object":
|
|
739
|
-
return !t.class;
|
|
740
|
-
case "union":
|
|
741
|
-
return t.types.every((m) => m.kind === "primitive" && m.name === "nil" || table2(m));
|
|
742
|
-
case "intersection":
|
|
743
|
-
return t.types.some(table2);
|
|
744
|
-
case "genericRef": {
|
|
745
|
-
const alias = types.aliases.get(t.name);
|
|
746
|
-
return alias !== void 0 && table2(alias);
|
|
747
|
-
}
|
|
748
|
-
default:
|
|
749
|
-
return false;
|
|
750
|
-
}
|
|
751
|
-
};
|
|
752
|
-
return table2(type);
|
|
753
|
-
}
|
|
754
724
|
isRewritten(node) {
|
|
755
725
|
const binding = this.bindingByDeclaration.get(node);
|
|
756
726
|
return binding !== void 0 && this.rewrites.has(binding.id);
|
|
@@ -974,7 +944,7 @@ var Lowerer = class {
|
|
|
974
944
|
prelude.push(...this.destructure(target, identifier(temp), "declare"));
|
|
975
945
|
return temp;
|
|
976
946
|
});
|
|
977
|
-
if (variables.length === 1 &&
|
|
947
|
+
if (variables.length === 1 && this.options.types?.iteratesValues.has(node)) {
|
|
978
948
|
variables.unshift(this.names.fresh("_"));
|
|
979
949
|
}
|
|
980
950
|
return [genericFor(
|
package/dist/cli.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -745,36 +745,6 @@ var Lowerer = class {
|
|
|
745
745
|
for (let i = 0; i < locals.length; i += 100) declarations.push(local(locals.slice(i, i + 100), []));
|
|
746
746
|
return [...declarations, ...hoisted, ...requires, ...body];
|
|
747
747
|
}
|
|
748
|
-
/** Is `expression` a table iterated directly — not an iterator function
|
|
749
|
-
* such as `pairs(t)` or `string.gmatch(s, p)`? Known from its type. */
|
|
750
|
-
iteratesTable(expression) {
|
|
751
|
-
const types = this.options.types;
|
|
752
|
-
const type = types?.typeOf.get(expression);
|
|
753
|
-
if (!types || !type) return false;
|
|
754
|
-
const seen = /* @__PURE__ */ new Set();
|
|
755
|
-
const table2 = (t) => {
|
|
756
|
-
if (seen.has(t)) return false;
|
|
757
|
-
seen.add(t);
|
|
758
|
-
switch (t.kind) {
|
|
759
|
-
case "array":
|
|
760
|
-
case "tuple":
|
|
761
|
-
return true;
|
|
762
|
-
case "object":
|
|
763
|
-
return !t.class;
|
|
764
|
-
case "union":
|
|
765
|
-
return t.types.every((m) => m.kind === "primitive" && m.name === "nil" || table2(m));
|
|
766
|
-
case "intersection":
|
|
767
|
-
return t.types.some(table2);
|
|
768
|
-
case "genericRef": {
|
|
769
|
-
const alias = types.aliases.get(t.name);
|
|
770
|
-
return alias !== void 0 && table2(alias);
|
|
771
|
-
}
|
|
772
|
-
default:
|
|
773
|
-
return false;
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
return table2(type);
|
|
777
|
-
}
|
|
778
748
|
isRewritten(node) {
|
|
779
749
|
const binding = this.bindingByDeclaration.get(node);
|
|
780
750
|
return binding !== void 0 && this.rewrites.has(binding.id);
|
|
@@ -998,7 +968,7 @@ var Lowerer = class {
|
|
|
998
968
|
prelude.push(...this.destructure(target, identifier(temp), "declare"));
|
|
999
969
|
return temp;
|
|
1000
970
|
});
|
|
1001
|
-
if (variables.length === 1 &&
|
|
971
|
+
if (variables.length === 1 && this.options.types?.iteratesValues.has(node)) {
|
|
1002
972
|
variables.unshift(this.names.fresh("_"));
|
|
1003
973
|
}
|
|
1004
974
|
return [genericFor(
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tilua/compiler",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Compiles tilua to Luau: lowers the @tilua/parser AST to a luau-parser AST and prints it",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"type": "module",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"luau-parser": "^1.0.3",
|
|
40
|
-
"@tilua/parser": "^1.0.
|
|
40
|
+
"@tilua/parser": "^1.0.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^22.20.2",
|