pub struct ExceptionTableData { /* private fields */ }
Expand description
Contents of an exception table.
The “no exception” target for is stored as the last element of the
underlying vector. It can be accessed through the normal_return
and normal_return_mut
functions. Exceptional catch clauses may
be iterated using the catches
and catches_mut
functions. All
targets may be iterated over using the all_targets
and
all_targets_mut
functions.
Implementations§
Source§impl ExceptionTableData
impl ExceptionTableData
Sourcepub fn new(
sig: SigRef,
normal_return: BlockCall,
tags_and_targets: impl IntoIterator<Item = (Option<ExceptionTag>, BlockCall)>,
) -> Self
pub fn new( sig: SigRef, normal_return: BlockCall, tags_and_targets: impl IntoIterator<Item = (Option<ExceptionTag>, BlockCall)>, ) -> Self
Create new exception-table data.
This data represents the destinations upon return from
try_call
or try_call_indirect
instruction. There are two
possibilities: “normal return” (no exception thrown), or an
exceptional return corresponding to one of the listed
exception tags.
The given tags are passed through to the metadata provided
alongside the provided function body, and Cranelift itself
does not implement an unwinder; thus, the meaning of the tags
is ultimately up to the embedder of Cranelift. The tags are
wrapped in Option
to allow encoding a “catch-all” handler.
The BlockCalls must have signatures that match the targeted
blocks, as usual. These calls are allowed to use
BlockArg::TryCallRet
in the normal-return case, with types
corresponding to the signature’s return values, and
BlockArg::TryCallExn
in the exceptional-return cases, with
types corresponding to native machine words and an arity
corresponding to the number of payload values that the calling
convention and platform support. (See [isa::CallConv
] for
more details.)
Sourcepub fn display<'a>(
&'a self,
pool: &'a ValueListPool,
) -> DisplayExceptionTable<'a>
pub fn display<'a>( &'a self, pool: &'a ValueListPool, ) -> DisplayExceptionTable<'a>
Return a value that can display the contents of this exception table.
Sourcepub fn deep_clone(&self, pool: &mut ValueListPool) -> Self
pub fn deep_clone(&self, pool: &mut ValueListPool) -> Self
Deep-clone this exception table.
Sourcepub fn normal_return(&self) -> &BlockCall
pub fn normal_return(&self) -> &BlockCall
Get the default target for the non-exceptional return case.
Sourcepub fn normal_return_mut(&mut self) -> &mut BlockCall
pub fn normal_return_mut(&mut self) -> &mut BlockCall
Get the default target for the non-exceptional return case.
Sourcepub fn catches(
&self,
) -> impl Iterator<Item = (Option<ExceptionTag>, &BlockCall)> + '_
pub fn catches( &self, ) -> impl Iterator<Item = (Option<ExceptionTag>, &BlockCall)> + '_
Get the targets for exceptional return cases, together with their tags.
Sourcepub fn catches_mut(
&mut self,
) -> impl Iterator<Item = (Option<ExceptionTag>, &mut BlockCall)> + '_
pub fn catches_mut( &mut self, ) -> impl Iterator<Item = (Option<ExceptionTag>, &mut BlockCall)> + '_
Get the targets for exceptional return cases, together with their tags.
Sourcepub fn len_catches(&self) -> usize
pub fn len_catches(&self) -> usize
The number of catch edges in this exception table.
Sourcepub fn get_catch(
&self,
index: usize,
) -> Option<(Option<ExceptionTag>, &BlockCall)>
pub fn get_catch( &self, index: usize, ) -> Option<(Option<ExceptionTag>, &BlockCall)>
Get the index
th catch edge from this table.
Sourcepub fn all_branches(&self) -> &[BlockCall]
pub fn all_branches(&self) -> &[BlockCall]
Get all branch targets.
Sourcepub fn all_branches_mut(&mut self) -> &mut [BlockCall]
pub fn all_branches_mut(&mut self) -> &mut [BlockCall]
Get all branch targets.
Sourcepub fn signature(&self) -> SigRef
pub fn signature(&self) -> SigRef
Get the signature of the function called with this exception table.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears all entries in this exception table, but leaves the function signature.
Sourcepub fn push_catch(&mut self, tag: Option<ExceptionTag>, block_call: BlockCall)
pub fn push_catch(&mut self, tag: Option<ExceptionTag>, block_call: BlockCall)
Push a catch target onto this exception table.
§Panics
Panics if this exception table has been cleared.
Trait Implementations§
Source§impl Clone for ExceptionTableData
impl Clone for ExceptionTableData
Source§fn clone(&self) -> ExceptionTableData
fn clone(&self) -> ExceptionTableData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more