Skip to content

Commit

Permalink
codegen: simplify NewExpression generation
Browse files Browse the repository at this point in the history
test262: 41.95% | πŸ§ͺ 48414 | 🀠 20308 | ❌ 6501 | πŸ’€ 15354 | πŸ—οΈ 64 | πŸ’₯ 301 | ⏰ 28 | πŸ“ 5858
  • Loading branch information
CanadaHonk committed Aug 31, 2024
1 parent 9ba2dc6 commit dbe67bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions compiler/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ const generate = (scope, decl, global = false, name = undefined, valueUnused = f
return cacheAst(decl, generateChain(scope, decl));

case 'CallExpression':
return cacheAst(decl, generateCall(scope, decl, global, name, valueUnused));

case 'NewExpression':
return cacheAst(decl, generateNew(scope, decl, global, name));
return cacheAst(decl, generateCall(scope, decl, global, name, valueUnused));

case 'ThisExpression':
return cacheAst(decl, generateThis(scope, decl));
Expand Down Expand Up @@ -1753,6 +1751,8 @@ const createThisArg = (scope, decl) => {
};

const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
if (decl.type === 'NewExpression') decl._new = true;

let out = [];
let name = decl.callee.name;

Expand Down Expand Up @@ -2536,11 +2536,6 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
return out;
};

const generateNew = (scope, decl, _global, _name) => generateCall(scope, {
...decl,
_new: true
}, _global, _name);

const generateThis = (scope, decl) => {
if (!scope.constr) {
// this in a non-constructor context is a reference to globalThis
Expand Down
2 changes: 1 addition & 1 deletion test262/history.json

Large diffs are not rendered by default.

0 comments on commit dbe67bc

Please sign in to comment.