2023-09-26 21:47:51 +00:00
|
|
|
mod instruction;
|
2023-09-25 01:40:28 +00:00
|
|
|
mod loader;
|
2023-09-24 22:40:45 +00:00
|
|
|
mod state;
|
2023-09-26 19:41:10 +00:00
|
|
|
mod value;
|
2023-09-24 21:34:28 +00:00
|
|
|
|
2023-09-24 22:40:45 +00:00
|
|
|
#[cfg (test)]
|
|
|
|
mod tests;
|
2023-09-24 21:34:28 +00:00
|
|
|
|
2023-09-26 18:33:59 +00:00
|
|
|
fn main () {
|
2023-09-25 03:14:08 +00:00
|
|
|
use state::State;
|
2023-09-24 22:40:45 +00:00
|
|
|
|
2023-09-25 03:14:08 +00:00
|
|
|
let lua_file = {
|
2023-09-26 18:33:59 +00:00
|
|
|
let source = std::fs::read ("test_vectors/hello.lua").expect ("couldn't load Lua source code");
|
|
|
|
let bytecode = loader::compile_bytecode(source);
|
|
|
|
let mut rdr = std::io::Cursor::new (bytecode);
|
2023-09-25 03:14:08 +00:00
|
|
|
loader::parse_chunk (&mut rdr).unwrap ()
|
2023-09-24 21:16:10 +00:00
|
|
|
};
|
|
|
|
|
2023-09-24 22:40:45 +00:00
|
|
|
let mut vm = State::default ();
|
2023-09-25 00:47:17 +00:00
|
|
|
if std::env::var("LUA_DEBUG").is_ok() {
|
|
|
|
vm.debug_print = true;
|
|
|
|
}
|
|
|
|
|
2023-09-24 22:40:45 +00:00
|
|
|
let upvalues = State::upvalues_from_args (std::env::args ());
|
2023-09-25 05:23:53 +00:00
|
|
|
|
|
|
|
vm.breakpoints.push (state::Breakpoint {
|
2023-09-26 17:04:17 +00:00
|
|
|
block_idx: 3,
|
|
|
|
program_counter: 0,
|
2023-09-25 05:23:53 +00:00
|
|
|
});
|
|
|
|
|
2023-09-26 18:46:01 +00:00
|
|
|
vm.execute_chunk (&lua_file, &upvalues);
|
2023-09-24 21:57:12 +00:00
|
|
|
}
|