Class: SyntaxTree::YARV::OptAset

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

Overview

### Summary

opt_aset is an instruction for setting the hash value by the key in the ‘recv = set` format. It is a specialization of the opt_send_without_block instruction. It pops the receiver, the key, and the value off the stack and pushes on the result.

### Usage

~~~ruby = value ~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Instruction

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

Constructor Details

#initialize(calldata) ⇒ OptAset

Returns a new instance of OptAset.



2784
2785
2786
# File 'lib/syntax_tree/yarv/instructions.rb', line 2784

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



2782
2783
2784
# File 'lib/syntax_tree/yarv/instructions.rb', line 2782

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



2800
2801
2802
# File 'lib/syntax_tree/yarv/instructions.rb', line 2800

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

#call(vm) ⇒ Object



2820
2821
2822
# File 'lib/syntax_tree/yarv/instructions.rb', line 2820

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

#canonicalObject



2816
2817
2818
# File 'lib/syntax_tree/yarv/instructions.rb', line 2816

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



2796
2797
2798
# File 'lib/syntax_tree/yarv/instructions.rb', line 2796

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



2788
2789
2790
# File 'lib/syntax_tree/yarv/instructions.rb', line 2788

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

#lengthObject



2804
2805
2806
# File 'lib/syntax_tree/yarv/instructions.rb', line 2804

def length
  2
end

#popsObject



2808
2809
2810
# File 'lib/syntax_tree/yarv/instructions.rb', line 2808

def pops
  3
end

#pushesObject



2812
2813
2814
# File 'lib/syntax_tree/yarv/instructions.rb', line 2812

def pushes
  1
end

#to_a(_iseq) ⇒ Object



2792
2793
2794
# File 'lib/syntax_tree/yarv/instructions.rb', line 2792

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