Class: SyntaxTree::YARV::PushToArrayKwSplat

Inherits:
Instruction
  • Object
show all
Defined in:
lib/syntax_tree/yarv/instructions.rb

Overview

### Summary

‘pushtoarraykwsplat` is used to append a hash literal that is being splatted onto an array.

### Usage

~~~ruby

“string”, **{ foo: “bar” }

~~~

Instance Method Summary collapse

Methods inherited from Instruction

#branch_targets, #canonical, #falls_through?, #leaves?, #side_effects?

Instance Method Details

#==(other) ⇒ Object



4552
4553
4554
# File 'lib/syntax_tree/yarv/instructions.rb', line 4552

def ==(other)
  other.is_a?(PushToArrayKwSplat)
end

#call(vm) ⇒ Object



4568
4569
4570
4571
# File 'lib/syntax_tree/yarv/instructions.rb', line 4568

def call(vm)
  array, hash = vm.pop(2)
  vm.push(array << hash)
end

#deconstruct_keys(_keys) ⇒ Object



4548
4549
4550
# File 'lib/syntax_tree/yarv/instructions.rb', line 4548

def deconstruct_keys(_keys)
  {}
end

#disasm(fmt) ⇒ Object



4540
4541
4542
# File 'lib/syntax_tree/yarv/instructions.rb', line 4540

def disasm(fmt)
  fmt.instruction("pushtoarraykwsplat")
end

#lengthObject



4556
4557
4558
# File 'lib/syntax_tree/yarv/instructions.rb', line 4556

def length
  2
end

#popsObject



4560
4561
4562
# File 'lib/syntax_tree/yarv/instructions.rb', line 4560

def pops
  2
end

#pushesObject



4564
4565
4566
# File 'lib/syntax_tree/yarv/instructions.rb', line 4564

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4544
4545
4546
# File 'lib/syntax_tree/yarv/instructions.rb', line 4544

def to_a(_iseq)
  [:pushtoarraykwsplat]
end