Class: SyntaxTree::YARV::ObjToString
- Inherits:
-
Instruction
- Object
- Instruction
- SyntaxTree::YARV::ObjToString
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
‘objtostring` pops a value from the stack, calls `to_s` on that value and then pushes the result back to the stack.
It has various fast paths for classes like String, Symbol, Module, Class, etc. For everything else it calls ‘to_s`.
### Usage
~~~ruby “#5” ~~~
Instance Attribute Summary collapse
-
#calldata ⇒ Object
readonly
Returns the value of attribute calldata.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(calldata) ⇒ ObjToString
constructor
A new instance of ObjToString.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #side_effects?
Constructor Details
#initialize(calldata) ⇒ ObjToString
Returns a new instance of ObjToString.
2618 2619 2620 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2618 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2616 2617 2618 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2616 def calldata @calldata end |
Instance Method Details
#==(other) ⇒ Object
2634 2635 2636 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2634 def ==(other) other.is_a?(ObjToString) && other.calldata == calldata end |
#call(vm) ⇒ Object
2650 2651 2652 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2650 def call(vm) vm.push(vm.pop.to_s) end |
#deconstruct_keys(_keys) ⇒ Object
2630 2631 2632 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2630 def deconstruct_keys(_keys) { calldata: calldata } end |
#disasm(fmt) ⇒ Object
2622 2623 2624 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2622 def disasm(fmt) fmt.instruction("objtostring", [fmt.calldata(calldata)]) end |
#length ⇒ Object
2638 2639 2640 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2638 def length 2 end |
#pops ⇒ Object
2642 2643 2644 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2642 def pops 1 end |
#pushes ⇒ Object
2646 2647 2648 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2646 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2626 2627 2628 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2626 def to_a(_iseq) [:objtostring, calldata.to_h] end |