~cdv/cuebee

03d1f35014e45bf42468a2220cafc627f85253af — Chris Vittal 7 months ago 2151e5a driver
Add initial testing/driver script
1 files changed, 55 insertions(+), 0 deletions(-)

A src/bin/cub/main.rs
A src/bin/cub/main.rs => src/bin/cub/main.rs +55 -0
@@ 0,0 1,55 @@
use std::io;

use cuebee::{
    ModuleContext,
    Type,
};

use Type::{Word, Long, Float, Double, Byte, Short};

fn main() {
    //    print!(
    //        r#"This is cub (pronouced `queue-bee') the frontend to the cuebee (pronouced
    //`queue-bee') library. An alternative implementation of the QBE compiler
    //backend (https://c9x.me/compile). It doesn't exist yet.
    //"#
    //    );
    let mb = ModuleContext::default();
    let m = mb.new_module("test");

    let op = m.opaque_type("opaque", 16, 64);
    let mut ty = m.new_type("regular");
    ty.add_subtype(Word);
    ty.add_subtype_array(Byte, 1024);
    let reg = m.add_type(ty);

    let mut ty = m.new_type("aligned");
    ty.align = Some(32);
    ty.add_subtype(op);
    ty.add_subtype(op);
    ty.add_subtype(reg);
    ty.add_subtype(Double);
    ty.add_subtype(Long);
    m.add_type(ty);

    let (dat, sym) = m.new_data("d");
    dat.zeros(1000);
    dat.symbol(Type::Double, sym, 500);
    m.add_data(dat);
    let (dat, _) = m.new_data("str");
    dat.string("The quick brown fox jumps over the lazy red dog.");
    dat.byte(0);
    m.add_data(dat);
    let (dat, _) = m.new_data("numbers");
    dat.long(30);
    dat.word(30);
    dat.word(-1);
    m.add_data(dat);
    let (dat, _) = m.new_data("fp");
    dat.float(-0.1);
    dat.double(std::f64::consts::PI);
    dat.float(std::f32::consts::E);
    m.add_data(dat);

    m.render(io::stdout()).unwrap();
}