diff options
author | Andreas Kling <kling@serenityos.org> | 2021-10-25 15:17:41 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-25 15:17:41 +0200 |
commit | 72736f9e93963334a879c4fbc432677138e7d42f (patch) | |
tree | 215ff2a35f5823bcf652954e68debc3dfb74bf67 /Userland/Libraries | |
parent | 1dc60b028f37366ec01b809a101224ada7dc82aa (diff) | |
download | serenity-72736f9e93963334a879c4fbc432677138e7d42f.zip |
LibJS: Generate bytecode for UpdateExpression with MemberExpression arg
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index b55a79dddd..c9c89557d1 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -1134,29 +1134,23 @@ void TaggedTemplateLiteral::generate_bytecode(Bytecode::Generator& generator) co void UpdateExpression::generate_bytecode(Bytecode::Generator& generator) const { - if (is<Identifier>(*m_argument)) { - auto& identifier = static_cast<Identifier const&>(*m_argument); - generator.emit<Bytecode::Op::GetVariable>(generator.intern_identifier(identifier.string())); - - Optional<Bytecode::Register> previous_value_for_postfix_reg; - if (!m_prefixed) { - previous_value_for_postfix_reg = generator.allocate_register(); - generator.emit<Bytecode::Op::Store>(*previous_value_for_postfix_reg); - } + generator.emit_load_from_reference(*m_argument); - if (m_op == UpdateOp::Increment) - generator.emit<Bytecode::Op::Increment>(); - else - generator.emit<Bytecode::Op::Decrement>(); + Optional<Bytecode::Register> previous_value_for_postfix_reg; + if (!m_prefixed) { + previous_value_for_postfix_reg = generator.allocate_register(); + generator.emit<Bytecode::Op::Store>(*previous_value_for_postfix_reg); + } - generator.emit<Bytecode::Op::SetVariable>(generator.intern_identifier(identifier.string())); + if (m_op == UpdateOp::Increment) + generator.emit<Bytecode::Op::Increment>(); + else + generator.emit<Bytecode::Op::Decrement>(); - if (!m_prefixed) - generator.emit<Bytecode::Op::Load>(*previous_value_for_postfix_reg); - return; - } + generator.emit_store_to_reference(*m_argument); - TODO(); + if (!m_prefixed) + generator.emit<Bytecode::Op::Load>(*previous_value_for_postfix_reg); } void ThrowStatement::generate_bytecode(Bytecode::Generator& generator) const |