Skip to main content

offlineasm_backend/
config.rs

1#[derive(Clone, Debug)]
2pub struct Config {
3    pub preferred_comment_start_column: usize,
4    pub preferred_debug_annotation_columns: usize,
5    pub enable_label_count_comments: bool,
6    pub enable_code_origin_comments: bool,
7    pub enable_instr_annotations: bool,
8    pub enable_debug_annotations: bool,
9    pub platform: Option<String>,
10    pub binary_format: Option<String>,
11    pub emit_elf_debug_directives: bool,
12}
13
14impl Default for Config {
15    fn default() -> Self {
16        Self {
17            preferred_comment_start_column: 40,
18            preferred_debug_annotation_columns: 18,
19            enable_label_count_comments: false,
20            enable_code_origin_comments: true,
21            enable_instr_annotations: false,
22            enable_debug_annotations: false,
23            platform: None,
24            binary_format: None,
25            emit_elf_debug_directives: false,
26        }
27    }
28}
29
30impl Config {
31    pub fn is_win(&self) -> bool {
32        self.platform.as_deref() == Some("Windows")
33    }
34
35    pub fn with_binary_format(mut self, format: Option<String>) -> Self {
36        self.emit_elf_debug_directives = format.as_deref() == Some("ELF");
37        self.binary_format = format;
38        self
39    }
40}