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.

Commit 87720ecb authored by qinsoon's avatar qinsoon
Browse files

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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment