porffor 0.50.9 → 0.50.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/codegen.js +22 -7
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -1786,15 +1786,11 @@ const disposeLeftover = wasm => {
|
|
1786
1786
|
};
|
1787
1787
|
|
1788
1788
|
const generateExp = (scope, decl) => {
|
1789
|
-
|
1790
|
-
|
1791
|
-
if (expression.type === 'Literal' && typeof expression.value === 'string') {
|
1792
|
-
if (expression.value === 'use strict') {
|
1793
|
-
scope.strict = true;
|
1794
|
-
}
|
1789
|
+
if (decl.directive === 'use strict') {
|
1790
|
+
scope.strict = true;
|
1795
1791
|
}
|
1796
1792
|
|
1797
|
-
const out = generate(scope, expression, undefined, undefined, !scope.inEval);
|
1793
|
+
const out = generate(scope, decl.expression, undefined, undefined, !scope.inEval);
|
1798
1794
|
disposeLeftover(out);
|
1799
1795
|
|
1800
1796
|
return out;
|
@@ -6432,6 +6428,25 @@ const generateFunc = (scope, decl, forceNoExpr = false) => {
|
|
6432
6428
|
};
|
6433
6429
|
}
|
6434
6430
|
|
6431
|
+
// todo: enable for all block statement bodies, not just main
|
6432
|
+
if (name === '#main') {
|
6433
|
+
// hoist function declarations to the top of AST pre-codegen so
|
6434
|
+
// we can optimize function calls so calls before decl are not indirect
|
6435
|
+
// (without more post-codegen jank)
|
6436
|
+
// plus, more spec-compliant hoisting!
|
6437
|
+
|
6438
|
+
let b = body.body, j = 0;
|
6439
|
+
|
6440
|
+
// append after directive if it exists
|
6441
|
+
if (b[0]?.directive) j++;
|
6442
|
+
|
6443
|
+
for (let i = 0; i < b.length; i++) {
|
6444
|
+
if (b[i].type === 'FunctionDeclaration') {
|
6445
|
+
b.splice(j++, 0, b.splice(i, 1)[0]);
|
6446
|
+
}
|
6447
|
+
}
|
6448
|
+
}
|
6449
|
+
|
6435
6450
|
func.identFailEarly = true;
|
6436
6451
|
let localInd = args.length * 2;
|
6437
6452
|
for (let i = 0; i < args.length; i++) {
|
package/package.json
CHANGED