Impl dbgprint bytecode
This commit is contained in:
parent
5eae0712bf
commit
02f258415d
@ -31,6 +31,8 @@ pub enum OP {
|
|||||||
Value(u32),
|
Value(u32),
|
||||||
|
|
||||||
Print,
|
Print,
|
||||||
|
|
||||||
|
DbgPrint,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
@ -94,7 +96,10 @@ impl Compiler {
|
|||||||
self.overwrite_i64(idx_else, self.ops.len() as i64);
|
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) => {
|
Stmt::Print(expr) => {
|
||||||
self.compile_expr(expr);
|
self.compile_expr(expr);
|
||||||
self.ops.push(OP::Print);
|
self.ops.push(OP::Print);
|
||||||
|
|||||||
@ -58,6 +58,13 @@ impl Vm {
|
|||||||
.expect("Trying to pop value from stack for printing");
|
.expect("Trying to pop value from stack for printing");
|
||||||
print!("{}", val);
|
print!("{}", val);
|
||||||
}
|
}
|
||||||
|
OP::DbgPrint => {
|
||||||
|
let val = self
|
||||||
|
.stack
|
||||||
|
.pop()
|
||||||
|
.expect("Trying to pop value from stack for printing");
|
||||||
|
print!("{:?}", val);
|
||||||
|
}
|
||||||
|
|
||||||
OP::Add => {
|
OP::Add => {
|
||||||
let vals = self.pop2_i64();
|
let vals = self.pop2_i64();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user