mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
LibJS/Bytecode: Implement the delete unary expression
`delete` has to operate directly on Reference Records, so this introduces a new set of operations called DeleteByValue, DeleteVariable and DeleteById. They operate similarly to their Get counterparts, except they end in creating a (temporary) Reference and calling delete_ on it.
This commit is contained in:
parent
589c3771e9
commit
7cc53b7ef1
6 changed files with 146 additions and 4 deletions
|
@ -427,6 +427,9 @@ Bytecode::CodeGenerationErrorOr<void> LogicalExpression::generate_bytecode(Bytec
|
|||
|
||||
Bytecode::CodeGenerationErrorOr<void> UnaryExpression::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
if (m_op == UnaryOp::Delete)
|
||||
return generator.emit_delete_reference(m_lhs);
|
||||
|
||||
TRY(m_lhs->generate_bytecode(generator));
|
||||
|
||||
switch (m_op) {
|
||||
|
@ -448,11 +451,9 @@ Bytecode::CodeGenerationErrorOr<void> UnaryExpression::generate_bytecode(Bytecod
|
|||
case UnaryOp::Void:
|
||||
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
|
||||
break;
|
||||
case UnaryOp::Delete: // Delete is implemented above.
|
||||
default:
|
||||
return Bytecode::CodeGenerationError {
|
||||
this,
|
||||
"Unimplemented operation"sv,
|
||||
};
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue