aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-09-25 20:22:10 +0800
committerchriseth <c@ethdev.com>2015-09-25 20:22:10 +0800
commit4457170ba637e0eb69a9ab65ef3c3505b38cb6bb (patch)
treed3603eb843cc071c17e24c71c1c3e48ed70ccf92
parent1736fe801591085534798fa40b347bab6f471cb3 (diff)
parente81f4ba45e11afcafe38d67dd3292ed1c6a57525 (diff)
downloaddexon-solidity-4457170ba637e0eb69a9ab65ef3c3505b38cb6bb.tar.gz
dexon-solidity-4457170ba637e0eb69a9ab65ef3c3505b38cb6bb.tar.zst
dexon-solidity-4457170ba637e0eb69a9ab65ef3c3505b38cb6bb.zip
Merge pull request #96 from chriseth/moreASTOutput
Provide types for VariableDeclaration.
-rw-r--r--libsolidity/ASTJsonConverter.cpp10
-rw-r--r--libsolidity/ASTJsonConverter.h1
-rw-r--r--libsolidity/ASTPrinter.cpp5
3 files changed, 15 insertions, 1 deletions
diff --git a/libsolidity/ASTJsonConverter.cpp b/libsolidity/ASTJsonConverter.cpp
index 3edcb77e..d0f76fb8 100644
--- a/libsolidity/ASTJsonConverter.cpp
+++ b/libsolidity/ASTJsonConverter.cpp
@@ -124,7 +124,10 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node)
bool ASTJsonConverter::visit(VariableDeclaration const& _node)
{
- addJsonNode("VariableDeclaration", { make_pair("name", _node.name()) }, true);
+ addJsonNode("VariableDeclaration", {
+ make_pair("name", _node.name()),
+ make_pair("name", _node.name()),
+ }, true);
return true;
}
@@ -444,5 +447,10 @@ string ASTJsonConverter::type(Expression const& _expression)
return _expression.annotation().type ? _expression.annotation().type->toString() : "Unknown";
}
+string ASTJsonConverter::type(VariableDeclaration const& _varDecl)
+{
+ return _varDecl.annotation().type ? _varDecl.annotation().type->toString() : "Unknown";
+}
+
}
}
diff --git a/libsolidity/ASTJsonConverter.h b/libsolidity/ASTJsonConverter.h
index a44df876..61f87860 100644
--- a/libsolidity/ASTJsonConverter.h
+++ b/libsolidity/ASTJsonConverter.h
@@ -116,6 +116,7 @@ private:
std::initializer_list<std::pair<std::string const, std::string const>> _list,
bool _hasChildren);
std::string type(Expression const& _expression);
+ std::string type(VariableDeclaration const& _varDecl);
inline void goUp()
{
solAssert(!m_jsonNodePtrs.empty(), "Uneven json nodes stack. Internal error.");
diff --git a/libsolidity/ASTPrinter.cpp b/libsolidity/ASTPrinter.cpp
index 5762051d..cebf6b8b 100644
--- a/libsolidity/ASTPrinter.cpp
+++ b/libsolidity/ASTPrinter.cpp
@@ -105,6 +105,11 @@ bool ASTPrinter::visit(FunctionDefinition const& _node)
bool ASTPrinter::visit(VariableDeclaration const& _node)
{
writeLine("VariableDeclaration \"" + _node.name() + "\"");
+ *m_ostream << indentation() << (
+ _node.annotation().type ?
+ string(" Type: ") + _node.annotation().type->toString() :
+ string(" Type unknown.")
+ ) << "\n";
printSourcePart(_node);
return goDeeper();
}