📝 doc: make it obvious that LWVM only handles bytecode for now

main
_ 2023-09-27 14:12:29 -05:00
parent af49dc68be
commit d9bba9fc07
2 changed files with 13 additions and 4 deletions

View File

@ -4,7 +4,7 @@ LunarWaveVM is a Lua 5.4 virtual machine written in Rust.
LunarWaveVM relies on the PUC-Rio implementation of `luac` to compile bytecode.
`cargo run -- --script test_vectors/fizz_buzz.lua`
`luac5.4 -o - test_vectors/fizz_buzz.lua | cargo run -- --pipe-bytecode`
```
1

View File

@ -11,24 +11,33 @@ mod tests;
fn main () {
use state::State;
let mut script = String::from ("test_vectors/hello.lua");
let mut pipe_bytecode = false;
let mut script = None;
let mut args = std::env::args ();
let exe_name = args.next ().unwrap ();
while let Some (arg) = args.next () {
match arg.as_str () {
"--script" => script = args.next ().unwrap (),
"--pipe-bytecode" => pipe_bytecode = true,
"--script" => script = Some (args.next ().unwrap ()),
"--" => break,
_ => panic! ("can't parse args"),
}
}
let lua_file = {
let lua_file = if let Some (script) = script {
let source = std::fs::read (script).expect ("couldn't load Lua source code");
let bytecode = loader::compile_bytecode(source);
let mut rdr = std::io::Cursor::new (bytecode);
loader::parse_chunk (&mut rdr).unwrap ()
}
else if pipe_bytecode {
let mut stdin = std::io::stdin ().lock ();
loader::parse_chunk (&mut stdin).unwrap ()
}
else {
unimplemented!();
};
let mut vm = State::default ();