Class: Rubinius::ToolSet.current::TS::AST::FormalArguments19
Instance Attribute Summary collapse
#block_arg, #block_index, #defaults, #names, #optional, #required, #splat
Attributes inherited from Node
#line
Instance Method Summary
collapse
#to_actual, #to_sexp
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, #to_sexp, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk
Constructor Details
#initialize(line, required, optional, splat, post, block) ⇒ FormalArguments19
Returns a new instance of FormalArguments19.
400
401
402
403
404
405
406
407
408
409
410
411
412
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
455
456
457
458
459
460
461
462
463
|
# File 'lib/rubinius/ast/definitions.rb', line 400
def initialize(line, required, optional, splat, post, block)
@line = line
@defaults = nil
@block_arg = nil
@splat_index = nil
@block_index = nil
@required = []
names = []
if required
required.each do |arg|
case arg
when Symbol
names << arg
@required << arg
when MultipleAssignment
@required << PatternArguments.from_masgn(arg)
@splat_index = -4 if @required.size == 1
end
end
end
if optional
@defaults = DefaultArguments.new line, optional
@optional = @defaults.names
names.concat @optional
else
@optional = []
end
case splat
when Symbol
names << splat
when true
splat = :*
names << splat
when false
@splat_index = -3
splat = nil
end
@post = []
if post
post.each do |arg|
case arg
when MultipleAssignment
@post << PatternArguments.from_masgn(arg)
when Symbol
@post << arg
names << arg
end
end
end
if block
@block_arg = BlockArgument.new line, block
names << block
@block_index = names.length - 1
end
@splat = splat
@names = names
end
|
Instance Attribute Details
#post ⇒ Object
Returns the value of attribute post.
398
399
400
|
# File 'lib/rubinius/ast/definitions.rb', line 398
def post
@post
end
|
Instance Method Details
#bytecode(g) ⇒ Object
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
|
# File 'lib/rubinius/ast/definitions.rb', line 516
def bytecode(g)
g.state.check_for_locals = false
map_arguments g.state.scope
@required.each do |arg|
if arg.kind_of? PatternArguments
arg.argument.position_bytecode(g)
arg.bytecode(g)
g.pop
end
end
@defaults.bytecode(g) if @defaults
@block_arg.bytecode(g) if @block_arg
@post.each do |arg|
if arg.kind_of? PatternArguments
arg.argument.position_bytecode(g)
arg.bytecode(g)
g.pop
end
end
g.state.check_for_locals = true
end
|
#map_arguments(scope) ⇒ Object
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
|
# File 'lib/rubinius/ast/definitions.rb', line 489
def map_arguments(scope)
@required.each_with_index do |arg, index|
case arg
when PatternArguments
arg.map_arguments scope
when Symbol
@required[index] = arg = :"_#{index}" if arg == :_ and index > 0
scope.new_local arg
end
end
@defaults.map_arguments scope if @defaults
scope.new_local @splat if @splat.kind_of? Symbol
@post.each do |arg|
case arg
when PatternArguments
arg.map_arguments scope
when Symbol
scope.new_local arg
end
end
scope.assign_local_reference @block_arg if @block_arg
end
|
#post_args ⇒ Object
469
470
471
|
# File 'lib/rubinius/ast/definitions.rb', line 469
def post_args
@post.size
end
|
#required_args ⇒ Object
465
466
467
|
# File 'lib/rubinius/ast/definitions.rb', line 465
def required_args
@required.size + @post.size
end
|
#splat_index ⇒ Object
477
478
479
480
481
482
483
484
485
486
487
|
# File 'lib/rubinius/ast/definitions.rb', line 477
def splat_index
return @splat_index if @splat_index
if @splat
index = @names.size
index -= 1 if @block_arg
index -= 1 if @splat.kind_of? Symbol
index -= @post.size
index
end
end
|
#total_args ⇒ Object
473
474
475
|
# File 'lib/rubinius/ast/definitions.rb', line 473
def total_args
@required.size + @optional.size + @post.size
end
|