Class: SyntaxTree::YARV::SetLocalWC0
Overview
### Summary
‘setlocal_WC_0` is a specialized version of the `setlocal` instruction. It sets the value of a local variable on the current frame to the value at the top of the stack as determined by the index given as its only argument.
### Usage
~~~ruby value = 5 ~~~
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #falls_through?, #leaves?, #pushes, #side_effects?
Constructor Details
Returns a new instance of SetLocalWC0.
5225
5226
5227
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5225
def initialize(index)
@index = index
end
|
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
5223
5224
5225
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5223
def index
@index
end
|
Instance Method Details
#==(other) ⇒ Object
5241
5242
5243
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5241
def ==(other)
other.is_a?(SetLocalWC0) && other.index == index
end
|
#call(vm) ⇒ Object
5257
5258
5259
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5257
def call(vm)
canonical.call(vm)
end
|
#canonical ⇒ Object
5253
5254
5255
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5253
def canonical
SetLocal.new(index, 0)
end
|
#deconstruct_keys(_keys) ⇒ Object
5237
5238
5239
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5237
def deconstruct_keys(_keys)
{ index: index }
end
|
#disasm(fmt) ⇒ Object
5229
5230
5231
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5229
def disasm(fmt)
fmt.instruction("setlocal_WC_0", [fmt.local(index, implicit: 0)])
end
|
#length ⇒ Object
5245
5246
5247
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5245
def length
2
end
|
#pops ⇒ Object
5249
5250
5251
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5249
def pops
1
end
|
#to_a(iseq) ⇒ Object
5233
5234
5235
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 5233
def to_a(iseq)
[:setlocal_WC_0, iseq.local_table.offset(index)]
end
|