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
number[R]
Public Class Methods
new(number)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2420 def initialize(number) @number = number end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2436 def ==(other) other.is_a?(NewHash) && other.number == number end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2452 def call(vm) vm.push(vm.pop(number).each_slice(2).to_h) end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2432 def deconstruct_keys(_keys) { number: number } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2424 def disasm(fmt) fmt.instruction("newhash", [fmt.object(number)]) end
length()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2440 def length 2 end
pops()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2444 def pops number end
pushes()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2448 def pushes 1 end
to_a(_iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2428 def to_a(_iseq) [:newhash, number] end