MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / reverse_target

Method reverse_target

cranelift/codegen/src/ranges.rs:118–130  ·  view source on GitHub ↗

Update these ranges to reflect that the list they refer to has been reversed. Afterwards, the ranges will still be indexed in the same order, but the first range will refer to the same-length range at the end of the target list instead of at the beginning, and subsequent ranges will proceed backwards from there. ```ignore use cranelift_codegen::ranges::Ranges; let mut ranges = Ranges::default();

(&mut self, target_len: usize)

Source from the content-addressed store, hash-verified

116 /// assert_eq!(ranges.get(1), 0..2);
117 /// ```
118 pub fn reverse_target(&mut self, target_len: usize) {
119 let target_len = u32::try_from(target_len).unwrap();
120 // The last endpoint added should be the same as the current
121 // length of the target list.
122 debug_assert_eq!(target_len, *self.ranges.last().unwrap_or(&0));
123 for end in self.ranges.iter_mut() {
124 *end = target_len - *end;
125 }
126 // Put the endpoints back in ascending order, but that means
127 // now our indexes are backwards.
128 self.ranges.reverse();
129 self.reverse_index();
130 }
131}

Callers 1

reverse_and_finalizeMethod · 0.80

Calls 4

reverseMethod · 0.80
reverse_indexMethod · 0.80
unwrapMethod · 0.45
iter_mutMethod · 0.45

Tested by

no test coverage detected