porffor 0.55.7 → 0.55.8
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 +36 -31
- package/compiler/index.js +2 -1
- package/package.json +1 -1
- package/runner/index.js +1 -1
- package/r.js +0 -6
package/compiler/codegen.js
CHANGED
@@ -2119,15 +2119,17 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2119
2119
|
}
|
2120
2120
|
|
2121
2121
|
// literal.func()
|
2122
|
-
if (!decl._new && !name && decl.callee.type === 'MemberExpression') {
|
2122
|
+
if (!decl._new && !name && (decl.callee.type === 'MemberExpression' || decl.callee.type === 'ChainExpression')) {
|
2123
|
+
const prop = (decl.callee.expression ?? decl.callee).property;
|
2124
|
+
const object = (decl.callee.expression ?? decl.callee).object;
|
2125
|
+
|
2123
2126
|
// megahack for /regex/.func()
|
2124
|
-
|
2125
|
-
|
2126
|
-
const
|
2127
|
-
const rhemynName = `regex_${funcName}_${sanitize(regex)}`;
|
2127
|
+
if (object?.regex && ['test'].includes(prop.name)) {
|
2128
|
+
const regex = object.regex.pattern;
|
2129
|
+
const rhemynName = `regex_${prop.name}_${sanitize(regex)}`;
|
2128
2130
|
|
2129
2131
|
if (!funcIndex[rhemynName]) {
|
2130
|
-
const func = Rhemyn[
|
2132
|
+
const func = Rhemyn[prop.name](regex, currentFuncIndex++, rhemynName);
|
2131
2133
|
func.internal = true;
|
2132
2134
|
|
2133
2135
|
funcIndex[func.name] = func.index;
|
@@ -2146,15 +2148,15 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2146
2148
|
[ Opcodes.call, idx ],
|
2147
2149
|
Opcodes.i32_from_u,
|
2148
2150
|
|
2149
|
-
...setLastType(scope, Rhemyn.types[
|
2151
|
+
...setLastType(scope, Rhemyn.types[prop.name])
|
2150
2152
|
];
|
2151
2153
|
}
|
2152
2154
|
|
2153
|
-
protoName =
|
2154
|
-
target =
|
2155
|
+
protoName = prop?.name;
|
2156
|
+
target = object;
|
2155
2157
|
}
|
2156
2158
|
|
2157
|
-
if (protoName) {
|
2159
|
+
if (protoName && target) {
|
2158
2160
|
if (protoName === 'call') {
|
2159
2161
|
const valTmp = localTmp(scope, '#call_val');
|
2160
2162
|
const typeTmp = localTmp(scope, '#call_type', Valtype.i32);
|
@@ -2528,28 +2530,31 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2528
2530
|
const calleeLocal = localTmp(scope, tmpName + 'callee');
|
2529
2531
|
|
2530
2532
|
// hack: this should be more thorough, Function.bind, etc
|
2531
|
-
if (decl.callee.type === 'MemberExpression'
|
2532
|
-
const
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
|
2537
|
-
|
2538
|
-
|
2539
|
-
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
|
2533
|
+
if (!decl._new && (decl.callee.type === 'MemberExpression' || decl.callee.type === 'ChainExpression')) {
|
2534
|
+
const { property, object, computed, optional } = decl.callee.expression ?? decl.callee;
|
2535
|
+
if (object && property) {
|
2536
|
+
const thisLocal = localTmp(scope, tmpName + 'caller');
|
2537
|
+
const thisLocalType = localTmp(scope, tmpName + 'caller#type', Valtype.i32);
|
2538
|
+
|
2539
|
+
knownThis = [
|
2540
|
+
[ Opcodes.local_get, thisLocal ],
|
2541
|
+
[ Opcodes.local_get, thisLocalType ]
|
2542
|
+
];
|
2543
|
+
getCallee = [
|
2544
|
+
...generate(scope, object),
|
2545
|
+
[ Opcodes.local_set, thisLocal ],
|
2546
|
+
...getNodeType(scope, object),
|
2547
|
+
[ Opcodes.local_set, thisLocalType ],
|
2544
2548
|
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2551
|
-
|
2552
|
-
|
2549
|
+
...generate(scope, {
|
2550
|
+
type: 'MemberExpression',
|
2551
|
+
object: { type: 'Identifier', name: tmpName + 'caller' },
|
2552
|
+
property,
|
2553
|
+
computed,
|
2554
|
+
optional
|
2555
|
+
})
|
2556
|
+
];
|
2557
|
+
}
|
2553
2558
|
}
|
2554
2559
|
|
2555
2560
|
let callee = decl.callee, callAsNew = decl._new;
|
package/compiler/index.js
CHANGED
@@ -250,7 +250,8 @@ export default (code, module = undefined) => {
|
|
250
250
|
|
251
251
|
const tmpfile = 'porffor_tmp.c';
|
252
252
|
const args = [ ...compiler, tmpfile, '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), '-' + cO ];
|
253
|
-
if (
|
253
|
+
if (compiler.includes('clang')) args.push('-flto=thin', '-march=native', '-ffast-math', '-fno-exceptions', '-fno-ident', '-fno-asynchronous-unwind-tables', '-ffunction-sections', '-fdata-sections');
|
254
|
+
if (Prefs.s) args.push('-s');
|
254
255
|
|
255
256
|
if (logProgress) progressStart('compiling Wasm to C...');
|
256
257
|
const t4 = performance.now();
|
package/package.json
CHANGED
package/runner/index.js
CHANGED