use crate::{Allocator, BlockArgument, Context, Operation};
use alloc::collections::LinkedList;
#[derive(Debug)]
pub struct Block<'a> {
arguments: Vec<BlockArgument<'a>, Allocator<'a>>,
operations: LinkedList<Operation<'a>, Allocator<'a>>,
}
impl<'a> Block<'a> {
pub fn new<const N: usize>(context: &'a Context, arguments: [BlockArgument<'a>; N]) -> Self {
Self {
arguments: {
let mut vec = Vec::new_in(context.allocator());
vec.extend(arguments);
vec
},
operations: LinkedList::new_in(context.allocator()),
}
}
pub fn arguments(&self) -> &[BlockArgument<'a>] {
&self.arguments
}
pub const fn operations(&self) -> &LinkedList<Operation<'a>, Allocator<'a>> {
&self.operations
}
pub fn operations_mut(&mut self) -> &mut LinkedList<Operation<'a>, Allocator<'a>> {
&mut self.operations
}
}