porffor 0.27.0 → 0.27.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/compiler/builtins/_internal_object.ts +78 -79
- package/compiler/builtins/array.ts +4 -4
- package/compiler/builtins/porffor.d.ts +47 -3
- package/compiler/builtins/promise.ts +10 -10
- package/compiler/builtins/set.ts +5 -14
- package/compiler/builtins/symbol.ts +1 -1
- package/compiler/builtins/z_map.ts +2 -2
- package/compiler/builtins_precompiled.js +42 -48
- package/compiler/codegen.js +9 -6
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -2682,7 +2682,7 @@ const typeSwitch = (scope, type, bc, returns = valtypeBinary) => {
|
|
2682
2682
|
if (Prefs.typeswitchBrtable)
|
2683
2683
|
return brTable(type, bc, returns);
|
2684
2684
|
|
2685
|
-
const tmp = localTmp(scope, '#typeswitch_tmp' + (Prefs.typeswitchUniqueTmp ?
|
2685
|
+
const tmp = localTmp(scope, '#typeswitch_tmp' + (Prefs.typeswitchUniqueTmp ? uniqId() : ''), Valtype.i32);
|
2686
2686
|
const out = [
|
2687
2687
|
...type,
|
2688
2688
|
[ Opcodes.local_set, tmp ],
|
@@ -2833,7 +2833,7 @@ const generateVar = (scope, decl) => {
|
|
2833
2833
|
for (const x of decl.declarations) {
|
2834
2834
|
if (x.id.type === 'ArrayPattern') {
|
2835
2835
|
const decls = [];
|
2836
|
-
const tmpName = '#destructure' +
|
2836
|
+
const tmpName = '#destructure' + uniqId();
|
2837
2837
|
|
2838
2838
|
let i = 0;
|
2839
2839
|
const elements = [...x.id.elements];
|
@@ -3660,6 +3660,8 @@ const generateDoWhile = (scope, decl) => {
|
|
3660
3660
|
};
|
3661
3661
|
|
3662
3662
|
const generateForOf = (scope, decl) => {
|
3663
|
+
if (decl.await) return todo(scope, 'for await is not supported');
|
3664
|
+
|
3663
3665
|
const out = [];
|
3664
3666
|
|
3665
3667
|
// todo: for of inside for of might fuck up?
|
@@ -4487,7 +4489,7 @@ const makeArray = (scope, decl, global = false, name = '$undeclared', initEmpty
|
|
4487
4489
|
|
4488
4490
|
const out = [];
|
4489
4491
|
|
4490
|
-
const uniqueName = name === '$undeclared' ? name +
|
4492
|
+
const uniqueName = name === '$undeclared' ? name + uniqId() : name;
|
4491
4493
|
|
4492
4494
|
const useRawElements = !!decl.rawElements;
|
4493
4495
|
const elements = useRawElements ? decl.rawElements : decl.elements;
|
@@ -4748,7 +4750,7 @@ const generateObject = (scope, decl, global = false, name = '$undeclared') => {
|
|
4748
4750
|
];
|
4749
4751
|
|
4750
4752
|
if (decl.properties.length > 0) {
|
4751
|
-
const tmp = localTmp(scope, `#objectexpr${
|
4753
|
+
const tmp = localTmp(scope, `#objectexpr${uniqId()}`, Valtype.i32);
|
4752
4754
|
out.push([ Opcodes.local_tee, tmp ]);
|
4753
4755
|
|
4754
4756
|
for (const x of decl.properties) {
|
@@ -5162,7 +5164,8 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
|
|
5162
5164
|
return out;
|
5163
5165
|
};
|
5164
5166
|
|
5165
|
-
|
5167
|
+
globalThis._uniqId = 0;
|
5168
|
+
const uniqId = () => '_' + globalThis._uniqId++;
|
5166
5169
|
|
5167
5170
|
let objectHackers = [];
|
5168
5171
|
const objectHack = node => {
|
@@ -5211,7 +5214,7 @@ const objectHack = node => {
|
|
5211
5214
|
const generateFunc = (scope, decl) => {
|
5212
5215
|
if (decl.generator) return todo(scope, 'generator functions are not supported');
|
5213
5216
|
|
5214
|
-
const name = decl.id ? decl.id.name : `anonymous${
|
5217
|
+
const name = decl.id ? decl.id.name : `anonymous${uniqId()}`;
|
5215
5218
|
const params = decl.params ?? [];
|
5216
5219
|
|
5217
5220
|
// TODO: share scope/locals between !!!
|
package/package.json
CHANGED