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
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ 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
4557 4558 4559 4560 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4557 def initialize(object, calldata) @object = object @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
4555 4556 4557 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4555 def calldata @calldata end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
4555 4556 4557 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4555 def object @object end |
Instance Method Details
#==(other) ⇒ Object
4577 4578 4579 4580 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4577 def ==(other) other.is_a?(OptStrFreeze) && other.object == object && other.calldata == calldata end |
#call(vm) ⇒ Object
4598 4599 4600 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4598 def call(vm) vm.push(object.freeze) end |
#canonical ⇒ Object
4594 4595 4596 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4594 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
4573 4574 4575 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4573 def deconstruct_keys(_keys) { object: object, calldata: calldata } end |
#disasm(fmt) ⇒ Object
4562 4563 4564 4565 4566 4567 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4562 def disasm(fmt) fmt.instruction( "opt_str_freeze", [fmt.object(object), fmt.calldata(calldata)] ) end |
#length ⇒ Object
4582 4583 4584 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4582 def length 3 end |
#pops ⇒ Object
4586 4587 4588 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4586 def pops 0 end |
#pushes ⇒ Object
4590 4591 4592 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4590 def pushes 1 end |
#to_a(_iseq) ⇒ Object
4569 4570 4571 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4569 def to_a(_iseq) [:opt_str_freeze, object, calldata.to_h] end |