use crate::{
count_idents,
expression::Expression,
impl_for_all_tuples,
lower::{Instructions, LowerCtx},
};
pub trait LowerGroupBy {
fn lower_group_by(self, ctx: &mut LowerCtx);
}
impl<E> LowerGroupBy for E
where
E: Expression,
{
fn lower_group_by(self, ctx: &mut LowerCtx) {
self.lower(ctx);
}
}
macro_rules! impl_groupby_macro {
($($T:ident),+) => {
impl<$($T,)+> LowerGroupBy for ($($T,)+)
where
$($T: LowerGroupBy,)+
{
fn lower_group_by(self, ctx: &mut LowerCtx) {
#[allow(non_snake_case)]
let ($($T,)+) = self;
$(
$T.lower_group_by(ctx);
)+
let count = count_idents!($($T,)+);
ctx.instrs.push_seperated(count);
}
}
};
}
impl_for_all_tuples!(impl_groupby_macro);