mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-18 14:31:31 +03:00
some compiler lib cleanup
This commit is contained in:
parent
5129276a4b
commit
3c7de6e389
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1355,6 +1355,7 @@ dependencies = [
|
||||
name = "leo-test-framework"
|
||||
version = "1.5.3"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"leo-errors",
|
||||
"regex",
|
||||
"serde",
|
||||
|
@ -147,23 +147,24 @@ impl<'a> Compiler<'a> {
|
||||
///
|
||||
/// Runs the type checker pass.
|
||||
///
|
||||
pub fn type_checker_pass(&'a self, symbol_table: &'a mut SymbolTable<'a>) -> Result<()> {
|
||||
TypeChecker::do_pass((&self.ast, symbol_table, self.handler))
|
||||
pub fn type_checker_pass(&'a self, symbol_table: &mut SymbolTable<'_>) -> Result<()> {
|
||||
TypeChecker::do_pass((&self.ast, &mut symbol_table.clone(), self.handler))
|
||||
}
|
||||
|
||||
///
|
||||
/// Runs the compiler stages.
|
||||
///
|
||||
fn compiler_stages(&self) -> Result<SymbolTable<'_>> {
|
||||
let symbol_table = self.symbol_table_pass()?;
|
||||
self.type_checker_pass(&mut symbol_table.clone())?;
|
||||
Ok(symbol_table)
|
||||
pub fn compiler_stages(&self) -> Result<SymbolTable<'_>> {
|
||||
let mut st = self.symbol_table_pass()?;
|
||||
self.type_checker_pass(&mut st)?;
|
||||
Ok(st)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a compiled Leo program.
|
||||
///
|
||||
pub fn compile(&self) -> Result<SymbolTable<'_>> {
|
||||
pub fn compile(&mut self) -> Result<SymbolTable<'_>> {
|
||||
self.parse_program()?;
|
||||
self.compiler_stages()
|
||||
}
|
||||
}
|
||||
|
@ -132,8 +132,10 @@ fn collect_all_inputs(test: &Test) -> Result<Vec<PathBuf>, String> {
|
||||
Ok(list)
|
||||
}
|
||||
|
||||
fn compile_and_process<'a>(parsed: &'a mut Compiler<'a>) -> Result<SymbolTable<'a>, LeoError> {
|
||||
parsed.compile()
|
||||
fn compile_and_process<'a>(parsed: &'a mut Compiler<'a>) -> Result<SymbolTable<'_>, LeoError> {
|
||||
let mut st = parsed.symbol_table_pass()?;
|
||||
parsed.type_checker_pass(&mut st)?;
|
||||
Ok(st)
|
||||
}
|
||||
|
||||
// Errors used in this module.
|
||||
@ -203,7 +205,7 @@ fn run_test(test: Test, handler: &Handler, err_buf: &BufferEmitter) -> Result<Va
|
||||
for input in inputs {
|
||||
let mut parsed = parsed.clone();
|
||||
handler.extend_if_error(parsed.parse_input(input))?;
|
||||
let initial_input_ast = hash_file("/tmp/output/inital_input_ast.json");
|
||||
let initial_input_ast = hash_file("/tmp/output/initial_input_ast.json");
|
||||
|
||||
output_items.push(OutputItem { initial_input_ast });
|
||||
}
|
||||
|
@ -181,7 +181,6 @@ impl Command for Build {
|
||||
output_directory,
|
||||
Some(self.compiler_options.into()),
|
||||
);
|
||||
program.parse_program()?;
|
||||
program.parse_input(input_path.to_path_buf())?;
|
||||
|
||||
// Compute the current program checksum
|
||||
|
Loading…
Reference in New Issue
Block a user