Class: SyntaxTree::YARV::DupHash
- Inherits:
-
Instruction
- Object
- Instruction
- SyntaxTree::YARV::DupHash
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
duphash dups a Hash literal and pushes it onto the stack.
### Usage
~~~ruby { a: 1 } ~~~
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(object) ⇒ DupHash
constructor
A new instance of DupHash.
- #length ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(object) ⇒ DupHash
Returns a new instance of DupHash.
1241 1242 1243 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1241 def initialize(object) @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
1239 1240 1241 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1239 def object @object end |
Instance Method Details
#==(other) ⇒ Object
1257 1258 1259 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1257 def ==(other) other.is_a?(DupHash) && other.object == object end |
#call(vm) ⇒ Object
1269 1270 1271 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1269 def call(vm) vm.push(object.dup) end |
#deconstruct_keys(_keys) ⇒ Object
1253 1254 1255 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1253 def deconstruct_keys(_keys) { object: object } end |
#disasm(fmt) ⇒ Object
1245 1246 1247 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1245 def disasm(fmt) fmt.instruction("duphash", [fmt.object(object)]) end |
#length ⇒ Object
1261 1262 1263 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1261 def length 2 end |
#pushes ⇒ Object
1265 1266 1267 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1265 def pushes 1 end |
#to_a(_iseq) ⇒ Object
1249 1250 1251 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1249 def to_a(_iseq) [:duphash, object] end |