Struct leo_compiler::compiler::Compiler
source · pub struct Compiler<'a, N: Network> {
handler: &'a Handler,
main_file_path: PathBuf,
output_directory: PathBuf,
pub program_name: String,
pub network: String,
pub ast: Ast,
compiler_options: CompilerOptions,
node_builder: NodeBuilder,
assigner: Assigner,
type_table: TypeTable,
import_stubs: IndexMap<Symbol, Stub>,
phantom: PhantomData<N>,
}
Expand description
The primary entry point of the Leo compiler.
Fields§
§handler: &'a Handler
The handler is used for error and warning emissions.
main_file_path: PathBuf
The path to the main leo file.
output_directory: PathBuf
The path to where the compiler outputs all generated files.
program_name: String
The program name,
network: String
The network name,
ast: Ast
The AST for the program.
compiler_options: CompilerOptions
Options configuring compilation.
node_builder: NodeBuilder
The NodeCounter
used to generate sequentially increasing NodeID
s.
assigner: Assigner
The Assigner
is used to construct (unique) assignment statements.
type_table: TypeTable
The type table.
import_stubs: IndexMap<Symbol, Stub>
The stubs for imported programs. Produced by Retriever
module.
phantom: PhantomData<N>
Implementations§
source§impl<'a, N: Network> Compiler<'a, N>
impl<'a, N: Network> Compiler<'a, N>
sourcepub fn new(
program_name: String,
network: String,
handler: &'a Handler,
main_file_path: PathBuf,
output_directory: PathBuf,
compiler_options: Option<CompilerOptions>,
import_stubs: IndexMap<Symbol, Stub>,
) -> Self
pub fn new( program_name: String, network: String, handler: &'a Handler, main_file_path: PathBuf, output_directory: PathBuf, compiler_options: Option<CompilerOptions>, import_stubs: IndexMap<Symbol, Stub>, ) -> Self
Returns a new Leo compiler.
sourcepub fn parse_program_from_string(
&mut self,
program_string: &str,
name: FileName,
) -> Result<()>
pub fn parse_program_from_string( &mut self, program_string: &str, name: FileName, ) -> Result<()>
Parses and stores a program file content from a string, constructs a syntax tree, and generates a program.
sourcepub fn parse_program(&mut self) -> Result<()>
pub fn parse_program(&mut self) -> Result<()>
Parses and stores the main program file, constructs a syntax tree, and generates a program.
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: SymbolTable,
) -> Result<(SymbolTable, StructGraph, CallGraph)>
pub fn type_checker_pass( &'a self, symbol_table: SymbolTable, ) -> Result<(SymbolTable, StructGraph, CallGraph)>
Runs the type checker pass.
sourcepub fn loop_unrolling_pass(
&mut self,
symbol_table: SymbolTable,
) -> Result<SymbolTable>
pub fn loop_unrolling_pass( &mut self, symbol_table: SymbolTable, ) -> Result<SymbolTable>
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 compiler_stages(
&mut self,
) -> Result<(SymbolTable, StructGraph, CallGraph)>
pub fn compiler_stages( &mut self, ) -> Result<(SymbolTable, StructGraph, CallGraph)>
Runs the compiler stages.
sourcefn write_ast_to_json(&self, file_suffix: &str) -> Result<()>
fn write_ast_to_json(&self, file_suffix: &str) -> Result<()>
Writes the AST to a JSON file.
sourcefn write_symbol_table_to_json(
&self,
file_suffix: &str,
symbol_table: &SymbolTable,
) -> Result<()>
fn write_symbol_table_to_json( &self, file_suffix: &str, symbol_table: &SymbolTable, ) -> Result<()>
Writes the Symbol Table to a JSON file.
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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