use crate::utils::collections::Vec;
use core::fmt;
mod advice;
pub use advice::AdviceInjector;
mod assembly_op;
pub use assembly_op::AssemblyOp;
mod debug;
pub use debug::DebugOptions;
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Decorator {
Advice(AdviceInjector),
AsmOp(AssemblyOp),
Debug(DebugOptions),
}
impl fmt::Display for Decorator {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Advice(injector) => write!(f, "advice({injector})"),
Self::AsmOp(assembly_op) => {
write!(f, "asmOp({}, {})", assembly_op.op(), assembly_op.num_cycles())
}
Self::Debug(options) => write!(f, "debug({options})"),
}
}
}
pub type DecoratorList = Vec<(usize, Decorator)>;
pub struct DecoratorIterator<'a> {
decorators: &'a DecoratorList,
idx: usize,
}
impl<'a> DecoratorIterator<'a> {
pub fn new(decorators: &'a DecoratorList) -> Self {
Self { decorators, idx: 0 }
}
#[inline(always)]
pub fn next_filtered(&mut self, pos: usize) -> Option<&Decorator> {
if self.idx < self.decorators.len() && self.decorators[self.idx].0 == pos {
self.idx += 1;
Some(&self.decorators[self.idx - 1].1)
} else {
None
}
}
}
impl<'a> Iterator for DecoratorIterator<'a> {
type Item = &'a Decorator;
fn next(&mut self) -> Option<Self::Item> {
if self.idx < self.decorators.len() {
self.idx += 1;
Some(&self.decorators[self.idx - 1].1)
} else {
None
}
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum SignatureKind {
RpoFalcon512,
}
impl fmt::Display for SignatureKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::RpoFalcon512 => write!(f, "rpo_falcon512"),
}
}
}