Class: SyntaxTree::YARV::DupHash
- Inherits:
-
Object
- Object
- 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
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(object) ⇒ DupHash
constructor
A new instance of DupHash.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(object) ⇒ DupHash
Returns a new instance of DupHash.
1201 1202 1203 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1201 def initialize(object) @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
1199 1200 1201 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1199 def object @object end |
Instance Method Details
#call(vm) ⇒ Object
1229 1230 1231 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1229 def call(vm) vm.push(object.dup) end |
#canonical ⇒ Object
1225 1226 1227 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1225 def canonical self end |
#disasm(fmt) ⇒ Object
1205 1206 1207 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1205 def disasm(fmt) fmt.instruction("duphash", [fmt.object(object)]) end |
#length ⇒ Object
1213 1214 1215 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1213 def length 2 end |
#pops ⇒ Object
1217 1218 1219 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1217 def pops 0 end |
#pushes ⇒ Object
1221 1222 1223 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1221 def pushes 1 end |
#to_a(_iseq) ⇒ Object
1209 1210 1211 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1209 def to_a(_iseq) [:duphash, object] end |