Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(revme): add new line in revme EOF printer #1503

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading