mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 04:17:34 +00:00
LibJS: Add PutById bytecode instruction for object property assignment
Note that this is only used for non-computed accesses. Computed access is not yet implemented. :^)
This commit is contained in:
parent
bea6e31ddc
commit
14cfc44855
3 changed files with 44 additions and 0 deletions
|
@ -90,6 +90,20 @@ Optional<Bytecode::Register> AssignmentExpression::generate_bytecode(Bytecode::G
|
|||
return rhs_reg;
|
||||
}
|
||||
|
||||
if (is<MemberExpression>(*m_lhs)) {
|
||||
auto& expression = static_cast<MemberExpression const&>(*m_lhs);
|
||||
auto object_reg = expression.object().generate_bytecode(generator);
|
||||
|
||||
if (expression.is_computed()) {
|
||||
TODO();
|
||||
} else {
|
||||
VERIFY(is<Identifier>(expression.property()));
|
||||
auto rhs_reg = m_rhs->generate_bytecode(generator);
|
||||
generator.emit<Bytecode::Op::PutById>(*object_reg, static_cast<Identifier const&>(expression.property()).string(), *rhs_reg);
|
||||
return rhs_reg;
|
||||
}
|
||||
}
|
||||
|
||||
TODO();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue