rubinius-melbourne 2.2.0.0 → 2.2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,7 @@
19
19
 
20
20
  #include "namespace.h"
21
21
  #include "melbourne.hpp"
22
+ #include "missing.hpp"
22
23
  #include "grammar.hpp"
23
24
  #include "parser_state.hpp"
24
25
  #include "visitor.hpp"
@@ -7305,15 +7306,12 @@ parser_negate_lit(rb_parser_state* parser_state, NODE *node)
7305
7306
  case T_FIXNUM:
7306
7307
  node->nd_lit = LONG2FIX(-FIX2LONG(node->nd_lit));
7307
7308
  break;
7308
- case T_BIGNUM:
7309
- case T_RATIONAL:
7310
- case T_COMPLEX:
7311
- node->nd_lit = REF(rb_funcall(node->nd_lit, rb_intern("-@"), 0, 0));
7312
- break;
7313
7309
  case T_FLOAT:
7314
7310
  node->nd_lit = REF(rb_float_new(-NUM2DBL(node->nd_lit)));
7315
7311
  break;
7312
+ case T_BIGNUM:
7316
7313
  default:
7314
+ node->nd_lit = REF(rb_funcall(node->nd_lit, rb_intern("-@"), 0, 0));
7317
7315
  break;
7318
7316
  }
7319
7317
  return node;
@@ -0,0 +1,29 @@
1
+ #ifndef MEL_MISSING_HPP
2
+ #define MEL_MISSING_HPP
3
+
4
+ extern "C" {
5
+
6
+ #ifndef rb_long2int
7
+ #if SIZEOF_INT < SIZEOF_LONG
8
+ int rb_long2int(long n) {
9
+ int i = (int)n;
10
+ if((long)i != n) {
11
+ rb_raise(rb_eRangeError, "long value is outside of range of int");
12
+ }
13
+ return i;
14
+ }
15
+ #else
16
+ #define rb_long2int(n) ((int)n)
17
+ #endif
18
+ #endif
19
+
20
+ #ifndef rb_rational_new
21
+ VALUE rb_rational_new(VALUE a, VALUE b) {
22
+ VALUE cls = rb_const_get(rb_cObject, rb_intern("Rational"));
23
+ return rb_funcall(cls, rb_intern("new"), 2, a, b);
24
+ }
25
+ #endif
26
+
27
+ } /* extern "C" */
28
+
29
+ #endif
@@ -1,5 +1,5 @@
1
1
  module CodeTools
2
2
  class Melbourne
3
- VERSION = "2.2.0.0"
3
+ VERSION = "2.2.1.0"
4
4
  end
5
5
  end
@@ -21,8 +21,9 @@ describe "An Attrasgn node" do
21
21
  [:call, nil, :a, [:arglist]],
22
22
  :[]=,
23
23
  [:arglist,
24
- [:splat, [:call, nil, :b, [:arglist]]],
25
- [:call, nil, :c, [:arglist]]]]
24
+ [:argspush,
25
+ [:splat, [:call, nil, :b, [:arglist]]],
26
+ [:call, nil, :c, [:arglist]]]]]
26
27
  end
27
28
 
28
29
  parse "a[b, *c] = d" do
@@ -30,10 +31,11 @@ describe "An Attrasgn node" do
30
31
  [:call, nil, :a, [:arglist]],
31
32
  :[]=,
32
33
  [:arglist,
33
- [:argscat,
34
- [:array, [:call, nil, :b, [:arglist]]],
35
- [:call, nil, :c, [:arglist]]],
36
- [:call, nil, :d, [:arglist]]]]
34
+ [:argspush,
35
+ [:argscat,
36
+ [:array, [:call, nil, :b, [:arglist]]],
37
+ [:call, nil, :c, [:arglist]]],
38
+ [:call, nil, :d, [:arglist]]]]]
37
39
  end
38
40
 
39
41
  parse "a[b, *c] = *d" do
@@ -41,10 +43,11 @@ describe "An Attrasgn node" do
41
43
  [:call, nil, :a, [:arglist]],
42
44
  :[]=,
