Class: CodeTools::AST::AttributeAssignment

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

Direct Known Subclasses

AndAttributeAssignment

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.



210
211
212
213
214
215
216
217
218
219
# File 'lib/rubinius/code/ast/sends.rb', line 210

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, anddot = false) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/rubinius/code/ast/sends.rb', line 221

def bytecode(g, anddot=false)
  @receiver.bytecode(g) unless anddot
  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



244
245
246
# File 'lib/rubinius/code/ast/sends.rb', line 244

def sexp_name
  :attrasgn
end