1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:17:42 +00:00

LibJS/Bytecode: Leave BlockDeclarationInstantiation in C++

Instead of implementing this AO in bytecode, we now have an instruction
for it that simply invokes the C++ implementation.

This allows us to simplify Bytecode::Generator quite a bit by removing
all the variable scope tracking.
This commit is contained in:
Andreas Kling 2023-06-16 16:34:47 +02:00
parent 4684d3fe54
commit ac246d764d
6 changed files with 56 additions and 91 deletions

View file

@ -1097,6 +1097,16 @@ ThrowCompletionOr<void> ToNumeric::execute_impl(Bytecode::Interpreter& interpret
return {};
}
ThrowCompletionOr<void> BlockDeclarationInstantiation::execute_impl(Bytecode::Interpreter& interpreter) const
{
auto& vm = interpreter.vm();
auto old_environment = vm.running_execution_context().lexical_environment;
interpreter.saved_lexical_environment_stack().append(old_environment);
vm.running_execution_context().lexical_environment = new_declarative_environment(*old_environment);
m_scope_node.block_declaration_instantiation(vm, vm.running_execution_context().lexical_environment);
return {};
}
DeprecatedString Load::to_deprecated_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("Load {}", m_src);
@ -1459,4 +1469,9 @@ DeprecatedString ToNumeric::to_deprecated_string_impl(Bytecode::Executable const
return "ToNumeric"sv;
}
DeprecatedString BlockDeclarationInstantiation::to_deprecated_string_impl(Bytecode::Executable const&) const
{
return "BlockDeclarationInstantiation"sv;
}
}