Class: CodeTools::AST::Arguments
- Inherits:
-
Node
- Object
- Node
- CodeTools::AST::Arguments
show all
- Defined in:
- lib/rubinius/code/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.
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
475
|
# File 'lib/rubinius/code/ast/sends.rb', line 434
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.
432
433
434
|
# File 'lib/rubinius/code/ast/sends.rb', line 432
def array
@array
end
|
#splat ⇒ Object
Returns the value of attribute splat.
432
433
434
|
# File 'lib/rubinius/code/ast/sends.rb', line 432
def splat
@splat
end
|
Instance Method Details
#bytecode(g) ⇒ Object
499
500
501
502
|
# File 'lib/rubinius/code/ast/sends.rb', line 499
def bytecode(g)
@array.each { |x| x.bytecode(g) }
@splat.bytecode(g) if @splat
end
|
#masgn_bytecode(g) ⇒ Object
491
492
493
494
495
496
497
|
# File 'lib/rubinius/code/ast/sends.rb', line 491
def masgn_bytecode(g)
@array.each do |x|
x.bytecode(g)
g.swap
end
end
|
#size ⇒ Object
477
478
479
|
# File 'lib/rubinius/code/ast/sends.rb', line 477
def size
@array.size
end
|
#splat? ⇒ Boolean
487
488
489
|
# File 'lib/rubinius/code/ast/sends.rb', line 487
def splat?
not @splat.nil?
end
|
#stack_size ⇒ Object
481
482
483
484
485
|
# File 'lib/rubinius/code/ast/sends.rb', line 481
def stack_size
size = @array.size
size += 1 if splat?
size
end
|
#to_sexp ⇒ Object
504
505
506
507
508
|
# File 'lib/rubinius/code/ast/sends.rb', line 504
def to_sexp
sexp = @array.map { |x| x.to_sexp }
sexp << @splat.to_sexp if @splat
sexp
end
|