Class: SyntaxTree::YARV::GetBlockParamProxy
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
def foo(&block)
block.call
end
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
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
Returns the value of attribute index.
1595
1596
1597
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1595
def index
@index
end
|
#level ⇒ Object
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
|