mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 01:08:11 +00:00
LibJS: Make sure scope expressions yield the correct value
When evaluated as an expression "{ 3 }" should yield 3. This updates the bytecode interpreter to make it so.
This commit is contained in:
parent
ed5777eb0a
commit
2c10bd72f2
1 changed files with 3 additions and 2 deletions
|
@ -21,10 +21,11 @@ Optional<Bytecode::Register> ASTNode::generate_bytecode(Bytecode::Generator&) co
|
||||||
Optional<Bytecode::Register> ScopeNode::generate_bytecode(Bytecode::Generator& generator) const
|
Optional<Bytecode::Register> ScopeNode::generate_bytecode(Bytecode::Generator& generator) const
|
||||||
{
|
{
|
||||||
generator.emit<Bytecode::Op::EnterScope>(*this);
|
generator.emit<Bytecode::Op::EnterScope>(*this);
|
||||||
|
Optional<Bytecode::Register> last_value_reg;
|
||||||
for (auto& child : children()) {
|
for (auto& child : children()) {
|
||||||
[[maybe_unused]] auto reg = child.generate_bytecode(generator);
|
last_value_reg = child.generate_bytecode(generator);
|
||||||
}
|
}
|
||||||
return {};
|
return last_value_reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Bytecode::Register> EmptyStatement::generate_bytecode(Bytecode::Generator&) const
|
Optional<Bytecode::Register> EmptyStatement::generate_bytecode(Bytecode::Generator&) const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue