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
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ 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.
3098 3099 3100 3101 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3098 def initialize(object, calldata) @object = object @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
3096 3097 3098 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3096 def calldata @calldata end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
3096 3097 3098 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3096 def object @object end |
Instance Method Details
#==(other) ⇒ Object
3118 3119 3120 3121 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3118 def ==(other) other.is_a?(OptAsetWith) && other.object == object && other.calldata == calldata end |
#call(vm) ⇒ Object
3139 3140 3141 3142 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3139 def call(vm) hash, value = vm.pop(2) vm.push(hash[object] = value) end |
#canonical ⇒ Object
3135 3136 3137 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3135 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
3114 3115 3116 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3114 def deconstruct_keys(_keys) { object: object, calldata: calldata } end |
#disasm(fmt) ⇒ Object
3103 3104 3105 3106 3107 3108 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3103 def disasm(fmt) fmt.instruction( "opt_aset_with", [fmt.object(object), fmt.calldata(calldata)] ) end |
#length ⇒ Object
3123 3124 3125 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3123 def length 3 end |
#pops ⇒ Object
3127 3128 3129 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3127 def pops 2 end |
#pushes ⇒ Object
3131 3132 3133 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3131 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3110 3111 3112 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3110 def to_a(_iseq) [:opt_aset_with, object, calldata.to_h] end |