1use rtlola_parser::ParserConfig;
4
5#[derive(Debug)]
10pub struct FrontendConfig<'a> {
11 parser_config: &'a ParserConfig,
12 memory_bound_mode: MemoryBoundMode,
13}
14
15#[derive(Default, Clone, Copy, Debug, PartialEq, Eq)]
16pub enum MemoryBoundMode {
18 #[default]
19 Static,
22 Dynamic,
25}
26
27impl<'a> From<&'a ParserConfig> for FrontendConfig<'a> {
28 fn from(parser_config: &'a ParserConfig) -> Self {
29 Self {
30 parser_config,
31 memory_bound_mode: MemoryBoundMode::default(),
32 }
33 }
34}
35
36pub trait ParserConfigExt<'a> {
38 fn with_memory_bound_mode(&'a self, memory_bound_mode: MemoryBoundMode) -> FrontendConfig<'a>;
40
41 fn parser_config(&self) -> &ParserConfig;
43}
44
45impl<'a> ParserConfigExt<'a> for ParserConfig {
46 fn with_memory_bound_mode(&'a self, memory_bound_mode: MemoryBoundMode) -> FrontendConfig<'a> {
47 FrontendConfig::from(self).with_memory_bound_mode(memory_bound_mode)
48 }
49
50 fn parser_config(&self) -> &ParserConfig {
51 self
52 }
53}
54
55impl<'a> FrontendConfig<'a> {
56 fn with_memory_bound_mode(self, memory_bound_mode: MemoryBoundMode) -> FrontendConfig<'a> {
57 Self {
58 memory_bound_mode,
59 ..self
60 }
61 }
62
63 pub fn parser_config(&self) -> &ParserConfig {
65 self.parser_config
66 }
67}
68
69impl FrontendConfig<'_> {
70 pub(crate) fn memory_bound_mode(&self) -> MemoryBoundMode {
71 self.memory_bound_mode
72 }
73}