Class: SyntaxTree::YARV::OptAset

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

Constructor Details

#initialize(calldata) ⇒ OptAset

Returns a new instance of OptAset.



3042
3043
3044
# File 'lib/syntax_tree/yarv/instructions.rb', line 3042

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



3040
3041
3042
# File 'lib/syntax_tree/yarv/instructions.rb', line 3040

def calldata
  @calldata
end

Instance Method Details

#==(other) ⇒ Object



3058
3059
3060
# File 'lib/syntax_tree/yarv/instructions.rb', line 3058

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

#call(vm) ⇒ Object



3078
3079
3080
# File 'lib/syntax_tree/yarv/instructions.rb', line 3078

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

#canonicalObject



3074
3075
3076
# File 'lib/syntax_tree/yarv/instructions.rb', line 3074

def canonical
  Send.new(calldata, nil)
end

#deconstruct_keys(_keys) ⇒ Object



3054
3055
3056
# File 'lib/syntax_tree/yarv/instructions.rb', line 3054

def deconstruct_keys(_keys)
  { calldata: calldata }
end

#disasm(fmt) ⇒ Object



3046
3047
3048
# File 'lib/syntax_tree/yarv/instructions.rb', line 3046

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

#lengthObject



3062
3063
3064
# File 'lib/syntax_tree/yarv/instructions.rb', line 3062

def length
  2
end

#popsObject



3066
3067
3068
# File 'lib/syntax_tree/yarv/instructions.rb', line 3066

def pops
  3
end

#pushesObject



3070
3071
3072
# File 'lib/syntax_tree/yarv/instructions.rb', line 3070

def pushes
  1
end

#to_a(_iseq) ⇒ Object



3050
3051
3052
# File 'lib/syntax_tree/yarv/instructions.rb', line 3050

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