class SyntaxTree::YARV::BranchIf
### Summary
‘branchif` has one argument: the jump index. It pops one value off the stack: the jump condition.
If the value popped off the stack is true, ‘branchif` jumps to the jump index and continues executing there.
### Usage
~~~ruby x = true x ||= “foo” puts x ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 178 def initialize(label) @label = label end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 194 def ==(other) other.is_a?(BranchIf) && other.label == label end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 210 def branch_targets [label] end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 206 def call(vm) vm.jump(label) if vm.pop end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 190 def deconstruct_keys(_keys) { label: label } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 182 def disasm(fmt) fmt.instruction("branchif", [fmt.label(label)]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 214 def falls_through? true end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 186 def to_a(_iseq) [:branchif, label.name] end