class SyntaxTree::YARV::GetGlobal

### Summary

‘getglobal` pushes the value of a global variables onto the stack.

### Usage

~~~ruby $$ ~~~

Attributes

name[R]

Public Class Methods

new(name) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1720
def initialize(name)
  @name = name
end

Public Instance Methods

==(other) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1736
def ==(other)
  other.is_a?(GetGlobal) && other.name == name
end
call(vm) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1748
def call(vm)
  # Evaluating the name of the global variable because there isn't a
  # reflection API for global variables.
  vm.push(eval(name.to_s, binding, __FILE__, __LINE__))
end
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1732
def deconstruct_keys(_keys)
  { name: name }
end
disasm(fmt) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1724
def disasm(fmt)
  fmt.instruction("getglobal", [fmt.object(name)])
end
length() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1740
def length
  2
end
pushes() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1744
def pushes
  1
end
to_a(_iseq) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1728
def to_a(_iseq)
  [:getglobal, name]
end