1
Fork 0
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:
Andreas Kling 2021-06-04 21:03:53 +02:00
parent 14cfc44855
commit 32561bb90d
4 changed files with 45 additions and 0 deletions

View file

@ -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);