use std::fmt;
use midenc_hir::{Felt, FunctionIdent, OperandStack};
use super::{Addr, InstructionPointer, InstructionWithOp};
pub struct CallFrame {
pub function: FunctionIdent,
pub fp: Addr,
pub ip: Option<InstructionPointer>,
}
pub struct DebugInfo<'a> {
pub cycle: usize,
pub function: FunctionIdent,
pub fp: Addr,
pub ip: Option<InstructionWithOp>,
pub stack: &'a OperandStack<Felt>,
}
impl DebugInfo<'_> {
pub fn to_owned(self) -> DebugInfoWithStack {
let stack = self.stack.clone();
DebugInfoWithStack {
cycle: self.cycle,
function: self.function,
fp: self.fp,
ip: self.ip,
stack,
}
}
}
impl<'a> fmt::Debug for DebugInfo<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use midenc_hir::Stack;
f.debug_struct("DebugInfo")
.field("cycle", &self.cycle)
.field("function", &self.function)
.field("fp", &self.fp)
.field("ip", &self.ip)
.field("stack", &self.stack.debug())
.finish()
}
}
pub struct DebugInfoWithStack {
pub cycle: usize,
pub function: FunctionIdent,
pub fp: Addr,
pub ip: Option<InstructionWithOp>,
pub stack: OperandStack<Felt>,
}
impl fmt::Debug for DebugInfoWithStack {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use midenc_hir::Stack;
f.debug_struct("DebugInfo")
.field("cycle", &self.cycle)
.field("function", &self.function)
.field("fp", &self.fp)
.field("ip", &self.ip)
.field("stack", &self.stack.debug())
.finish()
}
}