From 2ebfb23b882195ce23080f0843f1f22aa75a64ae Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Wed, 3 May 2023 20:21:13 -0700 Subject: [PATCH] Add --disassemble flag Dumps disassembly of the given script to STDOUT and exits immediately. Signed-off-by: Alek Ratzloff --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index c44c6ae..9185e15 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,9 @@ use crate::vm::frame::{Frame, UserFrame}; struct Opt { #[structopt(name = "PATH", parse(from_os_str))] path: Option, + + #[structopt(long)] + disassemble: bool, } type Result> = std::result::Result; @@ -72,8 +75,11 @@ fn main() -> Result { exec_body.push(Inst::Push(ObjPtr::new(Int::new(0)))); exec_body.push(Inst::Return); - //disassemble(&exec_body); - //return Ok(()); + // Disassemble + if opt.disassemble { + disassemble(&exec_body); + return Ok(()); + } let locals: Vec<_> = scope.keys().copied().collect(); let main_fun: ObjPtr<_> = UserFun::new(None, vec![], locals, exec_body).into();