Skip to main content

leo_passes/
lib.rs

1// Copyright (C) 2019-2026 Provable 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#![forbid(unsafe_code)]
18#![doc = include_str!("../README.md")]
19
20mod static_analysis;
21pub use static_analysis::*;
22
23mod code_generation;
24pub use code_generation::*;
25
26mod common;
27pub use common::*;
28
29mod common_subexpression_elimination;
30pub use common_subexpression_elimination::*;
31
32mod const_propagation;
33pub use const_propagation::*;
34
35mod const_prop_unroll_and_morphing;
36pub use const_prop_unroll_and_morphing::*;
37
38mod dead_code_elimination;
39pub use dead_code_elimination::*;
40
41mod destructuring;
42pub use destructuring::*;
43
44mod disambiguate;
45pub use disambiguate::*;
46
47mod flattening;
48pub use flattening::*;
49
50mod function_inlining;
51pub use function_inlining::*;
52
53mod global_items_collection;
54pub use global_items_collection::*;
55
56mod global_vars_collection;
57pub use global_vars_collection::*;
58
59mod loop_unrolling;
60pub use loop_unrolling::*;
61
62mod monomorphization;
63pub use monomorphization::*;
64
65mod option_lowering;
66pub use option_lowering::*;
67
68mod path_resolution;
69pub use path_resolution::*;
70
71mod pass;
72pub use pass::*;
73
74mod processing_async;
75pub use processing_async::*;
76
77mod remove_unreachable;
78pub use remove_unreachable::*;
79
80mod static_single_assignment;
81pub use static_single_assignment::*;
82
83mod ssa_const_propagation;
84pub use ssa_const_propagation::*;
85
86mod storage_lowering;
87pub use storage_lowering::*;
88
89mod type_checking;
90pub use type_checking::*;
91
92mod name_validation;
93pub use name_validation::*;
94
95mod check_interfaces;
96pub use check_interfaces::*;
97
98mod write_transforming;
99pub use write_transforming::*;
100
101/// The result of code generation for a Leo program.
102#[derive(Default)]
103pub struct CompiledPrograms {
104    /// The generated Aleo bytecode for the primary program.
105    pub primary_bytecode: String,
106    /// Compiled bytecodes for imported programs.
107    pub import_bytecodes: Vec<Bytecode>,
108}
109
110/// Bytecode for a single program.
111#[derive(Default)]
112pub struct Bytecode {
113    /// The name of the program.
114    pub program_name: String,
115    /// The generated Aleo bytecode.
116    pub bytecode: String,
117}
118
119#[cfg(test)]
120mod test_passes;