use std::collections::HashMap; use inkwell::{builder::Builder, context::Context, module::Module, values::{FunctionValue, PointerValue}}; use crate::code_generation::Function; pub struct Compiler<'a, 'ctx> { pub context: &'ctx Context, pub builder: &'a Builder<'ctx>, pub module: &'a Module<'ctx>, pub function: &'a Function, variables: HashMap>, fn_value_opt: Option> } impl<'a, 'ctx> Compiler<'a, 'ctx> { /// Gets a defined function given its name. #[inline] fn get_function(&self, name: &str) -> Option> { self.module.get_function(name) } /// Returns the `FunctionValue` representing the function being compiled. #[inline] fn fn_value(&self) -> FunctionValue<'ctx> { self.fn_value_opt.unwrap() } }