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



3883
3884
3885
# File 'lib/syntax_tree/yarv/instructions.rb', line 3883

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3881
3882
3883
# File 'lib/syntax_tree/yarv/instructions.rb', line 3881

def calldata
  @calldata
end

Instance Method Details

#call(vm) ⇒ Object



3911
3912
3913
# File 'lib/syntax_tree/yarv/instructions.rb', line 3911

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

#canonicalObject



3907
3908
3909
# File 'lib/syntax_tree/yarv/instructions.rb', line 3907

def canonical
  Send.new(calldata, nil)
end

#disasm(fmt) ⇒ Object



3887
3888
3889
# File 'lib/syntax_tree/yarv/instructions.rb', line 3887

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

#lengthObject



3895
3896
3897
# File 'lib/syntax_tree/yarv/instructions.rb', line 3895

def length
  2
end

#popsObject



3899
3900
3901
# File 'lib/syntax_tree/yarv/instructions.rb', line 3899

def pops
  1 + calldata.argc
end

#pushesObject



3903
3904
3905
# File 'lib/syntax_tree/yarv/instructions.rb', line 3903

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3891
3892
3893
# File 'lib/syntax_tree/yarv/instructions.rb', line 3891

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