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.
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
456
457
458
459
460
461
462
463
464
465
466
|
# File 'lib/rubinius/ast/sends.rb', line 425
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.
423
424
425
|
# File 'lib/rubinius/ast/sends.rb', line 423
def array
@array
end
|
#splat ⇒ Object
Returns the value of attribute splat.
423
424
425
|
# File 'lib/rubinius/ast/sends.rb', line 423
def splat
@splat
end
|
Instance Method Details
#bytecode(g) ⇒ Object
490
491
492
493
|
# File 'lib/rubinius/ast/sends.rb', line 490
def bytecode(g)
@array.each { |x| x.bytecode(g) }
@splat.bytecode(g) if @splat
end
|
#masgn_bytecode(g) ⇒ Object
482
483
484
485
486
487
488
|
# File 'lib/rubinius/ast/sends.rb', line 482
def masgn_bytecode(g)
@array.each do |x|
x.bytecode(g)
g.swap
end
end
|
#size ⇒ Object
468
469
470
|
# File 'lib/rubinius/ast/sends.rb', line 468
def size
@array.size
end
|
#splat? ⇒ Boolean
478
479
480
|
# File 'lib/rubinius/ast/sends.rb', line 478
def splat?
not @splat.nil?
end
|
#stack_size ⇒ Object
472
473
474
475
476
|
# File 'lib/rubinius/ast/sends.rb', line 472
def stack_size
size = @array.size
size += 1 if splat?
size
end
|
#to_sexp ⇒ Object
495
496
497
498
499
|
# File 'lib/rubinius/ast/sends.rb', line 495
def to_sexp
sexp = @array.map { |x| x.to_sexp }
sexp << @splat.to_sexp if @splat
sexp
end
|