Class: SyntaxTree::YARV::GetBlockParamProxy
- Inherits:
-
Instruction
- Object
- Instruction
- SyntaxTree::YARV::GetBlockParamProxy
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
‘getblockparamproxy` is almost the same as `getblockparam` except that it pushes a proxy object onto the stack instead of the actual value of the block local. This is used when a method is being called on the block local.
### Usage
~~~ruby def foo(&block)
block.call
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
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(index, level) ⇒ GetBlockParamProxy
constructor
A new instance of GetBlockParamProxy.
- #length ⇒ Object
- #pushes ⇒ Object
- #to_a(iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(index, level) ⇒ GetBlockParamProxy
Returns a new instance of GetBlockParamProxy.
1597 1598 1599 1600 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1597 def initialize(index, level) @index = index @level = level end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
1595 1596 1597 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1595 def index @index end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
1595 1596 1597 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1595 def level @level end |
Instance Method Details
#==(other) ⇒ Object
1619 1620 1621 1622 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1619 def ==(other) other.is_a?(GetBlockParamProxy) && other.index == index && other.level == level end |
#call(vm) ⇒ Object
1632 1633 1634 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1632 def call(vm) vm.push(vm.local_get(index, level)) end |
#deconstruct_keys(_keys) ⇒ Object
1615 1616 1617 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1615 def deconstruct_keys(_keys) { index: index, level: level } end |
#disasm(fmt) ⇒ Object
1602 1603 1604 1605 1606 1607 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1602 def disasm(fmt) fmt.instruction( "getblockparamproxy", [fmt.local(index, explicit: level)] ) end |
#length ⇒ Object
1624 1625 1626 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1624 def length 3 end |
#pushes ⇒ Object
1628 1629 1630 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1628 def pushes 1 end |
#to_a(iseq) ⇒ Object
1609 1610 1611 1612 1613 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1609 def to_a(iseq) current = iseq level.times { current = iseq.parent_iseq } [:getblockparamproxy, current.local_table.offset(index), level] end |