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
- #call(vm) ⇒ Object
- #canonical ⇒ 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
5028 5029 5030 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5028 def initialize(key) @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5026 5027 5028 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5026 def key @key end |
Instance Method Details
#call(vm) ⇒ Object
5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5056 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
5052 5053 5054 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5052 def canonical self end |
#disasm(fmt) ⇒ Object
5032 5033 5034 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5032 def disasm(fmt) fmt.instruction("setspecial", [fmt.object(key)]) end |
#length ⇒ Object
5040 5041 5042 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5040 def length 2 end |
#pops ⇒ Object
5044 5045 5046 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5044 def pops 1 end |
#pushes ⇒ Object
5048 5049 5050 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5048 def pushes 0 end |
#to_a(_iseq) ⇒ Object
5036 5037 5038 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5036 def to_a(_iseq) [:setspecial, key] end |