LibJS: Use Identifier to represent CatchClause parameter names

By doing that we consistently use Identifier node for identifiers and
also enable mechanism that registers identifiers in a corresponding
ScopePusher for catch parameters, which is necessary for work in the
upcoming changes.
This commit is contained in:
Aliaksandr Kalenik 2025-04-21 19:49:38 +02:00 committed by Alexander Kalenik
commit 0f14c70252
Notes: github-actions[bot] 2025-04-22 19:58:36 +00:00
4 changed files with 43 additions and 30 deletions

View file

@ -2075,7 +2075,7 @@ private:
class CatchClause final : public ASTNode {
public:
CatchClause(SourceRange source_range, FlyString parameter, NonnullRefPtr<BlockStatement const> body)
CatchClause(SourceRange source_range, NonnullRefPtr<Identifier const> parameter, NonnullRefPtr<BlockStatement const> body)
: ASTNode(move(source_range))
, m_parameter(move(parameter))
, m_body(move(body))
@ -2089,13 +2089,20 @@ public:
{
}
CatchClause(SourceRange source_range, NonnullRefPtr<BlockStatement const> body)
: ASTNode(move(source_range))
, m_parameter(Empty {})
, m_body(move(body))
{
}
auto& parameter() const { return m_parameter; }
BlockStatement const& body() const { return m_body; }
virtual void dump(int indent) const override;
private:
Variant<FlyString, NonnullRefPtr<BindingPattern const>> m_parameter;
Variant<NonnullRefPtr<Identifier const>, NonnullRefPtr<BindingPattern const>, Empty> m_parameter;
NonnullRefPtr<BlockStatement const> m_body;
};