mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:18:11 +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
|
@ -56,6 +56,12 @@ void SetVariable::execute(Bytecode::Interpreter& interpreter) const
|
|||
interpreter.vm().set_variable(m_identifier, interpreter.reg(m_src), interpreter.global_object());
|
||||
}
|
||||
|
||||
void GetById::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
if (auto* object = interpreter.reg(m_base).to_object(interpreter.global_object()))
|
||||
interpreter.reg(m_dst) = object->get(m_property);
|
||||
}
|
||||
|
||||
void PutById::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
if (auto* object = interpreter.reg(m_base).to_object(interpreter.global_object()))
|
||||
|
@ -133,6 +139,11 @@ String PutById::to_string() const
|
|||
return String::formatted("PutById base:{}, property:{}, src:{}", m_base, m_property, m_src);
|
||||
}
|
||||
|
||||
String GetById::to_string() const
|
||||
{
|
||||
return String::formatted("GetById dst:{}, base:{}, property:{}", m_dst, m_base, m_property);
|
||||
}
|
||||
|
||||
String Jump::to_string() const
|
||||
{
|
||||
return String::formatted("Jump {}", m_target);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue