diff options
author | Alex Sinyagin <sinyagin.alexander@gmail.com> | 2016-08-18 20:51:17 +0800 |
---|---|---|
committer | Alex Sinyagin <sinyagin.alexander@gmail.com> | 2016-08-18 20:51:17 +0800 |
commit | 5061eb2b2b622ae6d1eb743962e53e6ceaf74798 (patch) | |
tree | 0f5276d9b543f34f5c706d807918c3d5960952bb /libsolidity/ast/ASTJsonConverter.cpp | |
parent | 406f3a4b5d3827f09e5f1035b79627dcc0e907d9 (diff) | |
download | dexon-solidity-5061eb2b2b622ae6d1eb743962e53e6ceaf74798.tar.gz dexon-solidity-5061eb2b2b622ae6d1eb743962e53e6ceaf74798.tar.zst dexon-solidity-5061eb2b2b622ae6d1eb743962e53e6ceaf74798.zip |
Move creation of the root element of JSON AST to the SourceUnit visitor
Diffstat (limited to 'libsolidity/ast/ASTJsonConverter.cpp')
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index fc5ad498..f793f5f1 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -89,11 +89,6 @@ ASTJsonConverter::ASTJsonConverter( map<string, unsigned> _sourceIndices ): m_ast(&_ast), m_sourceIndices(_sourceIndices) { - Json::Value children(Json::arrayValue); - - m_astJson["name"] = "root"; - m_astJson["children"] = children; - m_jsonNodePtrs.push(&m_astJson["children"]); } void ASTJsonConverter::print(ostream& _stream) @@ -108,6 +103,17 @@ Json::Value const& ASTJsonConverter::json() return m_astJson; } +bool ASTJsonConverter::visit(SourceUnit const&) +{ + Json::Value children(Json::arrayValue); + + m_astJson["name"] = "root"; + m_astJson["children"] = children; + m_jsonNodePtrs.push(&m_astJson["children"]); + + return true; +} + bool ASTJsonConverter::visit(ImportDirective const& _node) { addJsonNode(_node, "Import", { make_pair("file", _node.path())}); @@ -390,6 +396,11 @@ bool ASTJsonConverter::visit(Literal const& _node) return true; } +void ASTJsonConverter::endVisit(SourceUnit const&) +{ + goUp(); +} + void ASTJsonConverter::endVisit(ImportDirective const&) { } |