class SyntaxTree::YARV::CheckMatch


~~~
foo in Foo
~~~ruby
### Usage
the stack if it matches or not.
pops the target and the pattern off the stack and pushes a boolean onto
`checkmatch` checks if the current pattern matches the current value. It
### Summary

def ==(other)

def ==(other)
  other.is_a?(CheckMatch) && other.type == type
end

def call(vm)

def call(vm)
  target, pattern = vm.pop(2)
  vm.push(
    if type & VM_CHECKMATCH_ARRAY > 0
      pattern.any? { |item| check?(item, target) }
    else
      check?(pattern, target)
    end
  )
end

def check?(pattern, target)

def check?(pattern, target)
  case type & VM_CHECKMATCH_TYPE_MASK
  when VM_CHECKMATCH_TYPE_WHEN
    pattern
  when VM_CHECKMATCH_TYPE_CASE
    pattern === target
  when VM_CHECKMATCH_TYPE_RESCUE
    unless pattern.is_a?(Module)
      raise TypeError, "class or module required for rescue clause"
    end
    pattern === target
  end
end

def deconstruct_keys(_keys)

def deconstruct_keys(_keys)
  { type: type }
end

def disasm(fmt)

def disasm(fmt)
  fmt.instruction("checkmatch", [fmt.object(type)])
end

def initialize(type)

def initialize(type)
  @type = type
end

def length

def length
  2
end

def pops

def pops
  2
end

def pushes

def pushes
  1
end

def to_a(_iseq)

def to_a(_iseq)
  [:checkmatch, type]
end