1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:17:35 +00:00

LibCpp: Add AST::Name

A Name node is basically an identifier with an optional scope,
e.g Core::File.
This commit is contained in:
Itamar 2021-03-29 16:52:35 +03:00 committed by Andreas Kling
parent 29b6915db9
commit 3295609aea
5 changed files with 105 additions and 44 deletions

View file

@ -43,6 +43,7 @@ class FunctionDefinition;
class Type;
class Parameter;
class Statement;
class Name;
class ASTNode : public RefCounted<ASTNode> {
public:
@ -76,6 +77,7 @@ public:
virtual bool is_function_call() const { return false; }
virtual bool is_type() const { return false; }
virtual bool is_declaration() const { return false; }
virtual bool is_name() const {return false;}
protected:
ASTNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
@ -212,7 +214,6 @@ class Type : public ASTNode {
public:
virtual ~Type() override = default;
virtual const char* class_name() const override { return "Type"; }
const StringView& name() const { return m_name; }
virtual void dump(size_t indent) const override;
virtual bool is_type() const override { return true; }
virtual bool is_templatized() const { return false; }
@ -222,7 +223,7 @@ public:
{
}
StringView m_name;
RefPtr<Name> m_name;
Vector<StringView> m_qualifiers;
};
@ -341,6 +342,23 @@ public:
StringView m_name;
};
class Name : public Expression {
public:
virtual ~Name() override = default;
virtual const char* class_name() const override { return "Name"; }
virtual void dump(size_t indent) const override;
virtual bool is_name() const override {return true;}
Name(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
: Expression(parent, start, end, filename)
{
}
String full_name() const;
RefPtr<Identifier> m_name;
NonnullRefPtrVector<Identifier> m_scope;
};
class NumericLiteral : public Expression {
public:
virtual ~NumericLiteral() override = default;
@ -453,7 +471,7 @@ public:
virtual void dump(size_t indent) const override;
virtual bool is_function_call() const override { return true; }
StringView m_name;
RefPtr<Name> m_name;
NonnullRefPtrVector<Expression> m_arguments;
};
@ -577,7 +595,7 @@ public:
virtual bool is_member_expression() const override { return true; }
RefPtr<Expression> m_object;
RefPtr<Identifier> m_property;
RefPtr<Expression> m_property;
};
class ForStatement : public Statement {