43
45
  [:arglist,
44
- [:argscat,
45
- [:array, [:call, nil, :b, [:arglist]]],
46
- [:call, nil, :c, [:arglist]]],
47
- [:splat, [:call, nil, :d, [:arglist]]]]]
46
+ [:argspush,
47
+ [:argscat,
48
+ [:array, [:call, nil, :b, [:arglist]]],
49
+ [:call, nil, :c, [:arglist]]],
50
+ [:splat, [:call, nil, :d, [:arglist]]]]]]
48
51
  end
49
52
 
50
53
  parse "a[b, *c] = d, e" do
@@ -52,10 +55,11 @@ describe "An Attrasgn node" do
52
55
  [:call, nil, :a, [:arglist]],
53
56
  :[]=,
54
57
  [:arglist,
55
- [:argscat,
56
- [:array, [:call, nil, :b, [:arglist]]],
57
- [:call, nil, :c, [:arglist]]],
58
- [:array, [:call, nil, :d, [:arglist]], [:call, nil, :e, [:arglist]]]]]
58
+ [:argspush,
59
+ [:argscat,
60
+ [:array, [:call, nil, :b, [:arglist]]],
61
+ [:call, nil, :c, [:arglist]]],
62
+ [:array, [:call, nil, :d, [:arglist]], [:call, nil, :e, [:arglist]]]]]]
59
63
  end
60
64
 
61
65
  parse "a[42] = 24" do
data/spec/defn_spec.rb CHANGED
@@ -70,7 +70,7 @@ describe "A Defn node" do
70
70
  def m(a:) end
71
71
  ruby
72
72
 
73
- [:defn, :m, [:args, :a, [:block, [:a]]], [:scope, [:block, [:nil]]]]
73
+ [:defn, :m, [:args, :a, [:kwargs, [:a]]], [:scope, [:block, [:nil]]]]
74
74
  end
75
75
 
76
76
  parse <<-ruby do
@@ -79,7 +79,7 @@ describe "A Defn node" do
79
79
 
80
80
  [:defn,
81
81
  :m,
82
- [:args, :a, [:block, [:a], [[:lasgn, :a, [:lit, 1]]]]],
82
+ [:args, :a, [:kwargs, [:a], [[:lasgn, :a, [:lit, 1]]]]],
83
83
  [:scope, [:block, [:nil]]]]
84
84
  end
85
85
 
@@ -87,14 +87,14 @@ describe "A Defn node" do
87
87
  def m(**) end
88
88
  ruby
89
89
 
90
- [:defn, :m, [:args, :**, [:block, [:**]]], [:scope, [:block, [:nil]]]]
90
+ [:defn, :m, [:args, :**, [:kwargs, [:**]]], [:scope, [:block, [:nil]]]]
91
91
  end
92
92
 
93
93
  parse <<-ruby do
94
94
  def m(**k) end
95
95
  ruby
96
96
 
97
- [:defn, :m, [:args, :"**k", [:block, [:"**k"]]], [:scope, [:block, [:nil]]]]
97
+ [:defn, :m, [:args, :"**k", [:kwargs, [:"**k"]]], [:scope, [:block, [:nil]]]]
98
98
  end
99
99
 
100
100
  parse <<-ruby do
@@ -268,7 +268,7 @@ describe "A Defn node" do
268
268
  def m(a, b:) end
269
269
  ruby
270
270
 
271
- [:defn, :m, [:args, :a, :b, [:block, [:b]]], [:scope, [:block, [:nil]]]]
271
+ [:defn, :m, [:args, :a, :b, [:kwargs, [:b]]], [:scope, [:block, [:nil]]]]
272
272
  end
273
273
 
274
274
  parse <<-ruby do
@@ -277,7 +277,7 @@ describe "A Defn node" do
277
277
 
278
278
  [:defn,
279
279
  :m,
280
- [:args, :a, :b, [:block, [:b], [[:lasgn, :b, [:lit, 1]]]]],
280
+ [:args, :a, :b, [:kwargs, [:b], [[:lasgn, :b, [:lit, 1]]]]],
281
281
  [:scope, [:block, [:nil]]]]
282
282
  end
283
283
 
@@ -285,7 +285,7 @@ describe "A Defn node" do
285
285
  def m(a, **) end
286
286
  ruby
287
287
 
