diff options
author | Christian <c@ethdev.com> | 2015-01-28 15:50:53 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-04-22 17:33:25 +0800 |
commit | 83cc8dfe008341948306fd38e5405429753cb8d0 (patch) | |
tree | f9e8fca70aad6cbea6681f445414bb763a1637cd /ASTJsonConverter.cpp | |
parent | a44bcb6909478543151cac871fdbbc4909ad54aa (diff) | |
download | dexon-solidity-83cc8dfe008341948306fd38e5405429753cb8d0.tar.gz dexon-solidity-83cc8dfe008341948306fd38e5405429753cb8d0.tar.zst dexon-solidity-83cc8dfe008341948306fd38e5405429753cb8d0.zip |
JSON compiler.
Diffstat (limited to 'ASTJsonConverter.cpp')
-rw-r--r-- | ASTJsonConverter.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/ASTJsonConverter.cpp b/ASTJsonConverter.cpp index c30e4ca2..be89de92 100644 --- a/ASTJsonConverter.cpp +++ b/ASTJsonConverter.cpp @@ -78,10 +78,16 @@ ASTJsonConverter::ASTJsonConverter(ASTNode const& _ast): m_ast(&_ast) void ASTJsonConverter::print(ostream& _stream) { - m_ast->accept(*this); + process(); _stream << m_astJson; } +Json::Value const& ASTJsonConverter::json() +{ + process(); + return m_astJson; +} + bool ASTJsonConverter::visit(ImportDirective const& _node) { addJsonNode("Import", { make_pair("file", _node.getIdentifier())}); @@ -460,9 +466,16 @@ void ASTJsonConverter::endVisit(Literal const&) { } +void ASTJsonConverter::process() +{ + if (!processed) + m_ast->accept(*this); + processed = true; +} + string ASTJsonConverter::getType(Expression const& _expression) { - return (_expression.getType()) ? _expression.getType()->toString() : "Unknown"; + return (_expression.getType()) ? _expression.getType()->toString() : "Unknown"; } } |