class SyntaxTree::YARV::BranchUnless
### Summary
‘branchunless` has one argument: the jump index. It pops one value off the stack: the jump condition.
If the value popped off the stack is false or nil, ‘branchunless` jumps to the jump index and continues executing there.
### Usage
~~~ruby if 2 + 3
puts "foo"
end ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 299 def initialize(label) @label = label end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 315 def ==(other) other.is_a?(BranchUnless) && other.label == label end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 331 def branch_targets [label] end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 327 def call(vm) vm.jump(label) unless vm.pop end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 311 def deconstruct_keys(_keys) { label: label } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 303 def disasm(fmt) fmt.instruction("branchunless", [fmt.label(label)]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 335 def falls_through? true end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 307 def to_a(_iseq) [:branchunless, label.name] end