class CodeTools::AST::ElementAssignment

Public Class Methods

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

  @receiver = receiver
  @privately = receiver.kind_of?(Self) ? true : false

  @name = :[]=

  case arguments
  when PushArgs
    @arguments = PushArguments.new line, arguments
  else
    @arguments = Arguments.new line, arguments
  end
end

Public Instance Methods

bytecode(g) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 292
def bytecode(g)
  return masgn_bytecode(g) if g.state.masgn?

  @receiver.bytecode(g)
  @arguments.bytecode(g)

  g.dup

  if @arguments.splat?
    case @arguments
    when PushArguments
      g.move_down @arguments.size + 2
      g.swap
      flag = true
    when Arguments
      # TODO: Optimize bytecode for x[a, *b, c, d] = e
      g.send :last, 0, true
      g.move_down @arguments.size + 2
      flag = false
    end

    g.push_tagged_nil 0
    g.send_with_splat @name, @arguments.size, @privately, flag
  else
    g.move_down @arguments.size + 1
    g.send @name, @arguments.size, @privately
  end

  g.pop
end
masgn_bytecode(g) click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 284
def masgn_bytecode(g)
  @receiver.bytecode(g)
  g.swap
  @arguments.masgn_bytecode(g)
  g.send @name, @arguments.size + 1, @privately
  # TODO: splat
end
sexp_name() click to toggle source
# File lib/rubinius/code/ast/sends.rb, line 323
def sexp_name
  :attrasgn
end