288
- [:defn, :m, [:args, :a, :**, [:block, [:**]]], [:scope, [:block, [:nil]]]]
288
+ [:defn, :m, [:args, :a, :**, [:kwargs, [:**]]], [:scope, [:block, [:nil]]]]
289
289
  end
290
290
 
291
291
  parse <<-ruby do
@@ -294,7 +294,7 @@ describe "A Defn node" do
294
294
 
295
295
  [:defn,
296
296
  :m,
297
- [:args, :a, :"**k", [:block, [:"**k"]]],
297
+ [:args, :a, :"**k", [:kwargs, [:"**k"]]],
298
298
  [:scope, [:block, [:nil]]]]
299
299
  end
300
300
 
@@ -463,7 +463,7 @@ describe "A Defn node" do
463
463
 
464
464
  [:defn,
465
465
  :m,
466
- [:args, :a, :b, [:block, [:lasgn, :a, [:lit, 1]]], [:block, [:b]]],
466
+ [:args, :a, :b, [:block, [:lasgn, :a, [:lit, 1]]], [:kwargs, [:b]]],
467
467
  [:scope, [:block, [:nil]]]]
468
468
  end
469
469
 
@@ -477,7 +477,7 @@ describe "A Defn node" do
477
477
  :a,
478
478
  :b,
479
479
  [:block, [:lasgn, :a, [:lit, 1]]],
480
- [:block, [:b], [[:lasgn, :b, [:lit, 2]]]]],
480
+ [:kwargs, [:b], [[:lasgn, :b, [:lit, 2]]]]],
481
481
  [:scope, [:block, [:nil]]]]
482
482
  end
483
483
 
@@ -487,7 +487,7 @@ describe "A Defn node" do
487
487
 
488
488
  [:defn,
489
489
  :m,
490
- [:args, :a, :**, [:block, [:lasgn, :a, [:lit, 1]]], [:block, [:**]]],
490
+ [:args, :a, :**, [:block, [:lasgn, :a, [:lit, 1]]], [:kwargs, [:**]]],
491
491
  [:scope, [:block, [:nil]]]]
492
492
  end
493
493
 
@@ -497,7 +497,7 @@ describe "A Defn node" do
497
497
 
498
498
  [:defn,
499
499
  :m,
500
- [:args, :a, :"**k", [:block, [:lasgn, :a, [:lit, 1]]], [:block, [:"**k"]]],
500
+ [:args, :a, :"**k", [:block, [:lasgn, :a, [:lit, 1]]], [:kwargs, [:"**k"]]],
501
501
  [:scope, [:block, [:nil]]]]
502
502
  end
503
503
 
@@ -529,14 +529,14 @@ describe "A Defn node" do
529
529
  def m(*, a:) end
530
530
  ruby
531
531
 
532
- [:defn, :m, [:args, :*, :a, [:block, [:a]]], [:scope, [:block, [:nil]]]]
532
+ [:defn, :m, [:args, :*, :a, [:kwargs, [:a]]], [:scope, [:block, [:nil]]]]
533
533
  end
534
534
 
535
535
  parse <<-ruby do
536
536
  def m(*a, b:) end
537
537
  ruby
538
538
 
539
- [:defn, :m, [:args, :"*a", :b, [:block, [:b]]], [:scope, [:block, [:nil]]]]
539
+ [:defn, :m, [:args, :"*a", :b, [:kwargs, [:b]]], [:scope, [:block, [:nil]]]]
540
540
  end
541
541
 
542
542
  parse <<-ruby do
@@ -545,7 +545,7 @@ describe "A Defn node" do
545
545
 
546
546
  [:defn,
547
547
  :m,
548
- [:args, :*, :a, [:block, [:a], [[:lasgn, :a, [:lit, 1]]]]],
548
+ [:args, :*, :a, [:kwargs, [:a], [[:lasgn, :a, [:lit, 1]]]]],
549
549
  [:scope, [:block, [:nil]]]]
550
550
  end
551
551
 
@@ -555,7 +555,7 @@ describe "A Defn node" do
555
555
 
556
556
  [:defn,
557
557
  :m,
558
- [:args, :"*a", :b, [:block, [:b], [[:lasgn, :b, [:lit, 1]]]]],
558
+ [:args, :"*a", :b, [:kwargs, [:b], [[:lasgn, :b, [:lit, 1]]]]],
559
559
  [:scope, [:block, [:nil]]]]
