use crate::{language::parsed::TreeType, BuildTarget};
#[derive(Default)]
pub struct Context {
module_has_configurable_block: bool,
destructured_struct_unique_suffix: usize,
destructured_tuple_unique_suffix: usize,
match_expression_return_var_unique_suffix: usize,
build_target: BuildTarget,
program_type: Option<TreeType>,
}
impl Context {
pub fn new(build_target: BuildTarget) -> Self {
Self {
build_target,
..Default::default()
}
}
pub fn set_module_has_configurable_block(&mut self, val: bool) {
self.module_has_configurable_block = val;
}
pub fn module_has_configurable_block(&self) -> bool {
self.module_has_configurable_block
}
pub fn next_destructured_struct_unique_suffix(&mut self) -> usize {
self.destructured_struct_unique_suffix += 1;
self.destructured_struct_unique_suffix
}
pub fn next_destructured_tuple_unique_suffix(&mut self) -> usize {
self.destructured_tuple_unique_suffix += 1;
self.destructured_tuple_unique_suffix
}
pub fn next_match_expression_return_var_unique_suffix(&mut self) -> usize {
self.match_expression_return_var_unique_suffix += 1;
self.match_expression_return_var_unique_suffix
}
pub fn build_target(&self) -> BuildTarget {
self.build_target
}
pub fn program_type(&self) -> Option<TreeType> {
self.program_type.clone()
}
pub fn set_program_type(&mut self, program_type: TreeType) {
self.program_type = Some(program_type);
}
}