Class: CodeTools::AST::AttributeAssignment

Inherits:
SendWithArguments show all
Defined in:
lib/rubinius/ast/sends.rb

Instance Attribute Summary

Attributes inherited from SendWithArguments

#arguments

Attributes inherited from Send

#block, #name, #privately, #receiver, #variable, #vcall_style

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from SendWithArguments

#arguments_sexp

Methods inherited from Send

#arguments_sexp, #check_local_reference, #defined, #receiver_sexp, #to_sexp, #value_defined

Methods inherited from Node

#ascii_graph, #attributes, #children, #defined, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #or_bytecode, #pos, #set_child, #to_sexp, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk

Constructor Details

#initialize(line, receiver, name, arguments) ⇒ AttributeAssignment

Returns a new instance of AttributeAssignment.



170
171
172
173
174
175
176
177
178
179
# File 'lib/rubinius/ast/sends.rb', line 170

def initialize(line, receiver, name, arguments)
  @line = line

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

  @name = :"#{name}="

  @arguments = Arguments.new line, arguments
end

Instance Method Details

#bytecode(g) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/rubinius/ast/sends.rb', line 181

def bytecode(g)
  @receiver.bytecode(g)
  if g.state.masgn?
    g.swap
    g.send @name, 1, @privately
  else
    @arguments.bytecode(g)
    g.dup

    if @arguments.splat?
      g.move_down @arguments.size + 2
      g.swap
      g.push :nil
      g.send_with_splat @name, @arguments.size, @privately, true
    else
      g.move_down @arguments.size + 1
      g.send @name, @arguments.size, @privately
    end

    g.pop
  end
end

#sexp_nameObject



204
205
206
# File 'lib/rubinius/ast/sends.rb', line 204

def sexp_name
  :attrasgn
end