Skip to content

Commit

Permalink
LibJS/Bytecode: Emit GetPrivateById for private member expressions
Browse files Browse the repository at this point in the history
This makes it possible to call private member functions.

347 new passes on test262. :^)
  • Loading branch information
awesomekling committed Jun 23, 2023
1 parent 55f1a70 commit a9bdbf6
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1353,14 +1353,10 @@ static Bytecode::CodeGenerationErrorOr<void> get_base_and_value_from_member_expr
if (member_expression.is_computed()) {
TRY(member_expression.property().generate_bytecode(generator));
generator.emit<Bytecode::Op::GetByValue>(this_reg);
} else if (is<PrivateIdentifier>(member_expression.property())) {
generator.emit<Bytecode::Op::GetPrivateById>(generator.intern_identifier(verify_cast<PrivateIdentifier>(member_expression.property()).string()));
} else {
auto identifier_table_ref = [&] {
if (is<PrivateIdentifier>(member_expression.property()))
return generator.intern_identifier(verify_cast<PrivateIdentifier>(member_expression.property()).string());
return generator.intern_identifier(verify_cast<Identifier>(member_expression.property()).string());
}();

generator.emit<Bytecode::Op::GetById>(identifier_table_ref);
generator.emit<Bytecode::Op::GetById>(generator.intern_identifier(verify_cast<Identifier>(member_expression.property()).string()));
}
}

Expand Down

0 comments on commit a9bdbf6

Please sign in to comment.