Class: SyntaxTree::YARV::GetLocalWC0
Overview
### Summary
getlocal_WC_0 is a specialized version of the getlocal instruction. It fetches the value of a local variable from the current frame determined by the index given as its only argument.
### Usage
~~~ruby value = 5 value ~~~
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
1825
1826
1827
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1825
def initialize(index)
@index = index
end
|
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
1823
1824
1825
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1823
def index
@index
end
|
Instance Method Details
#==(other) ⇒ Object
1841
1842
1843
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1841
def ==(other)
other.is_a?(GetLocalWC0) && other.index == index
end
|
#call(vm) ⇒ Object
1857
1858
1859
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1857
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
1853
1854
1855
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1853
def canonical
GetLocal.new(index, 0)
end
|
#deconstruct_keys(_keys) ⇒ Object
1837
1838
1839
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1837
def deconstruct_keys(_keys)
{ index: index }
end
|
#disasm(fmt) ⇒ Object
1829
1830
1831
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1829
def disasm(fmt)
fmt.instruction("getlocal_WC_0", [fmt.local(index, implicit: 0)])
end
|
#length ⇒ Object
1845
1846
1847
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1845
def length
2
end
|
#pushes ⇒ Object
1849
1850
1851
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1849
def pushes
1
end
|
#to_a(iseq) ⇒ Object
1833
1834
1835
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1833
def to_a(iseq)
[:getlocal_WC_0, iseq.local_table.offset(index)]
end
|