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.



4162
4163
4164
# File 'lib/syntax_tree/yarv/instructions.rb', line 4162

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



4160
4161
4162
# File 'lib/syntax_tree/yarv/instructions.rb', line 4160

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



4178
4179
4180
# File 'lib/syntax_tree/yarv/instructions.rb', line 4178

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

#call(vm) ⇒ Object



4198
4199
4200
# File 'lib/syntax_tree/yarv/instructions.rb', line 4198

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

#canonicalObject



4194
4195
4196
# File 'lib/syntax_tree/yarv/instructions.rb', line 4194

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



4174
4175
4176
# File 'lib/syntax_tree/yarv/instructions.rb', line 4174

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



4166
4167
4168
# File 'lib/syntax_tree/yarv/instructions.rb', line 4166

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

#lengthObject



4182
4183
4184
# File 'lib/syntax_tree/yarv/instructions.rb', line 4182

def length
  2
end

#popsObject



4186
4187
4188
# File 'lib/syntax_tree/yarv/instructions.rb', line 4186

def pops
  1 + calldata.argc
end

#pushesObject



4190
4191
4192
# File 'lib/syntax_tree/yarv/instructions.rb', line 4190

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4170
4171
4172
# File 'lib/syntax_tree/yarv/instructions.rb', line 4170

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