You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.1 KiB
Rust

use ledstrip_vm::runtime::Runtime;
use std::fs::read;
use std::io;
use std::time::Instant;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
struct Opts {
#[structopt(long)]
debug: bool,
#[structopt(short = "i", name = "input")]
input_file: String,
#[structopt(short = "a", name = "address")]
ip: String,
#[structopt(short = "p", name = "port")]
port: usize,
}
fn main() -> io::Result<()> {
let opts: Opts = Opts::from_args();
let bytecode = read(opts.input_file)?;
let mut runtime = Runtime::new(&opts.ip, opts.port);
let start = Instant::now();
runtime.set_debug(opts.debug);
runtime.parse_bytecode(bytecode);
println!("Parsing took {:?}\n", start.elapsed());
let start = Instant::now();
match runtime.run() {
Ok(code) => println!(
"Runtime exited with code {} after {:?}",
code,
start.elapsed()
),
Err(e) => println!(
"Runtime exited with error {:?} after {:?}",
e,
start.elapsed()
),
}
Ok(())
}