class SyntaxTree::YARV::OptCaseDispatch
~~~
end
puts “bar”
else
puts “foo”
when 1
case 1
~~~ruby
### Usage
`opt_case_dispatch` jumps to the ‘else_label` index.
there is one. If there is no value in the `case_dispatch_hash`,
key in the `case_dispatch_hash` and jumps to the corresponding label if
pops one value off the stack: a hash key. `opt_case_dispatch` looks up the
It has two arguments: the `case_dispatch_hash` and an `else_label`. It
keys for an internal hash.
for case statements that have clauses where they can all be used as hash
`opt_case_dispatch` is a branch instruction that moves the control flow
### Summary
def ==(other)
def ==(other) other.is_a?(OptCaseDispatch) && other.case_dispatch_hash == case_dispatch_hash && other.else_label == else_label end
def branch_targets
def branch_targets case_dispatch_hash.values.push(else_label) end
def call(vm)
def call(vm) vm.jump(case_dispatch_hash.fetch(vm.pop, else_label)) end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { case_dispatch_hash: case_dispatch_hash, else_label: else_label } end
def disasm(fmt)
def disasm(fmt) fmt.instruction( "opt_case_dispatch", ["<cdhash>", fmt.label(else_label)] ) end
def falls_through?
def falls_through? true end
def initialize(case_dispatch_hash, else_label)
def initialize(case_dispatch_hash, else_label) @case_dispatch_hash = case_dispatch_hash @else_label = else_label end
def length
def length 3 end
def pops
def pops 1 end
def to_a(_iseq)
def to_a(_iseq) [ :opt_case_dispatch, case_dispatch_hash.flat_map { |key, value| [key, value.name] }, else_label.name ] end