560
560
  end
561
561
 
@@ -563,14 +563,14 @@ describe "A Defn node" do
563
563
  def m(*, **) end
564
564
  ruby
565
565
 
566
- [:defn, :m, [:args, :*, :**, [:block, [:**]]], [:scope, [:block, [:nil]]]]
566
+ [:defn, :m, [:args, :*, :**, [:kwargs, [:**]]], [:scope, [:block, [:nil]]]]
567
567
  end
568
568
 
569
569
  parse <<-ruby do
570
570
  def m(*a, **) end
571
571
  ruby
572
572
 
573
- [:defn, :m, [:args, :"*a", :**, [:block, [:**]]], [:scope, [:block, [:nil]]]]
573
+ [:defn, :m, [:args, :"*a", :**, [:kwargs, [:**]]], [:scope, [:block, [:nil]]]]
574
574
  end
575
575
 
576
576
  parse <<-ruby do
@@ -579,7 +579,7 @@ describe "A Defn node" do
579
579
 
580
580
  [:defn,
581
581
  :m,
582
- [:args, :*, :"**k", [:block, [:"**k"]]],
582
+ [:args, :*, :"**k", [:kwargs, [:"**k"]]],
583
583
  [:scope, [:block, [:nil]]]]
584
584
  end
585
585
 
@@ -589,7 +589,7 @@ describe "A Defn node" do
589
589
 
590
590
  [:defn,
591
591
  :m,
592
- [:args, :"*a", :"**k", [:block, [:"**k"]]],
592
+ [:args, :"*a", :"**k", [:kwargs, [:"**k"]]],
593
593
  [:scope, [:block, [:nil]]]]
594
594
  end
595
595
 
@@ -611,7 +611,7 @@ describe "A Defn node" do
611
611
  def m(a:, b:) end
612
612
  ruby
613
613
 
614
- [:defn, :m, [:args, :a, :b, [:block, [:a, :b]]], [:scope, [:block, [:nil]]]]
614
+ [:defn, :m, [:args, :a, :b, [:kwargs, [:a, :b]]], [:scope, [:block, [:nil]]]]
615
615
  end
616
616
 
617
617
  parse <<-ruby do
@@ -620,7 +620,7 @@ describe "A Defn node" do
620
620
 
621
621
  [:defn,
622
622
  :m,
623
- [:args, :a, :b, [:block, [:a, :b], [[:lasgn, :b, [:lit, 1]]]]],
623
+ [:args, :a, :b, [:kwargs, [:a, :b], [[:lasgn, :b, [:lit, 1]]]]],
624
624
  [:scope, [:block, [:nil]]]]
625
625
  end
626
626
 
@@ -628,7 +628,7 @@ describe "A Defn node" do
628
628
  def m(a:, **) end
629
629
  ruby
630
630
 
631
- [:defn, :m, [:args, :a, :**, [:block, [:a, :**]]], [:scope, [:block, [:nil]]]]
631
+ [:defn, :m, [:args, :a, :**, [:kwargs, [:a, :**]]], [:scope, [:block, [:nil]]]]
632
632
  end
633
633
 
634
634
  parse <<-ruby do
@@ -637,7 +637,7 @@ describe "A Defn node" do
637
637
 
638
638
  [:defn,
639
639
  :m,
640
- [:args, :a, :"**k", [:block, [:a, :"**k"]]],
640
+ [:args, :a, :"**k", [:kwargs, [:a, :"**k"]]],
641
641
  [:scope, [:block, [:nil]]]]
642
642
  end
643
643
 
@@ -645,7 +645,7 @@ describe "A Defn node" do
645
645
  def m(a:, &b) end
646
646
  ruby
647
647
 
648
- [:defn, :m, [:args, :a, :"&b", [:block, [:a]]], [:scope, [:block, [:nil]]]]
648
+ [:defn, :m, [:args, :a, :"&b", [:kwargs, [:a]]], [:scope, [:block, [:nil]]]]
649
649
  end
650
650
 
651
651
  parse <<-ruby do
