Class: SyntaxTree::YARV::OptStrUMinus
- Inherits:
-
Instruction
- Object
- Instruction
- SyntaxTree::YARV::OptStrUMinus
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_str_uminus pushes a frozen known string value with no interpolation onto the stack. If the method gets overridden, this will fall back to a send.
### Usage
~~~ruby -“string” ~~~
Instance Attribute Summary collapse
-
#calldata ⇒ Object
readonly
Returns the value of attribute calldata.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(object, calldata) ⇒ OptStrUMinus
constructor
A new instance of OptStrUMinus.
- #length ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(object, calldata) ⇒ OptStrUMinus
Returns a new instance of OptStrUMinus.
4328 4329 4330 4331 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4328 def initialize(object, calldata) @object = object @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
4326 4327 4328 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4326 def calldata @calldata end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
4326 4327 4328 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4326 def object @object end |
Instance Method Details
#==(other) ⇒ Object
4348 4349 4350 4351 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4348 def ==(other) other.is_a?(OptStrUMinus) && other.object == object && other.calldata == calldata end |
#call(vm) ⇒ Object
4361 4362 4363 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4361 def call(vm) vm.push(-object) end |
#deconstruct_keys(_keys) ⇒ Object
4344 4345 4346 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4344 def deconstruct_keys(_keys) { object: object, calldata: calldata } end |
#disasm(fmt) ⇒ Object
4333 4334 4335 4336 4337 4338 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4333 def disasm(fmt) fmt.instruction( "opt_str_uminus", [fmt.object(object), fmt.calldata(calldata)] ) end |
#length ⇒ Object
4353 4354 4355 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4353 def length 3 end |
#pushes ⇒ Object
4357 4358 4359 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4357 def pushes 1 end |
#to_a(_iseq) ⇒ Object
4340 4341 4342 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4340 def to_a(_iseq) [:opt_str_uminus, object, calldata.to_h] end |