mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
style changes
This commit is contained in:
parent
e7568b5f4d
commit
5c1c690e28
3
AST.cpp
3
AST.cpp
@ -954,9 +954,6 @@ Declaration const& Identifier::getReferencedDeclaration() const
|
|||||||
void Identifier::overloadResolution(TypePointers const& _argumentTypes)
|
void Identifier::overloadResolution(TypePointers const& _argumentTypes)
|
||||||
{
|
{
|
||||||
solAssert(!m_referencedDeclaration, "Referenced declaration should be null before overload resolution.");
|
solAssert(!m_referencedDeclaration, "Referenced declaration should be null before overload resolution.");
|
||||||
//to delete
|
|
||||||
if (m_overloadedDeclarations.empty())
|
|
||||||
//--------------------------->
|
|
||||||
solAssert(!m_overloadedDeclarations.empty(), "No candidates for overload resolution found.");
|
solAssert(!m_overloadedDeclarations.empty(), "No candidates for overload resolution found.");
|
||||||
|
|
||||||
vector<Declaration const*> possibles;
|
vector<Declaration const*> possibles;
|
||||||
|
2
AST.h
2
AST.h
@ -1217,7 +1217,7 @@ public:
|
|||||||
}
|
}
|
||||||
Declaration const& getReferencedDeclaration() const;
|
Declaration const& getReferencedDeclaration() const;
|
||||||
|
|
||||||
/// Stores a possible declarations referenced by this identifier. Has to be resolved
|
/// Stores a set of possible declarations referenced by this identifier. Has to be resolved
|
||||||
/// providing argument types using overloadResolution before the referenced declaration
|
/// providing argument types using overloadResolution before the referenced declaration
|
||||||
/// is accessed.
|
/// is accessed.
|
||||||
void setOverloadedDeclarations(std::vector<Declaration const*> const& _declarations)
|
void setOverloadedDeclarations(std::vector<Declaration const*> const& _declarations)
|
||||||
|
@ -73,7 +73,7 @@ bool DeclarationContainer::registerDeclaration(Declaration const& _declaration,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const Declaration *> DeclarationContainer::resolveName(ASTString const& _name, bool _recursive) const
|
std::vector<Declaration const*> DeclarationContainer::resolveName(ASTString const& _name, bool _recursive) const
|
||||||
{
|
{
|
||||||
solAssert(!_name.empty(), "Attempt to resolve empty name.");
|
solAssert(!_name.empty(), "Attempt to resolve empty name.");
|
||||||
auto result = m_declarations.find(_name);
|
auto result = m_declarations.find(_name);
|
||||||
|
@ -53,12 +53,12 @@ void NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract)
|
|||||||
m_currentScope = &m_scopes[&_contract];
|
m_currentScope = &m_scopes[&_contract];
|
||||||
|
|
||||||
linearizeBaseContracts(_contract);
|
linearizeBaseContracts(_contract);
|
||||||
std::vector<ContractDefinition const*> realBases(
|
std::vector<ContractDefinition const*> properBases(
|
||||||
++_contract.getLinearizedBaseContracts().begin(),
|
++_contract.getLinearizedBaseContracts().begin(),
|
||||||
_contract.getLinearizedBaseContracts().end()
|
_contract.getLinearizedBaseContracts().end()
|
||||||
);
|
);
|
||||||
|
|
||||||
for (ContractDefinition const* base: realBases)
|
for (ContractDefinition const* base: properBases)
|
||||||
importInheritedScope(*base);
|
importInheritedScope(*base);
|
||||||
|
|
||||||
for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs())
|
for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs())
|
||||||
@ -130,11 +130,12 @@ vector<Declaration const*> NameAndTypeResolver::getNameFromCurrentScope(ASTStrin
|
|||||||
return m_currentScope->resolveName(_name, _recursive);
|
return m_currentScope->resolveName(_name, _recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Declaration const*> NameAndTypeResolver::cleanupedDeclarations(
|
vector<Declaration const*> NameAndTypeResolver::cleanedDeclarations(
|
||||||
Identifier const& _identifier,
|
Identifier const& _identifier,
|
||||||
vector<Declaration const*> const& _declarations
|
vector<Declaration const*> const& _declarations
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
solAssert(_declarations.size() > 1, "");
|
||||||
vector<Declaration const*> uniqueFunctions;
|
vector<Declaration const*> uniqueFunctions;
|
||||||
|
|
||||||
for (auto it = _declarations.begin(); it != _declarations.end(); ++it)
|
for (auto it = _declarations.begin(); it != _declarations.end(); ++it)
|
||||||
@ -155,9 +156,7 @@ vector<Declaration const*> NameAndTypeResolver::cleanupedDeclarations(
|
|||||||
uniqueFunctions.end(),
|
uniqueFunctions.end(),
|
||||||
[&](Declaration const* d)
|
[&](Declaration const* d)
|
||||||
{
|
{
|
||||||
FunctionDefinition const& newFunctionDefinition = dynamic_cast<FunctionDefinition const&>(*d);
|
FunctionType newFunctionType(dynamic_cast<FunctionDefinition const&>(*d));
|
||||||
FunctionType newFunctionType(newFunctionDefinition);
|
|
||||||
|
|
||||||
return functionType.hasEqualArgumentTypes(newFunctionType);
|
return functionType.hasEqualArgumentTypes(newFunctionType);
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
@ -482,7 +481,7 @@ bool ReferencesResolver::visit(Identifier& _identifier)
|
|||||||
else if (declarations.size() == 1)
|
else if (declarations.size() == 1)
|
||||||
_identifier.setReferencedDeclaration(*declarations.front(), m_currentContract);
|
_identifier.setReferencedDeclaration(*declarations.front(), m_currentContract);
|
||||||
else
|
else
|
||||||
_identifier.setOverloadedDeclarations(m_resolver.cleanupedDeclarations(_identifier, declarations));
|
_identifier.setOverloadedDeclarations(m_resolver.cleanedDeclarations(_identifier, declarations));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,13 +56,17 @@ public:
|
|||||||
/// Resolves the given @a _name inside the scope @a _scope. If @a _scope is omitted,
|
/// Resolves the given @a _name inside the scope @a _scope. If @a _scope is omitted,
|
||||||
/// the global scope is used (i.e. the one containing only the contract).
|
/// the global scope is used (i.e. the one containing only the contract).
|
||||||
/// @returns a pointer to the declaration on success or nullptr on failure.
|
/// @returns a pointer to the declaration on success or nullptr on failure.
|
||||||
std::vector<const Declaration *> resolveName(ASTString const& _name, Declaration const* _scope = nullptr) const;
|
std::vector<Declaration const*> resolveName(ASTString const& _name, Declaration const* _scope = nullptr) const;
|
||||||
|
|
||||||
/// Resolves a name in the "current" scope. Should only be called during the initial
|
/// Resolves a name in the "current" scope. Should only be called during the initial
|
||||||
/// resolving phase.
|
/// resolving phase.
|
||||||
std::vector<Declaration const*> getNameFromCurrentScope(ASTString const& _name, bool _recursive = true);
|
std::vector<Declaration const*> getNameFromCurrentScope(ASTString const& _name, bool _recursive = true);
|
||||||
|
|
||||||
std::vector<Declaration const*> cleanupedDeclarations(Identifier const& _identifier, std::vector<Declaration const*> const& _declarations);
|
/// returns the vector of declarations without repetitions
|
||||||
|
static std::vector<Declaration const*> cleanedDeclarations(
|
||||||
|
Identifier const& _identifier,
|
||||||
|
std::vector<Declaration const*> const& _declarations
|
||||||
|
);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reset();
|
void reset();
|
||||||
|
Loading…
Reference in New Issue
Block a user