diff options
author | Vincent Ambo <mail@tazj.in> | 2021-01-17T21·08+0300 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2021-01-17T21·17+0000 |
commit | d6d3c12efbcec61b3d868bc7d3f861fdb91835a5 (patch) | |
tree | feabb720b4412f15ee798d095d3705ea8b3dd193 /users/tazjin/rlox/src/bytecode/mod.rs | |
parent | 7fb93fb49008491184a7d55ccd43db846452dce0 (diff) |
feat(tazjin/rlox): Implement simple arithmetic operators r/2128
Change-Id: I9873bcd281053f4e9820a5119f5992a0b8cb8cfc Reviewed-on: https://cl.tvl.fyi/c/depot/+/2417 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/mod.rs')
-rw-r--r-- | users/tazjin/rlox/src/bytecode/mod.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/users/tazjin/rlox/src/bytecode/mod.rs b/users/tazjin/rlox/src/bytecode/mod.rs index de04d7b06f4d..2d83c4272239 100644 --- a/users/tazjin/rlox/src/bytecode/mod.rs +++ b/users/tazjin/rlox/src/bytecode/mod.rs @@ -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"); } |