rubinius-processor 1.3.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17bb63303deae27551913ea385e8fc323fc483df
4
- data.tar.gz: f4557fd0bc40e7e5c209b69209a9e43ed8c4c06c
3
+ metadata.gz: b91c4c695d269d32bf32e778acfd5bb3a0a5a885
4
+ data.tar.gz: 9598db1ec8feba3f114d9876abbb93ead8aaf5b9
5
5
  SHA512:
6
- metadata.gz: d826cb8efec9f9012ef95fbf27329bd4d9c9a8eb9399d32ac5b1c4ff3fd70e3a0d5402db56c8586fd8d4a90a4b59fd2631f51279bc7a2e4f0c903c6052eb6605
7
- data.tar.gz: ba3f008c8d171c0aeb96867925e2b68bf7cebf20107a18ace235f8dd5aa6bc4181e2d69cc57d70da3e05d4378259b8c08d48c52120496f3811732854651d27bc
6
+ metadata.gz: aee6f2e2769f414a0ab098a4c4c947e6533eb0840dedff19d8a6c97f9ca835b689109580b0ec5db415a761a26987abea2a26be6bd8c18e23450a95591c16972f
7
+ data.tar.gz: b9fa3229e3da0a6dcf42d91d724fa6dd697c212cdc20e98346b2657283ba4fdd87f2502873b4b34cf401dc71f07ca48398890b56bfd9f38322b97e13ec9a690c
@@ -1,4 +1,4 @@
1
- module CodeTools
1
+ module Rubinius::ToolSet.current::TS
2
2
  # TODO: This will change to:
3
3
  # class Processor
4
4
  class Melbourne
@@ -20,7 +20,7 @@ module CodeTools
20
20
 
21
21
  # TODO: remove when all processors are defined
22
22
  def method_missing(sym, *args)
23
- puts "#{self.class}#method_missing: #{sym} #{args.map { |x| x.inspect}.join(", ")}"
23
+ puts " *** missing #{sym} #{args.map { |x| x.inspect}.join(", ")}"
24
24
  end
25
25
 
26
26
 
@@ -34,8 +34,8 @@ module CodeTools
34
34
  AST::And.new line, left, right
35
35
  end
36
36
 
37
- def process_args(line, args, defaults, splat)
38
- AST::FormalArguments.new line, args, defaults, splat
37
+ def process_args(line, required, optional, splat, post, block)
38
+ AST::FormalArguments19.new line, required, optional, splat, post, block
39
39
  end
40
40
 
41
41
  def process_argscat(line, array, rest)
@@ -74,14 +74,8 @@ module CodeTools
74
74
  AST::BlockArgument.new line, name
75
75
  end
76
76
 
77
- def process_block_pass(line, method_send, body)
78
- node = AST::BlockPass.new line, body
79
- if method_send
80
- method_send.block = node
81
- method_send
82
- else
83
- node
84
- end
77
+ def process_block_pass(line, arguments, body)
78
+ AST::BlockPass19.new line, arguments, body
85
79
  end
86
80
 
87
81
  def process_break(line, value)
@@ -208,6 +202,10 @@ module CodeTools
208
202
  AST::DynamicExecuteString.new line, str, array
209
203
  end
210
204
 
205
+ def process_encoding(line, name)
206
+ AST::Encoding.new line, name
207
+ end
208
+
211
209
  def process_ensure(line, body, ensr)
212
210
  AST::Ensure.new line, body, ensr
213
211
  end
@@ -271,9 +269,9 @@ module CodeTools
271
269
  end
272
270
 
273
271
  def process_for(line, iter, arguments, body)
274
- method_send = AST::Send.new line, iter, :each
275
- method_send.block = AST::For.new line, arguments, body
276
- method_send
272
+ send = AST::Send.new line, iter, :each
273
+ send.block = AST::For19.new line, arguments, body
274
+ send
277
275
  end
278
276
 
279
277
  def process_gasgn(line, name, expr)
@@ -296,8 +294,32 @@ module CodeTools
296
294
  AST::If.new line, cond, body, else_body
297
295
  end
