Class: SyntaxTree::YARV::SetSpecial
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::SetSpecial
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
setspecial pops a value off the top of the stack and sets a special local variable to that value. The special local variable is determined by the key given as its only argument.
### Usage
~~~ruby baz if (foo == 1) .. (bar == 1) ~~~
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(key) ⇒ SetSpecial
constructor
A new instance of SetSpecial.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(key) ⇒ SetSpecial
Returns a new instance of SetSpecial.
5779 5780 5781 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5779 def initialize(key) @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5777 5778 5779 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5777 def key @key end |
Instance Method Details
#==(other) ⇒ Object
5795 5796 5797 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5795 def ==(other) other.is_a?(SetSpecial) && other.key == key end |
#call(vm) ⇒ Object
5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5815 def call(vm) case key when GetSpecial::SVAR_LASTLINE raise NotImplementedError, "setspecial SVAR_LASTLINE" when GetSpecial::SVAR_BACKREF raise NotImplementedError, "setspecial SVAR_BACKREF" when GetSpecial::SVAR_FLIPFLOP_START vm.frame_svar.svars[GetSpecial::SVAR_FLIPFLOP_START] end end |
#canonical ⇒ Object
5811 5812 5813 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5811 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
5791 5792 5793 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5791 def deconstruct_keys(_keys) { key: key } end |
#disasm(fmt) ⇒ Object
5783 5784 5785 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5783 def disasm(fmt) fmt.instruction("setspecial", [fmt.object(key)]) end |
#length ⇒ Object
5799 5800 5801 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5799 def length 2 end |
#pops ⇒ Object
5803 5804 5805 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5803 def pops 1 end |
#pushes ⇒ Object
5807 5808 5809 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5807 def pushes 0 end |
#to_a(_iseq) ⇒ Object
5787 5788 5789 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5787 def to_a(_iseq) [:setspecial, key] end |