mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
LibJS: Move [[HomeObject]] to ECMAScriptFunctionObject
This commit is contained in:
parent
06726d41ac
commit
136451c3af
6 changed files with 14 additions and 13 deletions
|
@ -924,7 +924,7 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob
|
|||
if (interpreter.exception())
|
||||
return {};
|
||||
|
||||
auto& method_function = method_value.as_function();
|
||||
auto& method_function = static_cast<ECMAScriptFunctionObject&>(method_value.as_function());
|
||||
|
||||
auto key = method.key().execute(interpreter, global_object);
|
||||
if (interpreter.exception())
|
||||
|
@ -965,7 +965,7 @@ Value ClassExpression::execute(Interpreter& interpreter, GlobalObject& global_ob
|
|||
if (interpreter.exception())
|
||||
return {};
|
||||
|
||||
FunctionObject* initializer = nullptr;
|
||||
ECMAScriptFunctionObject* initializer = nullptr;
|
||||
if (field.initializer()) {
|
||||
auto copy_initializer = field.initializer();
|
||||
auto body = create_ast_node<ExpressionStatement>(field.initializer()->source_range(), copy_initializer.release_nonnull());
|
||||
|
@ -1923,7 +1923,7 @@ Value ObjectExpression::execute(Interpreter& interpreter, GlobalObject& global_o
|
|||
return {};
|
||||
|
||||
if (value.is_function() && property.is_method())
|
||||
value.as_function().set_home_object(object);
|
||||
static_cast<ECMAScriptFunctionObject&>(value.as_function()).set_home_object(object);
|
||||
|
||||
String name = get_function_name(global_object, key);
|
||||
if (property.type() == ObjectProperty::Type::Getter) {
|
||||
|
|
|
@ -99,6 +99,7 @@ void ECMAScriptFunctionObject::visit_edges(Visitor& visitor)
|
|||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_environment);
|
||||
visitor.visit(m_realm);
|
||||
visitor.visit(m_home_object);
|
||||
}
|
||||
|
||||
FunctionEnvironment* ECMAScriptFunctionObject::create_environment(FunctionObject& function_being_invoked)
|
||||
|
@ -131,7 +132,7 @@ FunctionEnvironment* ECMAScriptFunctionObject::create_environment(FunctionObject
|
|||
}
|
||||
|
||||
auto* environment = heap().allocate<FunctionEnvironment>(global_object(), m_environment, variables);
|
||||
environment->set_function_object(function_being_invoked);
|
||||
environment->set_function_object(static_cast<ECMAScriptFunctionObject&>(function_being_invoked));
|
||||
if (m_is_arrow_function) {
|
||||
environment->set_this_binding_status(FunctionEnvironment::ThisBindingStatus::Lexical);
|
||||
if (is<FunctionEnvironment>(m_environment))
|
||||
|
|
|
@ -55,6 +55,9 @@ public:
|
|||
|
||||
ThisMode this_mode() const { return m_this_mode; }
|
||||
|
||||
Object* home_object() const { return m_home_object; }
|
||||
void set_home_object(Object* home_object) { m_home_object = home_object; }
|
||||
|
||||
protected:
|
||||
virtual bool is_strict_mode() const final { return m_strict; }
|
||||
|
||||
|
@ -73,6 +76,7 @@ private:
|
|||
Realm* m_realm { nullptr }; // [[Realm]]
|
||||
ThisMode m_this_mode { ThisMode::Global }; // [[ThisMode]]
|
||||
bool m_strict { false }; // [[Strict]]
|
||||
Object* m_home_object { nullptr }; // [[HomeObject]]
|
||||
bool m_is_class_constructor { false }; // [[IsClassConstructor]]
|
||||
|
||||
FlyString m_name;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibJS/Runtime/DeclarativeEnvironment.h>
|
||||
#include <LibJS/Runtime/ECMAScriptFunctionObject.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
|
@ -35,9 +36,9 @@ public:
|
|||
void set_this_binding_status(ThisBindingStatus status) { m_this_binding_status = status; }
|
||||
|
||||
// [[FunctionObject]]
|
||||
FunctionObject& function_object() { return *m_function_object; }
|
||||
FunctionObject const& function_object() const { return *m_function_object; }
|
||||
void set_function_object(FunctionObject& function) { m_function_object = &function; }
|
||||
ECMAScriptFunctionObject& function_object() { return *m_function_object; }
|
||||
ECMAScriptFunctionObject const& function_object() const { return *m_function_object; }
|
||||
void set_function_object(ECMAScriptFunctionObject& function) { m_function_object = &function; }
|
||||
|
||||
// [[NewTarget]]
|
||||
Value new_target() const { return m_new_target; }
|
||||
|
@ -56,7 +57,7 @@ private:
|
|||
|
||||
Value m_this_value;
|
||||
ThisBindingStatus m_this_binding_status { ThisBindingStatus::Uninitialized };
|
||||
FunctionObject* m_function_object { nullptr };
|
||||
ECMAScriptFunctionObject* m_function_object { nullptr };
|
||||
Value m_new_target;
|
||||
};
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ void FunctionObject::visit_edges(Visitor& visitor)
|
|||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
||||
visitor.visit(m_home_object);
|
||||
visitor.visit(m_bound_this);
|
||||
|
||||
for (auto argument : m_bound_arguments)
|
||||
|
|
|
@ -29,9 +29,6 @@ public:
|
|||
|
||||
const Vector<Value>& bound_arguments() const { return m_bound_arguments; }
|
||||
|
||||
Object* home_object() const { return m_home_object; }
|
||||
void set_home_object(Object* home_object) { m_home_object = home_object; }
|
||||
|
||||
virtual bool is_strict_mode() const { return false; }
|
||||
|
||||
// [[Environment]]
|
||||
|
@ -68,7 +65,6 @@ private:
|
|||
virtual bool is_function() const override { return true; }
|
||||
Value m_bound_this;
|
||||
Vector<Value> m_bound_arguments;
|
||||
Object* m_home_object { nullptr };
|
||||
bool m_has_simple_parameter_list { false };
|
||||
Vector<InstanceField> m_fields;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue