Skip to content

Commit

Permalink
Pull out helper to apply address member to contract members
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Sep 28, 2017
1 parent 3a80def commit f953b02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libsolidity/ast/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1660,12 +1660,18 @@ 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 it = addressMembers.begin(); it != addressMembers.end(); ++it)
{
bool clash = false;
for (auto const member: members)
for (auto const member: _members)
{
if (
member.name == it->name &&
Expand All @@ -1686,13 +1692,12 @@ MemberList::MemberMap ContractType::nativeMembers(ContractDefinition const*) con
}

if (!clash)
members.push_back(MemberList::Member(
_members.push_back(MemberList::Member(
it->name,
it->type,
it->declaration
));
}
return members;
}

shared_ptr<FunctionType const> const& ContractType::newExpressionType() const
Expand Down
2 changes: 2 additions & 0 deletions libsolidity/ast/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ class ContractType: public Type
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.
Expand Down

0 comments on commit f953b02

Please sign in to comment.