Change return type for interfaceType() to ResultType

This commit is contained in:
Mathias Baumann
2019-03-21 07:25:28 +01:00
parent 56f2912e61
commit 0fbea8a1a0
5 changed files with 34 additions and 34 deletions
+10 -10
View File
@@ -1869,7 +1869,7 @@ TypePointer ArrayType::decodingType() const
return shared_from_this();
}
TypePointer ArrayType::interfaceType(bool _inLibrary) const
TypeResult ArrayType::interfaceType(bool _inLibrary) const
{
if (_inLibrary && m_interfaceType_library.is_initialized())
return *m_interfaceType_library;
@@ -2135,7 +2135,7 @@ MemberList::MemberMap StructType::nativeMembers(ContractDefinition const*) const
return members;
}
TypePointer StructType::interfaceType(bool _inLibrary) const
TypeResult StructType::interfaceType(bool _inLibrary) const
{
if (_inLibrary && m_interfaceType_library.is_initialized())
return *m_interfaceType_library;
@@ -2168,7 +2168,7 @@ TypePointer StructType::interfaceType(bool _inLibrary) const
allOkay = false;
break;
}
if (!var->annotation().type->interfaceType(false))
if (!var->annotation().type->interfaceType(false).get())
{
allOkay = false;
break;
@@ -2204,8 +2204,8 @@ string StructType::signatureInExternalFunction(bool _structsByName) const
{
solAssert(_t, "Parameter should have external type.");
auto t = _t->interfaceType(_structsByName);
solAssert(t, "");
return t->signatureInExternalFunction(_structsByName);
solAssert(t.get(), "");
return t.get()->signatureInExternalFunction(_structsByName);
});
return "(" + boost::algorithm::join(memberTypeStrings, ",") + ")";
}
@@ -2574,7 +2574,7 @@ FunctionType::FunctionType(FunctionTypeName const& _typeName):
solAssert(t->annotation().type, "Type not set for parameter.");
if (m_kind == Kind::External)
solAssert(
t->annotation().type->interfaceType(false),
t->annotation().type->interfaceType(false).get(),
"Internal type used as parameter for external function."
);
m_parameterTypes.push_back(t->annotation().type);
@@ -2584,7 +2584,7 @@ FunctionType::FunctionType(FunctionTypeName const& _typeName):
solAssert(t->annotation().type, "Type not set for return parameter.");
if (m_kind == Kind::External)
solAssert(
t->annotation().type->interfaceType(false),
t->annotation().type->interfaceType(false).get(),
"Internal type used as return parameter for external function."
);
m_returnParameterTypes.push_back(t->annotation().type);
@@ -2885,14 +2885,14 @@ FunctionTypePointer FunctionType::interfaceFunctionType() const
for (auto type: m_parameterTypes)
{
if (auto ext = type->interfaceType(isLibraryFunction))
if (auto ext = type->interfaceType(isLibraryFunction).get())
paramTypes.push_back(ext);
else
return FunctionTypePointer();
}
for (auto type: m_returnParameterTypes)
{
if (auto ext = type->interfaceType(isLibraryFunction))
if (auto ext = type->interfaceType(isLibraryFunction).get())
retParamTypes.push_back(ext);
else
return FunctionTypePointer();
@@ -2978,7 +2978,7 @@ TypePointer FunctionType::encodingType() const
return TypePointer();
}
TypePointer FunctionType::interfaceType(bool /*_inLibrary*/) const
TypeResult FunctionType::interfaceType(bool /*_inLibrary*/) const
{
if (m_kind == Kind::External)
return shared_from_this();
+16 -16
View File
@@ -304,7 +304,7 @@ public:
/// If there is no such type, returns an empty shared pointer.
/// @param _inLibrary if set, returns types as used in a library, e.g. struct and contract types
/// are returned without modification.
virtual TypePointer interfaceType(bool /*_inLibrary*/) const { return TypePointer(); }
virtual TypeResult interfaceType(bool /*_inLibrary*/) const { return TypePointer(); }
private:
/// @returns a member list containing all members added to this type by `using for` directives.
@@ -355,7 +355,7 @@ public:
u256 literalValue(Literal const* _literal) const override;
TypePointer encodingType() const override { return shared_from_this(); }
TypePointer interfaceType(bool) const override { return shared_from_this(); }
TypeResult interfaceType(bool) const override { return shared_from_this(); }
StateMutability stateMutability(void) const { return m_stateMutability; }
@@ -395,7 +395,7 @@ public:
std::string toString(bool _short) const override;
TypePointer encodingType() const override { return shared_from_this(); }
TypePointer interfaceType(bool) const override { return shared_from_this(); }
TypeResult interfaceType(bool) const override { return shared_from_this(); }
unsigned numBits() const { return m_bits; }
bool isSigned() const { return m_modifier == Modifier::Signed; }
@@ -437,7 +437,7 @@ public:
std::string toString(bool _short) const override;
TypePointer encodingType() const override { return shared_from_this(); }
TypePointer interfaceType(bool) const override { return shared_from_this(); }
TypeResult interfaceType(bool) const override { return shared_from_this(); }
/// Number of bits used for this type in total.
unsigned numBits() const { return m_totalBits; }
@@ -583,7 +583,7 @@ public:
std::string toString(bool) const override { return "bytes" + dev::toString(m_bytes); }
MemberList::MemberMap nativeMembers(ContractDefinition const*) const override;
TypePointer encodingType() const override { return shared_from_this(); }
TypePointer interfaceType(bool) const override { return shared_from_this(); }
TypeResult interfaceType(bool) const override { return shared_from_this(); }
unsigned numBytes() const { return m_bytes; }
@@ -609,7 +609,7 @@ public:
std::string toString(bool) const override { return "bool"; }
u256 literalValue(Literal const* _literal) const override;
TypePointer encodingType() const override { return shared_from_this(); }
TypePointer interfaceType(bool) const override { return shared_from_this(); }
TypeResult interfaceType(bool) const override { return shared_from_this(); }
};
/**
@@ -716,7 +716,7 @@ public:
MemberList::MemberMap nativeMembers(ContractDefinition const* _currentScope) const override;
TypePointer encodingType() const override;
TypePointer decodingType() const override;
TypePointer interfaceType(bool _inLibrary) const override;
TypeResult interfaceType(bool _inLibrary) const override;
/// @returns true if this is valid to be stored in calldata
bool validForCalldata() const;
@@ -749,8 +749,8 @@ private:
TypePointer m_baseType;
bool m_hasDynamicLength = true;
u256 m_length;
mutable boost::optional<TypePointer> m_interfaceType;
mutable boost::optional<TypePointer> m_interfaceType_library;
mutable boost::optional<TypeResult> m_interfaceType;
mutable boost::optional<TypeResult> m_interfaceType_library;
};
/**
@@ -788,7 +788,7 @@ public:
return TypePointer{};
return std::make_shared<AddressType>(isPayable() ? StateMutability::Payable : StateMutability::NonPayable);
}
TypePointer interfaceType(bool _inLibrary) const override
TypeResult interfaceType(bool _inLibrary) const override
{
if (isSuper())
return TypePointer{};
@@ -842,7 +842,7 @@ public:
{
return location() == DataLocation::Storage ? std::make_shared<IntegerType>(256) : shared_from_this();
}
TypePointer interfaceType(bool _inLibrary) const override;
TypeResult interfaceType(bool _inLibrary) const override;
TypePointer copyForLocation(DataLocation _location, bool _isPointer) const override;
@@ -872,8 +872,8 @@ private:
StructDefinition const& m_struct;
/// Cache for the recursive() function.
mutable boost::optional<bool> m_recursive;
mutable boost::optional<TypePointer> m_interfaceType;
mutable boost::optional<TypePointer> m_interfaceType_library;
mutable boost::optional<TypeResult> m_interfaceType;
mutable boost::optional<TypeResult> m_interfaceType_library;
};
/**
@@ -902,7 +902,7 @@ public:
{
return std::make_shared<IntegerType>(8 * int(storageBytes()));
}
TypePointer interfaceType(bool _inLibrary) const override
TypeResult interfaceType(bool _inLibrary) const override
{
return _inLibrary ? shared_from_this() : encodingType();
}
@@ -1098,7 +1098,7 @@ public:
bool hasSimpleZeroValueInMemory() const override { return false; }
MemberList::MemberMap nativeMembers(ContractDefinition const* _currentScope) const override;
TypePointer encodingType() const override;
TypePointer interfaceType(bool _inLibrary) const override;
TypeResult interfaceType(bool _inLibrary) const override;
/// @returns TypePointer of a new FunctionType object. All input/return parameters are an
/// appropriate external types (i.e. the interfaceType()s) of input/return parameters of
@@ -1223,7 +1223,7 @@ public:
{
return std::make_shared<IntegerType>(256);
}
TypePointer interfaceType(bool _inLibrary) const override
TypeResult interfaceType(bool _inLibrary) const override
{
return _inLibrary ? shared_from_this() : TypePointer();
}