This commit is contained in:
2026-06-30 18:41:42 +08:00
parent f0e3f1eeca
commit dde3052e2d
13 changed files with 79 additions and 106 deletions
-1
View File
@@ -5,7 +5,6 @@ edition = "2024"
[dependencies]
colored = "3.1.1"
likely_stable = { workspace = true }
num_enum = { workspace = true }
string-interner = { workspace = true }
+3 -4
View File
@@ -1,7 +1,6 @@
use std::fmt::Write;
use colored::Colorize;
use num_enum::TryFromPrimitive;
use colored::Colorize as _;
use crate::{InstructionPtr, Op, OperandType, PrimOpPhase};
@@ -81,7 +80,7 @@ impl<'a, Ctx: DisassemblerContext> Disassembler<'a, Ctx> {
fn read_operand_data(&mut self) {
use OperandType::*;
let tag = self.read_u8();
let ty = OperandType::try_from_primitive(tag).expect("invalid operand type");
let ty = OperandType::try_from(tag).expect("invalid operand type");
match ty {
Const => {
self.read_u32();
@@ -201,7 +200,7 @@ impl<'a, Ctx: DisassemblerContext> Disassembler<'a, Ctx> {
}
fn decode_instruction(&mut self, op_byte: u8, current_pc: usize) -> (&'static str, String) {
let op = Op::try_from_primitive(op_byte).expect("invalid op code");
let op = Op::try_from(op_byte).expect("invalid op code");
match op {
Op::PushSmi => {
+2 -1
View File
@@ -447,7 +447,8 @@ impl<'a> BytecodeReader<'a> {
pub fn read_op(&mut self) -> Op {
self.inst_start_pc = self.pc;
let byte = self.bytecode[self.pc];
if !likely_stable::likely((0..Op::Illegal as u8).contains(&byte)) {
if !(0..Op::Illegal as u8).contains(&byte) {
std::hint::cold_path();
panic!("unknown opcode: {byte:#04x}")
}
self.pc += 1;