aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Types.cpp32
-rw-r--r--Types.h8
2 files changed, 21 insertions, 19 deletions
diff --git a/Types.cpp b/Types.cpp
index d2f0e9bf..a9c48017 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -573,19 +573,19 @@ MemberList const& ContractType::getMembers() const
if (!m_members)
{
// All address members and all interface functions
- map<string, TypePointer> members(IntegerType::AddressMemberList.begin(),
- IntegerType::AddressMemberList.end());
+ vector<pair<string, TypePointer>> members(IntegerType::AddressMemberList.begin(),
+ IntegerType::AddressMemberList.end());
if (m_super)
{
for (ContractDefinition const* base: m_contract.getLinearizedBaseContracts())
for (ASTPointer<FunctionDefinition> const& function: base->getDefinedFunctions())
- if (!function->isConstructor() && !function->getName().empty() &&
+ if (!function->isConstructor() && !function->getName().empty()&&
function->isVisibleInDerivedContracts())
- members.insert(make_pair(function->getName(), make_shared<FunctionType>(*function, true)));
+ members.push_back(make_pair(function->getName(), make_shared<FunctionType>(*function, true)));
}
else
for (auto const& it: m_contract.getInterfaceFunctions())
- members[it.second->getDeclaration().getName()] = it.second;
+ members.push_back(make_pair(it.second->getDeclaration().getName(), it.second));
m_members.reset(new MemberList(members));
}
return *m_members;
@@ -653,9 +653,9 @@ MemberList const& StructType::getMembers() const
// We need to lazy-initialize it because of recursive references.
if (!m_members)
{
- map<string, TypePointer> members;
+ vector<pair<string, TypePointer>> members;
for (ASTPointer<VariableDeclaration> const& variable: m_struct.getMembers())
- members[variable->getName()] = variable->getType();
+ members.push_back(make_pair(variable->getName(), variable->getType()));
m_members.reset(new MemberList(members));
}
return *m_members;
@@ -857,15 +857,15 @@ MemberList const& FunctionType::getMembers() const
case Location::Bare:
if (!m_members)
{
- map<string, TypePointer> members{
- {"gas", make_shared<FunctionType>(parseElementaryTypeVector({"uint"}),
- TypePointers{copyAndSetGasOrValue(true, false)},
- Location::SetGas, false, m_gasSet, m_valueSet)},
+ vector<pair<string, TypePointer>> members{
{"value", make_shared<FunctionType>(parseElementaryTypeVector({"uint"}),
TypePointers{copyAndSetGasOrValue(false, true)},
Location::SetValue, false, m_gasSet, m_valueSet)}};
- if (m_location == Location::Creation)
- members.erase("gas");
+ if (m_location != Location::Creation)
+ members.push_back(make_pair("gas", make_shared<FunctionType>(
+ parseElementaryTypeVector({"uint"}),
+ TypePointers{copyAndSetGasOrValue(true, false)},
+ Location::SetGas, false, m_gasSet, m_valueSet)));
m_members.reset(new MemberList(members));
}
return *m_members;
@@ -959,7 +959,7 @@ MemberList const& TypeType::getMembers() const
// We need to lazy-initialize it because of recursive references.
if (!m_members)
{
- map<string, TypePointer> members;
+ vector<pair<string, TypePointer>> members;
if (m_actualType->getCategory() == Category::Contract && m_currentContract != nullptr)
{
ContractDefinition const& contract = dynamic_cast<ContractType const&>(*m_actualType).getContractDefinition();
@@ -969,14 +969,14 @@ MemberList const& TypeType::getMembers() const
// functions. Note that this does not add inherited functions on purpose.
for (ASTPointer<FunctionDefinition> const& f: contract.getDefinedFunctions())
if (!f->isConstructor() && !f->getName().empty() && f->isVisibleInDerivedContracts())
- members[f->getName()] = make_shared<FunctionType>(*f);
+ members.push_back(make_pair(f->getName(), make_shared<FunctionType>(*f)));
}
else if (m_actualType->getCategory() == Category::Enum)
{
EnumDefinition const& enumDef = dynamic_cast<EnumType const&>(*m_actualType).getEnumDefinition();
auto enumType = make_shared<EnumType>(enumDef);
for (ASTPointer<EnumValue> const& enumValue: enumDef.getMembers())
- members.insert(make_pair(enumValue->getName(), enumType));
+ members.push_back(make_pair(enumValue->getName(), enumType));
}
m_members.reset(new MemberList(members));
}
diff --git a/Types.h b/Types.h
index b66857f0..d529d8d0 100644
--- a/Types.h
+++ b/Types.h
@@ -50,14 +50,16 @@ using TypePointers = std::vector<TypePointer>;
class MemberList
{
public:
- using MemberMap = std::map<std::string, TypePointer>;
+ using MemberMap = std::vector<std::pair<std::string, TypePointer>>;
MemberList() {}
explicit MemberList(MemberMap const& _members): m_memberTypes(_members) {}
TypePointer getMemberType(std::string const& _name) const
{
- auto it = m_memberTypes.find(_name);
- return it != m_memberTypes.end() ? it->second : TypePointer();
+ for (auto const& it: m_memberTypes)
+ if (it.first == _name)
+ return it.second;
+ return TypePointer();
}
MemberMap::const_iterator begin() const { return m_memberTypes.begin(); }