Class: SyntaxTree::YARV::GetLocalWC1
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::GetLocalWC1
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
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
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(index) ⇒ GetLocalWC1
constructor
A new instance of GetLocalWC1.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(iseq) ⇒ Object
Constructor Details
#initialize(index) ⇒ GetLocalWC1
Returns a new instance of GetLocalWC1.
1821 1822 1823 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1821 def initialize(index) @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
1819 1820 1821 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1819 def index @index end |
Instance Method Details
#call(vm) ⇒ Object
1849 1850 1851 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1849 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
1845 1846 1847 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1845 def canonical GetLocal.new(index, 1) end |
#disasm(fmt) ⇒ Object
1825 1826 1827 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1825 def disasm(fmt) fmt.instruction("getlocal_WC_1", [fmt.local(index, implicit: 1)]) end |
#length ⇒ Object
1833 1834 1835 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1833 def length 2 end |
#pops ⇒ Object
1837 1838 1839 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1837 def pops 0 end |
#pushes ⇒ Object
1841 1842 1843 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1841 def pushes 1 end |
#to_a(iseq) ⇒ Object
1829 1830 1831 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1829 def to_a(iseq) [:getlocal_WC_1, iseq.parent_iseq.local_table.offset(index)] end |