Class: SyntaxTree::YARV::OptStrFreeze
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
"hello".freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
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.
4340
4341
4342
4343
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4340
def initialize(object, calldata)
@object = object
@calldata = calldata
end
|
Instance Attribute Details
#calldata ⇒ Object
Returns the value of attribute calldata.
4338
4339
4340
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4338
def calldata
@calldata
end
|
#object ⇒ Object
Returns the value of attribute object.
4338
4339
4340
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4338
def object
@object
end
|
Instance Method Details
#==(other) ⇒ Object
4360
4361
4362
4363
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4360
def ==(other)
other.is_a?(OptStrFreeze) && other.object == object &&
other.calldata == calldata
end
|
#call(vm) ⇒ Object
4373
4374
4375
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4373
def call(vm)
vm.push(object.freeze)
end
|
#deconstruct_keys(_keys) ⇒ Object
4356
4357
4358
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4356
def deconstruct_keys(_keys)
{ object: object, calldata: calldata }
end
|
#disasm(fmt) ⇒ Object
4345
4346
4347
4348
4349
4350
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4345
def disasm(fmt)
fmt.instruction(
"opt_str_freeze",
[fmt.object(object), fmt.calldata(calldata)]
)
end
|
#length ⇒ Object
4365
4366
4367
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4365
def length
3
end
|
#pushes ⇒ Object
4369
4370
4371
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4369
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
4352
4353
4354
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 4352
def to_a(_iseq)
[:opt_str_freeze, object, calldata.to_h]
end
|