class CodeTools::AST::ForParameters

Attributes

arity[RW]
assignments[RW]
block_index[RW]
keywords[RW]
kwrest_index[RW]
post_args[RW]
required_args[RW]
splat_index[RW]
total_args[RW]

Public Class Methods

new(line, assignments) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 906
def initialize(line, assignments)
  @line = line
  @assignments = assignments
  @splat_index = assignments.kind_of?(MultipleAssignment) ? 0 : nil
  @required_args = @splat_index ? 0 : 1
  @post_args = 0
  @keywords = nil
  @block_index = nil
  @kwrest_index = nil
end

Public Instance Methods

bytecode(g) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 927
def bytecode(g)
  map_arguments(g.state.scope)

  if @splat_index
    g.push_rubinius
    g.find_const :Runtime
    g.push_local 0
    g.send :unwrap_block_arg, 1
  else
    g.push_local 0
  end

  g.state.push_masgn
  @assignments.bytecode(g)
  g.state.pop_masgn
end
map_arguments(scope) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 920
def map_arguments(scope)
  case @assignments
  when LocalVariable
    scope.assign_local_reference @assignments
  end
end
to_sexp() click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 944
def to_sexp
  sexp = [:args]

  case @assignments
  when ArrayLiteral
    @assignments.each do |a|
      case a
      when Symbol
        sexp << a
      when Node
        sexp << a.to_sexp
      end
    end
  else
    sexp << @assignments.to_sexp
  end

  sexp
end