mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00
LibJS+LibWeb: Plumb local variables names to ECMAScriptFunctionObject
Saving vector of local variables names in ECMAScriptFunctionObject will allow to get a name by index in case message of ReferenceError needs to contain a variable name.
This commit is contained in:
parent
401d97c45c
commit
7765ebb5f2
10 changed files with 27 additions and 20 deletions
|
@ -33,8 +33,8 @@ public:
|
|||
Global,
|
||||
};
|
||||
|
||||
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {});
|
||||
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {});
|
||||
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {});
|
||||
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {});
|
||||
|
||||
virtual ThrowCompletionOr<void> initialize(Realm&) override;
|
||||
virtual ~ECMAScriptFunctionObject() override = default;
|
||||
|
@ -80,6 +80,8 @@ public:
|
|||
// Equivalent to absence of [[Construct]]
|
||||
virtual bool has_constructor() const override { return m_kind == FunctionKind::Normal && !m_is_arrow_function; }
|
||||
|
||||
virtual Vector<DeprecatedFlyString> const& local_variables_names() const override { return m_local_variables_names; }
|
||||
|
||||
FunctionKind kind() const { return m_kind; }
|
||||
|
||||
// This is used by LibWeb to disassociate event handler attribute callback functions from the nearest script on the call stack.
|
||||
|
@ -94,7 +96,7 @@ protected:
|
|||
virtual Completion ordinary_call_evaluate_body();
|
||||
|
||||
private:
|
||||
ECMAScriptFunctionObject(DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name);
|
||||
ECMAScriptFunctionObject(DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name);
|
||||
|
||||
virtual bool is_ecmascript_function_object() const override { return true; }
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
@ -110,6 +112,7 @@ private:
|
|||
OwnPtr<Bytecode::Executable> m_bytecode_executable;
|
||||
Vector<OwnPtr<Bytecode::Executable>> m_default_parameter_bytecode_executables;
|
||||
i32 m_function_length { 0 };
|
||||
Vector<DeprecatedFlyString> m_local_variables_names;
|
||||
|
||||
// Internal Slots of ECMAScript Function Objects, https://tc39.es/ecma262/#table-internal-slots-of-ecmascript-function-objects
|
||||
GCPtr<Environment> m_environment; // [[Environment]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue