[libsolidity] remove ReferenceType::copyForLocationIfReference (use TypeProvider instead)

This commit is contained in:
Christian Parpart
2019-04-17 13:25:03 +02:00
parent b83097bdc6
commit 862b65d6e3
5 changed files with 9 additions and 21 deletions
+4 -11
View File
@@ -343,13 +343,13 @@ TypePointer Type::fullEncodingType(bool _inLibraryCall, bool _encoderV2, bool) c
MemberList::MemberMap Type::boundFunctions(Type const& _type, ContractDefinition const& _scope)
{
// Normalise data location of type.
TypePointer type = ReferenceType::copyForLocationIfReference(DataLocation::Storage, &_type);
TypePointer type = TypeProvider::withLocationIfReference(DataLocation::Storage, &_type);
set<Declaration const*> seenFunctions;
MemberList::MemberMap members;
for (ContractDefinition const* contract: _scope.annotation().linearizedBaseContracts)
for (UsingForDirective const* ufd: contract->usingForDirectives())
{
if (ufd->typeName() && *type != *ReferenceType::copyForLocationIfReference(
if (ufd->typeName() && *type != *TypeProvider::withLocationIfReference(
DataLocation::Storage,
ufd->typeName()->annotation().type
))
@@ -1479,16 +1479,9 @@ TypeResult ReferenceType::unaryOperatorResult(Token _operator) const
return nullptr;
}
TypePointer ReferenceType::copyForLocationIfReference(DataLocation _location, Type const* _type)
{
if (auto type = dynamic_cast<ReferenceType const*>(_type))
return TypeProvider::withLocation(type, _location, false);
return _type;
}
TypePointer ReferenceType::copyForLocationIfReference(Type const* _type) const
{
return copyForLocationIfReference(m_location, _type);
return TypeProvider::withLocationIfReference(m_location, _type);
}
string ReferenceType::stringForReferencePart() const
@@ -2202,7 +2195,7 @@ FunctionTypePointer StructType::constructorType() const
if (!member.type->canLiveOutsideStorage())
continue;
paramNames.push_back(member.name);
paramTypes.push_back(copyForLocationIfReference(DataLocation::Memory, member.type));
paramTypes.push_back(TypeProvider::withLocationIfReference(DataLocation::Memory, member.type));
}
return TypeProvider::functionType(
paramTypes,
-5
View File
@@ -654,11 +654,6 @@ public:
return location() == _other.location() && isPointer() == _other.isPointer();
}
/// @returns a copy of @a _type having the same location as this (and is not a pointer type)
/// if _type is a reference type and an unmodified copy of _type otherwise.
/// This function is mostly useful to modify inner types appropriately.
static Type const* copyForLocationIfReference(DataLocation _location, Type const* _type);
Type const* withLocation(DataLocation _location, bool _isPointer) const;
protected: