porffor 0.28.8 → 0.28.10
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/assemble.js +3 -0
- package/compiler/builtins/object.ts +1 -1
- package/compiler/builtins_precompiled.js +158 -158
- package/compiler/codegen.js +14 -12
- package/compiler/decompile.js +1 -1
- package/compiler/precompile.js +4 -1
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -1934,8 +1934,11 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
1934
1934
|
target = { ...decl.callee };
|
1935
1935
|
target.name = spl.slice(0, -1).join('_');
|
1936
1936
|
|
1937
|
-
|
1938
|
-
|
1937
|
+
if (builtinFuncs['__' + target.name + '_' + protoName]) protoName = null;
|
1938
|
+
else if (!lookupName(scope, target.name)[0] && !builtinFuncs[target.name]) {
|
1939
|
+
if (lookupName(scope, '__' + target.name)[0] || builtinFuncs['__' + target.name]) target.name = '__' + target.name;
|
1940
|
+
else protoName = null;
|
1941
|
+
}
|
1939
1942
|
}
|
1940
1943
|
|
1941
1944
|
// literal.func()
|
@@ -2189,6 +2192,11 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2189
2192
|
}
|
2190
2193
|
|
2191
2194
|
if (Object.keys(protoBC).length > 0) {
|
2195
|
+
let def = internalThrow(scope, 'TypeError', `'${protoName}' proto func tried to be called on a type without an impl`);
|
2196
|
+
|
2197
|
+
// fallback to object prototype impl as a basic prototype chain hack
|
2198
|
+
if (protoBC[TYPES.object]) def = protoBC[TYPES.object];
|
2199
|
+
|
2192
2200
|
return [
|
2193
2201
|
...out,
|
2194
2202
|
|
@@ -2196,7 +2204,7 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2196
2204
|
...protoBC,
|
2197
2205
|
|
2198
2206
|
// TODO: error better
|
2199
|
-
default:
|
2207
|
+
default: def
|
2200
2208
|
}, valtypeBinary)
|
2201
2209
|
];
|
2202
2210
|
}
|
@@ -4862,14 +4870,8 @@ const makeArray = (scope, decl, global = false, name = '$undeclared', initEmpty
|
|
4862
4870
|
// hack: handle allocation for #member_prop's here instead of in several places /shrug
|
4863
4871
|
let shouldGet = true;
|
4864
4872
|
if (name === '#member_prop') {
|
4865
|
-
|
4866
|
-
|
4867
|
-
...number(rawPtr),
|
4868
|
-
[ global ? Opcodes.global_set : Opcodes.local_set, local.idx ]
|
4869
|
-
);
|
4870
|
-
|
4871
|
-
scope._allocatedMemberProp = true;
|
4872
|
-
}
|
4873
|
+
out.push(...number(rawPtr, Valtype.i32));
|
4874
|
+
shouldGet = false;
|
4873
4875
|
}
|
4874
4876
|
|
4875
4877
|
if (name === '#member_prop_assign') {
|
@@ -5500,7 +5502,7 @@ const objectHack = node => {
|
|
5500
5502
|
};
|
5501
5503
|
|
5502
5504
|
const generateFunc = (scope, decl) => {
|
5503
|
-
const name = decl.id ? decl.id.name :
|
5505
|
+
const name = decl.id ? decl.id.name : `#anonymous${uniqId()}`;
|
5504
5506
|
const params = decl.params ?? [];
|
5505
5507
|
|
5506
5508
|
// TODO: share scope/locals between !!!
|
package/compiler/decompile.js
CHANGED
@@ -24,7 +24,7 @@ export default (wasm, name = '', ind = 0, locals = {}, params = [], returns = []
|
|
24
24
|
if (name) out += `${name}(${ind}) ${makeSignature(params, returns, locals)}\n`;
|
25
25
|
|
26
26
|
const justLocals = Object.values(locals).sort((a, b) => a.idx - b.idx).slice(params.length);
|
27
|
-
for (const x of justLocals) {
|
27
|
+
if (name) for (const x of justLocals) {
|
28
28
|
out += `;; local ${invLocals[x.idx]}(${x.idx}): ${invValtype[x.type]}\n`
|
29
29
|
}
|
30
30
|
|
package/compiler/precompile.js
CHANGED
@@ -216,7 +216,10 @@ ${funcs.map(x => {
|
|
216
216
|
|
217
217
|
const locals = Object.entries(x.locals).sort((a,b) => a[1].idx - b[1].idx)
|
218
218
|
|
219
|
-
|
219
|
+
// todo: check for other identifier unsafe characters
|
220
|
+
const name = x.name.includes('#') ? `['${x.name}']` : `.${x.name}`;
|
221
|
+
|
222
|
+
return ` this${name} = {
|
220
223
|
wasm: ${rewriteWasm(x.wasm)},
|
221
224
|
params: ${JSON.stringify(x.params)}, typedParams: 1,
|
222
225
|
returns: ${JSON.stringify(x.returns)}, ${x.returnType != null ? `returnType: ${JSON.stringify(x.returnType)}` : 'typedReturns: 1'},
|
package/package.json
CHANGED