From 2fd5e516a3dacc783daa98a82087851cabbb96ee Mon Sep 17 00:00:00 2001 From: rakita Date: Mon, 10 Jun 2024 13:23:33 +0200 Subject: [PATCH 1/3] chore(revme): add new line in revme EOF printer --- crates/interpreter/src/interpreter/analysis.rs | 15 +++++++++++++++ crates/interpreter/src/opcode/eof_printer.rs | 10 ++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/crates/interpreter/src/interpreter/analysis.rs b/crates/interpreter/src/interpreter/analysis.rs index 2b2d89f796..73d33d090d 100644 --- a/crates/interpreter/src/interpreter/analysis.rs +++ b/crates/interpreter/src/interpreter/analysis.rs @@ -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 + )) + ); + } } diff --git a/crates/interpreter/src/opcode/eof_printer.rs b/crates/interpreter/src/opcode/eof_printer.rs index dc22688222..74240b55a8 100644 --- a/crates/interpreter/src/opcode/eof_printer.rs +++ b/crates/interpreter/src/opcode/eof_printer.rs @@ -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 { From ff01604f6b764d096dabcfbf3aeac119018c87b7 Mon Sep 17 00:00:00 2001 From: rakita Date: Mon, 10 Jun 2024 13:29:29 +0200 Subject: [PATCH 2/3] format --- crates/interpreter/src/opcode/eof_printer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/interpreter/src/opcode/eof_printer.rs b/crates/interpreter/src/opcode/eof_printer.rs index 74240b55a8..f564366721 100644 --- a/crates/interpreter/src/opcode/eof_printer.rs +++ b/crates/interpreter/src/opcode/eof_printer.rs @@ -29,7 +29,7 @@ pub fn print_eof_code(code: &[u8]) { 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())); + print!(" ({})", i16::from_be_bytes(immediate.try_into().unwrap())); } } println!(""); @@ -49,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})"); } } From 14b55b8266c7d8faa0fd24b8546b6bc6faf80489 Mon Sep 17 00:00:00 2001 From: rakita Date: Mon, 10 Jun 2024 14:07:01 +0200 Subject: [PATCH 3/3] clippy --- crates/interpreter/src/opcode/eof_printer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/interpreter/src/opcode/eof_printer.rs b/crates/interpreter/src/opcode/eof_printer.rs index f564366721..e48f153dae 100644 --- a/crates/interpreter/src/opcode/eof_printer.rs +++ b/crates/interpreter/src/opcode/eof_printer.rs @@ -32,7 +32,7 @@ pub fn print_eof_code(code: &[u8]) { print!(" ({})", i16::from_be_bytes(immediate.try_into().unwrap())); } } - println!(""); + println!(); let mut rjumpv_additional_immediates = 0; if op == RJUMPV {