@@ -654,7 +654,7 @@ describe "A Defn node" do
654
654
 
655
655
  [:defn,
656
656
  :m,
657
- [:args, :a, :b, [:block, [:a, :b], [[:lasgn, :a, [:lit, 1]]]]],
657
+ [:args, :a, :b, [:kwargs, [:a, :b], [[:lasgn, :a, [:lit, 1]]]]],
658
658
  [:scope, [:block, [:nil]]]]
659
659
  end
660
660
 
@@ -667,13 +667,13 @@ describe "A Defn node" do
667
667
  [:args,
668
668
  :a,
669
669
  :b,
670
- [:block,
670
+ [:kwargs,
671
671
  [:a, :b],
672
672
  [[:lasgn,
673
673
  :a,
674
674
  [:defn,
675
675
  :m,
676
- [:args, :a, [:block, [:a], [[:lasgn, :a, [:lit, 1]]]]],
676
+ [:args, :a, [:kwargs, [:a], [[:lasgn, :a, [:lit, 1]]]]],
677
677
  [:scope, [:block, [:lvar, :a]]]]]]]],
678
678
  [:scope, [:block, [:nil]]]]
679
679
  end
@@ -687,7 +687,7 @@ describe "A Defn node" do
687
687
  [:args,
688
688
  :a,
689
689
  :b,
690
- [:block, [:a, :b], [[:lasgn, :a, [:lit, 1]], [:lasgn, :b, [:lit, 2]]]]],
690
+ [:kwargs, [:a, :b], [[:lasgn, :a, [:lit, 1]], [:lasgn, :b, [:lit, 2]]]]],
691
691
  [:scope, [:block, [:nil]]]]
692
692
  end
693
693
 
@@ -697,7 +697,7 @@ describe "A Defn node" do
697
697
 
698
698
  [:defn,
699
699
  :m,
700
- [:args, :a, :**, [:block, [:a, :**], [[:lasgn, :a, [:lit, 1]]]]],
700
+ [:args, :a, :**, [:kwargs, [:a, :**], [[:lasgn, :a, [:lit, 1]]]]],
701
701
  [:scope, [:block, [:nil]]]]
702
702
  end
703
703
 
@@ -707,7 +707,7 @@ describe "A Defn node" do
707
707
 
708
708
  [:defn,
709
709
  :m,
710
- [:args, :a, :"**k", [:block, [:a, :"**k"], [[:lasgn, :a, [:lit, 1]]]]],
710
+ [:args, :a, :"**k", [:kwargs, [:a, :"**k"], [[:lasgn, :a, [:lit, 1]]]]],
711
711
  [:scope, [:block, [:nil]]]]
712
712
  end
713
713
 
@@ -717,7 +717,7 @@ describe "A Defn node" do
717
717
 
718
718
  [:defn,
719
719
  :m,
720
- [:args, :a, :"&b", [:block, [:a], [[:lasgn, :a, [:lit, 1]]]]],
720
+ [:args, :a, :"&b", [:kwargs, [:a], [[:lasgn, :a, [:lit, 1]]]]],
721
721
  [:scope, [:block, [:nil]]]]
722
722
  end
723
723
 
@@ -725,7 +725,7 @@ describe "A Defn node" do
725
725
  def m(**, &b) end
726
726
  ruby
727
727
 
728
- [:defn, :m, [:args, :**, :"&b", [:block, [:**]]], [:scope, [:block, [:nil]]]]
728
+ [:defn, :m, [:args, :**, :"&b", [:kwargs, [:**]]], [:scope, [:block, [:nil]]]]
729
729
  end
730
730
 
731
731
  parse <<-ruby do
@@ -734,7 +734,7 @@ describe "A Defn node" do
734
734
 
735
735
  [:defn,
736
736
  :m,
737
- [:args, :"**k", :"&b", [:block, [:"**k"]]],
737
+ [:args, :"**k", :"&b", [:kwargs, [:"**k"]]],
738
738
  [:scope, [:block, [:nil]]]]
739
739
  end
740
740
 
@@ -755,7 +755,7 @@ describe "A Defn node" do
755
755
  :"**k",
756
756
  :"&l",
757
757
  [:block, [:lasgn, :b, [:lit, 1]]],
