feat(tazjin/rlox): Implement simple arithmetic operators
Change-Id: I9873bcd281053f4e9820a5119f5992a0b8cb8cfc Reviewed-on: https://cl.tvl.fyi/c/depot/+/2417 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
parent
7fb93fb490
commit
d6d3c12efb
4 changed files with 34 additions and 1 deletions
|
@ -16,7 +16,12 @@ pub fn main() {
|
|||
|
||||
let constant = chunk.add_constant(1.2);
|
||||
chunk.add_op(OpCode::OpConstant(constant), 1);
|
||||
chunk.add_op(OpCode::OpReturn, 1);
|
||||
|
||||
let constant = chunk.add_constant(2.0);
|
||||
chunk.add_op(OpCode::OpConstant(constant), 2);
|
||||
|
||||
chunk.add_op(OpCode::OpAdd, 3);
|
||||
chunk.add_op(OpCode::OpReturn, 4);
|
||||
|
||||
vm::interpret(chunk).expect("it should work");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue