Class: Rubinius::Melbourne19
- Inherits:
-
Melbourne
show all
- Defined in:
- lib/melbourne.rb,
lib/melbourne/processor.rb
Instance Attribute Summary
Attributes inherited from Melbourne
#magic_handler, #pre_exe, #references, #syntax_errors, #transforms
Instance Method Summary
collapse
-
#process_args(line, required, optional, splat, post, block) ⇒ Object
-
#process_block_pass(line, arguments, body) ⇒ Object
-
#process_encoding(line, name) ⇒ Object
-
#process_for(line, iter, arguments, body) ⇒ Object
-
#process_iter(line, method_send, scope) ⇒ Object
-
#process_lambda(line, scope) ⇒ Object
-
#process_number(line, value) ⇒ Object
-
#process_op_asgn_or(line, var, value) ⇒ Object
-
#process_opt_arg(line, arguments) ⇒ Object
-
#process_postarg(line, into, rest) ⇒ Object
-
#process_postexe(line, body) ⇒ Object
-
#process_preexe(line, body) ⇒ Object
-
#process_scope(line, arguments, body, locals) ⇒ Object
-
#process_super(line, arguments) ⇒ Object
Methods inherited from Melbourne
#add_magic_comment, #add_pre_exe, #initialize, #method_missing, parse_file, #parse_file, parse_string, #parse_string, #process_alias, #process_and, #process_argscat, #process_argspush, #process_array, #process_attrasgn, #process_back_ref, #process_begin, #process_block, #process_block_arg, #process_break, #process_call, #process_case, #process_cdecl, #process_class, #process_colon2, #process_colon3, #process_const, #process_cvar, #process_cvasgn, #process_cvdecl, #process_dangling_node, #process_data, #process_defined, #process_defn, #process_defs, #process_dot2, #process_dot3, #process_dregx, #process_dregx_once, #process_dstr, #process_dsym, #process_dxstr, #process_ensure, #process_evstr, #process_false, #process_fcall, #process_file, #process_fixnum, #process_flip2, #process_flip3, #process_float, #process_gasgn, #process_gvar, #process_hash, #process_iasgn, #process_if, #process_ivar, #process_lasgn, #process_lit, #process_lvar, #process_masgn, #process_match, #process_match2, #process_match3, #process_missing_node, #process_module, #process_negate, #process_next, #process_nil, #process_not, #process_nth_ref, #process_op_asgn1, #process_op_asgn2, #process_op_asgn_and, #process_or, #process_parse_error, #process_redo, #process_regex, #process_resbody, #process_rescue, #process_retry, #process_return, #process_sclass, #process_self, #process_splat, #process_str, #process_svalue, #process_to_ary, #process_transforms, #process_true, #process_undef, #process_until, #process_valias, #process_values, #process_vcall, #process_when, #process_while, #process_xstr, #process_yield, #process_zarray, #process_zsuper, #syntax_error, system_parser
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Rubinius::Melbourne
Instance Method Details
#process_args(line, required, optional, splat, post, block) ⇒ Object
512
513
514
|
# File 'lib/melbourne/processor.rb', line 512
def process_args(line, required, optional, splat, post, block)
AST::FormalArguments19.new line, required, optional, splat, post, block
end
|
#process_block_pass(line, arguments, body) ⇒ Object
516
517
518
|
# File 'lib/melbourne/processor.rb', line 516
def process_block_pass(line, arguments, body)
AST::BlockPass19.new line, arguments, body
end
|
#process_encoding(line, name) ⇒ Object
520
521
522
|
# File 'lib/melbourne/processor.rb', line 520
def process_encoding(line, name)
AST::Encoding.new line, name
end
|
#process_for(line, iter, arguments, body) ⇒ Object
557
558
559
560
561
|
# File 'lib/melbourne/processor.rb', line 557
def process_for(line, iter, arguments, body)
send = AST::Send.new line, iter, :each
send.block = AST::For19.new line, arguments, body
send
end
|
#process_iter(line, method_send, scope) ⇒ Object
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
|
# File 'lib/melbourne/processor.rb', line 528
def process_iter(line, method_send, scope)
ary = scope && scope.array || []
arguments = nil
if ary.first.kind_of? AST::FormalArguments
arguments = scope.array.shift
end
unless arguments
arguments = AST::FormalArguments19.new line, nil, nil, nil, nil, nil
end
case ary.size
when 0
body = nil
when 1
if scope.locals
body = scope
else
body = scope.array.shift
end
else
body = scope
end
method_send.block = AST::Iter19.new line, arguments, body
method_send
end
|
#process_lambda(line, scope) ⇒ Object
563
564
565
566
567
568
569
570
571
572
573
574
575
576
|
# File 'lib/melbourne/processor.rb', line 563
def process_lambda(line, scope)
arguments = scope.array.shift
if scope.array.size == 1
body = scope.array.shift
else
body = scope
end
receiver = AST::Self.new line
method_send = AST::Send.new line, receiver, :lambda, true
method_send.block = AST::Iter19.new line, arguments, body
method_send
end
|
#process_number(line, value) ⇒ Object
578
579
580
581
582
583
584
585
|
# File 'lib/melbourne/processor.rb', line 578
def process_number(line, value)
case value
when Fixnum
AST::FixnumLiteral.new line, value
when Bignum
AST::NumberLiteral.new line, value
end
end
|
#process_op_asgn_or(line, var, value) ⇒ Object
587
588
589
|
# File 'lib/melbourne/processor.rb', line 587
def process_op_asgn_or(line, var, value)
AST::OpAssignOr19.new line, var, value
end
|
#process_opt_arg(line, arguments) ⇒ Object
591
592
593
|
# File 'lib/melbourne/processor.rb', line 591
def process_opt_arg(line, arguments)
AST::Block.new line, arguments
end
|
#process_postarg(line, into, rest) ⇒ Object
524
525
526
|
# File 'lib/melbourne/processor.rb', line 524
def process_postarg(line, into, rest)
AST::PostArg.new line, into, rest
end
|
#process_postexe(line, body) ⇒ Object
595
596
597
598
599
|
# File 'lib/melbourne/processor.rb', line 595
def process_postexe(line, body)
node = AST::Send.new line, AST::Self.new(line), :at_exit, true
node.block = AST::Iter.new line, nil, body
node
end
|
#process_preexe(line, body) ⇒ Object
601
602
603
604
605
606
|
# File 'lib/melbourne/processor.rb', line 601
def process_preexe(line, body)
node = AST::PreExe19.new line
node.block = AST::Iter19.new line, nil, body
add_pre_exe node
node
end
|
#process_scope(line, arguments, body, locals) ⇒ Object
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
|
# File 'lib/melbourne/processor.rb', line 608
def process_scope(line, arguments, body, locals)
case body
when AST::Begin
if body.rescue.kind_of? AST::NilLiteral
return nil unless arguments
end
body = AST::Block.new line, [body.rescue]
when AST::Block
ary = body.array
if ary.size > 1 and
ary.first.kind_of?(AST::Begin) and
ary.first.rescue.kind_of?(AST::NilLiteral)
ary.shift
end
when nil
else
body = AST::Block.new line, [body]
end
if arguments and body
body.array.unshift arguments
end
body.locals = locals if locals
body
end
|
#process_super(line, arguments) ⇒ Object
637
638
639
640
641
642
643
644
645
646
647
648
649
|
# File 'lib/melbourne/processor.rb', line 637
def process_super(line, arguments)
if arguments.kind_of? AST::BlockPass
block = arguments
arguments = block.arguments
block.arguments = nil
else
block = nil
end
node = AST::Super.new line, arguments
node.block = block
node
end
|