Replace superFunction by baseFunctions in AST annotations and JSON AST.

This commit is contained in:
Daniel Kirchner 2019-12-05 03:17:28 +01:00
parent 6c0660ac66
commit 8b35918ad0
5 changed files with 7 additions and 7 deletions

View File

@ -22,6 +22,7 @@ Breaking changes:
* Natspec JSON Interface: Properly support multiple ``@return`` statements in ``@dev`` documentation and enforce named return parameters to be mentioned documentation. * Natspec JSON Interface: Properly support multiple ``@return`` statements in ``@dev`` documentation and enforce named return parameters to be mentioned documentation.
* Source mappings: Add "modifier depth" as a fifth field in the source mappings. * Source mappings: Add "modifier depth" as a fifth field in the source mappings.
* AST: Inline assembly is exported as structured JSON instead of plain string. * AST: Inline assembly is exported as structured JSON instead of plain string.
* JSON AST: Replace ``superFunction`` attribute by ``baseFunctions``.
* General: ``private`` cannot be used together with ``virtual``. * General: ``private`` cannot be used together with ``virtual``.
* Inheritance: State variable shadowing is now disallowed. * Inheritance: State variable shadowing is now disallowed.

View File

@ -290,8 +290,7 @@ bool ContractLevelChecker::checkFunctionOverride(FunctionDefinition const& _func
success = false; success = false;
} }
if (!_function.annotation().superFunction) _function.annotation().baseFunctions.emplace(&_super);
_function.annotation().superFunction = &_super;
if (_function.visibility() != _super.visibility()) if (_function.visibility() != _super.visibility())
{ {

View File

@ -171,7 +171,7 @@ void ViewPureChecker::endVisit(FunctionDefinition const& _funDef)
!_funDef.isConstructor() && !_funDef.isConstructor() &&
!_funDef.isFallback() && !_funDef.isFallback() &&
!_funDef.isReceive() && !_funDef.isReceive() &&
!_funDef.annotation().superFunction !_funDef.overrides()
) )
m_errorReporter.warning( m_errorReporter.warning(
_funDef.location(), _funDef.location(),

View File

@ -106,9 +106,8 @@ struct ContractDefinitionAnnotation: TypeDeclarationAnnotation, DocumentedAnnota
struct FunctionDefinitionAnnotation: ASTAnnotation, DocumentedAnnotation struct FunctionDefinitionAnnotation: ASTAnnotation, DocumentedAnnotation
{ {
/// The function this function overrides, if any. This is always the closest /// The set of functions this function overrides.
/// in the linearized inheritance hierarchy. std::set<FunctionDefinition const*> baseFunctions;
FunctionDefinition const* superFunction = nullptr;
/// Pointer to the contract this function is defined in /// Pointer to the contract this function is defined in
ContractDefinition const* contract = nullptr; ContractDefinition const* contract = nullptr;
}; };

View File

@ -344,7 +344,6 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node)
make_pair("documentation", _node.documentation() ? Json::Value(*_node.documentation()) : Json::nullValue), make_pair("documentation", _node.documentation() ? Json::Value(*_node.documentation()) : Json::nullValue),
make_pair("kind", TokenTraits::toString(_node.kind())), make_pair("kind", TokenTraits::toString(_node.kind())),
make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())), make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())),
make_pair("superFunction", idOrNull(_node.annotation().superFunction)),
make_pair("visibility", Declaration::visibilityToString(_node.visibility())), make_pair("visibility", Declaration::visibilityToString(_node.visibility())),
make_pair("overrides", _node.overrides() ? toJson(_node.overrides()->overrides()) : Json::nullValue), make_pair("overrides", _node.overrides() ? toJson(_node.overrides()->overrides()) : Json::nullValue),
make_pair("parameters", toJson(_node.parameterList())), make_pair("parameters", toJson(_node.parameterList())),
@ -354,6 +353,8 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node)
make_pair("implemented", _node.isImplemented()), make_pair("implemented", _node.isImplemented()),
make_pair("scope", idOrNull(_node.scope())) make_pair("scope", idOrNull(_node.scope()))
}; };
if (!_node.annotation().baseFunctions.empty())
attributes.emplace_back(make_pair("baseFunctions", getContainerIds(_node.annotation().baseFunctions, true)));
if (m_legacy) if (m_legacy)
attributes.emplace_back("isConstructor", _node.isConstructor()); attributes.emplace_back("isConstructor", _node.isConstructor());
setJsonNode(_node, "FunctionDefinition", std::move(attributes)); setJsonNode(_node, "FunctionDefinition", std::move(attributes));