use crate::{CallGraph, StructGraph, SymbolTable, TypeTable};
use leo_ast::{Function, Program, ProgramId, Variant};
use leo_span::Symbol;
use indexmap::IndexMap;
pub struct CodeGenerator<'a> {
pub(crate) symbol_table: &'a SymbolTable,
pub(crate) type_table: &'a TypeTable,
pub(crate) struct_graph: &'a StructGraph,
pub(crate) _call_graph: &'a CallGraph,
pub(crate) next_register: u64,
pub(crate) current_function: Option<&'a Function>,
pub(crate) variable_mapping: IndexMap<&'a Symbol, String>,
pub(crate) composite_mapping: IndexMap<&'a Symbol, (bool, String)>,
pub(crate) global_mapping: IndexMap<&'a Symbol, String>,
pub(crate) variant: Option<Variant>,
pub(crate) program: &'a Program,
pub(crate) program_id: Option<ProgramId>,
pub(crate) finalize_caller: Option<Symbol>,
pub(crate) next_label: u64,
pub(crate) conditional_depth: u64,
}
impl<'a> CodeGenerator<'a> {
pub fn new(
symbol_table: &'a SymbolTable,
type_table: &'a TypeTable,
struct_graph: &'a StructGraph,
_call_graph: &'a CallGraph,
program: &'a Program,
) -> Self {
Self {
symbol_table,
type_table,
struct_graph,
_call_graph,
next_register: 0,
current_function: None,
variable_mapping: IndexMap::new(),
composite_mapping: IndexMap::new(),
global_mapping: IndexMap::new(),
variant: None,
program,
program_id: None,
finalize_caller: None,
next_label: 0u64,
conditional_depth: 0u64,
}
}
}