patchouly-core 0.1.0

Essential types for patchouly stencils.
Documentation
#![no_std]

pub mod relocation;
pub mod stencils;

/// A trait for a stencil stack
///
/// The compiler will generate code that uses stacks
/// when a variable is determined to be "spilled".
///
/// ## Requirements
///
/// Note that the functions must be annotated with `#[inline]`
/// and must not involve further linkage. `patchouly-build` will
/// report these violations on build-time.
pub trait StencilStack {
    fn get(&self, i: usize) -> usize;
    fn set(&mut self, i: usize, v: usize);
}

/// A library of stencils
pub struct StencilLibrary<const MAX_REGS: usize> {
    /// All the stencil binary code, referred to by stencils
    pub code: &'static [u8],
    /// The code for an empty stencil, used to prune consecutive jumps
    pub empty: &'static [u8],
    /// Stencils to move values between registers/the stack
    pub moves: &'static StencilFamily<1, 1, MAX_REGS, 0, 1>,
}

pub use stencils::Stencil;
pub use stencils::StencilFamily;