31 lines
693 B
Rust
31 lines
693 B
Rust
mod ijvm;
|
|
|
|
|
|
use ijvm::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;
|
|
}
|
|
}
|
|
}
|
|
} |