Class: SyntaxTree::YARV::OptStrUMinus
- Inherits:
-
Object
- Object
- 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
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(object, calldata) ⇒ OptStrUMinus
constructor
A new instance of OptStrUMinus.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(object, calldata) ⇒ OptStrUMinus
4618 4619 4620 4621 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4618 def initialize(object, calldata) @object = object @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
4616 4617 4618 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4616 def calldata @calldata end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
4616 4617 4618 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4616 def object @object end |
Instance Method Details
#==(other) ⇒ Object
4638 4639 4640 4641 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4638 def ==(other) other.is_a?(OptStrUMinus) && other.object == object && other.calldata == calldata end |
#call(vm) ⇒ Object
4659 4660 4661 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4659 def call(vm) vm.push(-object) end |
#canonical ⇒ Object
4655 4656 4657 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4655 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
4634 4635 4636 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4634 def deconstruct_keys(_keys) { object: object, calldata: calldata } end |
#disasm(fmt) ⇒ Object
4623 4624 4625 4626 4627 4628 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4623 def disasm(fmt) fmt.instruction( "opt_str_uminus", [fmt.object(object), fmt.calldata(calldata)] ) end |
#length ⇒ Object
4643 4644 4645 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4643 def length 3 end |
#pops ⇒ Object
4647 4648 4649 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4647 def pops 0 end |
#pushes ⇒ Object
4651 4652 4653 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4651 def pushes 1 end |
#to_a(_iseq) ⇒ Object
4630 4631 4632 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4630 def to_a(_iseq) [:opt_str_uminus, object, calldata.to_h] end |