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
Returns a new instance of GetLocalWC0.
1883
1884
1885
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1883
def initialize(index)
@index = index
end
|
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
1881
1882
1883
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1881
def index
@index
end
|
Instance Method Details
#==(other) ⇒ Object
1899
1900
1901
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1899
def ==(other)
other.is_a?(GetLocalWC0) && other.index == index
end
|
#call(vm) ⇒ Object
1915
1916
1917
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1915
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
1911
1912
1913
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1911
def canonical
GetLocal.new(index, 0)
end
|
#deconstruct_keys(_keys) ⇒ Object
1895
1896
1897
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1895
def deconstruct_keys(_keys)
{ index: index }
end
|
#disasm(fmt) ⇒ Object
1887
1888
1889
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1887
def disasm(fmt)
fmt.instruction("getlocal_WC_0", [fmt.local(index, implicit: 0)])
end
|
#length ⇒ Object
1903
1904
1905
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1903
def length
2
end
|
#pushes ⇒ Object
1907
1908
1909
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1907
def pushes
1
end
|
#to_a(iseq) ⇒ Object
1891
1892
1893
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1891
def to_a(iseq)
[:getlocal_WC_0, iseq.local_table.offset(index)]
end
|