Add --disassemble flag
Dumps disassembly of the given script to STDOUT and exits immediately. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -16,6 +16,9 @@ use crate::vm::frame::{Frame, UserFrame};
|
|||||||
struct Opt {
|
struct Opt {
|
||||||
#[structopt(name = "PATH", parse(from_os_str))]
|
#[structopt(name = "PATH", parse(from_os_str))]
|
||||||
path: Option<PathBuf>,
|
path: Option<PathBuf>,
|
||||||
|
|
||||||
|
#[structopt(long)]
|
||||||
|
disassemble: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
type Result<T = (), E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
|
type Result<T = (), E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
|
||||||
@@ -72,8 +75,11 @@ fn main() -> Result {
|
|||||||
exec_body.push(Inst::Push(ObjPtr::new(Int::new(0))));
|
exec_body.push(Inst::Push(ObjPtr::new(Int::new(0))));
|
||||||
exec_body.push(Inst::Return);
|
exec_body.push(Inst::Return);
|
||||||
|
|
||||||
//disassemble(&exec_body);
|
// Disassemble
|
||||||
//return Ok(());
|
if opt.disassemble {
|
||||||
|
disassemble(&exec_body);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let locals: Vec<_> = scope.keys().copied().collect();
|
let locals: Vec<_> = scope.keys().copied().collect();
|
||||||
let main_fun: ObjPtr<_> = UserFun::new(None, vec![], locals, exec_body).into();
|
let main_fun: ObjPtr<_> = UserFun::new(None, vec![], locals, exec_body).into();
|
||||||
|
|||||||
Reference in New Issue
Block a user