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
- #call(vm) ⇒ Object
- #canonical ⇒ 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
4933 4934 4935 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4933 def initialize(index) @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
4931 4932 4933 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4931 def index @index end |
Instance Method Details
#call(vm) ⇒ Object
4961 4962 4963 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4961 def call(vm) canonical.call(vm) end |
#canonical ⇒ Object
4957 4958 4959 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4957 def canonical SetLocal.new(index, 1) end |
#disasm(fmt) ⇒ Object
4937 4938 4939 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4937 def disasm(fmt) fmt.instruction("setlocal_WC_1", [fmt.local(index, implicit: 1)]) end |
#length ⇒ Object
4945 4946 4947 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4945 def length 2 end |
#pops ⇒ Object
4949 4950 4951 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4949 def pops 1 end |
#pushes ⇒ Object
4953 4954 4955 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4953 def pushes 0 end |
#to_a(iseq) ⇒ Object
4941 4942 4943 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4941 def to_a(iseq) [:setlocal_WC_1, iseq.parent_iseq.local_table.offset(index)] end |