use cranelift_codegen::ir::immediates::Uimm64;
use std::fmt::{self, Display, Formatter};
#[derive(PartialEq, Debug, Clone)]
pub struct HeapCommand {
pub heap_type: HeapType,
pub size: Uimm64,
pub ptr_offset: Option<Uimm64>,
pub bound_offset: Option<Uimm64>,
}
impl Display for HeapCommand {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "heap: {}, size={}", self.heap_type, self.size)?;
if let Some(offset) = self.ptr_offset {
write!(f, ", ptr=vmctx+{}", offset)?
}
if let Some(offset) = self.bound_offset {
write!(f, ", bound=vmctx+{}", offset)?
}
Ok(())
}
}
#[allow(missing_docs)]
#[derive(Debug, PartialEq, Clone)]
pub enum HeapType {
Static,
Dynamic,
}
impl Display for HeapType {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
HeapType::Static => write!(f, "static"),
HeapType::Dynamic => write!(f, "dynamic"),
}
}
}