Use function names instead of members.

This commit is contained in:
chriseth 2021-12-20 13:38:03 +01:00
parent b28cd00aa0
commit 4fa8eee683
2 changed files with 44 additions and 44 deletions

View File

@ -2942,11 +2942,11 @@ string FunctionType::richIdentifier() const
} }
id += "_" + stateMutabilityToString(m_stateMutability); id += "_" + stateMutabilityToString(m_stateMutability);
id += identifierList(m_parameterTypes) + "returns" + identifierList(m_returnParameterTypes); id += identifierList(m_parameterTypes) + "returns" + identifierList(m_returnParameterTypes);
if (m_gasSet) if (gasSet())
id += "gas"; id += "gas";
if (m_valueSet) if (valueSet())
id += "value"; id += "value";
if (m_saltSet) if (saltSet())
id += "salt"; id += "salt";
if (bound()) if (bound())
id += "bound_to" + identifierList(selfType()); id += "bound_to" + identifierList(selfType());
@ -3094,11 +3094,11 @@ bool FunctionType::nameable() const
{ {
return return
(m_kind == Kind::Internal || m_kind == Kind::External) && (m_kind == Kind::Internal || m_kind == Kind::External) &&
!m_bound && !bound() &&
!m_arbitraryParameters && !takesArbitraryParameters() &&
!m_gasSet && !gasSet() &&
!m_valueSet && !valueSet() &&
!m_saltSet; !saltSet();
} }
vector<tuple<string, Type const*>> FunctionType::makeStackItems() const vector<tuple<string, Type const*>> FunctionType::makeStackItems() const
@ -3140,11 +3140,11 @@ vector<tuple<string, Type const*>> FunctionType::makeStackItems() const
break; break;
} }
if (m_gasSet) if (gasSet())
slots.emplace_back("gas", TypeProvider::uint256()); slots.emplace_back("gas", TypeProvider::uint256());
if (m_valueSet) if (valueSet())
slots.emplace_back("value", TypeProvider::uint256()); slots.emplace_back("value", TypeProvider::uint256());
if (m_saltSet) if (saltSet())
slots.emplace_back("salt", TypeProvider::fixedBytes(32)); slots.emplace_back("salt", TypeProvider::fixedBytes(32));
if (bound()) if (bound())
slots.emplace_back("self", m_parameterTypes.front()); slots.emplace_back("self", m_parameterTypes.front());
@ -3182,7 +3182,7 @@ FunctionTypePointer FunctionType::interfaceFunctionType() const
m_parameterNames, m_parameterNames,
m_returnParameterNames, m_returnParameterNames,
m_kind, m_kind,
m_arbitraryParameters, takesArbitraryParameters(),
m_stateMutability, m_stateMutability,
m_declaration m_declaration
); );
@ -3240,9 +3240,9 @@ MemberList::MemberMap FunctionType::nativeMembers(ASTNode const* _scope) const
false, false,
StateMutability::Pure, StateMutability::Pure,
nullptr, nullptr,
m_gasSet, gasSet(),
m_valueSet, valueSet(),
m_saltSet saltSet()
) )
); );
} }
@ -3258,9 +3258,9 @@ MemberList::MemberMap FunctionType::nativeMembers(ASTNode const* _scope) const
false, false,
StateMutability::Pure, StateMutability::Pure,
nullptr, nullptr,
m_gasSet, gasSet(),
m_valueSet, valueSet(),
m_saltSet saltSet()
) )
); );
return members; return members;
@ -3288,7 +3288,7 @@ MemberList::MemberMap FunctionType::nativeMembers(ASTNode const* _scope) const
Type const* FunctionType::encodingType() const Type const* FunctionType::encodingType() const
{ {
if (m_gasSet || m_valueSet) if (gasSet() || valueSet())
return nullptr; return nullptr;
// Only external functions can be encoded, internal functions cannot leave code boundaries. // Only external functions can be encoded, internal functions cannot leave code boundaries.
if (m_kind == Kind::External) if (m_kind == Kind::External)
@ -3307,7 +3307,7 @@ TypeResult FunctionType::interfaceType(bool /*_inLibrary*/) const
Type const* FunctionType::mobileType() const Type const* FunctionType::mobileType() const
{ {
if (m_valueSet || m_gasSet || m_saltSet || m_bound) if (valueSet() || gasSet() || saltSet() || bound())
return nullptr; return nullptr;
// return function without parameter names // return function without parameter names
@ -3317,13 +3317,13 @@ Type const* FunctionType::mobileType() const
strings(m_parameterTypes.size()), strings(m_parameterTypes.size()),
strings(m_returnParameterNames.size()), strings(m_returnParameterNames.size()),
m_kind, m_kind,
m_arbitraryParameters, takesArbitraryParameters(),
m_stateMutability, m_stateMutability,
m_declaration, m_declaration,
m_gasSet, gasSet(),
m_valueSet, valueSet(),
m_bound, bound(),
m_saltSet saltSet()
); );
} }
@ -3409,7 +3409,7 @@ bool FunctionType::equalExcludingStateMutability(FunctionType const& _other) con
return false; return false;
//@todo this is ugly, but cannot be prevented right now //@todo this is ugly, but cannot be prevented right now
if (m_gasSet != _other.m_gasSet || m_valueSet != _other.m_valueSet || m_saltSet != _other.m_saltSet) if (gasSet() != _other.gasSet() || valueSet() != _other.valueSet() || saltSet() != _other.saltSet())
return false; return false;
if (bound() != _other.bound()) if (bound() != _other.bound())
@ -3526,34 +3526,34 @@ Type const* FunctionType::copyAndSetCallOptions(bool _setGas, bool _setValue, bo
m_parameterNames, m_parameterNames,
m_returnParameterNames, m_returnParameterNames,
m_kind, m_kind,
m_arbitraryParameters, takesArbitraryParameters(),
m_stateMutability, m_stateMutability,
m_declaration, m_declaration,
m_gasSet || _setGas, gasSet() || _setGas,
m_valueSet || _setValue, valueSet() || _setValue,
m_saltSet || _setSalt, saltSet() || _setSalt,
m_bound bound()
); );
} }
FunctionTypePointer FunctionType::asBoundFunction() const FunctionTypePointer FunctionType::asBoundFunction() const
{ {
solAssert(!m_parameterTypes.empty(), ""); solAssert(!m_parameterTypes.empty(), "");
solAssert(!m_gasSet, ""); solAssert(!gasSet(), "");
solAssert(!m_valueSet, ""); solAssert(!valueSet(), "");
solAssert(!m_saltSet, ""); solAssert(!saltSet(), "");
return TypeProvider::function( return TypeProvider::function(
m_parameterTypes, m_parameterTypes,
m_returnParameterTypes, m_returnParameterTypes,
m_parameterNames, m_parameterNames,
m_returnParameterNames, m_returnParameterNames,
m_kind, m_kind,
m_arbitraryParameters, takesArbitraryParameters(),
m_stateMutability, m_stateMutability,
m_declaration, m_declaration,
m_gasSet, gasSet(),
m_valueSet, valueSet(),
m_saltSet, saltSet(),
true true
); );
} }
@ -3592,13 +3592,13 @@ FunctionTypePointer FunctionType::asExternallyCallableFunction(bool _inLibrary)
m_parameterNames, m_parameterNames,
m_returnParameterNames, m_returnParameterNames,
kind, kind,
m_arbitraryParameters, takesArbitraryParameters(),
m_stateMutability, m_stateMutability,
m_declaration, m_declaration,
m_gasSet, gasSet(),
m_valueSet, valueSet(),
m_saltSet, saltSet(),
m_bound bound()
); );
} }

View File

@ -1314,7 +1314,7 @@ public:
"Return parameter names list must match return parameter types list!" "Return parameter names list must match return parameter types list!"
); );
solAssert( solAssert(
!m_bound || !m_parameterTypes.empty(), !bound() || !m_parameterTypes.empty(),
"Attempted construction of bound function without self type" "Attempted construction of bound function without self type"
); );
} }