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