Class: SyntaxTree::YARV::OptSendWithoutBlock

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

Overview

### Summary

opt_send_without_block is a specialization of the send instruction that occurs when a method is being called without a block. It pops the receiver and the arguments off the stack and pushes on the result.

### Usage

~~~ruby puts “Hello, world!” ~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(calldata) ⇒ OptSendWithoutBlock

Returns a new instance of OptSendWithoutBlock.



4444
4445
4446
# File 'lib/syntax_tree/yarv/instructions.rb', line 4444

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



4442
4443
4444
# File 'lib/syntax_tree/yarv/instructions.rb', line 4442

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



4460
4461
4462
# File 'lib/syntax_tree/yarv/instructions.rb', line 4460

def ==(other)
  other.is_a?(OptSendWithoutBlock) && other.calldata == calldata
end

#call(vm) ⇒ Object



4480
4481
4482
# File 'lib/syntax_tree/yarv/instructions.rb', line 4480

def call(vm)
  canonical.call(vm)
end

#canonicalObject



4476
4477
4478
# File 'lib/syntax_tree/yarv/instructions.rb', line 4476

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



4456
4457
4458
# File 'lib/syntax_tree/yarv/instructions.rb', line 4456

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



4448
4449
4450
# File 'lib/syntax_tree/yarv/instructions.rb', line 4448

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

#lengthObject



4464
4465
4466
# File 'lib/syntax_tree/yarv/instructions.rb', line 4464

def length
  2
end

#popsObject



4468
4469
4470
# File 'lib/syntax_tree/yarv/instructions.rb', line 4468

def pops
  1 + calldata.argc
end

#pushesObject



4472
4473
4474
# File 'lib/syntax_tree/yarv/instructions.rb', line 4472

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4452
4453
4454
# File 'lib/syntax_tree/yarv/instructions.rb', line 4452

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