mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1503 from federicobond/json-visibility
Include visibility level for functions in AST
This commit is contained in:
commit
f8fe6e4f7c
@ -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";
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user