Load asm from commandline

This commit is contained in:
shylie 2025-03-09 05:49:44 -04:00
parent e15a2e2aaf
commit 8bdd8a47f6

View File

@ -1,5 +1,7 @@
mod vm;
use std::{env, fs};
use std::io::{stderr, Write};
use std::sync::Arc;
use vm::FootVM;
@ -111,16 +113,25 @@ impl ApplicationHandler for App
}
}
const ASM_SRC: &'static str = include_str!("../examples/first.asm");
fn main()
{
let args: Vec<String> = env::args().collect();
if args.len() < 2
{
_ = stderr().write("No filename supplied".as_bytes())
}
else
{
let src = fs::read_to_string(&args[1])
.expect("Unable to read file");
let mut vm = FootVM::new();
vm.load(ASM_SRC, Some(&mut std::io::stderr())).expect("");
vm.load(src.as_str(), Some(&mut std::io::stderr())).expect("");
let event_loop = EventLoop::new().unwrap();
event_loop.set_control_flow(ControlFlow::Poll);
let mut app = App::new(vm);
event_loop.run_app(&mut app).expect("");
}
}