Impl dbgprint bytecode

This commit is contained in:
Daniel M 2022-01-31 23:50:52 +01:00
parent 5eae0712bf
commit 02f258415d
2 changed files with 13 additions and 1 deletions

View File

@ -31,6 +31,8 @@ pub enum OP {
Value(u32),
Print,
DbgPrint,
}
#[derive(Debug, Default)]
@ -94,7 +96,10 @@ impl Compiler {
self.overwrite_i64(idx_else, self.ops.len() as i64);
},
Stmt::DbgPrint(_) => todo!(),
Stmt::DbgPrint(expr) => {
self.compile_expr(expr);
self.ops.push(OP::DbgPrint);
}
Stmt::Print(expr) => {
self.compile_expr(expr);
self.ops.push(OP::Print);

View File

@ -58,6 +58,13 @@ impl Vm {
.expect("Trying to pop value from stack for printing");
print!("{}", val);
}
OP::DbgPrint => {
let val = self
.stack
.pop()
.expect("Trying to pop value from stack for printing");
print!("{:?}", val);
}
OP::Add => {
let vals = self.pop2_i64();