1use super::vars::NamingConvention;
2
3#[derive(Clone, Debug)]
5pub struct PicusParams {
6 expr_cutoff: Option<usize>,
7 entrypoint: Option<String>,
8 naming_convention: NamingConvention,
9 optimize: bool,
10 inline: bool,
11}
12
13impl PicusParams {
14 pub fn naming_convention(&self) -> NamingConvention {
16 self.naming_convention
17 }
18
19 pub fn optimize(&self) -> bool {
21 self.optimize
22 }
23
24 pub fn expr_cutoff(&self) -> Option<usize> {
26 self.expr_cutoff
27 }
28
29 pub fn entrypoint(&self) -> &str {
31 self.entrypoint.as_deref().unwrap_or("Main")
32 }
33
34 fn new() -> Self {
35 Self {
36 expr_cutoff: None,
37 entrypoint: None,
38 naming_convention: NamingConvention::Short,
39 optimize: true,
40 inline: false,
41 }
42 }
43
44 pub fn inline(&self) -> bool {
46 self.inline
47 }
48}
49
50impl Default for PicusParams {
51 fn default() -> Self {
52 Self::new()
53 }
54}
55
56#[derive(Debug, Default)]
58pub struct PicusParamsBuilder(PicusParams);
59
60impl PicusParamsBuilder {
61 pub fn new() -> Self {
63 Self(PicusParams::new())
64 }
65
66 pub fn expr_cutoff(&mut self, expr_cutoff: usize) -> &mut Self {
68 self.0.expr_cutoff = Some(expr_cutoff);
69 self
70 }
71
72 pub fn no_expr_cutoff(&mut self) -> &mut Self {
74 self.0.expr_cutoff = None;
75 self
76 }
77
78 pub fn entrypoint(&mut self, name: &str) -> &mut Self {
80 self.0.entrypoint = Some(name.to_owned());
81 self
82 }
83
84 pub fn short_names(&mut self) -> &mut Self {
86 self.0.naming_convention = NamingConvention::Short;
87 self
88 }
89
90 pub fn optimize(&mut self) -> &mut Self {
92 self.0.optimize = true;
93 self
94 }
95
96 pub fn no_optimize(&mut self) -> &mut Self {
98 self.0.optimize = false;
99 self
100 }
101
102 pub fn inline(&mut self) -> &mut Self {
104 self.0.inline = true;
105 self
106 }
107
108 pub fn no_inline(&mut self) -> &mut Self {
110 self.0.inline = false;
111 self
112 }
113
114 pub fn build(&mut self) -> PicusParams {
116 std::mem::take(&mut self.0)
117 }
118}
119
120impl From<PicusParamsBuilder> for PicusParams {
121 fn from(builder: PicusParamsBuilder) -> PicusParams {
122 builder.0
123 }
124}