Skip to content

Commit

Permalink
chore(revme): add new line in revme EOF printer (#1503)
Browse files Browse the repository at this point in the history
* chore(revme): add new line in revme EOF printer

* format

* clippy
  • Loading branch information
rakita authored Jun 10, 2024
1 parent 733bf5e commit e734537
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
15 changes: 15 additions & 0 deletions crates/interpreter/src/interpreter/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,4 +589,19 @@ mod test {
))
);
}

#[test]
fn test4() {
//0xef0001010004020001000e04000000008000045f6000e100025f5f6000e1fffd00
// result:Result { result: false, exception: Some("EOF_InvalidNumberOfOutputs") }
let err = validate_raw_eof(
hex!("ef0001010004020001000e04000000008000045f6000e100025f5f6000e1fffd00").into(),
);
assert_eq!(
err,
Err(EofError::Validation(
EofValidationError::BackwardJumpBiggestNumMismatch
))
);
}
}
12 changes: 7 additions & 5 deletions crates/interpreter/src/opcode/eof_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ pub fn print_eof_code(code: &[u8]) {

print!("{}", opcode.name());
if opcode.immediate_size() != 0 {
print!(
" : 0x{:}",
hex::encode(&code[i + 1..i + 1 + opcode.immediate_size() as usize])
);
let immediate = &code[i + 1..i + 1 + opcode.immediate_size() as usize];
print!(" : 0x{:}", hex::encode(immediate));
if opcode.immediate_size() == 2 {
print!(" ({})", i16::from_be_bytes(immediate.try_into().unwrap()));
}
}
println!();

let mut rjumpv_additional_immediates = 0;
if op == RJUMPV {
Expand All @@ -47,7 +49,7 @@ pub fn print_eof_code(code: &[u8]) {

for vtablei in 0..len {
let offset = unsafe { read_i16(code.as_ptr().add(i + 2 + 2 * vtablei)) } as isize;
println!("RJUMPV[{vtablei}]: 0x{offset:04X}({offset})");
println!("RJUMPV[{vtablei}]: 0x{offset:04X} ({offset})");
}
}

Expand Down

0 comments on commit e734537

Please sign in to comment.