LibJS: Add Declaration class to the AST

This is just here to make the AST class hierarchy more spec-like.
This commit is contained in:
Andreas Kling 2020-04-04 21:32:10 +02:00
parent f8393b80e3
commit 9691286cf0
Notes: sideshowbarker 2024-07-19 07:55:54 +09:00

View file

@ -131,6 +131,9 @@ private:
class Expression : public ASTNode {
};
class Declaration : public Statement {
};
class FunctionNode {
public:
const FlyString& name() const { return m_name; }
@ -154,7 +157,7 @@ private:
};
class FunctionDeclaration final
: public Statement
: public Declaration
, public FunctionNode {
public:
static bool must_have_name() { return true; }
@ -576,7 +579,7 @@ enum class DeclarationType {
Const,
};
class VariableDeclaration : public Statement {
class VariableDeclaration : public Declaration {
public:
VariableDeclaration(NonnullRefPtr<Identifier> name, RefPtr<Expression> initializer, DeclarationType declaration_type)
: m_declaration_type(declaration_type)