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
- #call(vm) ⇒ Object
- #canonical ⇒ 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
4570 4571 4572 4573 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4570 def initialize(index, level) @index = index @level = level end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
4568 4569 4570 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4568 def index @index end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
4568 4569 4570 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4568 def level @level end |
Instance Method Details
#call(vm) ⇒ Object
4601 4602 4603 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4601 def call(vm) vm.local_set(index, level, vm.pop) end |
#canonical ⇒ Object
4597 4598 4599 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4597 def canonical self end |
#disasm(fmt) ⇒ Object
4575 4576 4577 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4575 def disasm(fmt) fmt.instruction("setblockparam", [fmt.local(index, explicit: level)]) end |
#length ⇒ Object
4585 4586 4587 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4585 def length 3 end |
#pops ⇒ Object
4589 4590 4591 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4589 def pops 1 end |
#pushes ⇒ Object
4593 4594 4595 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4593 def pushes 0 end |
#to_a(iseq) ⇒ Object
4579 4580 4581 4582 4583 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4579 def to_a(iseq) current = iseq level.times { current = current.parent_iseq } [:setblockparam, current.local_table.offset(index), level] end |