1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

LibJS: Reduce use of Interpreter in LexicalEnvironment

This commit is contained in:
Andreas Kling 2020-09-29 16:41:28 +02:00
parent 1175ecf1dd
commit 3df604ad12
7 changed files with 22 additions and 22 deletions

View file

@ -77,10 +77,10 @@ Optional<Variable> LexicalEnvironment::get(const FlyString& name) const
return m_variables.get(name);
}
void LexicalEnvironment::set(const FlyString& name, Variable variable)
void LexicalEnvironment::set(GlobalObject& global_object, const FlyString& name, Variable variable)
{
if (type() == EnvironmentRecordType::Global)
interpreter().global_object().put(name, variable.value);
global_object.put(name, variable.value);
else
m_variables.set(name, variable);
}
@ -114,21 +114,21 @@ bool LexicalEnvironment::has_this_binding() const
ASSERT_NOT_REACHED();
}
Value LexicalEnvironment::get_this_binding() const
Value LexicalEnvironment::get_this_binding(GlobalObject& global_object) const
{
ASSERT(has_this_binding());
if (this_binding_status() == ThisBindingStatus::Uninitialized) {
vm().throw_exception<ReferenceError>(interpreter().global_object(), ErrorType::ThisHasNotBeenInitialized);
vm().throw_exception<ReferenceError>(global_object, ErrorType::ThisHasNotBeenInitialized);
return {};
}
return m_this_value;
}
void LexicalEnvironment::bind_this_value(Value this_value)
void LexicalEnvironment::bind_this_value(GlobalObject& global_object, Value this_value)
{
ASSERT(has_this_binding());
if (m_this_binding_status == ThisBindingStatus::Initialized) {
vm().throw_exception<ReferenceError>(interpreter().global_object(), ErrorType::ThisIsAlreadyInitialized);
vm().throw_exception<ReferenceError>(global_object, ErrorType::ThisIsAlreadyInitialized);
return;
}
m_this_value = this_value;