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 d
(
sig: SigRef,
normal_return: BlockCall,
matches: impl IntoIterator<Item = ExceptionTableItem>,
)
| 132 | /// convention and platform support. (See [`CallConv`](crate::isa::CallConv) for |
| 133 | /// more details.) |
| 134 | pub fn new( |
| 135 | sig: SigRef, |
| 136 | normal_return: BlockCall, |
| 137 | matches: impl IntoIterator<Item = ExceptionTableItem>, |
| 138 | ) -> Self { |
| 139 | let mut targets = vec![]; |
| 140 | let mut items = vec![]; |
| 141 | for item in matches { |
| 142 | let target_idx = u32::try_from(targets.len()).unwrap(); |
| 143 | match item { |
| 144 | ExceptionTableItem::Tag(tag, target) => { |
| 145 | items.push(InternalExceptionTableItem::Tag(tag, target_idx)); |
| 146 | targets.push(target); |
| 147 | } |
| 148 | ExceptionTableItem::Default(target) => { |
| 149 | items.push(InternalExceptionTableItem::Default(target_idx)); |
| 150 | targets.push(target); |
| 151 | } |
| 152 | ExceptionTableItem::Context(ctx) => { |
| 153 | items.push(InternalExceptionTableItem::Context(ctx)); |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | targets.push(normal_return); |
| 158 | |
| 159 | ExceptionTableData { |
| 160 | targets, |
| 161 | items, |
| 162 | sig, |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /// Return a value that can display the contents of this exception |
| 167 | /// table. |