mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Move creation of the root element of JSON AST to the SourceUnit visitor
This commit is contained in:
parent
406f3a4b5d
commit
5061eb2b2b
@ -89,11 +89,6 @@ ASTJsonConverter::ASTJsonConverter(
|
|||||||
map<string, unsigned> _sourceIndices
|
map<string, unsigned> _sourceIndices
|
||||||
): m_ast(&_ast), m_sourceIndices(_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)
|
void ASTJsonConverter::print(ostream& _stream)
|
||||||
@ -108,6 +103,17 @@ Json::Value const& ASTJsonConverter::json()
|
|||||||
return m_astJson;
|
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)
|
bool ASTJsonConverter::visit(ImportDirective const& _node)
|
||||||
{
|
{
|
||||||
addJsonNode(_node, "Import", { make_pair("file", _node.path())});
|
addJsonNode(_node, "Import", { make_pair("file", _node.path())});
|
||||||
@ -390,6 +396,11 @@ bool ASTJsonConverter::visit(Literal const& _node)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ASTJsonConverter::endVisit(SourceUnit const&)
|
||||||
|
{
|
||||||
|
goUp();
|
||||||
|
}
|
||||||
|
|
||||||
void ASTJsonConverter::endVisit(ImportDirective const&)
|
void ASTJsonConverter::endVisit(ImportDirective const&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ public:
|
|||||||
void print(std::ostream& _stream);
|
void print(std::ostream& _stream);
|
||||||
Json::Value const& json();
|
Json::Value const& json();
|
||||||
|
|
||||||
|
bool visit(SourceUnit const& _node) override;
|
||||||
bool visit(ImportDirective const& _node) override;
|
bool visit(ImportDirective const& _node) override;
|
||||||
bool visit(ContractDefinition const& _node) override;
|
bool visit(ContractDefinition const& _node) override;
|
||||||
bool visit(InheritanceSpecifier const& _node) override;
|
bool visit(InheritanceSpecifier const& _node) override;
|
||||||
@ -94,6 +95,7 @@ public:
|
|||||||
bool visit(ElementaryTypeNameExpression const& _node) override;
|
bool visit(ElementaryTypeNameExpression const& _node) override;
|
||||||
bool visit(Literal const& _node) override;
|
bool visit(Literal const& _node) override;
|
||||||
|
|
||||||
|
void endVisit(SourceUnit const&) override;
|
||||||
void endVisit(ImportDirective const&) override;
|
void endVisit(ImportDirective const&) override;
|
||||||
void endVisit(ContractDefinition const&) override;
|
void endVisit(ContractDefinition const&) override;
|
||||||
void endVisit(InheritanceSpecifier const&) override;
|
void endVisit(InheritanceSpecifier const&) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user