Class: SyntaxTree::YARV::OptAsetWith
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptAsetWith
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_aset_with is an instruction for setting the hash value by the known string key in the ‘recv = set` format. It pops the receiver and the value off the stack and pushes on the result.
### Usage
Instance Attribute Summary collapse
-
#calldata ⇒ Object
readonly
Returns the value of attribute calldata.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(object, calldata) ⇒ OptAsetWith
constructor
A new instance of OptAsetWith.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(object, calldata) ⇒ OptAsetWith
Returns a new instance of OptAsetWith.
2725 2726 2727 2728 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2725 def initialize(object, calldata) @object = object @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
2723 2724 2725 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2723 def calldata @calldata end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
2723 2724 2725 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2723 def object @object end |
Instance Method Details
#call(vm) ⇒ Object
2757 2758 2759 2760 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2757 def call(vm) hash, value = vm.pop(2) vm.push(hash[object] = value) end |
#canonical ⇒ Object
2753 2754 2755 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2753 def canonical self end |
#disasm(fmt) ⇒ Object
2730 2731 2732 2733 2734 2735 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2730 def disasm(fmt) fmt.instruction( "opt_aset_with", [fmt.object(object), fmt.calldata(calldata)] ) end |
#length ⇒ Object
2741 2742 2743 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2741 def length 3 end |
#pops ⇒ Object
2745 2746 2747 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2745 def pops 2 end |
#pushes ⇒ Object
2749 2750 2751 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2749 def pushes 1 end |
#to_a(_iseq) ⇒ Object
2737 2738 2739 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 2737 def to_a(_iseq) [:opt_aset_with, object, calldata.to_h] end |