758
- [:block, [:e, :f, :g, :"**k"], [[:lasgn, :f, [:lit, 2]]]]],
758
+ [:kwargs, [:e, :f, :g, :"**k"], [[:lasgn, :f, [:lit, 2]]]]],
759
759
  [:scope, [:block, [:nil]]]]
760
760
  end
761
761
 
@@ -777,7 +777,7 @@ describe "A Defn node" do
777
777
  :"**k",
778
778
  :"&l",
779
779
  [:block, [:lasgn, :b, [:lit, 1]]],
780
- [:block, [:e, :f, :g, :"**k"], [[:lasgn, :f, [:lit, 2]]]]],
780
+ [:kwargs, [:e, :f, :g, :"**k"], [[:lasgn, :f, [:lit, 2]]]]],
781
781
  [:scope, [:block, [:nil]]]]
782
782
  end
783
783
  end
data/spec/defs_spec.rb CHANGED
@@ -67,7 +67,7 @@ describe "A Defs node" do
67
67
  :"**k",
68
68
  :"&l",
69
69
  [:block, [:lasgn, :b, [:lit, 1]]],
70
- [:block, [:e, :f, :g, :"**k"], [[:lasgn, :f, [:lit, 2]]]]],
70
+ [:kwargs, [:e, :f, :g, :"**k"], [[:lasgn, :f, [:lit, 2]]]]],
71
71
  [:scope, [:block, [:nil]]]]
72
72
  end
73
73
 
@@ -90,7 +90,7 @@ describe "A Defs node" do
90
90
  :"**k",
91
91
  :"&l",
92
92
  [:block, [:lasgn, :b, [:lit, 1]]],
93
- [:block, [:e, :f, :g, :"**k"], [[:lasgn, :f, [:lit, 2]]]]],
93
+ [:kwargs, [:e, :f, :g, :"**k"], [[:lasgn, :f, [:lit, 2]]]]],
94
94
  [:scope, [:block, [:nil]]]]
95
95
  end
96
96
  end
data/spec/for_spec.rb CHANGED
@@ -6,7 +6,7 @@ describe "A For node" do
6
6
  ruby
7
7
 
8
8
  [:for,
9
- [:lasgn, :o],
9
+ [:args, [:lasgn, :o]],
10
10
  [:call, nil, :ary, [:arglist]],
11
11
  [:call, nil, :puts, [:arglist, [:lvar, :o]]]]
12
12
  end
@@ -18,7 +18,7 @@ describe "A For node" do
18
18
  ruby
19
19
 
20
20
  [:for,
21
- [:lasgn, :i],
21
+ [:args, [:lasgn, :i]],
22
22
  [:dot2, [:lit, 0], [:call, nil, :max, [:arglist]]],
23
23
  [:nil]]
24
24
  end
@@ -30,7 +30,7 @@ describe "A For node" do
30
30
  ruby
31
31
 
32
32
  [:for,
33
- [:masgn, [:array, [:lasgn, :a], [:lasgn, :b]]],
33
+ [:args, [:masgn, [:array, [:lasgn, :a], [:lasgn, :b]]]],
34
34
  [:call, nil, :x, [:arglist]],
35
35
  [:lit, 5]]
36
36
  end
@@ -41,7 +41,7 @@ describe "A For node" do
41
41
  end
42
42
  ruby
43
43
 
44
- [:for, [:lasgn, :i], [:nil], [:lvar, :i]]
44
+ [:for, [:args, [:lasgn, :i]], [:nil], [:lvar, :i]]
45
45
  end
46
46
 
47
47
  parse <<-ruby do
@@ -56,8 +56,8 @@ describe "A For node" do
56
56
  [:block,
57
57
  [:lasgn, :c, [:lit, 1]],
58
58
  [:for,
59
- [:lasgn, :i],
59
+ [:args, [:lasgn, :i]],
60
60
  [:call, nil, :a, [:arglist]],
61
- [:for, [:lasgn, :j], [:call, nil, :b, [:arglist]], [:lvar, :c]]]]
61
+ [:for, [:args, [:lasgn, :j]], [:call, nil, :b, [:arglist]], [:lvar, :c]]]]
62
62
  end
63
63
  end