[rlox] Dedop tracing

This commit is contained in:
ctsk
2023-03-30 20:17:00 +02:00
parent acc95c36e9
commit 278bcf5a54
2 changed files with 85 additions and 38 deletions

View File

@@ -2,8 +2,13 @@ mod vm;
fn main() {
let mut chunk = vm::Chunk::new("TEST".to_string());
chunk.add_op(vm::Op::Return, 1);
chunk.add_op(vm::Op::Constant { offset: 0 }, 1);
chunk.add_constant(vm::Value::from(3.14));
chunk.add_op(vm::Op::Constant { offset: 0 }, 1);
chunk.add_op(vm::Op::Negate, 1);
chunk.add_op(vm::Op::Return, 1);
println!("{:?}", chunk);
let mut interpreter = vm::VM::new();
interpreter.trace = true;
interpreter.interpret(&chunk).unwrap()
}