class CodeTools::AST::Arguments

Attributes

array[RW]
splat[RW]

Public Class Methods

new(line, arguments=nil) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 490
def initialize(line, arguments=nil)
  @line = line
  @splat = nil

  case arguments
  when SplatValue
    @splat = arguments
    @array = []
  when ConcatArgs
    case arguments.array
    when ArrayLiteral
      @array = arguments.array.body
      @splat = SplatValue.new line, arguments.rest
    when PushArgs
      @array = []
      node = SplatValue.new line, arguments.rest
      @splat = CollectSplat.new line, arguments.array, node
    else
      @array = []
      @splat = CollectSplat.new line, arguments.array, arguments.rest
    end
  when PushArgs
    if arguments.arguments.kind_of? ConcatArgs
      if ary = arguments.arguments.peel_lhs
        @array = ary
      else
        @array = []
      end
    else
      @array = []
    end

    node = ArrayLiteral.new line, [arguments.value]
    @splat = CollectSplat.new line, arguments.arguments, node
  when ArrayLiteral
    @array = arguments.body
  when nil
    @array = []
  else
    @array = [arguments]
  end
end

Public Instance Methods

bytecode(g) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 555
def bytecode(g)
  @array.each { |x| x.bytecode(g) }
  @splat.bytecode(g) if @splat
end
masgn_bytecode(g) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 547
def masgn_bytecode(g)
  @array.each do |x|
    x.bytecode(g)
    g.swap
  end
  # TODO: splat
end
size() click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 533
def size
  @array.size
end
splat?() click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 543
def splat?
  not @splat.nil?
end
stack_size() click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 537
def stack_size
  size = @array.size
  size += 1 if splat?
  size
end
to_sexp() click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 560
def to_sexp
  sexp = @array.map { |x| x.to_sexp }
  sexp << @splat.to_sexp if @splat
  sexp
end