1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:37:45 +00:00

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

View file

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