|
|
|
@ -5,6 +5,10 @@ use crate::value::Value;
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub enum OpCode {
|
|
|
|
|
Constant(usize),
|
|
|
|
|
Add,
|
|
|
|
|
Subtract,
|
|
|
|
|
Multiply,
|
|
|
|
|
Divide,
|
|
|
|
|
Negate,
|
|
|
|
|
Return,
|
|
|
|
|
}
|
|
|
|
@ -68,6 +72,10 @@ impl fmt::Display for DisassembledInstruction<'_> {
|
|
|
|
|
"{:<16} {:4} '{}'",
|
|
|
|
|
"OP_CONSTANT", constant, self.chunk.constants[constant]
|
|
|
|
|
)?,
|
|
|
|
|
OpCode::Add => write!(f, "OP_ADD")?,
|
|
|
|
|
OpCode::Subtract => write!(f, "OP_SUBTRACT")?,
|
|
|
|
|
OpCode::Multiply => write!(f, "OP_MULTIPLY")?,
|
|
|
|
|
OpCode::Divide => write!(f, "OP_DIVIDE")?,
|
|
|
|
|
OpCode::Negate => write!(f, "OP_NEGATE")?,
|
|
|
|
|
OpCode::Return => write!(f, "OP_RETURN")?,
|
|
|
|
|
}
|
|
|
|
|