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 processing_script;
78pub use processing_script::*;
79
80mod remove_unreachable;
81pub use remove_unreachable::*;
82
83mod static_single_assignment;
84pub use static_single_assignment::*;
85
86mod ssa_const_propagation;
87pub use ssa_const_propagation::*;
88
89mod storage_lowering;
90pub use storage_lowering::*;
91
92mod type_checking;
93pub use type_checking::*;
94
95mod name_validation;
96pub use name_validation::*;
97
98mod write_transforming;
99pub use write_transforming::*;
100
101/// The result of code generation for a Leo program.
102pub struct CompiledPrograms {
103    /// The generated Aleo bytecode for the primary program.
104    pub primary_bytecode: String,
105    /// Compiled bytecodes for imported programs.
106    pub import_bytecodes: Vec<Bytecode>,
107}
108
109/// Bytecode for a single program.
110pub struct Bytecode {
111    /// The name of the program.
112    pub program_name: String,
113    /// The generated Aleo bytecode.
114    pub bytecode: String,
115}
116
117#[cfg(test)]
118mod test_passes;