298
296
 
299
- def process_iter(line, method_send, arguments, body)
300
- method_send.block = AST::Iter.new line, arguments, body
297
+ def process_iter(line, method_send, scope)
298
+ ary = scope && scope.array || []
299
+ arguments = nil
300
+
301
+ if ary.first.kind_of? AST::FormalArguments
302
+ arguments = scope.array.shift
303
+ end
304
+
305
+ unless arguments
306
+ arguments = AST::FormalArguments19.new line, nil, nil, nil, nil, nil
307
+ end
308
+
309
+ case ary.size
310
+ when 0
311
+ body = nil
312
+ when 1
313
+ if scope.locals
314
+ body = scope
315
+ else
316
+ body = scope.array.shift
317
+ end
318
+ else
319
+ body = scope
320
+ end
321
+
322
+ method_send.block = AST::Iter19.new line, arguments, body
301
323
  method_send
302
324
  end
303
325
 
@@ -305,6 +327,21 @@ module CodeTools
305
327
  AST::InstanceVariableAccess.new line, name
306
328
  end
307
329
 
330
+ def process_lambda(line, scope)
331
+ arguments = scope.array.shift
332
+ if scope.array.size == 1
333
+ body = scope.array.shift
334
+ else
335
+ body = scope
336
+ end
337
+
338
+ receiver = AST::Self.new line
339
+ method_send = AST::Send.new line, receiver, :lambda, true
340
+
341
+ method_send.block = AST::Iter19.new line, arguments, body
342
+ method_send
343
+ end
344
+
308
345
  def process_lasgn(line, name, value)
309
346
  AST::LocalVariableAssignment.new line, name, value
310
347
  end
@@ -357,9 +394,7 @@ module CodeTools
357
394
  AST::NthRef.new line, ref
358
395
  end
359
396
 
360
- # TODO: Fix the way 1.8 parser handles this
361
- def process_number(line, base, str)
362
- value = str.to_i base
397
+ def process_number(line, value)
363
398
  case value
364
399
  when Fixnum
365
400
  AST::FixnumLiteral.new line, value
@@ -369,11 +404,11 @@ module CodeTools
369
404
  end
370
405
 
371
406
  def process_op_asgn1(line, receiver, index, op, value)
372
- AST::OpAssignElement.new line, receiver, index, op, value
407
+ AST::OpAssign1.new line, receiver, index, op, value
373
408
  end
374
409
 
375
410
  def process_op_asgn2(line, receiver, name, op, value)
376
- AST::OpAssignAttribute.new line, receiver, name, op, value
411
+ AST::OpAssign2.new line, receiver, name, op, value
377
412
  end
378
413
 
379
414
  def process_op_asgn_and(line, var, value)
@@ -381,19 +416,30 @@ module CodeTools
381
416
  end
382
417
 
383
418
  def process_op_asgn_or(line, var, value)
384
- AST::OpAssignOr.new line, var, value
419
+ AST::OpAssignOr19.new line, var, value
420
+ end
421
+
422
+ def process_opt_arg(line, arguments)
423
+ AST::Block.new line, arguments
385
424
  end
386
425
 
387
426
  def process_or(line, left, right)
388
427
  AST::Or.new line, left, right
389
428
  end
390
429
 
391
- def process_postexe(line)
392
- AST::Send.new line, AST::Self.new(line), :at_exit, true
430
+ def process_postarg(line, into, rest)
431
+ AST::PostArg.new line, into, rest
432
+ end
433
+
434
+ def process_postexe(line, body)
435
+ node = AST::Send.new line, AST::Self.new(line), :at_exit, true
436
+ node.block = AST::Iter.new line, nil, body
437
+ node
393
438
  end
394
439
 
395
- def process_preexe(line)
396
- node = AST::PreExe.new line
440
+ def process_preexe(line, body)
441
+ node = AST::PreExe19.new line
442
+ node.block = AST::Iter19.new line, nil, body
397
443
  add_pre_exe node
398
444
  node
399
445
  end
@@ -426,12 +472,33 @@ module CodeTools
426
472
  AST::SClass.new line, receiver, body
