pub struct Signature {
pub params: Vec<Param>,
pub returns: Vec<Param>,
pub variadic: bool,
}Expand description
What a function takes and returns.
A signature is not a type. Nothing in the IR has a function type, because a ptr has no
pointee and there is nothing else a function type could sit on. A call_indirect names the
signature it is called with, and that is where the ABI attributes are read from.
Fields§
§params: Vec<Param>What it takes, in their C-level form until the ABI has been applied.
returns: Vec<Param>What it returns, which is empty for a void function and for one whose return value
comes back through an Abi::Sret parameter.
variadic: boolWhether it takes arguments beyond the ones named.
Implementations§
Source§impl Signature
impl Signature
Sourcepub fn with_params(self, params: &[Type]) -> Self
pub fn with_params(self, params: &[Type]) -> Self
The same signature with these parameters, each in its C-level form.
Sourcepub fn with_returns(self, returns: &[Type]) -> Self
pub fn with_returns(self, returns: &[Type]) -> Self
The same signature returning these, each in its C-level form.
Sourcepub fn and_param(self, param: Param) -> Self
pub fn and_param(self, param: Param) -> Self
The same signature with one more parameter, travelling the way the ABI said.
Sourcepub fn and_return(self, param: Param) -> Self
pub fn and_return(self, param: Param) -> Self
The same signature with one more return value, travelling the way the ABI said.
Sourcepub fn param_types(&self) -> impl Iterator<Item = Type> + use<'_>
pub fn param_types(&self) -> impl Iterator<Item = Type> + use<'_>
The types it takes, without what the ABI asks of them.
Sourcepub fn return_types(&self) -> impl Iterator<Item = Type> + use<'_>
pub fn return_types(&self) -> impl Iterator<Item = Type> + use<'_>
The types it returns.