porffor 0.34.20 → 0.34.21
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/CONTRIBUTING.md +1 -1
- package/compiler/assemble.js +6 -10
- package/compiler/codegen.js +33 -26
- package/compiler/wrap.js +3 -0
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/CONTRIBUTING.md
CHANGED
@@ -366,7 +366,7 @@ builtins/tostring_number: impl radix
|
|
366
366
|
|
367
367
|
## Test262
|
368
368
|
|
369
|
-
For the first time, ensure you run `./test262/setup.sh
|
369
|
+
For the first time, ensure you run `./test262/setup.sh` (Unix) or `.\test262\setup.cmd` (Windows).
|
370
370
|
|
371
371
|
Run `node test262` to run all the tests and get an output of total overall test results.
|
372
372
|
|
package/compiler/assemble.js
CHANGED
@@ -33,15 +33,11 @@ const encodeNames = funcs => {
|
|
33
33
|
funcs.map(x => unsignedLEB128(x.asmIndex).concat(encodeString(x.name))),
|
34
34
|
);
|
35
35
|
const localsSection = encodeVector(
|
36
|
-
funcs.map(x =>
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
),
|
42
|
-
),
|
43
|
-
),
|
44
|
-
),
|
36
|
+
funcs.map(x => unsignedLEB128(x.asmIndex).concat(encodeVector(
|
37
|
+
Object.entries(x.locals).map(([name, local]) =>
|
38
|
+
unsignedLEB128(local.idx).concat(encodeString(name))
|
39
|
+
)
|
40
|
+
)))
|
45
41
|
);
|
46
42
|
|
47
43
|
return [
|
@@ -49,7 +45,7 @@ const encodeNames = funcs => {
|
|
49
45
|
...encodeSection(1, functionsSection),
|
50
46
|
...encodeSection(2, localsSection),
|
51
47
|
];
|
52
|
-
}
|
48
|
+
};
|
53
49
|
|
54
50
|
export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) => {
|
55
51
|
const types = [], typeCache = {};
|
package/compiler/codegen.js
CHANGED
@@ -5404,7 +5404,7 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
|
|
5404
5404
|
const type = TYPES[x.split('_prototype')[0].slice(2).toLowerCase()];
|
5405
5405
|
if (type == null) continue;
|
5406
5406
|
|
5407
|
-
// do not __proto__ primitive hack for objects
|
5407
|
+
// do not __proto__ primitive hack for objects or functions
|
5408
5408
|
if (type === TYPES.object || type === TYPES.function) continue;
|
5409
5409
|
|
5410
5410
|
const ident = {
|
@@ -5721,27 +5721,34 @@ const generateClass = (scope, decl) => {
|
|
5721
5721
|
|
5722
5722
|
if (decl.superClass) {
|
5723
5723
|
out.push(
|
5724
|
-
...generateCall(scope, {
|
5725
|
-
|
5726
|
-
|
5727
|
-
|
5728
|
-
|
5729
|
-
|
5730
|
-
|
5731
|
-
|
5732
|
-
|
5733
|
-
|
5734
|
-
|
5735
|
-
|
5736
|
-
|
5737
|
-
|
5738
|
-
|
5739
|
-
|
5740
|
-
|
5741
|
-
|
5742
|
-
|
5743
|
-
}),
|
5744
|
-
[ Opcodes.drop ]
|
5724
|
+
// ...generateCall(scope, {
|
5725
|
+
// type: 'CallExpression',
|
5726
|
+
// callee: {
|
5727
|
+
// type: 'Identifier',
|
5728
|
+
// name: '__Porffor_object_assignAll'
|
5729
|
+
// },
|
5730
|
+
// arguments: [
|
5731
|
+
// proto,
|
5732
|
+
// {
|
5733
|
+
// type: 'MemberExpression',
|
5734
|
+
// object: decl.superClass,
|
5735
|
+
// property: {
|
5736
|
+
// type: 'Identifier',
|
5737
|
+
// name: 'prototype'
|
5738
|
+
// },
|
5739
|
+
// computed: false,
|
5740
|
+
// optional: false
|
5741
|
+
// }
|
5742
|
+
// ]
|
5743
|
+
// }),
|
5744
|
+
// [ Opcodes.drop ]
|
5745
|
+
|
5746
|
+
// class Foo {}
|
5747
|
+
// class Bar extends Foo {}
|
5748
|
+
// Bar.__proto__ = Foo
|
5749
|
+
// Bar.prototype.__proto__ = Foo.prototype
|
5750
|
+
...generate(scope, setObjProp(root, '__proto__', decl.superClass)),
|
5751
|
+
...generate(scope, setObjProp(getObjProp(root, 'prototype'), '__proto__', getObjProp(decl.superClass, 'prototype')))
|
5745
5752
|
);
|
5746
5753
|
}
|
5747
5754
|
|
@@ -6024,8 +6031,8 @@ const generateFunc = (scope, decl, outUnused = false) => {
|
|
6024
6031
|
else func.returns = [];
|
6025
6032
|
}
|
6026
6033
|
|
6027
|
-
// inject promise job runner func at the end of main if
|
6028
|
-
if (Object.hasOwn(funcIndex, '
|
6034
|
+
// inject promise job runner func at the end of main if promises are made
|
6035
|
+
if (Object.hasOwn(funcIndex, 'Promise') || Object.hasOwn(funcIndex, '__Promise_resolve') || Object.hasOwn(funcIndex, '__Promise_reject')) {
|
6029
6036
|
wasm.push(
|
6030
6037
|
[ Opcodes.call, includeBuiltin(scope, '__Porffor_promise_runJobs').index ],
|
6031
6038
|
[ Opcodes.drop ],
|
@@ -6358,8 +6365,8 @@ export default program => {
|
|
6358
6365
|
|
6359
6366
|
delete globals['#ind'];
|
6360
6367
|
|
6361
|
-
// if blank main func and other exports, remove it
|
6362
|
-
if (main.wasm.length === 0 && funcs.
|
6368
|
+
// if wanted and blank main func and other exports, remove it
|
6369
|
+
if (Prefs.rmBlankMain && main.wasm.length === 0 && funcs.some(x => x.export)) funcs.splice(main.index - importedFuncs.length, 1);
|
6363
6370
|
|
6364
6371
|
// make ~empty funcs for never generated funcs
|
6365
6372
|
// todo: these should just be deleted once able
|
package/compiler/wrap.js
CHANGED
@@ -137,6 +137,9 @@ ${flags & 0b0001 ? ` get func idx: ${get}
|
|
137
137
|
// eg: __String_prototype_toLowerCase -> toLowerCase
|
138
138
|
if (name.startsWith('__')) name = name.split('_').pop();
|
139
139
|
|
140
|
+
// anonymous functions
|
141
|
+
if (name.startsWith('#')) name = '';
|
142
|
+
|
140
143
|
// make fake empty func for repl/etc
|
141
144
|
return {[name]() {}}[name];
|
142
145
|
}
|
package/package.json
CHANGED