Class: Rubinius::ToolSets.current::ToolSet::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.



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
455
# File 'lib/rubinius/ast/sends.rb', line 414

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.



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

def array
  @array
end

#splatObject

Returns the value of attribute splat.



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

def splat
  @splat
end

Instance Method Details

#bytecode(g) ⇒ Object



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

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

#masgn_bytecode(g) ⇒ Object



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

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

#sizeObject



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

def size
  @array.size
end

#splat?Boolean

Returns:

  • (Boolean)


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

def splat?
  not @splat.nil?
end

#stack_sizeObject



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

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

#to_sexpObject



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

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