Generate an opcode_name() function.
This function returning a &'static str is more primitive that the Display implementation. It allows the opcode strings to be reused by the parser.
This commit is contained in:
@@ -8,9 +8,16 @@
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
use std::mem;
|
||||
|
||||
// The `Opcode` enum is generated from the meta instruction descriptions.
|
||||
// The `Opcode` enum and the `opcode_name` function are generated from the meta instruction
|
||||
// descriptions.
|
||||
include!(concat!(env!("OUT_DIR"), "/opcodes.rs"));
|
||||
|
||||
impl Display for Opcode {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
write!(f, "{}", opcode_name(*self))
|
||||
}
|
||||
}
|
||||
|
||||
/// 64-bit immediate integer operand.
|
||||
///
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user