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
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ 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
2048 2049 2050 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2048 def initialize(index) @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
2046 2047 2048 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2046 def index @index end |
Instance Method Details
#==(other) ⇒ Object
2064 2065 2066 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2064 def ==(other) other.is_a?(GetLocalWC1) && other.index == index end |
#call(vm) ⇒ Object
2084 2085 2086 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2084 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
2080 2081 2082 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2080 def canonical GetLocal.new(index, 1) end |
#deconstruct_keys(_keys) ⇒ Object
2060 2061 2062 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2060 def deconstruct_keys(_keys) { index: index } end |
#disasm(fmt) ⇒ Object
2052 2053 2054 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2052 def disasm(fmt) fmt.instruction("getlocal_WC_1", [fmt.local(index, implicit: 1)]) end |
#length ⇒ Object
2068 2069 2070 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2068 def length 2 end |
#pops ⇒ Object
2072 2073 2074 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2072 def pops 0 end |
#pushes ⇒ Object
2076 2077 2078 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2076 def pushes 1 end |
#to_a(iseq) ⇒ Object
2056 2057 2058 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2056 def to_a(iseq) [:getlocal_WC_1, iseq.parent_iseq.local_table.offset(index)] end |