aboutsummaryrefslogtreecommitdiff
path: root/src/long_mode
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2024-06-18 22:28:06 -0700
committeriximeow <me@iximeow.net>2024-06-18 22:32:59 -0700
commit89838f6bc67d0f7e8ae509a8bfa9d7e2ccc3137c (patch)
tree55d8f69237851b48eb58ca2ced4c37a09e27e21d /src/long_mode
parentcbdfa8402603e3a756b10d1527f1dc3c594f57cd (diff)
unreachable panics for impossible op_nr. clean this up though..
Diffstat (limited to 'src/long_mode')
-rw-r--r--src/long_mode/display.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/long_mode/display.rs b/src/long_mode/display.rs
index 1d14ff8..24d35be 100644
--- a/src/long_mode/display.rs
+++ b/src/long_mode/display.rs
@@ -1402,6 +1402,9 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
fn visit_abs_u32(&mut self, imm: u32) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
self.f.write_fixed_size(" ")?;
+ if self.op_nr >= 4 {
+ unsafe { core::hint::unreachable_unchecked(); }
+ }
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
self.f.write_char(name[0] as char)?;
@@ -1417,6 +1420,9 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
fn visit_abs_u64(&mut self, imm: u64) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
self.f.write_fixed_size(" ")?;
+ if self.op_nr >= 4 {
+ unsafe { core::hint::unreachable_unchecked(); }
+ }
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
self.f.write_char(name[0] as char)?;
@@ -1428,6 +1434,9 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
fn visit_disp(&mut self, reg: RegSpec, disp: i32) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
self.f.write_fixed_size(" ")?;
+ if self.op_nr >= 4 {
+ unsafe { core::hint::unreachable_unchecked(); }
+ }
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
self.f.write_char(name[0] as char)?;
@@ -1453,6 +1462,9 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
fn visit_deref(&mut self, reg: RegSpec) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
self.f.write_fixed_size(" ")?;
+ if self.op_nr >= 4 {
+ unsafe { core::hint::unreachable_unchecked(); }
+ }
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
self.f.write_char(name[0] as char)?;
@@ -1466,6 +1478,9 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
fn visit_reg_scale(&mut self, reg: RegSpec, scale: u8) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
self.f.write_fixed_size(" ")?;
+ if self.op_nr >= 4 {
+ unsafe { core::hint::unreachable_unchecked(); }
+ }
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
self.f.write_char(name[0] as char)?;
@@ -1483,6 +1498,9 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
fn visit_reg_scale_disp(&mut self, reg: RegSpec, scale: u8, disp: i32) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
self.f.write_fixed_size(" ")?;
+ if self.op_nr >= 4 {
+ unsafe { core::hint::unreachable_unchecked(); }
+ }
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
self.f.write_char(name[0] as char)?;
@@ -1510,6 +1528,9 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
fn visit_index_base_scale(&mut self, base: RegSpec, index: RegSpec, scale: u8) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
self.f.write_fixed_size(" ")?;
+ if self.op_nr >= 4 {
+ unsafe { core::hint::unreachable_unchecked(); }
+ }
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
self.f.write_char(name[0] as char)?;
@@ -1527,6 +1548,9 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
fn visit_index_base_scale_disp(&mut self, base: RegSpec, index: RegSpec, scale: u8, disp: i32) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
self.f.write_fixed_size(" ")?;
+ if self.op_nr >= 4 {
+ unsafe { core::hint::unreachable_unchecked(); }
+ }
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
self.f.write_char(name[0] as char)?;