Struct leo_compiler::Compiler
source · pub struct Compiler<'a> {
pub program_name: String,
pub network: String,
pub ast: Ast,
pub input_ast: Option<InputAst>,
/* private fields */
}Expand description
The primary entry point of the Leo compiler.
Fields§
§program_name: StringThe program name,
network: StringThe network name,
ast: AstThe AST for the program.
input_ast: Option<InputAst>The input ast for the program if it exists.
Implementations§
source§impl<'a> Compiler<'a>
impl<'a> Compiler<'a>
sourcepub fn new(
program_name: String,
network: String,
handler: &'a Handler,
main_file_path: PathBuf,
output_directory: PathBuf,
compiler_options: Option<CompilerOptions>
) -> Self
pub fn new( program_name: String, network: String, handler: &'a Handler, main_file_path: PathBuf, output_directory: PathBuf, compiler_options: Option<CompilerOptions> ) -> 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 parse_input(&mut self, input_file_path: PathBuf) -> Result<()>
pub fn parse_input(&mut self, input_file_path: PathBuf) -> Result<()>
Parses and stores the input file, constructs a syntax tree, and generates a program input.
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<Assigner>
pub fn static_single_assignment_pass( &mut self, symbol_table: &SymbolTable ) -> Result<Assigner>
Runs the static single assignment pass.
sourcepub fn flattening_pass(
&mut self,
symbol_table: &SymbolTable,
assigner: Assigner
) -> Result<Assigner>
pub fn flattening_pass( &mut self, symbol_table: &SymbolTable, assigner: Assigner ) -> Result<Assigner>
Runs the flattening pass.
sourcepub fn function_inlining_pass(
&mut self,
call_graph: &CallGraph,
assigner: Assigner
) -> Result<Assigner>
pub fn function_inlining_pass( &mut self, call_graph: &CallGraph, assigner: Assigner ) -> Result<Assigner>
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.
sourcepub fn compile(&mut self) -> Result<(SymbolTable, String)>
pub fn compile(&mut self) -> Result<(SymbolTable, String)>
Returns a compiled Leo program.