Class: SyntaxTree::YARV::OptStrFreeze
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptStrFreeze
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_str_freeze pushes a frozen known string value with no interpolation onto the stack using the #freeze method. If the method gets overridden, this will fall back to a send.
### Usage
~~~ruby “hello”.freeze ~~~
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
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(object, calldata) ⇒ OptStrFreeze
constructor
A new instance of OptStrFreeze.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(object, calldata) ⇒ OptStrFreeze
3980 3981 3982 3983 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3980 def initialize(object, calldata) @object = object @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3978 3979 3980 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3978 def calldata @calldata end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
3978 3979 3980 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3978 def object @object end |
Instance Method Details
#call(vm) ⇒ Object
4012 4013 4014 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4012 def call(vm) vm.push(object.freeze) end |
#canonical ⇒ Object
4008 4009 4010 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4008 def canonical self end |
#disasm(fmt) ⇒ Object
3985 3986 3987 3988 3989 3990 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3985 def disasm(fmt) fmt.instruction( "opt_str_freeze", [fmt.object(object), fmt.calldata(calldata)] ) end |
#length ⇒ Object
3996 3997 3998 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3996 def length 3 end |
#pops ⇒ Object
4000 4001 4002 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4000 def pops 0 end |
#pushes ⇒ Object
4004 4005 4006 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4004 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3992 3993 3994 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3992 def to_a(_iseq) [:opt_str_freeze, object, calldata.to_h] end |