porffor 0.42.2 → 0.42.3
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 +6 -6
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -1922,7 +1922,7 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
1922
1922
|
|
1923
1923
|
// opt: virtualize iifes
|
1924
1924
|
if (isFuncType(decl.callee.type)) {
|
1925
|
-
const [ func ] = generateFunc(scope, decl.callee);
|
1925
|
+
const [ func ] = generateFunc(scope, decl.callee, true);
|
1926
1926
|
name = func.name;
|
1927
1927
|
}
|
1928
1928
|
|
@@ -2999,7 +2999,7 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
|
|
2999
2999
|
// hack for let a = function () { ... }
|
3000
3000
|
if (!init.id) {
|
3001
3001
|
init.id = { name };
|
3002
|
-
generateFunc(scope, init);
|
3002
|
+
generateFunc(scope, init, true);
|
3003
3003
|
return out;
|
3004
3004
|
}
|
3005
3005
|
}
|
@@ -5988,7 +5988,7 @@ const funcByIndex = idx => {
|
|
5988
5988
|
};
|
5989
5989
|
const funcByName = name => funcByIndex(funcIndex[name]);
|
5990
5990
|
|
5991
|
-
const generateFunc = (scope, decl) => {
|
5991
|
+
const generateFunc = (scope, decl, forceNoExpr = false) => {
|
5992
5992
|
const name = decl.id ? decl.id.name : `#anonymous${uniqId()}`;
|
5993
5993
|
if (decl.type.startsWith('Class')) {
|
5994
5994
|
const out = generateClass(scope, {
|
@@ -6066,7 +6066,7 @@ const generateFunc = (scope, decl) => {
|
|
6066
6066
|
);
|
6067
6067
|
}
|
6068
6068
|
|
6069
|
-
if (decl.async) {
|
6069
|
+
if (decl.async && !decl.generator) {
|
6070
6070
|
// make out promise local
|
6071
6071
|
allocVar(func, '#async_out_promise', false, false);
|
6072
6072
|
|
@@ -6076,7 +6076,7 @@ const generateFunc = (scope, decl) => {
|
|
6076
6076
|
|
6077
6077
|
const wasm = prelude.concat(generate(func, body));
|
6078
6078
|
|
6079
|
-
if (
|
6079
|
+
if (func.async) {
|
6080
6080
|
// make promise at the start
|
6081
6081
|
wasm.unshift(
|
6082
6082
|
[ Opcodes.call, includeBuiltin(func, '__Porffor_promise_create').index ],
|
@@ -6271,7 +6271,7 @@ const generateFunc = (scope, decl) => {
|
|
6271
6271
|
// force generate all for precompile
|
6272
6272
|
if (globalThis.precompile) func.generate();
|
6273
6273
|
|
6274
|
-
const out = decl.type.endsWith('Expression') ? funcRef(func) : [];
|
6274
|
+
const out = decl.type.endsWith('Expression') && !forceNoExpr ? funcRef(func) : [];
|
6275
6275
|
astCache.set(decl, out);
|
6276
6276
|
return [ func, out ];
|
6277
6277
|
};
|
package/package.json
CHANGED