class CodeTools::AST::CollectSplat

Attributes

array[RW]
last[RW]
splat[RW]

Public Class Methods

new(line, *parts) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 442
def initialize(line, *parts)
  @line = line
  @splat = parts.shift
  @last = parts.pop
  @array = parts
end

Public Instance Methods

bytecode(g) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 449
def bytecode(g)
  @splat.bytecode(g)

  @array.each do |x|
    x.bytecode(g)
    g.cast_array
    g.send :+, 1
  end

  return unless @last

  not_hash = g.new_label
  done = g.new_label

  @last.bytecode(g)

  g.dup
  g.push_cpath_top
  g.find_const :Hash
  g.swap
  g.kind_of
  g.goto_if_false not_hash

  g.make_array 1
  g.goto done

  not_hash.set!
  g.cast_array

  done.set!
  g.send :+, 1
end
to_sexp() click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 482
def to_sexp
  [:collect_splat] + @array.map { |x| x.to_sexp }
end