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

Function pretty_instruction_error

cranelift/codegen/src/print_errors.rs:117–152  ·  view source on GitHub ↗

Pretty-print a function verifier error for a given instruction.

(
    w: &mut dyn Write,
    func: &Function,
    aliases: &SecondaryMap<Value, Vec<Value>>,
    cur_inst: Inst,
    indent: usize,
    func_w: &mut dyn FuncWriter,
    errors: &mut Vec<VerifierError>

Source from the content-addressed store, hash-verified

115
116/// Pretty-print a function verifier error for a given instruction.
117fn pretty_instruction_error(
118 w: &mut dyn Write,
119 func: &Function,
120 aliases: &SecondaryMap<Value, Vec<Value>>,
121 cur_inst: Inst,
122 indent: usize,
123 func_w: &mut dyn FuncWriter,
124 errors: &mut Vec<VerifierError>,
125) -> fmt::Result {
126 let mut s = String::new();
127 func_w.write_instruction(&mut s, func, aliases, cur_inst, indent)?;
128 write!(w, "{s}")?;
129
130 // TODO: Use drain_filter here when it gets stabilized
131 let mut i = 0;
132 let mut printed_error = false;
133 while i != errors.len() {
134 match errors[i].location {
135 ir::entities::AnyEntity::Inst(inst) if inst == cur_inst => {
136 if !printed_error {
137 print_arrow(w, &s)?;
138 printed_error = true;
139 }
140 let err = errors.remove(i);
141 print_error(w, err)?;
142 }
143 _ => i += 1,
144 }
145 }
146
147 if printed_error {
148 w.write_char('\n')?;
149 }
150
151 Ok(())
152}
153
154fn pretty_preamble_error(
155 w: &mut dyn Write,

Callers 1

write_instructionMethod · 0.85

Calls 7

print_arrowFunction · 0.85
print_errorFunction · 0.85
OkFunction · 0.85
newFunction · 0.50
write_instructionMethod · 0.45
lenMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected