summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCpp/AST.h
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibCpp/AST.h')
-rw-r--r--Userland/Libraries/LibCpp/AST.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/Userland/Libraries/LibCpp/AST.h b/Userland/Libraries/LibCpp/AST.h
index 487c2c094a..9634d40ebc 100644
--- a/Userland/Libraries/LibCpp/AST.h
+++ b/Userland/Libraries/LibCpp/AST.h
@@ -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 {