427
473
  end
428
474
 
429
- def process_scope(line, body)
430
- if body.kind_of? AST::Block
431
- body
432
- elsif body
433
- AST::Block.new line, [body]
475
+ def process_scope(line, arguments, body, locals)
476
+ case body
477
+ when AST::Begin
478
+ if body.rescue.kind_of? AST::NilLiteral
479
+ return nil unless arguments
480
+ end
481
+ body = AST::Block.new line, [body.rescue]
482
+ when AST::Block
483
+ ary = body.array
484
+ if ary.size > 1 and
485
+ ary.first.kind_of?(AST::Begin) and
486
+ ary.first.rescue.kind_of?(AST::NilLiteral)
487
+ ary.shift
488
+ end
489
+ when nil
490
+ # Nothing
491
+ else
492
+ body = AST::Block.new line, [body]
434
493
  end
494
+
495
+ if arguments and body
496
+ body.array.unshift arguments
497
+ end
498
+
499
+ body.locals = locals if locals
500
+
501
+ body
435
502
  end
436
503
 
437
504
  def process_self(line)
@@ -447,7 +514,17 @@ module CodeTools
447
514
  end
448
515
 
449
516
  def process_super(line, arguments)
450
- AST::Super.new line, arguments
517
+ if arguments.kind_of? AST::BlockPass
518
+ block = arguments
519
+ arguments = block.arguments
520
+ block.arguments = nil
521
+ else
522
+ block = nil
523
+ end
524
+
525
+ node = AST::Super.new line, arguments
526
+ node.block = block
527
+ node
451
528
  end
452
529
 
453
530
  def process_svalue(line, expr)
@@ -513,4 +590,145 @@ module CodeTools
513
590
  AST::ZSuper.new line
514
591
  end
515
592
  end
593
+
594
+ class Melbourne19 < Melbourne
595
+ def process_args(line, required, optional, splat, post, block)
596
+ AST::FormalArguments19.new line, required, optional, splat, post, block
597
+ end
598
+
599
+ def process_block_pass(line, arguments, body)
600
+ AST::BlockPass19.new line, arguments, body
601
+ end
602
+
603
+ def process_encoding(line, name)
604
+ AST::Encoding.new line, name
605
+ end
606
+
607
+ def process_postarg(line, into, rest)
608
+ AST::PostArg.new line, into, rest
609
+ end
610
+
611
+ def process_iter(line, method_send, scope)
612
+ ary = scope && scope.array || []
613
+ arguments = nil
614
+
615
+ if ary.first.kind_of? AST::FormalArguments
616
+ arguments = scope.array.shift
617
+ end
618
+
619
+ unless arguments
620
+ arguments = AST::FormalArguments19.new line, nil, nil, nil, nil, nil
621
+ end
622
+
623
+ case ary.size
624
+ when 0
625
+ body = nil
626
+ when 1
627
+ if scope.locals
628
+ body = scope
629
+ else
630
+ body = scope.array.shift
631
+ end
632
+ else
633
+ body = scope
634
+ end
635
+
636
+ method_send.block = AST::Iter19.new line, arguments, body
637
+ method_send
638
+ end
639
+
640
+ def process_for(line, iter, arguments, body)
641
+ send = AST::Send.new line, iter, :each
642
+ send.block = AST::For19.new line, arguments, body
643
+ send
644
+ end
645
+
646
+ def process_lambda(line, scope)
647
+ arguments = scope.array.shift
648
+ if scope.array.size == 1
649
+ body = scope.array.shift
650
+ else
651
+ body = scope
652
+ end
653
+
654
+ receiver = AST::Self.new line
655
+ method_send = AST::Send.new line, receiver, :lambda, true
656
+
657
+ method_send.block = AST::Iter19.new line, arguments, body
658
+ method_send
659
+ end
660
+
661
+ def process_number(line, value)
662
+ case value
663
+ when Fixnum
664
+ AST::FixnumLiteral.new line, value
665
+ when Bignum
666
+ AST::NumberLiteral.new line, value
667
+ end
668
+ end
669
+
670
+ def process_op_asgn_or(line, var, value)
671
+ AST::OpAssignOr19.new line, var, value
672
+ end
673
+
674
+ def process_opt_arg(line, arguments)
675
+ AST::Block.new line, arguments
676
+ end
677
+
678
+ def process_postexe(line, body)
679
+ node = AST::Send.new line, AST::Self.new(line), :at_exit, true
680
+ node.block = AST::Iter.new line, nil, body
681
+ node
682
+ end
683
+
684
+ def process_preexe(line, body)
685
+ node = AST::PreExe19.new line
686
+ node.block = AST::Iter19.new line, nil, body
687
+ add_pre_exe node
688
+ node
689
+ end
690
+
691
+ def process_scope(line, arguments, body, locals)
692
+ case body
693
+ when AST::Begin
694
+ if body.rescue.kind_of? AST::NilLiteral
695
+ return nil unless arguments
696
+ end
697
+ body = AST::Block.new line, [body.rescue]
698
+ when AST::Block
699
+ ary = body.array
700
+ if ary.size > 1 and
701
+ ary.first.kind_of?(AST::Begin) and
702
+ ary.first.rescue.kind_of?(AST::NilLiteral)
703
+ ary.shift
704
+ end
705
+ when nil
706
+ # Nothing
707
+ else
708
+ body = AST::Block.new line, [body]
709
+ end
710
+
711
+ if arguments and body
712
+ body.array.unshift arguments
713
+ end
714
+
715
+ body.locals = locals if locals
716
+
717
+ body
718
+ end
719
+
720
+ def process_super(line, arguments)
721
+ if arguments.kind_of? AST::BlockPass
722
+ block = arguments
723
+ arguments = block.arguments
724
+ block.arguments = nil
725
+ else
726
+ block = nil
727
+ end
728
+
729
+ node = AST::Super.new line, arguments
730
+ node.block = block
731
+ node
732
+ end
733
+ end
516
734
  end
