WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.6% of users enabled 2FA.

mod.rs 874 Bytes
Newer Older
1
use ast::ir::*;
qinsoon's avatar
qinsoon committed
2 3
use vm::context::VMContext;

4 5 6 7 8 9 10 11 12 13 14 15 16
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)}
    }
    
qinsoon's avatar
qinsoon committed
17
    pub fn compile(&self, vm: &VMContext, func: &mut MuFunction) {
18
        for pass in self.policy.borrow_mut().passes.iter_mut() {
qinsoon's avatar
qinsoon committed
19
            pass.execute(vm, func);
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
        }
    }
}

pub struct CompilerPolicy {
    passes: Vec<Box<CompilerPass>>
}

impl CompilerPolicy {
    pub fn default() -> CompilerPolicy {
        let mut passes : Vec<Box<CompilerPass>> = vec![];
        passes.push(Box::new(passes::tree_gen::TreeGenerationPass::new()));
        
        CompilerPolicy{passes: passes}
    }
}

pub trait CompilerPass {
qinsoon's avatar
qinsoon committed
38
    fn execute(&mut self, vm:&VMContext, func: &mut MuFunction);
39
}