Class: SyntaxTree::YARV::GetLocalWC1
Overview
### Summary
getlocal_WC_1 is a specialized version of the getlocal instruction. It fetches the value of a local variable from the parent frame determined by the index given as its only argument.
### Usage
~~~ruby value = 5 self.then { 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 GetLocalWC1.
1878
1879
1880
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1878
def initialize(index)
@index = index
end
|
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
1876
1877
1878
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1876
def index
@index
end
|
Instance Method Details
#==(other) ⇒ Object
1894
1895
1896
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1894
def ==(other)
other.is_a?(GetLocalWC1) && other.index == index
end
|
#call(vm) ⇒ Object
1910
1911
1912
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1910
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
1906
1907
1908
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1906
def canonical
GetLocal.new(index, 1)
end
|
#deconstruct_keys(_keys) ⇒ Object
1890
1891
1892
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1890
def deconstruct_keys(_keys)
{ index: index }
end
|
#disasm(fmt) ⇒ Object
1882
1883
1884
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1882
def disasm(fmt)
fmt.instruction("getlocal_WC_1", [fmt.local(index, implicit: 1)])
end
|
#length ⇒ Object
1898
1899
1900
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1898
def length
2
end
|
#pushes ⇒ Object
1902
1903
1904
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1902
def pushes
1
end
|
#to_a(iseq) ⇒ Object
1886
1887
1888
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1886
def to_a(iseq)
[:getlocal_WC_1, iseq.parent_iseq.local_table.offset(index)]
end
|