Class: SyntaxTree::YARV::GetGlobal
Overview
Summary
getglobal pushes the value of a global variables onto the stack.
Usage
$$
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(name) ⇒ GetGlobal
Returns a new instance of GetGlobal.
1720
1721
1722
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1720
def initialize(name)
@name = name
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
1718
1719
1720
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1718
def name
@name
end
|
Instance Method Details
#==(other) ⇒ Object
1736
1737
1738
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1736
def ==(other)
other.is_a?(GetGlobal) && other.name == name
end
|
#call(vm) ⇒ Object
1748
1749
1750
1751
1752
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1748
def call(vm)
vm.push(eval(name.to_s, binding, __FILE__, __LINE__))
end
|
#deconstruct_keys(_keys) ⇒ Object
1732
1733
1734
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1732
def deconstruct_keys(_keys)
{ name: name }
end
|
#disasm(fmt) ⇒ Object
1724
1725
1726
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1724
def disasm(fmt)
fmt.instruction("getglobal", [fmt.object(name)])
end
|
#length ⇒ Object
1740
1741
1742
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1740
def length
2
end
|
#pushes ⇒ Object
1744
1745
1746
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1744
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
1728
1729
1730
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1728
def to_a(_iseq)
[:getglobal, name]
end
|