Deterministic AST node identifiers.

This commit is contained in:
chriseth
2017-01-17 10:45:45 +01:00
parent 6ecb4aa36f
commit 99eaadd2cd
4 changed files with 11 additions and 2 deletions
+4
View File
@@ -57,6 +57,9 @@ public:
explicit ASTNode(SourceLocation const& _location);
virtual ~ASTNode();
/// @returns an identifier of this AST node that is unique for a single compilation run.
size_t id() const { return m_id; }
virtual void accept(ASTVisitor& _visitor) = 0;
virtual void accept(ASTConstVisitor& _visitor) const = 0;
template <class T>
@@ -94,6 +97,7 @@ public:
///@}
protected:
size_t m_id = 0;
/// Annotation - is specialised in derived classes, is created upon request (because of polymorphism).
mutable ASTAnnotation* m_annotation = nullptr;