mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:17:44 +00:00
LibCpp: Parse Namespace declaration
Also, remove unused State::Context
This commit is contained in:
parent
505c84fdf0
commit
b5cab861e3
4 changed files with 111 additions and 57 deletions
|
@ -96,23 +96,16 @@ class TranslationUnit : public ASTNode {
|
|||
|
||||
public:
|
||||
virtual ~TranslationUnit() override = default;
|
||||
const NonnullRefPtrVector<Declaration>& children() const { return m_children; }
|
||||
virtual const char* class_name() const override { return "TranslationUnit"; }
|
||||
virtual void dump(size_t indent) const override;
|
||||
void append(NonnullRefPtr<Declaration> child)
|
||||
{
|
||||
m_children.append(move(child));
|
||||
}
|
||||
virtual NonnullRefPtrVector<Declaration> declarations() const override { return m_children; }
|
||||
virtual NonnullRefPtrVector<Declaration> declarations() const override { return m_declarations; }
|
||||
|
||||
public:
|
||||
TranslationUnit(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
NonnullRefPtrVector<Declaration> m_children;
|
||||
NonnullRefPtrVector<Declaration> m_declarations;
|
||||
};
|
||||
|
||||
class Statement : public ASTNode {
|
||||
|
@ -140,6 +133,7 @@ public:
|
|||
virtual bool is_struct() const { return false; }
|
||||
virtual bool is_class() const { return false; }
|
||||
virtual bool is_function() const { return false; }
|
||||
virtual bool is_namespace() const { return false; }
|
||||
const StringView& name() const { return m_name; }
|
||||
|
||||
StringView m_name;
|
||||
|
@ -618,4 +612,22 @@ public:
|
|||
RefPtr<Statement> m_else;
|
||||
};
|
||||
|
||||
class NamespaceDeclaration : public Declaration {
|
||||
public:
|
||||
virtual ~NamespaceDeclaration() override = default;
|
||||
virtual const char* class_name() const override { return "NamespaceDeclaration"; }
|
||||
virtual void dump(size_t indent) const override;
|
||||
virtual bool is_namespace() const override { return true; }
|
||||
|
||||
NamespaceDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
||||
virtual NonnullRefPtrVector<Declaration> declarations() const override { return m_declarations; }
|
||||
|
||||
StringView m_name;
|
||||
NonnullRefPtrVector<Declaration> m_declarations;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue