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

Function decode_exception_table

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

Decode all exception table entries.

(table: &[u8])

Source from the content-addressed store, hash-verified

106
107/// Decode all exception table entries.
108pub fn decode_exception_table(table: &[u8]) -> Vec<ExceptionTableEntry> {
109 let mut entries = Vec::new();
110 let mut pos = 0;
111 while pos < table.len() {
112 let Some(start) = read_varint_with_start(table, &mut pos) else {
113 break;
114 };
115 let Some(size) = read_varint(table, &mut pos) else {
116 break;
117 };
118 let Some(target) = read_varint(table, &mut pos) else {
119 break;
120 };
121 let Some(depth_lasti) = read_varint(table, &mut pos) else {
122 break;
123 };
124 let Some(end) = start.checked_add(size) else {
125 break;
126 };
127 entries.push(ExceptionTableEntry {
128 start,
129 end,
130 target,
131 depth: (depth_lasti >> 1) as u16,
132 push_lasti: (depth_lasti & 1) != 0,
133 });
134 }
135 entries
136}
137
138/// Parse linetable to build a boolean mask indicating which code units
139/// have NO_LOCATION (line == -1). Returns a Vec<bool> of length `num_units`.

Callers 2

instrument_codeFunction · 0.85
mark_stacksFunction · 0.85

Calls 5

newFunction · 0.85
read_varint_with_startFunction · 0.85
read_varintFunction · 0.70
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected