feat(tazjin/rlox): Implement simple conditionals
... 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>
This commit is contained in:
parent
d57e43e161
commit
670662a360
4 changed files with 84 additions and 16 deletions
|
|
@ -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),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue