Restructure to library / binary combo
This commit is contained in:
30
src/bin/ijvm.rs
Normal file
30
src/bin/ijvm.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
extern crate rustijvm;
|
||||
|
||||
use rustijvm::machine::Machine;
|
||||
use std::env;
|
||||
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
if args.len() < 2 {
|
||||
println!("Usage: {} ijvmfile", args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
let ijvmfile = &args[1];
|
||||
|
||||
let mut machine = Machine::new_from_file(ijvmfile).unwrap();
|
||||
while machine.has_step() {
|
||||
match machine.step() {
|
||||
Ok(_) => (),
|
||||
Err(str) => {
|
||||
println!("\n\nERROR: pc=0x{:x} fp=0x{:x}: {}\nProgram exit",
|
||||
machine.get_program_counter(),
|
||||
machine.frame.len() - 1,
|
||||
str);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user