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

LibCpp: Support non-field class members

Previously, we had a special ASTNode for class members,
"MemberDeclaration", which only represented fields.

This commit removes MemberDeclaration and instead uses regular
Declaration nodes for representing the members of a class.

This means that we can now also parse methods, inner-classes, and other
declarations that appear inside of a class.
This commit is contained in:
Itamar 2021-06-05 17:57:13 +03:00 committed by Andreas Kling
parent 8f074222e8
commit dcdb0c7035
6 changed files with 71 additions and 77 deletions

View file

@ -506,22 +506,6 @@ public:
Vector<StringView> m_entries;
};
class MemberDeclaration : public Declaration {
public:
virtual ~MemberDeclaration() override = default;
virtual const char* class_name() const override { return "MemberDeclaration"; }
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual bool is_member() const override { return true; }
MemberDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
: Declaration(parent, start, end, filename)
{
}
RefPtr<Type> m_type;
RefPtr<Expression> m_initial_value;
};
class StructOrClassDeclaration : public Declaration {
public:
virtual ~StructOrClassDeclaration() override = default;
@ -544,7 +528,7 @@ public:
}
StructOrClassDeclaration::Type m_type;
NonnullRefPtrVector<MemberDeclaration> m_members;
NonnullRefPtrVector<Declaration> m_members;
};
enum class UnaryOp {