MCPcopy Index your code
hub / github.com/RustPython/RustPython / find_exception_handler

Function find_exception_handler

crates/compiler-core/src/bytecode.rs:82–105  ·  view source on GitHub ↗

Find exception handler for given instruction offset.

(table: &[u8], offset: u32)

Source from the content-addressed store, hash-verified

80
81/// Find exception handler for given instruction offset.
82pub fn find_exception_handler(table: &[u8], offset: u32) -> Option<ExceptionTableEntry> {
83 let mut pos = 0;
84 while pos < table.len() {
85 let start = read_varint_with_start(table, &mut pos)?;
86 let size = read_varint(table, &mut pos)?;
87 let target = read_varint(table, &mut pos)?;
88 let depth_lasti = read_varint(table, &mut pos)?;
89
90 let end = start + size;
91 let depth = (depth_lasti >> 1) as u16;
92 let push_lasti = (depth_lasti & 1) != 0;
93
94 if offset >= start && offset < end {
95 return Some(ExceptionTableEntry {
96 start,
97 end,
98 target,
99 depth,
100 push_lasti,
101 });
102 }
103 }
104 None
105}
106
107/// Decode all exception table entries.
108pub fn decode_exception_table(table: &[u8]) -> Vec<ExceptionTableEntry> {

Callers 3

unwind_blocksMethod · 0.85

Calls 4

read_varint_with_startFunction · 0.85
read_varintFunction · 0.70
SomeClass · 0.50
lenMethod · 0.45