Class: SyntaxTree::YARV::OptStrFreeze
- Inherits:
-
Instruction
- Object
- Instruction
- 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
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(object, calldata) ⇒ OptStrFreeze
constructor
A new instance of OptStrFreeze.
- #length ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(object, calldata) ⇒ OptStrFreeze
Returns a new instance of OptStrFreeze.
4275 4276 4277 4278 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4275 def initialize(object, calldata) @object = object @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
4273 4274 4275 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4273 def calldata @calldata end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
4273 4274 4275 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4273 def object @object end |
Instance Method Details
#==(other) ⇒ Object
4295 4296 4297 4298 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4295 def ==(other) other.is_a?(OptStrFreeze) && other.object == object && other.calldata == calldata end |
#call(vm) ⇒ Object
4308 4309 4310 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4308 def call(vm) vm.push(object.freeze) end |
#deconstruct_keys(_keys) ⇒ Object
4291 4292 4293 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4291 def deconstruct_keys(_keys) { object: object, calldata: calldata } end |
#disasm(fmt) ⇒ Object
4280 4281 4282 4283 4284 4285 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4280 def disasm(fmt) fmt.instruction( "opt_str_freeze", [fmt.object(object), fmt.calldata(calldata)] ) end |
#length ⇒ Object
4300 4301 4302 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4300 def length 3 end |
#pushes ⇒ Object
4304 4305 4306 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4304 def pushes 1 end |
#to_a(_iseq) ⇒ Object
4287 4288 4289 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4287 def to_a(_iseq) [:opt_str_freeze, object, calldata.to_h] end |