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.



2842
2843
2844
# File 'lib/syntax_tree/yarv/instructions.rb', line 2842

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



2840
2841
2842
# File 'lib/syntax_tree/yarv/instructions.rb', line 2840

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



2858
2859
2860
# File 'lib/syntax_tree/yarv/instructions.rb', line 2858

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

#call(vm) ⇒ Object



2878
2879
2880
# File 'lib/syntax_tree/yarv/instructions.rb', line 2878

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

#canonicalObject



2874
2875
2876
# File 'lib/syntax_tree/yarv/instructions.rb', line 2874

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



2854
2855
2856
# File 'lib/syntax_tree/yarv/instructions.rb', line 2854

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



2846
2847
2848
# File 'lib/syntax_tree/yarv/instructions.rb', line 2846

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

#lengthObject



2862
2863
2864
# File 'lib/syntax_tree/yarv/instructions.rb', line 2862

def length
  2
end

#popsObject



2866
2867
2868
# File 'lib/syntax_tree/yarv/instructions.rb', line 2866

def pops
  3
end

#pushesObject



2870
2871
2872
# File 'lib/syntax_tree/yarv/instructions.rb', line 2870

def pushes
  1
end

#to_a(_iseq) ⇒ Object



2850
2851
2852
# File 'lib/syntax_tree/yarv/instructions.rb', line 2850

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