1extern crate mruby_compiler2_sys;
2use mruby_compiler2_sys::MRubyCompiler2Context;
3
4fn main() -> Result<(), Box<dyn std::error::Error>> {
5 unsafe {
6 let mut cxt = MRubyCompiler2Context::new();
7 cxt.dump_bytecode("puts \"Hello, mruby-compiler2!\"")?;
8
9 let bin = cxt.compile("puts \"Hello, mruby-compiler2!\"")?;
10
11 let out = std::fs::File::create("examples/out.mrb")?;
12 std::io::Write::write_all(&mut &out, &bin)?;
13
14 println!("Compiled bytecode file: examples/out.mrb, size: {}", bin.len());
15 }
16 Ok(())
17}