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

Method display_inner

crates/compiler-core/src/bytecode.rs:1138–1184  ·  view source on GitHub ↗
(
        &self,
        f: &mut fmt::Formatter<'_>,
        expand_code_objects: bool,
        level: usize,
    )

Source from the content-addressed store, hash-verified

1136 }
1137
1138 fn display_inner(
1139 &self,
1140 f: &mut fmt::Formatter<'_>,
1141 expand_code_objects: bool,
1142 level: usize,
1143 ) -> fmt::Result {
1144 let label_targets = self.label_targets();
1145 let line_digits = (3).max(self.locations.last().unwrap().0.line.digits().get());
1146 let offset_digits = (4).max(1 + self.instructions.len().ilog10() as usize);
1147 let mut last_line = OneIndexed::MAX;
1148 let mut arg_state = OpArgState::default();
1149 for (offset, &instruction) in self.instructions.iter().enumerate() {
1150 let (instruction, arg) = arg_state.get(instruction);
1151 // optional line number
1152 let line = self.locations[offset].0.line;
1153 if line != last_line {
1154 if last_line != OneIndexed::MAX {
1155 writeln!(f)?;
1156 }
1157 last_line = line;
1158 write!(f, "{line:line_digits$}")?;
1159 } else {
1160 for _ in 0..line_digits {
1161 write!(f, " ")?;
1162 }
1163 }
1164 write!(f, " ")?;
1165
1166 // level indent
1167 for _ in 0..level {
1168 write!(f, " ")?;
1169 }
1170
1171 // arrow and offset
1172 let arrow = if label_targets.contains(&Label::from_u32(offset as u32)) {
1173 ">>"
1174 } else {
1175 " "
1176 };
1177 write!(f, "{arrow} {offset:offset_digits$} ")?;
1178
1179 // instruction
1180 instruction.fmt_dis(arg, f, self, expand_code_objects, 21, level)?;
1181 writeln!(f)?;
1182 }
1183 Ok(())
1184 }
1185
1186 /// Recursively display this CodeObject
1187 pub fn display_expand_code_objects(&self) -> impl fmt::Display + '_ {

Callers 2

fmtMethod · 0.80
fmt_disMethod · 0.80

Calls 9

label_targetsMethod · 0.80
fmt_disMethod · 0.80
maxMethod · 0.45
getMethod · 0.45
unwrapMethod · 0.45
lastMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected