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

LibJS: Delete Declaration::for_each_bound_name

We can delete for_each_bound_name() because there is more generic
version of this function called for_each_bound_identifier() that gives
you identifier using which you can get both name and check if it is
local/global.
This commit is contained in:
Aliaksandr Kalenik 2023-07-20 16:43:32 +02:00 committed by Andreas Kling
parent 348e43b36d
commit 231d58dd62
2 changed files with 0 additions and 74 deletions

View file

@ -2296,14 +2296,6 @@ void ClassDeclaration::dump(int indent) const
m_class_expression->dump(indent + 1);
}
ThrowCompletionOr<void> ClassDeclaration::for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
{
if (m_class_expression->name().is_empty())
return {};
return callback(m_class_expression->name());
}
ThrowCompletionOr<void> ClassDeclaration::for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&& callback) const
{
if (!m_class_expression->m_name)
@ -2434,23 +2426,6 @@ bool BindingPattern::contains_expression() const
return false;
}
ThrowCompletionOr<void> BindingPattern::for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
{
for (auto const& entry : entries) {
auto const& alias = entry.alias;
if (alias.has<NonnullRefPtr<Identifier const>>()) {
TRY(callback(alias.get<NonnullRefPtr<Identifier const>>()->string()));
} else if (alias.has<NonnullRefPtr<BindingPattern const>>()) {
TRY(alias.get<NonnullRefPtr<BindingPattern const>>()->for_each_bound_name(forward<decltype(callback)>(callback)));
} else {
auto const& name = entry.name;
if (name.has<NonnullRefPtr<Identifier const>>())
TRY(callback(name.get<NonnullRefPtr<Identifier const>>()->string()));
}
}
return {};
}
ThrowCompletionOr<void> BindingPattern::for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&& callback) const
{
for (auto const& entry : entries) {
@ -2558,13 +2533,6 @@ void FunctionDeclaration::dump(int indent) const
FunctionNode::dump(indent, class_name());
}
ThrowCompletionOr<void> FunctionDeclaration::for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
{
if (name().is_empty())
return {};
return callback(name());
}
ThrowCompletionOr<void> FunctionDeclaration::for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&& callback) const
{
if (!m_name)
@ -3115,23 +3083,6 @@ Completion VariableDeclarator::execute(Interpreter& interpreter) const
VERIFY_NOT_REACHED();
}
ThrowCompletionOr<void> VariableDeclaration::for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
{
for (auto const& entry : declarations()) {
TRY(entry->target().visit(
[&](NonnullRefPtr<Identifier const> const& id) {
return callback(id->string());
},
[&](NonnullRefPtr<BindingPattern const> const& binding) {
return binding->for_each_bound_identifier([&](auto const& identifier) {
return callback(identifier.string());
});
}));
}
return {};
}
ThrowCompletionOr<void> VariableDeclaration::for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&& callback) const
{
for (auto const& entry : declarations()) {
@ -3196,16 +3147,6 @@ Completion UsingDeclaration::execute(Interpreter& interpreter) const
return normal_completion({});
}
ThrowCompletionOr<void> UsingDeclaration::for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
{
for (auto const& entry : m_declarations) {
VERIFY(entry->target().has<NonnullRefPtr<Identifier const>>());
TRY(callback(entry->target().get<NonnullRefPtr<Identifier const>>()->string()));
}
return {};
}
ThrowCompletionOr<void> UsingDeclaration::for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&& callback) const
{
for (auto const& entry : m_declarations) {

View file

@ -609,7 +609,6 @@ 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
@ -626,11 +625,6 @@ public:
}
Completion execute(Interpreter&) const override { return {}; }
ThrowCompletionOr<void> for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&&) const override
{
VERIFY_NOT_REACHED();
}
ThrowCompletionOr<void> for_each_bound_identifier(ThrowCompletionOrVoidCallback<Identifier const&>&&) const override
{
VERIFY_NOT_REACHED();
@ -656,7 +650,6 @@ 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;
@ -774,8 +767,6 @@ public:
virtual void dump(int indent) const override;
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
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; }
@ -1496,8 +1487,6 @@ public:
virtual void dump(int indent) const override;
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
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; }
@ -1804,8 +1793,6 @@ public:
Vector<NonnullRefPtr<VariableDeclarator const>> const& declarations() const { return m_declarations; }
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; }
@ -1830,8 +1817,6 @@ public:
virtual Completion execute(Interpreter&) const override;
virtual void dump(int indent) const override;
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; }