pub struct Compiler<'a, N: Network> {
pub program_name: String,
pub ast: Ast,
pub statements_before_dce: u32,
pub statements_after_dce: u32,
/* private fields */
}
Expand description
The primary entry point of the Leo compiler.
Fields§
§program_name: String
The program name,
ast: Ast
The AST for the program.
statements_before_dce: u32
How many statements were in the AST before DCE?
statements_after_dce: u32
How many statements were in the AST after DCE?
Implementations§
Source§impl<'a, N: Network> Compiler<'a, N>
impl<'a, N: Network> Compiler<'a, N>
pub fn parse(&mut self, source: &str, filename: FileName) -> Result<()>
pub fn parse_from_file( &mut self, source_file_path: impl AsRef<Path>, ) -> Result<()>
Sourcepub fn new(
handler: &'a Handler,
output_directory: PathBuf,
compiler_options: Option<CompilerOptions>,
import_stubs: IndexMap<Symbol, Stub>,
) -> Self
pub fn new( handler: &'a Handler, output_directory: PathBuf, compiler_options: Option<CompilerOptions>, import_stubs: IndexMap<Symbol, Stub>, ) -> Self
Returns a new Leo compiler.
Sourcepub fn symbol_table_pass(&self) -> Result<SymbolTable>
pub fn symbol_table_pass(&self) -> Result<SymbolTable>
Runs the symbol table pass.
Sourcepub fn type_checker_pass(
&'a self,
symbol_table: &mut SymbolTable,
) -> Result<(StructGraph, CallGraph)>
pub fn type_checker_pass( &'a self, symbol_table: &mut SymbolTable, ) -> Result<(StructGraph, CallGraph)>
Runs the type checker pass.
Sourcepub fn static_analysis_pass(&mut self, symbol_table: &SymbolTable) -> Result<()>
pub fn static_analysis_pass(&mut self, symbol_table: &SymbolTable) -> Result<()>
Runs the static analysis pass.
Sourcepub fn const_propagation_and_unroll_loop(
&mut self,
symbol_table: &mut SymbolTable,
) -> Result<()>
pub fn const_propagation_and_unroll_loop( &mut self, symbol_table: &mut SymbolTable, ) -> Result<()>
Run const propagation and loop unrolling until we hit a fixed point or find an error.
Sourcepub fn const_propagation_pass(
&mut self,
symbol_table: &mut SymbolTable,
) -> Result<ConstPropagatorOutput>
pub fn const_propagation_pass( &mut self, symbol_table: &mut SymbolTable, ) -> Result<ConstPropagatorOutput>
Runs the const propagation pass.
Sourcepub fn loop_unrolling_pass(
&mut self,
symbol_table: &mut SymbolTable,
) -> Result<UnrollerOutput>
pub fn loop_unrolling_pass( &mut self, symbol_table: &mut SymbolTable, ) -> Result<UnrollerOutput>
Runs the loop unrolling pass.
Sourcepub fn static_single_assignment_pass(
&mut self,
symbol_table: &SymbolTable,
) -> Result<()>
pub fn static_single_assignment_pass( &mut self, symbol_table: &SymbolTable, ) -> Result<()>
Runs the static single assignment pass.
Sourcepub fn flattening_pass(&mut self, symbol_table: &SymbolTable) -> Result<()>
pub fn flattening_pass(&mut self, symbol_table: &SymbolTable) -> Result<()>
Runs the flattening pass.
Sourcepub fn destructuring_pass(&mut self) -> Result<()>
pub fn destructuring_pass(&mut self) -> Result<()>
Runs the destructuring pass.
Sourcepub fn function_inlining_pass(&mut self, call_graph: &CallGraph) -> Result<()>
pub fn function_inlining_pass(&mut self, call_graph: &CallGraph) -> Result<()>
Runs the function inlining pass.
Sourcepub fn dead_code_elimination_pass(&mut self) -> Result<()>
pub fn dead_code_elimination_pass(&mut self) -> Result<()>
Runs the dead code elimination pass.
Sourcepub fn code_generation_pass(
&mut self,
symbol_table: &SymbolTable,
struct_graph: &StructGraph,
call_graph: &CallGraph,
) -> Result<String>
pub fn code_generation_pass( &mut self, symbol_table: &SymbolTable, struct_graph: &StructGraph, call_graph: &CallGraph, ) -> Result<String>
Runs the code generation pass.
Sourcepub fn intermediate_passes(
&mut self,
) -> Result<(SymbolTable, StructGraph, CallGraph)>
pub fn intermediate_passes( &mut self, ) -> Result<(SymbolTable, StructGraph, CallGraph)>
Runs the compiler stages.
Sourcepub fn compile(&mut self, source: &str, filename: FileName) -> Result<String>
pub fn compile(&mut self, source: &str, filename: FileName) -> Result<String>
Returns a compiled Leo program.
pub fn compile_from_file( &mut self, source_file_path: impl AsRef<Path>, ) -> Result<String>
Sourcepub fn add_import_stubs(&mut self) -> Result<()>
pub fn add_import_stubs(&mut self) -> Result<()>
Merges the dependencies defined in program.json
with the dependencies imported in .leo
file
Trait Implementations§
Auto Trait Implementations§
impl<'a, N> !Freeze for Compiler<'a, N>
impl<'a, N> !RefUnwindSafe for Compiler<'a, N>
impl<'a, N> !Send for Compiler<'a, N>
impl<'a, N> !Sync for Compiler<'a, N>
impl<'a, N> Unpin for Compiler<'a, N>where
N: Unpin,
impl<'a, N> !UnwindSafe for Compiler<'a, N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more