use super::structural::BracketType;
use crate::{
classification::{quotes::QuoteClassifiedIterator, ResumeClassifierState},
input::{error::InputError, InputBlockIterator},
FallibleIterator, MaskType, BLOCK_SIZE,
};
pub trait DepthBlock<'a>: Sized {
fn add_depth(&mut self, depth: isize);
fn get_depth(&self) -> isize;
fn estimate_lowest_possible_depth(&self) -> isize;
fn depth_at_end(&self) -> isize;
fn advance_to_next_depth_decrease(&mut self) -> bool;
}
pub trait DepthIterator<'i, I, Q, M, const N: usize>: FallibleIterator<Item = Self::Block, Error = InputError>
where
I: InputBlockIterator<'i, N>,
{
type Block: DepthBlock<'i>;
fn resume(state: ResumeClassifierState<'i, I, Q, M, N>, opening: BracketType) -> (Option<Self::Block>, Self);
fn stop(self, block: Option<Self::Block>) -> ResumeClassifierState<'i, I, Q, M, N>;
}
pub struct DepthIteratorResumeOutcome<'i, I, Q, D, M, const N: usize>(pub Option<D::Block>, pub D)
where
I: InputBlockIterator<'i, N>,
D: DepthIterator<'i, I, Q, M, N>;
pub(crate) mod nosimd;
pub(crate) mod shared;
#[cfg(target_arch = "x86")]
pub(crate) mod avx2_32;
#[cfg(target_arch = "x86_64")]
pub(crate) mod avx2_64;
#[cfg(target_arch = "x86_64")]
pub(crate) mod avx512_64;
#[cfg(target_arch = "aarch64")]
pub(crate) mod neon_64;
#[cfg(target_arch = "x86")]
pub(crate) mod sse2_32;
#[cfg(target_arch = "x86_64")]
pub(crate) mod sse2_64;
pub(crate) trait DepthImpl {
type Classifier<'i, I, Q>: DepthIterator<'i, I, Q, MaskType, BLOCK_SIZE>
where
I: InputBlockIterator<'i, BLOCK_SIZE>,
Q: QuoteClassifiedIterator<'i, I, MaskType, BLOCK_SIZE>;
fn resume<'i, I, Q>(
state: ResumeClassifierState<'i, I, Q, MaskType, BLOCK_SIZE>,
opening: BracketType,
) -> DepthIteratorResumeOutcome<'i, I, Q, Self::Classifier<'i, I, Q>, MaskType, BLOCK_SIZE>
where
I: InputBlockIterator<'i, BLOCK_SIZE>,
Q: QuoteClassifiedIterator<'i, I, MaskType, BLOCK_SIZE>,
{
let (first_block, iter) =
<Self::Classifier<'i, I, Q> as DepthIterator<'i, I, Q, MaskType, BLOCK_SIZE>>::resume(state, opening);
DepthIteratorResumeOutcome(first_block, iter)
}
}