porffor 0.57.27 → 0.57.28
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/codegen.js +30 -31
- package/foo.js +8 -0
- package/package.json +1 -1
- package/runtime/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -1255,28 +1255,16 @@ const generateBinaryExp = (scope, decl) => {
|
|
1255
1255
|
const asmFuncToAsm = (scope, func, extra) => func(scope, {
|
1256
1256
|
Valtype, Opcodes, TYPES, TYPE_NAMES, usedTypes, typeSwitch, makeString, internalThrow,
|
1257
1257
|
getNodeType, generate, generateIdent,
|
1258
|
-
builtin: (
|
1259
|
-
let idx = importedFuncs[
|
1260
|
-
if (idx == null
|
1261
|
-
includeBuiltin(scope, n);
|
1262
|
-
idx = funcIndex[n];
|
1263
|
-
}
|
1264
|
-
|
1265
|
-
scope.includes ??= new Set();
|
1266
|
-
scope.includes.add(n);
|
1267
|
-
|
1268
|
-
if (idx == null) throw new Error(`builtin('${n}') failed: could not find func (from ${scope.name})`);
|
1258
|
+
builtin: (name, offset = false) => {
|
1259
|
+
let idx = importedFuncs[name] ?? includeBuiltin(scope, name)?.index;
|
1260
|
+
if (idx == null) throw new Error(`builtin('${name}') failed: could not find func (from ${scope.name})`);
|
1269
1261
|
if (offset) idx -= importedFuncs.length;
|
1270
1262
|
|
1271
1263
|
return idx;
|
1272
1264
|
},
|
1273
1265
|
hasFunc: x => funcIndex[x] != null,
|
1274
1266
|
funcRef: name => {
|
1275
|
-
|
1276
|
-
includeBuiltin(scope, name);
|
1277
|
-
}
|
1278
|
-
|
1279
|
-
const func = funcByName(name);
|
1267
|
+
const func = includeBuiltin(scope, name);
|
1280
1268
|
return funcRef(func);
|
1281
1269
|
},
|
1282
1270
|
glbl: (opcode, name, type) => {
|
@@ -1340,7 +1328,7 @@ const asmFunc = (name, { wasm, params = [], typedParams = false, locals: localTy
|
|
1340
1328
|
wasm = [];
|
1341
1329
|
}
|
1342
1330
|
|
1343
|
-
const existing =
|
1331
|
+
const existing = builtinFuncByName(name);
|
1344
1332
|
if (existing) return existing;
|
1345
1333
|
|
1346
1334
|
const allLocals = params.concat(localTypes);
|
@@ -2498,20 +2486,24 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2498
2486
|
[ Opcodes.local_get, thisLocal ],
|
2499
2487
|
[ Opcodes.local_get, thisLocalType ]
|
2500
2488
|
];
|
2501
|
-
getCallee =
|
2502
|
-
|
2503
|
-
|
2504
|
-
|
2505
|
-
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2509
|
-
|
2510
|
-
|
2511
|
-
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2489
|
+
getCallee = generate(scope, {
|
2490
|
+
type: 'MemberExpression',
|
2491
|
+
object: {
|
2492
|
+
type: 'Wasm',
|
2493
|
+
wasm: () => [
|
2494
|
+
...generate(scope, object),
|
2495
|
+
[ Opcodes.local_tee, thisLocal ],
|
2496
|
+
...getNodeType(scope, object),
|
2497
|
+
[ Opcodes.local_set, thisLocalType ]
|
2498
|
+
],
|
2499
|
+
_type: [
|
2500
|
+
[ Opcodes.local_get, thisLocalType ]
|
2501
|
+
]
|
2502
|
+
},
|
2503
|
+
property,
|
2504
|
+
computed,
|
2505
|
+
optional
|
2506
|
+
});
|
2515
2507
|
}
|
2516
2508
|
}
|
2517
2509
|
|
@@ -6539,6 +6531,13 @@ const funcByIndex = idx => {
|
|
6539
6531
|
};
|
6540
6532
|
const funcByName = name => funcByIndex(funcIndex[name]);
|
6541
6533
|
|
6534
|
+
const builtinFuncByName = name => {
|
6535
|
+
const normal = funcByName(name);
|
6536
|
+
if (!normal || normal.internal) return normal;
|
6537
|
+
|
6538
|
+
return funcs.find(x => x.name === name && x.internal);
|
6539
|
+
};
|
6540
|
+
|
6542
6541
|
const generateFunc = (scope, decl, forceNoExpr = false) => {
|
6543
6542
|
doNotMarkFuncRef = false;
|
6544
6543
|
|
package/foo.js
ADDED
package/package.json
CHANGED