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
- #call(vm) ⇒ Object
- #canonical ⇒ 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.
2425 2426 2427 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2425 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2423 2424 2425 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2423 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
2453 2454 2455 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2453 def call(vm) vm.push(vm.pop.to_s) end |
#canonical ⇒ Object
2449 2450 2451 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2449 def canonical self end |
#disasm(fmt) ⇒ Object
2429 2430 2431 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2429 def disasm(fmt) fmt.instruction("objtostring", [fmt.calldata(calldata)]) end |
#length ⇒ Object
2437 2438 2439 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2437 def length 2 end |
#pops ⇒ Object
2441 2442 2443 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2441 def pops 1 end |
#pushes ⇒ Object
2445 2446 2447 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2445 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2433 2434 2435 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2433 def to_a(_iseq) [:objtostring, calldata.to_h] end |