Use options struct for function type factory function.

This commit is contained in:
chriseth
2021-12-23 12:05:14 +01:00
parent 4fa8eee683
commit f94279a437
6 changed files with 107 additions and 91 deletions
+32
View File
@@ -1247,6 +1247,38 @@ public:
/// Cannot be called.
Declaration,
};
struct Options
{
/// true iff the function takes an arbitrary number of arguments of arbitrary types
bool arbitraryParameters = false;
/// true iff the gas value to be used is on the stack
bool gasSet = false;
/// true iff the value to be sent is on the stack
bool valueSet = false;
/// iff the salt value (for create2) to be used is on the stack
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;
static Options withArbitraryParameters()
{
Options result;
result.arbitraryParameters = true;
return result;
}
static Options fromFunctionType(FunctionType const& _type)
{
Options result;
result.arbitraryParameters = _type.takesArbitraryParameters();
result.gasSet = _type.gasSet();
result.valueSet = _type.valueSet();
result.saltSet = _type.saltSet();
result.bound = _type.bound();
return result;
}
};
/// Creates the type of a function.
/// @arg _kind must be Kind::Internal, Kind::External or Kind::Declaration.