class SyntaxTree::YARV::NewHash
### Summary
‘newhash` puts a new hash onto the stack, using `number` elements from the stack. `number` needs to be even. It pops `number` elements off the stack and pushes a hash onto the stack.
### Usage
~~~ruby def foo(key, value)
{ key => value }
end ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 2473 def initialize(number) @number = number end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 2489 def ==(other) other.is_a?(NewHash) && other.number == number end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 2505 def call(vm) vm.push(vm.pop(number).each_slice(2).to_h) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 2485 def deconstruct_keys(_keys) { number: number } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 2477 def disasm(fmt) fmt.instruction("newhash", [fmt.object(number)]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 2481 def to_a(_iseq) [:newhash, number] end