porffor 0.30.12 → 0.30.13
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/allocators.js +1 -1
- package/compiler/builtins/_internal_object.ts +34 -7
- package/compiler/builtins/object.ts +7 -43
- package/compiler/builtins.js +0 -38
- package/compiler/builtins_objects.js +45 -20
- package/compiler/builtins_precompiled.js +177 -177
- package/compiler/codegen.js +20 -6
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -398,6 +398,7 @@ const generateReturn = (scope, decl) => {
|
|
398
398
|
!globalThis.precompile // skip in precompiled built-ins, we should not require this and handle it ourselves
|
399
399
|
) {
|
400
400
|
// ignore return value and return this if being constructed
|
401
|
+
// todo: only do this when trying to return a primitive?
|
401
402
|
out.push(
|
402
403
|
// ...truthy(scope, [ [ Opcodes.local_get, '#newtarget' ] ], [ [ Opcodes.local_get, '#newtarget#type' ] ], false, true),
|
403
404
|
[ Opcodes.local_get, '#newtarget' ],
|
@@ -1804,7 +1805,6 @@ const generateExp = (scope, decl) => {
|
|
1804
1805
|
if (expression.value === 'use strict') {
|
1805
1806
|
scope.strict = true;
|
1806
1807
|
}
|
1807
|
-
return [];
|
1808
1808
|
}
|
1809
1809
|
|
1810
1810
|
const out = generate(scope, expression, undefined, undefined, Prefs.optUnused);
|
@@ -1999,9 +1999,10 @@ const createThisArg = (scope, decl, knownThis = undefined) => {
|
|
1999
1999
|
];
|
2000
2000
|
}
|
2001
2001
|
|
2002
|
+
// do not generate globalThis for builtins
|
2002
2003
|
return [
|
2003
|
-
...
|
2004
|
-
...
|
2004
|
+
...number(NULL),
|
2005
|
+
...number(TYPES.object, Valtype.i32)
|
2005
2006
|
];
|
2006
2007
|
}
|
2007
2008
|
};
|
@@ -2340,9 +2341,6 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2340
2341
|
}
|
2341
2342
|
}
|
2342
2343
|
|
2343
|
-
// TODO: only allows callee as identifier
|
2344
|
-
// if (!name) return todo(scope, `only identifier callees (got ${decl.callee.type})`);
|
2345
|
-
|
2346
2344
|
let idx;
|
2347
2345
|
if (Object.hasOwn(funcIndex, name)) idx = funcIndex[name];
|
2348
2346
|
else if (Object.hasOwn(importedFuncs, name)) idx = importedFuncs[name];
|
@@ -2770,6 +2768,22 @@ const generateThis = (scope, decl, _global, _name) => {
|
|
2770
2768
|
}
|
2771
2769
|
|
2772
2770
|
return [
|
2771
|
+
// default this to globalThis
|
2772
|
+
[ Opcodes.local_get, '#this' ],
|
2773
|
+
Opcodes.i32_to_u,
|
2774
|
+
[ Opcodes.i32_eqz ],
|
2775
|
+
[ Opcodes.if, Blocktype.void ],
|
2776
|
+
[ Opcodes.local_get, '#this#type' ],
|
2777
|
+
...number(TYPES.object, Valtype.i32),
|
2778
|
+
[ Opcodes.i32_eq ],
|
2779
|
+
[ Opcodes.if, Blocktype.void ],
|
2780
|
+
...generate(scope, { type: 'Identifier', name: 'globalThis' }),
|
2781
|
+
[ Opcodes.local_set, '#this' ],
|
2782
|
+
...getType(scope, 'globalThis'),
|
2783
|
+
[ Opcodes.local_set, '#this#type' ],
|
2784
|
+
[ Opcodes.end ],
|
2785
|
+
[ Opcodes.end ],
|
2786
|
+
|
2773
2787
|
[ Opcodes.local_get, '#this' ],
|
2774
2788
|
...setLastType(scope, [ [ Opcodes.local_get, '#this#type' ] ])
|
2775
2789
|
];
|
package/package.json
CHANGED