class SyntaxTree::YARV::GetConstant


~~~
Constant
~~~ruby
### Usage
whether or not it should look globally as well.
constant onto the stack. It pops both the class it should look in and
`getconstant` performs a constant lookup and pushes the value of the
### Summary

def ==(other)

def ==(other)
  other.is_a?(GetConstant) && other.name == name
end

def call(vm)

def call(vm)
  const_base, allow_nil = vm.pop(2)
  if const_base
    if const_base.const_defined?(name)
      vm.push(const_base.const_get(name))
      return
    end
  elsif const_base.nil? && allow_nil
    vm.frame.nesting.reverse_each do |clazz|
      if clazz.const_defined?(name)
        vm.push(clazz.const_get(name))
        return
      end
    end
  end
  raise NameError, "uninitialized constant #{name}"
end

def deconstruct_keys(_keys)

def deconstruct_keys(_keys)
  { name: name }
end

def disasm(fmt)

def disasm(fmt)
  fmt.instruction("getconstant", [fmt.object(name)])
end

def initialize(name)

def initialize(name)
  @name = name
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)
  [:getconstant, name]
end