diff options
author | Federico Bond <federicobond@gmail.com> | 2016-12-13 03:21:57 +0800 |
---|---|---|
committer | Federico Bond <federicobond@gmail.com> | 2016-12-13 03:21:57 +0800 |
commit | 9ed65f2ab9d5d6e67e07219006434356ce5c64ee (patch) | |
tree | fc87d230d66e5e7d80c11a403c77358dcd62865f /libsolidity | |
parent | e53fdb49335ccf5356a2fa8c1689afe82430a134 (diff) | |
download | dexon-solidity-9ed65f2ab9d5d6e67e07219006434356ce5c64ee.tar dexon-solidity-9ed65f2ab9d5d6e67e07219006434356ce5c64ee.tar.gz dexon-solidity-9ed65f2ab9d5d6e67e07219006434356ce5c64ee.tar.bz2 dexon-solidity-9ed65f2ab9d5d6e67e07219006434356ce5c64ee.tar.lz dexon-solidity-9ed65f2ab9d5d6e67e07219006434356ce5c64ee.tar.xz dexon-solidity-9ed65f2ab9d5d6e67e07219006434356ce5c64ee.tar.zst dexon-solidity-9ed65f2ab9d5d6e67e07219006434356ce5c64ee.zip |
Include visibility level for functions in AST
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.cpp | 28 | ||||
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.h | 1 |
2 files changed, 22 insertions, 7 deletions
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 493707b9..abaad0fd 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -24,6 +24,7 @@ #include <boost/algorithm/string/join.hpp> #include <libdevcore/UTF8.h> #include <libsolidity/ast/AST.h> +#include <libsolidity/interface/Exceptions.h> using namespace std; @@ -173,9 +174,9 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node) { addJsonNode(_node, "FunctionDefinition", { make_pair("name", _node.name()), - make_pair("public", _node.isPublic()), make_pair("constant", _node.isDeclaredConst()), - make_pair("payable", _node.isPayable()) + make_pair("payable", _node.isPayable()), + make_pair("visibility", visibility(_node.visibility())) }, true); return true; } @@ -228,13 +229,9 @@ bool ASTJsonConverter::visit(UserDefinedTypeName const& _node) bool ASTJsonConverter::visit(FunctionTypeName const& _node) { - string visibility = "internal"; - if (_node.visibility() == Declaration::Visibility::External) - visibility = "external"; - addJsonNode(_node, "FunctionTypeName", { make_pair("payable", _node.isPayable()), - make_pair("visibility", visibility), + make_pair("visibility", visibility(_node.visibility())), make_pair("constant", _node.isDeclaredConst()) }, true); return true; @@ -656,6 +653,23 @@ void ASTJsonConverter::process() processed = true; } +string ASTJsonConverter::visibility(Declaration::Visibility const& _visibility) +{ + switch (_visibility) + { + case Declaration::Visibility::Private: + return "private"; + case Declaration::Visibility::Internal: + return "internal"; + case Declaration::Visibility::Public: + return "public"; + case Declaration::Visibility::External: + return "external"; + default: + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown declaration visibility.")); + } +} + string ASTJsonConverter::type(Expression const& _expression) { return _expression.annotation().type ? _expression.annotation().type->toString() : "Unknown"; diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h index 277476d5..49f23f99 100644 --- a/libsolidity/ast/ASTJsonConverter.h +++ b/libsolidity/ast/ASTJsonConverter.h @@ -152,6 +152,7 @@ private: bool _hasChildren ); std::string sourceLocationToString(SourceLocation const& _location) const; + std::string visibility(Declaration::Visibility const& _visibility); std::string type(Expression const& _expression); std::string type(VariableDeclaration const& _varDecl); inline void goUp() |