Class: SyntaxTree::YARV::SetSpecial
- Inherits:
-
Instruction
- Object
- Instruction
- 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
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(key) ⇒ SetSpecial
constructor
A new instance of SetSpecial.
- #length ⇒ Object
- #pops ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pushes, #side_effects?
Constructor Details
#initialize(key) ⇒ SetSpecial
Returns a new instance of SetSpecial.
5381 5382 5383 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5381 def initialize(key) @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5379 5380 5381 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5379 def key @key end |
Instance Method Details
#==(other) ⇒ Object
5397 5398 5399 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5397 def ==(other) other.is_a?(SetSpecial) && other.key == key end |
#call(vm) ⇒ Object
5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5409 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 |
#deconstruct_keys(_keys) ⇒ Object
5393 5394 5395 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5393 def deconstruct_keys(_keys) { key: key } end |
#disasm(fmt) ⇒ Object
5385 5386 5387 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5385 def disasm(fmt) fmt.instruction("setspecial", [fmt.object(key)]) end |
#length ⇒ Object
5401 5402 5403 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5401 def length 2 end |
#pops ⇒ Object
5405 5406 5407 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5405 def pops 1 end |
#to_a(_iseq) ⇒ Object
5389 5390 5391 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 5389 def to_a(_iseq) [:setspecial, key] end |