Class: SyntaxTree::YARV::OptAref

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

Overview

### Summary

opt_aref is a specialization of the opt_send_without_block instruction that occurs when the [] operator is used. There are fast paths if the receiver is an integer, array, or hash.

### Usage

~~~ruby 7 ~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(calldata) ⇒ OptAref



2575
2576
2577
# File 'lib/syntax_tree/yarv/instructions.rb', line 2575

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



2573
2574
2575
# File 'lib/syntax_tree/yarv/instructions.rb', line 2573

def calldata
  @calldata
end

Instance Method Details

#call(vm) ⇒ Object



2603
2604
2605
# File 'lib/syntax_tree/yarv/instructions.rb', line 2603

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

#canonicalObject



2599
2600
2601
# File 'lib/syntax_tree/yarv/instructions.rb', line 2599

def canonical
  Send.new(calldata, nil)
end

#disasm(fmt) ⇒ Object



2579
2580
2581
# File 'lib/syntax_tree/yarv/instructions.rb', line 2579

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

#lengthObject



2587
2588
2589
# File 'lib/syntax_tree/yarv/instructions.rb', line 2587

def length
  2
end

#popsObject



2591
2592
2593
# File 'lib/syntax_tree/yarv/instructions.rb', line 2591

def pops
  2
end

#pushesObject



2595
2596
2597
# File 'lib/syntax_tree/yarv/instructions.rb', line 2595

def pushes
  1
end

#to_a(_iseq) ⇒ Object



2583
2584
2585
# File 'lib/syntax_tree/yarv/instructions.rb', line 2583

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