Class: CodeTools::AST::Arguments
- Inherits:
-
Node
- Object
- Node
- CodeTools::AST::Arguments
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) ⇒ Arguments
Returns a new instance of Arguments.
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
|
# File 'lib/rubinius/ast/sends.rb', line 433
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
#array ⇒ Object
Returns the value of attribute array.
431
432
433
|
# File 'lib/rubinius/ast/sends.rb', line 431
def array
@array
end
|
#splat ⇒ Object
Returns the value of attribute splat.
431
432
433
|
# File 'lib/rubinius/ast/sends.rb', line 431
def splat
@splat
end
|
Instance Method Details
#bytecode(g) ⇒ Object
498
499
500
501
|
# File 'lib/rubinius/ast/sends.rb', line 498
def bytecode(g)
@array.each { |x| x.bytecode(g) }
@splat.bytecode(g) if @splat
end
|
#masgn_bytecode(g) ⇒ Object
490
491
492
493
494
495
496
|
# File 'lib/rubinius/ast/sends.rb', line 490
def masgn_bytecode(g)
@array.each do |x|
x.bytecode(g)
g.swap
end
end
|
#size ⇒ Object
476
477
478
|
# File 'lib/rubinius/ast/sends.rb', line 476
def size
@array.size
end
|
#splat? ⇒ Boolean
486
487
488
|
# File 'lib/rubinius/ast/sends.rb', line 486
def splat?
not @splat.nil?
end
|
#stack_size ⇒ Object
480
481
482
483
484
|
# File 'lib/rubinius/ast/sends.rb', line 480
def stack_size
size = @array.size
size += 1 if splat?
size
end
|
#to_sexp ⇒ Object
503
504
505
506
507
|
# File 'lib/rubinius/ast/sends.rb', line 503
def to_sexp
sexp = @array.map { |x| x.to_sexp }
sexp << @splat.to_sexp if @splat
sexp
end
|