mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 07:36:50 +00:00
LibJS: Reduce use of Interpreter in LexicalEnvironment
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user