mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:07:36 +00:00
LibJS: Add for_each_bound_identifier for AST::Declaration
The same as for_each_bound_name but for identifiers.
This commit is contained in:
parent
a6cdb1655b
commit
7f0074ac23
2 changed files with 78 additions and 1 deletions
|
@ -609,6 +609,7 @@ public:
|
|||
}
|
||||
|
||||
virtual ThrowCompletionOr<void> for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const = 0;
|
||||
virtual ThrowCompletionOr<void> for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&& callback) const = 0;
|
||||
|
||||
// 8.1.3 Static Semantics: IsConstantDeclaration, https://tc39.es/ecma262/#sec-static-semantics-isconstantdeclaration
|
||||
virtual bool is_constant_declaration() const { return false; }
|
||||
|
@ -628,6 +629,11 @@ public:
|
|||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&&) const override
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
};
|
||||
|
||||
struct BindingPattern : RefCounted<BindingPattern> {
|
||||
|
@ -650,6 +656,7 @@ struct BindingPattern : RefCounted<BindingPattern> {
|
|||
void dump(int indent) const;
|
||||
|
||||
ThrowCompletionOr<void> for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const;
|
||||
ThrowCompletionOr<void> for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&& callback) const;
|
||||
|
||||
bool contains_expression() const;
|
||||
|
||||
|
@ -729,8 +736,9 @@ protected:
|
|||
|
||||
void dump(int indent, DeprecatedString const& class_name) const;
|
||||
|
||||
private:
|
||||
RefPtr<Identifier const> m_name { nullptr };
|
||||
|
||||
private:
|
||||
DeprecatedString m_source_text;
|
||||
NonnullRefPtr<Statement const> m_body;
|
||||
Vector<FunctionParameter> const m_parameters;
|
||||
|
@ -762,6 +770,8 @@ public:
|
|||
|
||||
virtual ThrowCompletionOr<void> for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const override;
|
||||
|
||||
ThrowCompletionOr<void> for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&&) const override;
|
||||
|
||||
virtual bool is_function_declaration() const override { return true; }
|
||||
|
||||
void set_should_do_additional_annexB_steps() { m_is_hoisted = true; }
|
||||
|
@ -1458,6 +1468,8 @@ public:
|
|||
private:
|
||||
virtual bool is_class_expression() const override { return true; }
|
||||
|
||||
friend ClassDeclaration;
|
||||
|
||||
RefPtr<Identifier const> m_name;
|
||||
DeprecatedString m_source_text;
|
||||
RefPtr<FunctionExpression const> m_constructor;
|
||||
|
@ -1479,6 +1491,8 @@ public:
|
|||
|
||||
virtual ThrowCompletionOr<void> for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const override;
|
||||
|
||||
ThrowCompletionOr<void> for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&&) const override;
|
||||
|
||||
virtual bool is_lexical_declaration() const override { return true; }
|
||||
|
||||
StringView name() const { return m_class_expression->name(); }
|
||||
|
@ -1785,6 +1799,8 @@ public:
|
|||
|
||||
virtual ThrowCompletionOr<void> for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const override;
|
||||
|
||||
ThrowCompletionOr<void> for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&&) const override;
|
||||
|
||||
virtual bool is_constant_declaration() const override { return m_declaration_kind == DeclarationKind::Const; };
|
||||
|
||||
virtual bool is_lexical_declaration() const override { return m_declaration_kind != DeclarationKind::Var; }
|
||||
|
@ -1809,6 +1825,8 @@ public:
|
|||
|
||||
virtual ThrowCompletionOr<void> for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const override;
|
||||
|
||||
ThrowCompletionOr<void> for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&&) const override;
|
||||
|
||||
virtual bool is_constant_declaration() const override { return true; };
|
||||
|
||||
virtual bool is_lexical_declaration() const override { return true; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue