Class: SyntaxTree::YARV::SetBlockParam
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::SetBlockParam
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
setblockparam sets the value of a block local variable on a frame determined by the level and index arguments. The level is the number of frames back to look and the index is the index in the local table. It pops the value it is setting off the stack.
### Usage
~~~ruby def foo(&bar)
= baz
end ~~~
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(index, level) ⇒ SetBlockParam
constructor
A new instance of SetBlockParam.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(iseq) ⇒ Object
Constructor Details
#initialize(index, level) ⇒ SetBlockParam
Returns a new instance of SetBlockParam.
5246 5247 5248 5249 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5246 def initialize(index, level) @index = index @level = level end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
5244 5245 5246 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5244 def index @index end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
5244 5245 5246 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5244 def level @level end |
Instance Method Details
#==(other) ⇒ Object
5265 5266 5267 5268 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5265 def ==(other) other.is_a?(SetBlockParam) && other.index == index && other.level == level end |
#call(vm) ⇒ Object
5286 5287 5288 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5286 def call(vm) vm.local_set(index, level, vm.pop) end |
#canonical ⇒ Object
5282 5283 5284 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5282 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
5261 5262 5263 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5261 def deconstruct_keys(_keys) { index: index, level: level } end |
#disasm(fmt) ⇒ Object
5251 5252 5253 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5251 def disasm(fmt) fmt.instruction("setblockparam", [fmt.local(index, explicit: level)]) end |
#length ⇒ Object
5270 5271 5272 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5270 def length 3 end |
#pops ⇒ Object
5274 5275 5276 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5274 def pops 1 end |
#pushes ⇒ Object
5278 5279 5280 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5278 def pushes 0 end |
#to_a(iseq) ⇒ Object
5255 5256 5257 5258 5259 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5255 def to_a(iseq) current = iseq level.times { current = current.parent_iseq } [:setblockparam, current.local_table.offset(index), level] end |