pub mod context;
pub mod builder;
pub mod entities;
pub mod inst;
pub mod ir;
#[cfg(test)]
#[allow(dead_code)]
mod tests {
use super::{
context::Context,
inst,
builder::Builder,
entities::Type
};
pub fn test1() {
let mut context = Context::create();
let mut builder = Builder::new(&mut context);
builder
.create_function("main".to_string(), 0, Type::Int)
.assign("v0".to_string(), inst::iconst(5), Type::Int)
.assign("v1".to_string(), inst::iconst(6), Type::Int
)
.assign("v2".to_string(), inst::iadd(
inst::v("v0"),
inst::v("v1")
), Type::Int)
.assign("v2".to_string(), inst::iadd(
inst::v("v0"),
inst::v("v1")
), Type::Int
)
.assign("v3".to_string(), inst::iconst(2), Type::Int)
.assign(
"v4".to_string(),
inst::imul(
inst::v("v2"),
inst::v("v3")
),
Type::Int
)
.ret(inst::v("v4"))
.close_function("main");
let result = builder.finalize_program();
println!("{}", result);
}
}