Fix compilation
This commit is contained in:
24
src/bin.rs
24
src/bin.rs
@@ -9,6 +9,7 @@ use cranelift_object::{object, ObjectBuilder, ObjectModule};
|
||||
use ngr::asts::lil;
|
||||
use ngr::passes::{run_front_end, BackendError};
|
||||
use ngr::runtime::RuntimeFunctions;
|
||||
use pretty::Arena;
|
||||
use std::io;
|
||||
use target_lexicon::Triple;
|
||||
use thiserror::Error;
|
||||
@@ -74,8 +75,21 @@ fn main() -> Result<(), MainError> {
|
||||
}
|
||||
|
||||
if let Some((hil_tree, variable_map)) = hil_conversion_result.result {
|
||||
//let arena = Arena::new();
|
||||
let arena = Arena::new();
|
||||
println!("HIL Tree:");
|
||||
hil_tree
|
||||
.pretty(&variable_map, &arena)
|
||||
.into_doc()
|
||||
.render_colored(72, StandardStream::stdout(ColorChoice::Auto))
|
||||
.unwrap();
|
||||
|
||||
let lil_tree = lil::Program::convert(hil_tree, variable_map);
|
||||
println!("LIL Tree:");
|
||||
lil_tree
|
||||
.pretty(&arena)
|
||||
.into_doc()
|
||||
.render_colored(72, StandardStream::stdout(ColorChoice::Auto))
|
||||
.unwrap();
|
||||
|
||||
let isa = isa::lookup(Triple::host())?.finish(settings::Flags::new(settings::builder()))?;
|
||||
let object_builder = ObjectBuilder::new(isa, "example", default_libcall_names())?;
|
||||
@@ -84,17 +98,11 @@ fn main() -> Result<(), MainError> {
|
||||
|
||||
let _compiled = lil_tree.into_cranelift(&mut object_module, &rtfuns)?;
|
||||
|
||||
// something?
|
||||
// somethingvar?
|
||||
|
||||
let bytes = object_module.finish().emit()?;
|
||||
|
||||
std::fs::write("output.o", bytes)?;
|
||||
|
||||
// lil_tree
|
||||
// .pretty(&variable_map, &arena)
|
||||
// .into_doc()
|
||||
// .render_colored(72, StandardStream::stdout(ColorChoice::Auto))
|
||||
// .unwrap()
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -79,7 +79,7 @@ impl<Annotation: Clone> lil::Statement<Annotation> {
|
||||
lil::Statement::ResultBinding(
|
||||
annotation,
|
||||
var,
|
||||
lil::Primitive::Plus(arg0, arg1),
|
||||
lil::Primitive::Minus(arg0, arg1),
|
||||
)
|
||||
}
|
||||
hil::Primitive::Times => {
|
||||
@@ -88,7 +88,7 @@ impl<Annotation: Clone> lil::Statement<Annotation> {
|
||||
lil::Statement::ResultBinding(
|
||||
annotation,
|
||||
var,
|
||||
lil::Primitive::Plus(arg0, arg1),
|
||||
lil::Primitive::Times(arg0, arg1),
|
||||
)
|
||||
}
|
||||
hil::Primitive::Divide => {
|
||||
@@ -97,7 +97,7 @@ impl<Annotation: Clone> lil::Statement<Annotation> {
|
||||
lil::Statement::ResultBinding(
|
||||
annotation,
|
||||
var,
|
||||
lil::Primitive::Plus(arg0, arg1),
|
||||
lil::Primitive::Divide(arg0, arg1),
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user