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.
1544 1545 1546 1547 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1544 def initialize(index, level) @index = index @level = level end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
1542 1543 1544 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1542 def index @index end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
1542 1543 1544 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1542 def level @level end |
Instance Method Details
#==(other) ⇒ Object
1566 1567 1568 1569 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1566 def ==(other) other.is_a?(GetBlockParamProxy) && other.index == index && other.level == level end |
#call(vm) ⇒ Object
1579 1580 1581 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1579 def call(vm) vm.push(vm.local_get(index, level)) end |
#deconstruct_keys(_keys) ⇒ Object
1562 1563 1564 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1562 def deconstruct_keys(_keys) { index: index, level: level } end |
#disasm(fmt) ⇒ Object
1549 1550 1551 1552 1553 1554 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1549 def disasm(fmt) fmt.instruction( "getblockparamproxy", [fmt.local(index, explicit: level)] ) end |
#length ⇒ Object
1571 1572 1573 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1571 def length 3 end |
#pushes ⇒ Object
1575 1576 1577 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1575 def pushes 1 end |
#to_a(iseq) ⇒ Object
1556 1557 1558 1559 1560 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1556 def to_a(iseq) current = iseq level.times { current = iseq.parent_iseq } [:getblockparamproxy, current.local_table.offset(index), level] end |