Class: SyntaxTree::YARV::ObjToString
- Inherits:
-
Object
- Object
- 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
- #canonical ⇒ 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
Constructor Details
#initialize(calldata) ⇒ ObjToString
Returns a new instance of ObjToString.
2749 2750 2751 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2749 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2747 2748 2749 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2747 def calldata @calldata end |
Instance Method Details
#==(other) ⇒ Object
2765 2766 2767 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2765 def ==(other) other.is_a?(ObjToString) && other.calldata == calldata end |
#call(vm) ⇒ Object
2785 2786 2787 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2785 def call(vm) vm.push(vm.pop.to_s) end |
#canonical ⇒ Object
2781 2782 2783 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2781 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
2761 2762 2763 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2761 def deconstruct_keys(_keys) { calldata: calldata } end |
#disasm(fmt) ⇒ Object
2753 2754 2755 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2753 def disasm(fmt) fmt.instruction("objtostring", [fmt.calldata(calldata)]) end |
#length ⇒ Object
2769 2770 2771 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2769 def length 2 end |
#pops ⇒ Object
2773 2774 2775 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2773 def pops 1 end |
#pushes ⇒ Object
2777 2778 2779 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2777 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2757 2758 2759 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2757 def to_a(_iseq) [:objtostring, calldata.to_h] end |