mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 15:47:42 +00:00
LibJS: Move has_simple_parameter_list to ECMAScriptFunctionObject
This commit is contained in:
parent
76eb8fe717
commit
a08292d76c
4 changed files with 7 additions and 9 deletions
|
@ -58,7 +58,7 @@ ECMAScriptFunctionObject::ECMAScriptFunctionObject(GlobalObject& global_object,
|
|||
m_this_mode = ThisMode::Global;
|
||||
|
||||
// 15.1.3 Static Semantics: IsSimpleParameterList, https://tc39.es/ecma262/#sec-static-semantics-issimpleparameterlist
|
||||
set_has_simple_parameter_list(all_of(m_formal_parameters, [&](auto& parameter) {
|
||||
m_has_simple_parameter_list = all_of(m_formal_parameters, [&](auto& parameter) {
|
||||
if (parameter.is_rest)
|
||||
return false;
|
||||
if (parameter.default_value)
|
||||
|
@ -66,7 +66,7 @@ ECMAScriptFunctionObject::ECMAScriptFunctionObject(GlobalObject& global_object,
|
|||
if (!parameter.binding.template has<FlyString>())
|
||||
return false;
|
||||
return true;
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
void ECMAScriptFunctionObject::initialize(GlobalObject& global_object)
|
||||
|
|
|
@ -68,6 +68,9 @@ public:
|
|||
Vector<InstanceField> const& fields() const { return m_fields; }
|
||||
void add_field(StringOrSymbol property_key, ECMAScriptFunctionObject* initializer) { m_fields.empend(property_key, initializer); }
|
||||
|
||||
// This is for IsSimpleParameterList (static semantics)
|
||||
bool has_simple_parameter_list() const { return m_has_simple_parameter_list; }
|
||||
|
||||
protected:
|
||||
virtual bool is_strict_mode() const final { return m_strict; }
|
||||
|
||||
|
@ -95,6 +98,7 @@ private:
|
|||
i32 m_function_length { 0 };
|
||||
FunctionKind m_kind { FunctionKind::Regular };
|
||||
bool m_is_arrow_function { false };
|
||||
bool m_has_simple_parameter_list { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -39,22 +39,16 @@ public:
|
|||
// [[Realm]]
|
||||
virtual Realm* realm() const { return nullptr; }
|
||||
|
||||
// This is for IsSimpleParameterList (static semantics)
|
||||
bool has_simple_parameter_list() const { return m_has_simple_parameter_list; }
|
||||
|
||||
protected:
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
explicit FunctionObject(Object& prototype);
|
||||
FunctionObject(Value bound_this, Vector<Value> bound_arguments, Object& prototype);
|
||||
|
||||
void set_has_simple_parameter_list(bool b) { m_has_simple_parameter_list = b; }
|
||||
|
||||
private:
|
||||
virtual bool is_function() const override { return true; }
|
||||
Value m_bound_this;
|
||||
Vector<Value> m_bound_arguments;
|
||||
bool m_has_simple_parameter_list { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -374,7 +374,7 @@ Value VM::get_variable(const FlyString& name, GlobalObject& global_object)
|
|||
if (possible_match.has_value())
|
||||
return possible_match.value().value;
|
||||
if (!context.arguments_object) {
|
||||
if (context.function->is_strict_mode() || !context.function->has_simple_parameter_list()) {
|
||||
if (context.function->is_strict_mode() || (is<ECMAScriptFunctionObject>(context.function) && !static_cast<ECMAScriptFunctionObject*>(context.function)->has_simple_parameter_list())) {
|
||||
context.arguments_object = create_unmapped_arguments_object(global_object, context.arguments.span());
|
||||
} else {
|
||||
context.arguments_object = create_mapped_arguments_object(global_object, *context.function, verify_cast<ECMAScriptFunctionObject>(context.function)->formal_parameters(), context.arguments.span(), *lexical_environment());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue