aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast/AST.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-01-20 18:47:20 +0800
committerchriseth <c@ethdev.com>2017-01-20 19:00:16 +0800
commit7159944f0fa5d9eb3205cd8a3e1d6ec4f133a4ad (patch)
tree1fbfc682094a366170500cf2987084c42e1c4834 /libsolidity/ast/AST.cpp
parentda178d967fb66ca508d16bbe3feecf1962dcf6ef (diff)
downloaddexon-solidity-7159944f0fa5d9eb3205cd8a3e1d6ec4f133a4ad.tar.gz
dexon-solidity-7159944f0fa5d9eb3205cd8a3e1d6ec4f133a4ad.tar.zst
dexon-solidity-7159944f0fa5d9eb3205cd8a3e1d6ec4f133a4ad.zip
Reset AST node IDs between compilation runs.
Diffstat (limited to 'libsolidity/ast/AST.cpp')
-rw-r--r--libsolidity/ast/AST.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index fcd6e38c..8a43c3f7 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -34,11 +34,24 @@ using namespace std;
using namespace dev;
using namespace dev::solidity;
+class IDDispenser
+{
+public:
+ static size_t next() { return ++instance(); }
+ static void reset() { instance() = 0; }
+private:
+ static size_t& instance()
+ {
+ static IDDispenser dispenser;
+ return dispenser.id;
+ }
+ size_t id = 0;
+};
+
ASTNode::ASTNode(SourceLocation const& _location):
+ m_id(IDDispenser::next()),
m_location(_location)
{
- static size_t id = 0;
- m_id = ++id;
}
ASTNode::~ASTNode()
@@ -46,6 +59,11 @@ ASTNode::~ASTNode()
delete m_annotation;
}
+void ASTNode::resetID()
+{
+ IDDispenser::reset();
+}
+
ASTAnnotation& ASTNode::annotation() const
{
if (!m_annotation)