Class: SyntaxTree::YARV::OptStrUMinus

Inherits:
Instruction show all
Defined in:
lib/syntax_tree/yarv/instructions.rb

Overview

### Summary

‘opt_str_uminus` pushes a frozen known string value with no interpolation onto the stack. If the method gets overridden, this will fall back to a send.

### Usage

~~~ruby -“string” ~~~

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) ⇒ OptStrUMinus

Returns a new instance of OptStrUMinus.



4386
4387
4388
4389
# File 'lib/syntax_tree/yarv/instructions.rb', line 4386

def initialize(object, calldata)
  @object = object
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



4384
4385
4386
# File 'lib/syntax_tree/yarv/instructions.rb', line 4384

def calldata
  @calldata
end

#objectObject (readonly)

Returns the value of attribute object.



4384
4385
4386
# File 'lib/syntax_tree/yarv/instructions.rb', line 4384

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



4406
4407
4408
4409
# File 'lib/syntax_tree/yarv/instructions.rb', line 4406

def ==(other)
  other.is_a?(OptStrUMinus) && other.object == object &&
    other.calldata == calldata
end

#call(vm) ⇒ Object



4419
4420
4421
# File 'lib/syntax_tree/yarv/instructions.rb', line 4419

def call(vm)
  vm.push(-object)
end

#deconstruct_keys(_keys) ⇒ Object



4402
4403
4404
# File 'lib/syntax_tree/yarv/instructions.rb', line 4402

def deconstruct_keys(_keys)
  { object: object, calldata: calldata }
end

#disasm(fmt) ⇒ Object



4391
4392
4393
4394
4395
4396
# File 'lib/syntax_tree/yarv/instructions.rb', line 4391

def disasm(fmt)
  fmt.instruction(
    "opt_str_uminus",
    [fmt.object(object), fmt.calldata(calldata)]
  )
end

#lengthObject



4411
4412
4413
# File 'lib/syntax_tree/yarv/instructions.rb', line 4411

def length
  3
end

#pushesObject



4415
4416
4417
# File 'lib/syntax_tree/yarv/instructions.rb', line 4415

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4398
4399
4400
# File 'lib/syntax_tree/yarv/instructions.rb', line 4398

def to_a(_iseq)
  [:opt_str_uminus, object, calldata.to_h]
end