use super::instructions::StepAddr;
use super::{StringId, TypeId};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(C)]
pub struct Entrypoint {
pub name: StringId,
pub target: StepAddr,
pub result_type: TypeId,
_pad: u16,
}
const _: () = assert!(std::mem::size_of::<Entrypoint>() == 8);
impl Entrypoint {
pub fn new(name: StringId, target: StepAddr, result_type: TypeId) -> Self {
Self {
name,
target,
result_type,
_pad: 0,
}
}
pub(crate) fn from_bytes(bytes: &[u8]) -> Self {
Self {
name: StringId::new(u16::from_le_bytes([bytes[0], bytes[1]])),
target: u16::from_le_bytes([bytes[2], bytes[3]]),
result_type: TypeId(u16::from_le_bytes([bytes[4], bytes[5]])),
_pad: 0,
}
}
pub fn name(&self) -> StringId {
self.name
}
pub fn target(&self) -> StepAddr {
self.target
}
pub fn result_type(&self) -> TypeId {
self.result_type
}
}