mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Change retrieveContract to take name and not index
This commit is contained in:
parent
fbe24da159
commit
7ed938b95e
@ -106,12 +106,12 @@ void AnalysisFramework::printErrors()
|
||||
);
|
||||
}
|
||||
|
||||
ContractDefinition const* AnalysisFramework::retrieveContract(SourceUnit const& _source, unsigned index)
|
||||
ContractDefinition const* AnalysisFramework::retrieveContractByName(SourceUnit const& _source, string const& _name)
|
||||
{
|
||||
ContractDefinition* contract = nullptr;
|
||||
unsigned counter = 0;
|
||||
|
||||
for (shared_ptr<ASTNode> const& node: _source.nodes())
|
||||
if ((contract = dynamic_cast<ContractDefinition*>(node.get())) && counter == index)
|
||||
if ((contract = dynamic_cast<ContractDefinition*>(node.get())) && contract->name() == _name)
|
||||
return contract;
|
||||
|
||||
return nullptr;
|
||||
|
@ -59,7 +59,7 @@ protected:
|
||||
|
||||
void printErrors();
|
||||
|
||||
ContractDefinition const* retrieveContract(SourceUnit const& _source, unsigned index);
|
||||
ContractDefinition const* retrieveContractByName(SourceUnit const& _source, std::string const& _name);
|
||||
FunctionTypePointer retrieveFunctionBySignature(
|
||||
ContractDefinition const& _contract,
|
||||
std::string const& _signature
|
||||
|
@ -976,7 +976,7 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors)
|
||||
SourceUnit const* source;
|
||||
ContractDefinition const* contract;
|
||||
source = parseAndAnalyse(text);
|
||||
BOOST_REQUIRE((contract = retrieveContract(*source, 0)) != nullptr);
|
||||
BOOST_REQUIRE((contract = retrieveContractByName(*source, "test")) != nullptr);
|
||||
FunctionTypePointer function = retrieveFunctionBySignature(*contract, "foo()");
|
||||
BOOST_REQUIRE(function && function->hasDeclaration());
|
||||
auto returnParams = function->returnParameterTypes();
|
||||
@ -1029,7 +1029,7 @@ BOOST_AUTO_TEST_CASE(private_state_variable)
|
||||
|
||||
ContractDefinition const* contract;
|
||||
SourceUnit const* source = parseAndAnalyse(text);
|
||||
BOOST_CHECK((contract = retrieveContract(*source, 0)) != nullptr);
|
||||
BOOST_CHECK((contract = retrieveContractByName(*source, "test")) != nullptr);
|
||||
FunctionTypePointer function;
|
||||
function = retrieveFunctionBySignature(*contract, "foo()");
|
||||
BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of a private variable should not exist");
|
||||
|
Loading…
Reference in New Issue
Block a user