Class: Rubinius::ToolSet.current::TS::AST::ActualArguments

Inherits:
Node
  • Object
show all
Defined in:
lib/rubinius/ast/sends.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

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, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk

Constructor Details

#initialize(line, arguments = nil) ⇒ ActualArguments

Returns a new instance of ActualArguments.



413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/rubinius/ast/sends.rb', line 413

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

Instance Attribute Details

#arrayObject

Returns the value of attribute array.



411
412
413
# File 'lib/rubinius/ast/sends.rb', line 411

def array
  @array
end

#splatObject

Returns the value of attribute splat.



411
412
413
# File 'lib/rubinius/ast/sends.rb', line 411

def splat
  @splat
end

Instance Method Details

#bytecode(g) ⇒ Object



478
479
480
481
# File 'lib/rubinius/ast/sends.rb', line 478

def bytecode(g)
  @array.each { |x| x.bytecode(g) }
  @splat.bytecode(g) if @splat
end

#masgn_bytecode(g) ⇒ Object



470
471
472
473
474
475
476
# File 'lib/rubinius/ast/sends.rb', line 470

def masgn_bytecode(g)
  @array.each do |x|
    x.bytecode(g)
    g.swap
  end
  # TODO: splat
end

#sizeObject



456
457
458
# File 'lib/rubinius/ast/sends.rb', line 456

def size
  @array.size
end

#splat?Boolean

Returns:

  • (Boolean)


466
467
468
# File 'lib/rubinius/ast/sends.rb', line 466

def splat?
  not @splat.nil?
end

#stack_sizeObject



460
461
462
463
464
# File 'lib/rubinius/ast/sends.rb', line 460

def stack_size
  size = @array.size
  size += 1 if splat?
  size
end

#to_sexpObject



483
484
485
486
487
# File 'lib/rubinius/ast/sends.rb', line 483

def to_sexp
  sexp = @array.map { |x| x.to_sexp }
  sexp << @splat.to_sexp if @splat
  sexp
end