diff options
author | djuju <julfaber@gmail.com> | 2017-05-05 22:15:09 +0800 |
---|---|---|
committer | djudjuu <julfaber@gmail.com> | 2017-05-17 17:14:33 +0800 |
commit | a4ba5ace8a5d77397715204fe737b0dba4429368 (patch) | |
tree | 2b8e03d608a186c10daeec453fe8b82e05cef555 /libsolidity | |
parent | 2fa7646944451bdb804d842c0dacdbbba960f857 (diff) | |
download | dexon-solidity-a4ba5ace8a5d77397715204fe737b0dba4429368.tar dexon-solidity-a4ba5ace8a5d77397715204fe737b0dba4429368.tar.gz dexon-solidity-a4ba5ace8a5d77397715204fe737b0dba4429368.tar.bz2 dexon-solidity-a4ba5ace8a5d77397715204fe737b0dba4429368.tar.lz dexon-solidity-a4ba5ace8a5d77397715204fe737b0dba4429368.tar.xz dexon-solidity-a4ba5ace8a5d77397715204fe737b0dba4429368.tar.zst dexon-solidity-a4ba5ace8a5d77397715204fe737b0dba4429368.zip |
prefixChanges and contractKind-field
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.cpp | 36 | ||||
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.h | 1 |
2 files changed, 24 insertions, 13 deletions
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 4046073e..492429d7 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -242,7 +242,7 @@ bool ASTJsonConverter::visit(ContractDefinition const& _node) { setJsonNode(_node, "ContractDefinition", { make_pair("name", _node.name()), - make_pair("isLibrary", _node.isLibrary()), + make_pair("contractKind", contractKind(_node.contractKind())), make_pair("fullyImplemented", _node.annotation().isFullyImplemented), make_pair("linearizedBaseContracts", getContainerIds(_node.annotation().linearizedBaseContracts)), make_pair("baseContracts", toJson(_node.baseContracts())), @@ -265,7 +265,7 @@ bool ASTJsonConverter::visit(InheritanceSpecifier const& _node) bool ASTJsonConverter::visit(UsingForDirective const& _node) { setJsonNode(_node, "UsingForDirective", { - make_pair("libraryNames", toJson(_node.libraryName())), + make_pair("libraryName", toJson(_node.libraryName())), make_pair("typeName", _node.typeName() ? toJson(*_node.typeName()) : Json::nullValue) }); return false; @@ -321,7 +321,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node) make_pair("returnParameters", toJson(*_node.returnParameterList())), make_pair("modifiers", toJson(_node.modifiers())), make_pair("body", _node.isImplemented() ? toJson(_node.body()) : Json::nullValue), - make_pair("isImplemented", _node.isImplemented()), + make_pair("implemented", _node.isImplemented()), make_pair("scope", idOrNull(_node.scope())) }; setJsonNode(_node, "FunctionDefinition", std::move(attributes)); @@ -438,18 +438,13 @@ bool ASTJsonConverter::visit(ArrayTypeName const& _node) bool ASTJsonConverter::visit(InlineAssembly const& _node) { - std::map<assembly::Identifier const*, Declaration const*>::iterator it; Json::Value externalReferences(Json::arrayValue); - for ( - it = _node.annotation().externalReferences.begin(); - it != _node.annotation().externalReferences.end(); - it++ - ) + for (auto const& it : _node.annotation().externalReferences) { - if (it->first && it->second) + if (it.first && it.second) { Json::Value tuple(Json::objectValue); - tuple[it->first->name] = nodeId(*it->second); + tuple[it.first->name] = nodeId(*it.second); externalReferences.append(tuple); } } @@ -500,7 +495,7 @@ bool ASTJsonConverter::visit(WhileStatement const& _node) bool ASTJsonConverter::visit(ForStatement const& _node) { setJsonNode(_node, "ForStatement", { - make_pair("initExpression", toJsonOrNull(_node.initializationExpression())), + make_pair("initializationExpression", toJsonOrNull(_node.initializationExpression())), make_pair("condition", toJsonOrNull(_node.condition())), make_pair("loopExpression", toJsonOrNull(_node.loopExpression())), make_pair("body", toJson(_node.body())) @@ -623,7 +618,7 @@ bool ASTJsonConverter::visit(FunctionCall const& _node) names.append(Json::Value(*name)); std::vector<pair<string, Json::Value>> attributes = { make_pair(m_legacy ? "type_conversion" : "isTypeConversion", _node.annotation().isTypeConversion), - make_pair("isStructContstructorCall", _node.annotation().isStructConstructorCall), + make_pair("isStructConstructorCall", _node.annotation().isStructConstructorCall), make_pair("expression", toJson(_node.expression())), make_pair("names", std::move(names)), make_pair("arguments", toJson(_node.arguments())) @@ -752,6 +747,21 @@ string ASTJsonConverter::location(VariableDeclaration::Location _location) } } +string ASTJsonConverter::contractKind(ContractDefinition::ContractKind _kind) +{ + switch (_kind) + { + case ContractDefinition::ContractKind::Interface: + return "interface"; + case ContractDefinition::ContractKind::Contract: + return "contract"; + case ContractDefinition::ContractKind::Library: + return "library"; + default: + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown contract kind.")); + } +} + 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 aab8c124..1499c3b8 100644 --- a/libsolidity/ast/ASTJsonConverter.h +++ b/libsolidity/ast/ASTJsonConverter.h @@ -130,6 +130,7 @@ private: } std::string visibility(Declaration::Visibility const& _visibility); std::string location(VariableDeclaration::Location _location); + std::string contractKind(ContractDefinition::ContractKind _kind); std::string type(Expression const& _expression); std::string type(VariableDeclaration const& _varDecl); int nodeId(ASTNode const& _node) |