Class: SyntaxTree::YARV::SetBlockParam
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
def foo(&bar)
bar = baz
end
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pushes, #side_effects?
Constructor Details
#initialize(index, level) ⇒ SetBlockParam
Returns a new instance of SetBlockParam.
5055
5056
5057
5058
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5055
def initialize(index, level)
@index = index
@level = level
end
|
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
5053
5054
5055
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5053
def index
@index
end
|
#level ⇒ Object
Returns the value of attribute level.
5053
5054
5055
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5053
def level
@level
end
|
Instance Method Details
#==(other) ⇒ Object
5074
5075
5076
5077
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5074
def ==(other)
other.is_a?(SetBlockParam) && other.index == index &&
other.level == level
end
|
#call(vm) ⇒ Object
5087
5088
5089
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5087
def call(vm)
vm.local_set(index, level, vm.pop)
end
|
#deconstruct_keys(_keys) ⇒ Object
5070
5071
5072
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5070
def deconstruct_keys(_keys)
{ index: index, level: level }
end
|
#disasm(fmt) ⇒ Object
5060
5061
5062
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5060
def disasm(fmt)
fmt.instruction("setblockparam", [fmt.local(index, explicit: level)])
end
|
#length ⇒ Object
5079
5080
5081
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5079
def length
3
end
|
#pops ⇒ Object
5083
5084
5085
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5083
def pops
1
end
|
#to_a(iseq) ⇒ Object
5064
5065
5066
5067
5068
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5064
def to_a(iseq)
current = iseq
level.times { current = current.parent_iseq }
[:setblockparam, current.local_table.offset(index), level]
end
|