Commit 87720ecb authored by qinsoon's avatar qinsoon

some structs for implementing compiler passes

parent 4ae9559a
use ast::ir::*;
use std::cell::RefCell;
pub mod passes;
pub struct Compiler {
policy: RefCell<CompilerPolicy>
impl Compiler {
pub fn new(policy: CompilerPolicy) -> Compiler {
Compiler{policy: RefCell::new(policy)}
pub fn compile(&self, func: &mut MuFunction) {
for pass in self.policy.borrow_mut().passes.iter_mut() {
pub struct CompilerPolicy {
passes: Vec<Box<CompilerPass>>
impl CompilerPolicy {
pub fn default() -> CompilerPolicy {
let mut passes : Vec<Box<CompilerPass>> = vec![];
CompilerPolicy{passes: passes}
pub trait CompilerPass {
fn execute(&mut self, func: &mut MuFunction);
pub mod tree_gen;
\ No newline at end of file
use ast::ir::*;
use compiler::CompilerPass;
pub struct TreeGenerationPass;
impl TreeGenerationPass {
pub fn new() -> TreeGenerationPass {
impl CompilerPass for TreeGenerationPass {
fn execute(&mut self, func: &mut MuFunction) {
\ No newline at end of file
extern crate mu;
mod tests {
mod test_types {
use mu::ast::ptr::*;
use mu::ast::types::*;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment