Consistent terminology for attached/bound functions

This commit is contained in:
wechman
2022-12-07 19:31:41 +01:00
committed by Kamil Śliwak
parent 1c8745c54a
commit 64a4f32bc2
42 changed files with 132 additions and 133 deletions
+15 -15
View File
@@ -326,7 +326,7 @@ public:
/// given location.
virtual bool dataStoredIn(DataLocation) const { return false; }
/// Returns the list of all members of this type. Default implementation: no members apart from bound.
/// Returns the list of all members of this type. Default implementation: no members apart from attached functions.
/// @param _currentScope scope in which the members are accessed.
MemberList const& members(ASTNode const* _currentScope) const;
/// Convenience method, returns the type of the given named member or an empty pointer if no such member exists.
@@ -379,11 +379,11 @@ public:
private:
/// @returns a member list containing all members added to this type by `using for` directives.
static MemberList::MemberMap boundFunctions(Type const& _type, ASTNode const& _scope);
static MemberList::MemberMap attachedFunctions(Type const& _type, ASTNode const& _scope);
protected:
/// @returns the members native to this type depending on the given context. This function
/// is used (in conjunction with boundFunctions to fill m_members below.
/// is used (in conjunction with attachedFunctions to fill m_members below.
virtual MemberList::MemberMap nativeMembers(ASTNode const* /*_currentScope*/) const
{
return MemberList::MemberMap();
@@ -1272,7 +1272,7 @@ public:
bool saltSet = false;
/// true iff the function is called as arg1.fun(arg2, ..., argn).
/// This is achieved through the "using for" directive.
bool bound = false;
bool hasBoundFirstArgument = false;
static Options withArbitraryParameters()
{
@@ -1287,7 +1287,7 @@ public:
result.gasSet = _type.gasSet();
result.valueSet = _type.valueSet();
result.saltSet = _type.saltSet();
result.bound = _type.bound();
result.hasBoundFirstArgument = _type.hasBoundFirstArgument();
return result;
}
};
@@ -1322,7 +1322,7 @@ public:
)
{
// In this constructor, only the "arbitrary Parameters" option should be used.
solAssert(!bound() && !gasSet() && !valueSet() && !saltSet());
solAssert(!hasBoundFirstArgument() && !gasSet() && !valueSet() && !saltSet());
}
/// Detailed constructor, use with care.
@@ -1354,8 +1354,8 @@ public:
"Return parameter names list must match return parameter types list!"
);
solAssert(
!bound() || !m_parameterTypes.empty(),
"Attempted construction of bound function without self type"
!hasBoundFirstArgument() || !m_parameterTypes.empty(),
"Attempted construction of attached function without self type"
);
}
@@ -1372,7 +1372,7 @@ public:
/// storage pointers) are replaced by InaccessibleDynamicType instances.
TypePointers returnParameterTypesWithoutDynamicTypes() const;
std::vector<std::string> const& returnParameterNames() const { return m_returnParameterNames; }
/// @returns the "self" parameter type for a bound function
/// @returns the "self" parameter type for an attached function
Type const* selfType() const;
std::string richIdentifier() const override;
@@ -1406,8 +1406,8 @@ public:
/// @returns true if this function can take the given arguments (possibly
/// after implicit conversion).
/// @param _selfType if the function is bound, this has to be supplied and is the type of the
/// expression the function is called on.
/// @param _selfType if the function is attached as a member function, this has to be supplied
/// and is the type of the expression the function is called on.
bool canTakeArguments(
FuncCallArguments const& _arguments,
Type const* _selfType = nullptr
@@ -1471,20 +1471,20 @@ public:
bool gasSet() const { return m_options.gasSet; }
bool valueSet() const { return m_options.valueSet; }
bool saltSet() const { return m_options.saltSet; }
bool bound() const { return m_options.bound; }
bool hasBoundFirstArgument() const { return m_options.hasBoundFirstArgument; }
/// @returns a copy of this type, where gas or value are set manually. This will never set one
/// of the parameters to false.
Type const* copyAndSetCallOptions(bool _setGas, bool _setValue, bool _setSalt) const;
/// @returns a copy of this function type with the `bound` flag set to true.
/// @returns a copy of this function type with the `hasBoundFirstArgument` flag set to true.
/// Should only be called on library functions.
FunctionTypePointer asBoundFunction() const;
FunctionTypePointer withBoundFirstArgument() const;
/// @returns a copy of this function type where the location of reference types is changed
/// from CallData to Memory. This is the type that would be used when the function is
/// called externally, as opposed to the parameter types that are available inside the function body.
/// Also supports variants to be used for library or bound calls.
/// Also supports variants to be used for library or attached function calls.
/// @param _inLibrary if true, uses DelegateCall as location.
FunctionTypePointer asExternallyCallableFunction(bool _inLibrary) const;