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.



2677
2678
2679
# File 'lib/syntax_tree/yarv/instructions.rb', line 2677

def initialize(calldata)
  @calldata = calldata
end

Instance Attribute Details

#calldataObject (readonly)

Returns the value of attribute calldata.



2675
2676
2677
# File 'lib/syntax_tree/yarv/instructions.rb', line 2675

def calldata
  @calldata
end

Instance Method Details

#call(vm) ⇒ Object



2705
2706
2707
# File 'lib/syntax_tree/yarv/instructions.rb', line 2705

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

#canonicalObject



2701
2702
2703
# File 'lib/syntax_tree/yarv/instructions.rb', line 2701

def canonical
  Send.new(calldata, nil)
end

#disasm(fmt) ⇒ Object



2681
2682
2683
# File 'lib/syntax_tree/yarv/instructions.rb', line 2681

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

#lengthObject



2689
2690
2691
# File 'lib/syntax_tree/yarv/instructions.rb', line 2689

def length
  2
end

#popsObject



2693
2694
2695
# File 'lib/syntax_tree/yarv/instructions.rb', line 2693

def pops
  3
end

#pushesObject



2697
2698
2699
# File 'lib/syntax_tree/yarv/instructions.rb', line 2697

def pushes
  1
end

#to_a(_iseq) ⇒ Object



2685
2686
2687
# File 'lib/syntax_tree/yarv/instructions.rb', line 2685

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