Class: SyntaxTree::YARV::SetLocalWC1
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::SetLocalWC1
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
setlocal_WC_1 is a specialized version of the setlocal instruction. It sets the value of a local variable on the parent frame to the value at the top of the stack as determined by the index given as its only argument.
### Usage
~~~ruby value = 5 self.then { value = 10 } ~~~
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(index) ⇒ SetLocalWC1
constructor
A new instance of SetLocalWC1.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(iseq) ⇒ Object
Constructor Details
#initialize(index) ⇒ SetLocalWC1
Returns a new instance of SetLocalWC1.
5668 5669 5670 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5668 def initialize(index) @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
5666 5667 5668 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5666 def index @index end |
Instance Method Details
#==(other) ⇒ Object
5684 5685 5686 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5684 def ==(other) other.is_a?(SetLocalWC1) && other.index == index end |
#call(vm) ⇒ Object
5704 5705 5706 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5704 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
5700 5701 5702 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5700 def canonical SetLocal.new(index, 1) end |
#deconstruct_keys(_keys) ⇒ Object
5680 5681 5682 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5680 def deconstruct_keys(_keys) { index: index } end |
#disasm(fmt) ⇒ Object
5672 5673 5674 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5672 def disasm(fmt) fmt.instruction("setlocal_WC_1", [fmt.local(index, implicit: 1)]) end |
#length ⇒ Object
5688 5689 5690 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5688 def length 2 end |
#pops ⇒ Object
5692 5693 5694 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5692 def pops 1 end |
#pushes ⇒ Object
5696 5697 5698 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5696 def pushes 0 end |
#to_a(iseq) ⇒ Object
5676 5677 5678 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5676 def to_a(iseq) [:setlocal_WC_1, iseq.parent_iseq.local_table.offset(index)] end |