leo_compiler/
options.rs

1// Copyright (C) 2019-2024 Aleo Systems Inc.
2// This file is part of the Leo library.
3
4// The Leo library is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// The Leo library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
16
17// NOTE: If compiler passes are made optional, pass preconditions and invariants may not necessarily hold true.
18
19#[derive(Clone, Default)]
20pub struct CompilerOptions {
21    /// Build options.
22    pub build: BuildOptions,
23    /// Output options.
24    pub output: OutputOptions,
25}
26
27#[derive(Clone, Default)]
28pub struct BuildOptions {
29    /// Whether to enable dead code elimination.
30    pub dce_enabled: bool,
31    /// Max depth to type check nested conditionals.
32    pub conditional_block_max_depth: usize,
33    /// Whether to disable type checking for nested conditionals.
34    pub disable_conditional_branch_type_checking: bool,
35}
36
37#[derive(Clone, Default)]
38pub struct OutputOptions {
39    //// Whether spans are enabled in the output symbol tables.
40    pub symbol_table_spans_enabled: bool,
41    // If enabled writes the symbol table after symbol table pass
42    pub initial_symbol_table: bool,
43    /// If enabled writes the symbol table after type checking.
44    pub type_checked_symbol_table: bool,
45    /// If enabled writes the symbol table after loop unrolling.
46    pub unrolled_symbol_table: bool,
47    /// Whether spans are enabled in the output ASTs.
48    pub ast_spans_enabled: bool,
49    /// If enabled writes the AST after parsing.
50    pub initial_ast: bool,
51    /// If enabled writes the AST after loop unrolling.
52    pub unrolled_ast: bool,
53    /// If enabled writes the AST after static single assignment.
54    pub ssa_ast: bool,
55    /// If enabled writes the AST after flattening.
56    pub flattened_ast: bool,
57    /// If enabled writes the AST after destructuring.
58    pub destructured_ast: bool,
59    /// If enabled writes the AST after inlining.
60    pub inlined_ast: bool,
61    /// If enabled writes the AST after dead code elimination.
62    pub dce_ast: bool,
63}