mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 10:35:09 +00:00
LibJS: Add GetById bytecode instruction for object property retrieval
Same as PutById but in the other direction. :^)
This commit is contained in:
parent
14cfc44855
commit
32561bb90d
4 changed files with 45 additions and 0 deletions
|
@ -141,4 +141,18 @@ Optional<Bytecode::Register> ObjectExpression::generate_bytecode(Bytecode::Gener
|
|||
return reg;
|
||||
}
|
||||
|
||||
Optional<Bytecode::Register> MemberExpression::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
auto object_reg = object().generate_bytecode(generator);
|
||||
|
||||
if (is_computed()) {
|
||||
TODO();
|
||||
} else {
|
||||
VERIFY(is<Identifier>(property()));
|
||||
auto dst_reg = generator.allocate_register();
|
||||
generator.emit<Bytecode::Op::GetById>(dst_reg, *object_reg, static_cast<Identifier const&>(property()).string());
|
||||
return dst_reg;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue