class SyntaxTree::YARV::Throw


~~~
[1, 2, 3].map { break 2 }
~~~ruby
### Usage
on the result of throwing the value.
using the instruction sequence’s (or an ancestor’s) catch table. It pushes
`throw` pops a value off the top of the stack and throws it. It is caught
### Summary

def ==(other)

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

def call(vm)

def call(vm)
  state = type & VM_THROW_STATE_MASK
  value = vm.pop
  case state
  when RUBY_TAG_NONE
    case value
    when nil
      # do nothing
    when Exception
      raise value
    else
      raise NotImplementedError
    end
  when RUBY_TAG_RETURN
    raise VM::ReturnError.new(value, error_backtrace(vm))
  when RUBY_TAG_BREAK
    raise VM::BreakError.new(value, error_backtrace(vm))
  when RUBY_TAG_NEXT
    raise VM::NextError.new(value, error_backtrace(vm))
  else
    raise NotImplementedError, "Unknown throw kind #{state}"
  end
end

def deconstruct_keys(_keys)

def deconstruct_keys(_keys)
  { type: type }
end

def disasm(fmt)

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

def error_backtrace(vm)

def error_backtrace(vm)
  backtrace = []
  current = vm.frame
  while current
    backtrace << "#{current.iseq.file}:#{current.line}:in" \
      "`#{current.iseq.name}'"
    current = current.parent
  end
  [*backtrace, *caller]
end

def initialize(type)

def initialize(type)
  @type = type
end

def length

def length
  2
end

def pops

def pops
  1
end

def pushes

def pushes
  1
end

def to_a(_iseq)

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