class SyntaxTree::YARV::SplatArray
### Summary
‘splatarray` coerces the array object at the top of the stack into Array by calling `to_a`. It pushes a duplicate of the array if there is a flag, and the original array if there isn’t one.
### Usage
~~~ruby x = *(5) ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5583 def initialize(flag) @flag = flag end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5599 def ==(other) other.is_a?(SplatArray) && other.flag == flag end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5615 def call(vm) value = vm.pop vm.push( if Array === value value.instance_of?(Array) ? value.dup : Array[*value] elsif value.nil? value.to_a else if value.respond_to?(:to_a, true) result = value.to_a if result.nil? [value] elsif !result.is_a?(Array) raise TypeError, "expected to_a to return an Array" end else [value] end end ) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5595 def deconstruct_keys(_keys) { flag: flag } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5587 def disasm(fmt) fmt.instruction("splatarray", [fmt.object(flag)]) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 5591 def to_a(_iseq) [:splatarray, flag] end