about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/bytecode/opcode.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-10-21T09·00+0200
committertazjin <mail@tazj.in>2021-10-22T09·42+0000
commit670662a360447509940dac417195cf419d7f42c5 (patch)
treed602009e12bac63309f60e2a4e271317bb6b17b4 /users/tazjin/rlox/src/bytecode/opcode.rs
parentd57e43e1615ae28cfdc74c1c65cbe7863d782018 (diff)
feat(tazjin/rlox): Implement simple conditionals r/2986
... basically just optional blocks (no else).

Change-Id: If091c6b8fdeb6c13a5f3dd284d0a9a87f9f4228d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3739
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/opcode.rs')
-rw-r--r--users/tazjin/rlox/src/bytecode/opcode.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/users/tazjin/rlox/src/bytecode/opcode.rs b/users/tazjin/rlox/src/bytecode/opcode.rs
index 13e2f23939ed..accc6b3bac10 100644
--- a/users/tazjin/rlox/src/bytecode/opcode.rs
+++ b/users/tazjin/rlox/src/bytecode/opcode.rs
@@ -7,6 +7,9 @@ pub struct StackIdx(pub usize);
 #[derive(Clone, Copy, Debug)]
 pub struct CodeIdx(pub usize);
 
+#[derive(Clone, Copy, Debug)]
+pub struct CodeOffset(pub usize);
+
 #[derive(Debug)]
 pub enum OpCode {
     /// Push a constant onto the stack.
@@ -45,4 +48,8 @@ pub enum OpCode {
     OpSetGlobal(ConstantIdx),
     OpGetLocal(StackIdx),
     OpSetLocal(StackIdx),
+
+    // Control flow
+    OpJumpPlaceholder(bool),
+    OpJumpIfFalse(CodeOffset),
 }