-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathutils.rs
More file actions
51 lines (42 loc) · 1.5 KB
/
utils.rs
File metadata and controls
51 lines (42 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// TODO Reconsider the importance of this module. All of its functions do the same?
#[cfg(debug_assertions)]
pub fn print_beautiful_instruction_name_1_byte(first_byte: u8, pc: usize) {
use crate::core::reader::types::opcode::opcode_byte_to_str;
trace!(
"Read instruction {} at wasm_binary[{}]",
opcode_byte_to_str(first_byte),
pc
);
}
#[cfg(debug_assertions)]
pub fn print_beautiful_fc_extension(second_byte: u32, pc: usize) {
use crate::core::reader::types::opcode::fc_extension_opcode_to_str;
trace!(
"Read instruction {} at wasm_binary[{}]",
fc_extension_opcode_to_str(second_byte),
pc,
);
}
#[cfg(debug_assertions)]
pub fn print_beautiful_fd_extension(second_byte: u32, pc: usize) {
use crate::core::reader::types::opcode::fd_extension_opcode_to_str;
trace!(
"Read instruction {} at wasm_binary[{}]",
fd_extension_opcode_to_str(second_byte),
pc,
);
}
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
pub trait ToUsizeExt {
fn into_usize(self) -> usize;
}
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
impl ToUsizeExt for u32 {
fn into_usize(self) -> usize {
// SAFETY: The current trait only exists for architectures where
// pointers are at least 32 bits wide.
unsafe { usize::try_from(self).unwrap_unchecked() }
}
}
#[cfg(target_pointer_width = "16")]
compile_error!("targets with 16 bit wide pointers are currently not supported");