@@ -1,5 +1,5 @@
1
- module CodeTools
1
+ module Rubinius::ToolSet.current::TS
2
2
  class Processor
3
- VERSION = "1.3.0"
3
+ VERSION = "2.0.1"
4
4
  end
5
5
  end
@@ -1,15 +1,16 @@
1
1
  # coding: utf-8
2
+ require 'rubinius/toolset'
2
3
  require './lib/rubinius/processor/version'
3
4
 
4
5
  Gem::Specification.new do |spec|
5
6
  spec.name = "rubinius-processor"
6
- spec.version = CodeTools::Processor::VERSION
7
+ spec.version = Rubinius::ToolSet.current::TS::Processor::VERSION
7
8
  spec.authors = ["Brian Shirai"]
8
9
  spec.email = ["brixen@gmail.com"]
9
10
  spec.description = %q{Converts Melbourne parse tree into an AST.}
10
11
  spec.summary = %q{Converts Melbourne parse tree into an AST.}
11
12
  spec.homepage = "https://github.com/rubinius/rubinius-processor"
12
- spec.license = "BSD"
13
+ spec.license = "MIT"
13
14
 
14
15
  spec.files = `git ls-files`.split($/)
15
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubinius-processor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Shirai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-14 00:00:00.000000000 Z
11
+ date: 2013-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  description: Converts Melbourne parse tree into an AST.
@@ -45,7 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - ".gitignore"
48
+ - .gitignore
49
49
  - Gemfile
50
50
  - LICENSE
51
51
  - README.md
@@ -56,7 +56,7 @@ files:
56
56
  - rubinius-processor.gemspec
57
57
  homepage: https://github.com/rubinius/rubinius-processor
58
58
  licenses:
59
- - BSD
59
+ - MIT
60
60
  metadata: {}
61
61
  post_install_message:
62
62
  rdoc_options: []
@@ -64,17 +64,17 @@ require_paths:
64
64
  - lib
65
65
  required_ruby_version: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ">="
72
+ - - '>='
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.2.2
77
+ rubygems_version: 2.0.7
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Converts Melbourne parse tree into an AST.