mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Deterministic AST node identifiers.
This commit is contained in:
parent
6ecb4aa36f
commit
99eaadd2cd
@ -1,5 +1,8 @@
|
||||
### 0.4.9 (unreleased)
|
||||
|
||||
Features:
|
||||
* AST: Use deterministic node identifiers.
|
||||
|
||||
### 0.4.8 (2017-01-13)
|
||||
|
||||
Features:
|
||||
|
@ -37,6 +37,8 @@ using namespace dev::solidity;
|
||||
ASTNode::ASTNode(SourceLocation const& _location):
|
||||
m_location(_location)
|
||||
{
|
||||
static size_t id = 0;
|
||||
m_id = ++id;
|
||||
}
|
||||
|
||||
ASTNode::~ASTNode()
|
||||
|
@ -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;
|
||||
|
||||
|
@ -42,7 +42,7 @@ void ASTJsonConverter::addJsonNode(
|
||||
{
|
||||
Json::Value node;
|
||||
|
||||
node["id"] = reinterpret_cast<Json::UInt64>(&_node);
|
||||
node["id"] = _node.id();
|
||||
node["src"] = sourceLocationToString(_node.location());
|
||||
node["name"] = _nodeName;
|
||||
if (_attributes.size() != 0)
|
||||
@ -124,7 +124,7 @@ bool ASTJsonConverter::visit(ContractDefinition const& _node)
|
||||
{
|
||||
Json::Value linearizedBaseContracts(Json::arrayValue);
|
||||
for (auto const& baseContract: _node.annotation().linearizedBaseContracts)
|
||||
linearizedBaseContracts.append(reinterpret_cast<Json::UInt64>(baseContract));
|
||||
linearizedBaseContracts.append(baseContract->id());
|
||||
addJsonNode(_node, "ContractDefinition", {
|
||||
make_pair("name", _node.name()),
|
||||
make_pair("isLibrary", _node.isLibrary()),
|
||||
|
Loading…
Reference in New Issue
Block a user