Pull out helper to apply address member to contract members

This commit is contained in:
Alex Beregszaszi 2017-09-28 13:43:09 +01:00
parent aa6de49457
commit d5d1a08b09
2 changed files with 10 additions and 4 deletions

View File

@ -1660,12 +1660,17 @@ MemberList::MemberMap ContractType::nativeMembers(ContractDefinition const*) con
&it.second->declaration()
));
}
// Add overloads from address only if there is no conflict
addNonConflictingAddressMembers(members);
return members;
}
void ContractType::addNonConflictingAddressMembers(MemberList::MemberMap& _members)
{
MemberList::MemberMap addressMembers = IntegerType(160, IntegerType::Modifier::Address).nativeMembers(nullptr);
for (auto const& addressMember: addressMembers)
{
bool clash = false;
for (auto const& member: members)
for (auto const& member: _members)
{
if (
member.name == addressMember.name &&
@ -1686,13 +1691,12 @@ MemberList::MemberMap ContractType::nativeMembers(ContractDefinition const*) con
}
if (!clash)
members.push_back(MemberList::Member(
_members.push_back(MemberList::Member(
addressMember.name,
addressMember.type,
addressMember.declaration
));
}
return members;
}
shared_ptr<FunctionType const> const& ContractType::newExpressionType() const

View File

@ -716,6 +716,8 @@ public:
std::vector<std::tuple<VariableDeclaration const*, u256, unsigned>> stateVariables() const;
private:
static void addNonConflictingAddressMembers(MemberList::MemberMap& _members);
ContractDefinition const& m_contract;
/// If true, it is the "super" type of the current contract, i.e. it contains only inherited
/// members.