1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:27:35 +00:00

LibJS: Remove home object from DeclarativeEnvironmentRecord

According to the spec, [[HomeObject]] is an internal slot on function
objects, and should always be accessed through there.
This commit is contained in:
Andreas Kling 2021-06-22 11:40:16 +02:00
parent 49340f98f7
commit 6ed6434bab
3 changed files with 7 additions and 14 deletions

View file

@ -50,7 +50,6 @@ void DeclarativeEnvironmentRecord::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_this_value);
visitor.visit(m_home_object);
visitor.visit(m_new_target);
visitor.visit(m_current_function);
for (auto& it : m_variables)
@ -72,17 +71,15 @@ bool DeclarativeEnvironmentRecord::delete_from_environment_record(FlyString cons
return m_variables.remove(name);
}
bool DeclarativeEnvironmentRecord::has_super_binding() const
{
return m_environment_record_type == EnvironmentRecordType::Function && this_binding_status() != ThisBindingStatus::Lexical && m_home_object.is_object();
}
Value DeclarativeEnvironmentRecord::get_super_base()
{
VERIFY(has_super_binding());
if (m_home_object.is_object())
return m_home_object.as_object().prototype();
return {};
if (m_environment_record_type != EnvironmentRecordType::Function)
return {};
VERIFY(m_current_function);
auto home_object = m_current_function->home_object();
if (!home_object.is_object())
return {};
return home_object.as_object().prototype();
}
bool DeclarativeEnvironmentRecord::has_this_binding() const

View file

@ -46,8 +46,6 @@ public:
HashMap<FlyString, Variable> const& variables() const { return m_variables; }
void set_home_object(Value object) { m_home_object = object; }
bool has_super_binding() const;
Value get_super_base();
ThisBindingStatus this_binding_status() const { return m_this_binding_status; }
@ -71,7 +69,6 @@ private:
EnvironmentRecordType m_environment_record_type : 8 { EnvironmentRecordType::Declarative };
ThisBindingStatus m_this_binding_status : 8 { ThisBindingStatus::Uninitialized };
HashMap<FlyString, Variable> m_variables;
Value m_home_object;
Value m_this_value;
Value m_new_target;
// Corresponds to [[FunctionObject]]

View file

@ -123,7 +123,6 @@ DeclarativeEnvironmentRecord* ScriptFunction::create_environment_record()
}
auto* environment = heap().allocate<DeclarativeEnvironmentRecord>(global_object(), move(variables), m_parent_scope, DeclarativeEnvironmentRecord::EnvironmentRecordType::Function);
environment->set_home_object(home_object());
environment->set_current_function(*this);
if (m_is_arrow_function) {
if (is<DeclarativeEnvironmentRecord>(m_parent_scope))