Class: SyntaxTree::YARV::OptSendWithoutBlock

Inherits:
Instruction
  • 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

Methods inherited from Instruction

#branch_targets, #falls_through?, #leaves?, #side_effects?

Constructor Details

#initialize(calldata) ⇒ OptSendWithoutBlock

Returns a new instance of OptSendWithoutBlock.



4220
4221
4222
# File 'lib/syntax_tree/yarv/instructions.rb', line 4220

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



4218
4219
4220
# File 'lib/syntax_tree/yarv/instructions.rb', line 4218

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



4236
4237
4238
# File 'lib/syntax_tree/yarv/instructions.rb', line 4236

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

#call(vm) ⇒ Object



4256
4257
4258
# File 'lib/syntax_tree/yarv/instructions.rb', line 4256

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

#canonicalObject



4252
4253
4254
# File 'lib/syntax_tree/yarv/instructions.rb', line 4252

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



4232
4233
4234
# File 'lib/syntax_tree/yarv/instructions.rb', line 4232

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



4224
4225
4226
# File 'lib/syntax_tree/yarv/instructions.rb', line 4224

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

#lengthObject



4240
4241
4242
# File 'lib/syntax_tree/yarv/instructions.rb', line 4240

def length
  2
end

#popsObject



4244
4245
4246
# File 'lib/syntax_tree/yarv/instructions.rb', line 4244

def pops
  1 + calldata.argc
end

#pushesObject



4248
4249
4250
# File 'lib/syntax_tree/yarv/instructions.rb', line 4248

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4228
4229
4230
# File 'lib/syntax_tree/yarv/instructions.rb', line 4228

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