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

Function encode_exception_table

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

Encode exception table entries. Uses 6-bit varint encoding with start marker (MSB) and continuation bit.

(entries: &[ExceptionTableEntry])

Source from the content-addressed store, hash-verified

65/// Encode exception table entries.
66/// Uses 6-bit varint encoding with start marker (MSB) and continuation bit.
67pub fn encode_exception_table(entries: &[ExceptionTableEntry]) -> alloc::boxed::Box<[u8]> {
68 let mut data = Vec::new();
69 for entry in entries {
70 let size = entry.end.saturating_sub(entry.start);
71 let depth_lasti = ((entry.depth as u32) << 1) | (entry.push_lasti as u32);
72
73 write_varint_with_start(&mut data, entry.start);
74 write_varint_be(&mut data, size);
75 write_varint_be(&mut data, entry.target);
76 write_varint_be(&mut data, depth_lasti);
77 }
78 data.into_boxed_slice()
79}
80
81/// Find exception handler for given instruction offset.
82pub fn find_exception_handler(table: &[u8], offset: u32) -> Option<ExceptionTableEntry> {

Calls 3

newFunction · 0.85
write_varint_with_startFunction · 0.85
write_varint_beFunction · 0.85