Take the 2008 Git User's Survey and help out! [ hide ]

public
Description: Rubinius, the Ruby VM
Homepage: http://rubini.us
Clone URL: git://github.com/evanphx/rubinius.git
Search Repo:
trailing whitespace drives me nuts
Ryan Davis (author)
Thu May 01 16:03:28 -0700 2008
commit  ac21a7655ea68a7ac6bf75c7689e5cd01d7a14bd
tree    f91e9912d0573a93121d15408516722c310ee28a
parent  dddbf70563773211e28c43e4e3baa59bfc2edcd1
...
13
14
15
16
 
17
18
19
...
21
22
23
24
 
25
26
27
28
29
30
 
31
32
33
...
38
39
40
41
 
42
43
 
44
45
46
...
53
54
55
56
 
57
58
59
...
65
66
67
68
 
69
70
71
...
73
74
75
76
 
77
78
79
80
81
82
83
84
85
 
 
 
 
86
87
88
89
90
 
91
92
93
...
97
98
99
100
 
101
102
103
104
105
106
107
 
108
109
110
111
 
112
113
114
115
 
116
117
118
119
120
 
121
122
123
...
126
127
128
129
 
130
131
132
...
139
140
141
142
 
143
144
145
146
147
148
 
149
150
151
...
157
158
159
160
 
161
162
163
164
 
165
166
167
168
 
169
170
171
...
183
184
185
186
 
187
188
 
189
190
191
...
196
197
198
199
 
200
201
202
...
227
228
229
230
 
231
232
233
234
 
235
236
237
238
239
240
241
 
242
243
244
245
246
247
 
248
249
250
...
260
261
262
263
 
264
265
266
...
269
270
271
272
 
273
274
275
...
280
281
282
283
 
284
285
286
...
288
289
290
291
 
292
293
294
...
296
297
298
299
 
300
301
302
...
305
306
307
308
309
 
 
310
311
312
...
315
316
317
318
 
319
320
321
...
325
326
327
328
329
 
 
330
331
332
...
336
337
338
339
340
341
 
 
 
342
343
344
...
349
350
351
352
353
 
 
354
355
356
...
360
361
362
363
 
364
365
366
367
 
368
369
370
...
373
374
375
376
 
377
378
379
...
385
386
387
388
 
389
390
 
391
392
 
393
394
 
395
396
397
398
399
400
 
401
402
403
404
405
406
407
 
408
409
410
...
418
419
420
421
422
 
 
423
424
425
426
427
428
429
 
430
431
432
433
434
 
435
436
437
...
462
463
464
465
 
466
467
468
...
479
480
481
482
 
483
484
485
...
503
504
505
506
 
507
508
509
510
511
512
 
513
514
 
515
516
517
...
531
532
533
534
 
535
536
537
...
553
554
555
556
 
557
558
559
560
561
562
 
563
564
565
...
573
574
575
576
 
577
578
579
...
585
586
587
588
 
589
590
591
...
597
598
599
600
 
601
602
603
...
666
667
668
669
 
670
671
672
...
701
702
703
704
705
 
 
706
707
708
...
714
715
716
717
 
718
719
 
720
721
722
 
723
724
725
...
729
730
731
732
 
733
734
735
...
755
756
757
758
 
759
760
761
...
764
765
766
767
 
768
769
770
...
778
779
780
781
782
 
 
783
784
785
786
 
787
788
789
...
791
792
793
794
 
795
796
 
797
798
799
800
801
802
 
803
804
805
806
807
808
809
 
810
811
812
813
 
814
815
816
...
843
844
845
846
 
847
848
849
850
851
852
 
853
854
855
856
857
858
859
860
 
 
 
861
862
863
864
865
866
867
 
868
869
870
...
873
874
875
876
 
877
878
879
...
881
882
883
884
885
 
 
886
887
888
...
900
901
902
903
 
904
905
906
...
970
971
972
973
 
974
975
976
 
977
978
 
979
980
981
...
1027
1028
1029
1030
 
1031
1032
1033
...
1101
1102
1103
1104
 
1105
1106
1107
...
1125
1126
1127
1128
 
1129
1130
1131
 
1132
1133
1134
1135
1136
 
 
1137
1138
1139
...
1182
1183
1184
1185
 
1186
1187
1188
...
1205
1206
1207
1208
 
1209
1210
1211
...
1222
1223
1224
1225
 
1226
1227
1228
1229
1230
1231
1232
 
1233
1234
 
1235
1236
1237
1238
1239
 
1240
1241
1242
1243
1244
 
1245
1246
1247
...
1250
1251
1252
1253
 
1254
1255
1256
...
1262
1263
1264
1265
 
1266
1267
1268
1269
 
1270
1271
1272
1273
1274
1275
 
1276
1277
1278
1279
 
1280
1281
 
1282
1283
1284
1285
1286
1287
1288
 
1289
1290
1291
...
1295
1296
1297
1298
 
1299
1300
1301
1302
1303
1304
1305
1306
 
 
1307
1308
1309
1310
1311
 
1312
1313
1314
...
1318
1319
1320
1321
 
1322
1323
1324
...
1331
1332
1333
1334
 
1335
1336
1337
1338
1339
 
 
1340
1341
1342
...
1348
1349
1350
1351
 
1352
1353
1354
1355
1356
1357
1358
 
 
 
1359
1360
1361
...
1368
1369
1370
1371
 
1372
1373
1374
1375
1376
1377
 
1378
1379
1380
1381
 
1382
1383
 
1384
1385
1386
 
 
1387
1388
1389
...
1406
1407
1408
1409
 
1410
1411
1412
...
1449
1450
1451
1452
 
1453
1454
1455
1456
 
1457
1458
1459
...
1464
1465
1466
1467
 
1468
1469
1470
...
1475
1476
1477
1478
 
1479
1480
1481
...
1504
1505
1506
1507
 
1508
1509
1510
1511
1512
 
1513
1514
1515
...
1517
1518
1519
1520
 
1521
1522
1523
...
1543
1544
1545
1546
 
1547
1548
1549
...
1562
1563
1564
1565
 
1566
1567
1568
 
1569
1570
1571
...
1573
1574
1575
1576
 
1577
1578
1579
...
1603
1604
1605
1606
 
1607
1608
1609
1610
 
1611
1612
1613
...
1641
1642
1643
1644
 
1645
1646
1647
...
1660
1661
1662
1663
 
1664
1665
1666
...
13
14
15
 
16
17
18
19
...
21
22
23
 
24
25
26
27
28
29
 
30
31
32
33
...
38
39
40
 
41
42
 
43
44
45
46
...
53
54
55
 
56
57
58
59
...
65
66
67
 
68
69
70
71
...
73
74
75
 
76
77
78
79
80
81
 
 
 
 
82
83
84
85
86
87
88
89
 
90
91
92
93
...
97
98
99
 
100
101
102
103
104
105
106
 
107
108
109
110
 
111
112
113
114
 
115
116
117
118
119
 
120
121
122
123
...
126
127
128
 
129
130
131
132
...
139
140
141
 
142
143
144
145
146
147
 
148
149
150
151
...
157
158
159
 
160
161
162
163
 
164
165
166
167
 
168
169
170
171
...
183
184
185
 
186
187
 
188
189
190
191
...
196
197
198
 
199
200
201
202
...
227
228
229
 
230
231
232
233
 
234
235
236
237
238
239
240
 
241
242
243
244
245
246
 
247
248
249
250
...
260
261
262
 
263
264
265
266
...
269
270
271
 
272
273
274
275
...
280
281
282
 
283
284
285
286
...
288
289
290
 
291
292
293
294
...
296
297
298
 
299
300
301
302
...
305
306
307
 
 
308
309
310
311
312
...
315
316
317
 
318
319
320
321
...
325
326
327
 
 
328
329
330
331
332
...
336
337
338
 
 
 
339
340
341
342
343
344
...
349
350
351
 
 
352
353
354
355
356
...
360
361
362
 
363
364
365
366
 
367
368
369
370
...
373
374
375
 
376
377
378
379
...
385
386
387
 
388
389
 
390
391
 
392
393
 
394
395
396
397
398
399
 
400
401
402
403
404
405
406
 
407
408
409
410
...
418
419
420
 
 
421
422
423
424
425
426
427
428
 
429
430
431
432
433
 
434
435
436
437
...
462
463
464
 
465
466
467
468
...
479
480
481
 
482
483
484
485
...
503
504
505
 
506
507
508
509
510
511
 
512
513
 
514
515
516
517
...
531
532
533
 
534
535
536
537
...
553
554
555
 
556
557
558
559
560
561
 
562
563
564
565
...
573
574
575
 
576
577
578
579
...
585
586
587
 
588
589
590
591
...
597
598
599
 
600
601
602
603
...
666
667
668
 
669
670
671
672
...
701
702
703
 
 
704
705
706
707
708
...
714
715
716
 
717
718
 
719
720
721
 
722
723
724
725
...
729
730
731
 
732
733
734
735
...
755
756
757
 
758
759
760
761
...
764
765
766
 
767
768
769
770
...
778
779
780
 
 
781
782
783
784
785
 
786
787
788
789
...
791
792
793
 
794
795
 
796
797
798
799
800
801
 
802
803
804
805
806
807
808
 
809
810
811
812
 
813
814
815
816
...
843
844
845
 
846
847
848
849
850
851
 
852
853
854
855
856
857
 
 
 
858
859
860
861
862
863
864
865
866
 
867
868
869
870
...
873
874
875
 
876
877
878
879
...
881
882
883
 
 
884
885
886
887
888
...
900
901
902
 
903
904
905
906
...
970
971
972
 
973
974
975
 
976
977
 
978
979
980
981
...
1027
1028
1029
 
1030
1031
1032
1033
...
1101
1102
1103
 
1104
1105
1106
1107
...
1125
1126
1127
 
1128
1129
1130
 
1131
1132
1133
1134
 
 
1135
1136
1137
1138
1139
...
1182
1183
1184
 
1185
1186
1187
1188
...
1205
1206
1207
 
1208
1209
1210
1211
...
1222
1223
1224
 
1225
1226
1227
1228
1229
1230
1231
 
1232
1233
 
1234
1235
1236
1237
1238
 
1239
1240
1241
1242
1243
 
1244
1245
1246
1247
...
1250
1251
1252
 
1253
1254
1255
1256
...
1262
1263
1264
 
1265
1266
1267
1268
 
1269
1270
1271
1272
1273
1274
 
1275
1276
1277
1278
 
1279
1280
 
1281
1282
1283
1284
1285
1286
1287
 
1288
1289
1290
1291
...
1295
1296
1297
 
1298
1299
1300
1301
1302
1303
1304
 
 
1305
1306
1307
1308
1309
1310
 
1311
1312
1313
1314
...
1318
1319
1320
 
1321
1322
1323
1324
...
1331
1332
1333
 
1334
1335
1336
1337
 
 
1338
1339
1340
1341
1342
...
1348
1349
1350
 
1351
1352
1353
1354
1355
 
 
 
1356
1357
1358
1359
1360
1361
...
1368
1369
1370
 
1371
1372
1373
1374
1375
1376
 
1377
1378
1379
1380
 
1381
1382
 
1383
1384
 
 
1385
1386
1387
1388
1389
...
1406
1407
1408
 
1409
1410
1411
1412
...
1449
1450
1451
 
1452
1453
1454
1455
 
1456
1457
1458
1459
...
1464
1465
1466
 
1467
1468
1469
1470
...
1475
1476
1477
 
1478
1479
1480
1481
...
1504
1505
1506
 
1507
1508
1509
1510
1511
 
1512
1513
1514
1515
...
1517
1518
1519
 
1520
1521
1522
1523
...
1543
1544
1545
 
1546
1547
1548
1549
...
1562
1563
1564
 
1565
1566
1567
 
1568
1569
1570
1571
...
1573
1574
1575
 
1576
1577
1578
1579
...
1603
1604
1605
 
1606
1607
1608
1609
 
1610
1611
1612
1613
...
1641
1642
1643
 
1644
1645
1646
1647
...
1660
1661
1662
 
1663
1664
1665
1666
0
@@ -13,7 +13,7 @@ class Array
0
   def total=(n) ; @total = n ; end
0
   def tuple=(t) ; @tuple = t ; end
0
   def start=(s) ; @start = s ; end
0
-
0
+
0
   include Enumerable
0
 
0
   # The flow control for many of these methods is
0
@@ -21,13 +21,13 @@ class Array
0
   # also a lot of duplication of code due to very
0
   # subtle processing differences and, in some
0
   # cases, to avoid mutual dependency. Apologies.
0
-
0
+
0
 
0
   # Returns a new Array populated with the given objects
0
   def self.[](*args)
0
     new args
0
   end
0
-
0
+
0
   def self.allocate
0
     ary = __allocate__
0
     ary.start = 0
0
@@ -38,9 +38,9 @@ class Array
0
 
0
   # Creates a new Array. Without arguments, an empty
0
   # Array is returned. If the only argument is an object
0
- # that responds to +to_ary+, a copy of that Array is
0
+ # that responds to +to_ary+, a copy of that Array is
0
   # created. Otherwise the first argument is the size
0
- # of the new Array (default 0.) The second argument
0
+ # of the new Array (default 0.) The second argument
0
   # may be an object used to fill the Array up to the
0
   # size given (the same object, not a copy.) Alternatively,
0
   # a block that takes the numeric index can be given and
0
@@ -53,7 +53,7 @@ class Array
0
     unless args.empty?
0
       if args.size == 1 and (args.first.__kind_of__ Array or args.first.respond_to? :to_ary)
0
         ary = Type.coerce_to args.first, Array, :to_ary
0
-
0
+
0
         tuple = Tuple.new(ary.size + 10)
0
         @total = ary.size
0
         tuple.copy_from ary.tuple, ary.start, 0
0
@@ -65,7 +65,7 @@ class Array
0
 
0
         @tuple = Tuple.new(count + 10)
0
         @total = count
0
-
0
+
0
         if block_given?
0
           count.times { |i| @tuple.put i, yield(i) }
0
         else
0
@@ -73,21 +73,21 @@ class Array
0
         end
0
       end
0
     end
0
-
0
+
0
     self
0
   end
0
 
0
   private :initialize
0
 
0
- # Element reference, returns the element at the given index or
0
- # a subarray starting from the index continuing for length
0
- # elements or returns a subarray from range elements. Negative
0
- # indices count from the end. Returns nil if the index or subarray
0
+ # Element reference, returns the element at the given index or
0
+ # a subarray starting from the index continuing for length
0
+ # elements or returns a subarray from range elements. Negative
0
+ # indices count from the end. Returns nil if the index or subarray
0
   # request cannot be completed. Array#slice is synonymous with #[].
0
   # Subclasses return instances of themselves.
0
   def [](one, two = nil)
0
     Ruby.primitive :array_aref
0
-
0
+
0
     # Normalise the argument variants
0
     start, finish, count, simple, is_range = nil, nil, nil, false, false
0
 
0
@@ -97,27 +97,27 @@ class Array
0
     elsif two
0
       start, count = one, Type.coerce_to(two, Fixnum, :to_int)
0
       return nil if count < 0 # No need to go further
0
- else
0
+ else
0
       start, finish, simple = one, one, true
0
     end
0
 
0
     # Convert negative indices
0
     start = Type.coerce_to start, Fixnum, :to_int
0
     start += @total if start < 0
0
-
0
+
0
     if simple
0
       return nil if start < 0 or start >= @total
0
       return @tuple.at(@start + start)
0
-
0
+
0
     # ONE past end only, MRI compat
0
     elsif start == @total
0
       return self.class.new
0
-
0
+
0
     elsif start < 0 or start >= @total
0
       return nil
0
     end
0
 
0
-
0
+
0
     finish = Type.coerce_to finish, Fixnum, :to_int if finish
0
     finish = (start + count - 1) if count # For non-ranges
0
 
0
@@ -126,7 +126,7 @@ class Array
0
     finish -= 1 if is_range and one.exclude_end?
0
 
0
     # Going past the end is ignored (sort of)
0
- finish = (@total - 1) if finish >= @total
0
+ finish = (@total - 1) if finish >= @total
0
 
0
     if finish < 0
0
       return self.class.new if is_range
0
@@ -139,13 +139,13 @@ class Array
0
 
0
     start.upto(finish) { |i| out << at(i) }
0
     out
0
- end
0
+ end
0
 
0
   alias_method :slice, :[]
0
 
0
   def []=(idx, ent, *args)
0
     Ruby.primitive :array_aset
0
-
0
+
0
     cnt = nil
0
     if args.size != 0
0
       cnt = ent.to_int
0
@@ -157,15 +157,15 @@ class Array
0
       if cnt
0
         raise ArgumentError, "Second argument invalid with a range"
0
       end
0
-
0
+
0
       unless idx.first.respond_to?(:to_int)
0
         raise TypeError, "can't convert #{idx.first.class} into Integer"
0
       end
0
-
0
+
0
       unless idx.last.respond_to?(:to_int)
0
         raise TypeError, "can't convert #{idx.last.class} into Integer"
0
       end
0
-
0
+
0
       lst = idx.last.to_int
0
       if lst < 0
0
         lst += @total
0
@@ -183,9 +183,9 @@ class Array
0
 
0
       cnt = lst - idx
0
     end
0
-
0
+
0
     idx = idx.to_int
0
-
0
+
0
     if idx < 0
0
       idx += @total
0
       raise IndexError.new("Index #{idx -= @total} out of bounds") if idx < 0
0
@@ -196,7 +196,7 @@ class Array
0
       raise IndexError.new("Negative length #{cnt}") if cnt < 0
0
 
0
       cnt = @total - idx if cnt > @total - idx # MRI seems to be forgiving here!
0
-
0
+
0
       if ent.nil?
0
         replacement = []
0
       elsif ent.is_a?(Array)
0
@@ -227,24 +227,24 @@ class Array
0
       replacement.each_with_index { |el, i|
0
         @tuple.put(@start+idx+i, el)
0
       }
0
-
0
+
0
       if replacement.size < cnt
0
         f = @start + idx + cnt
0
         t = @start + idx + replacement.size
0
-
0
+
0
         # shift fields to the left
0
         while f < @total
0
           @tuple.put(t, @tuple.at(f))
0
           t += 1
0
           f += 1
0
         end
0
-
0
+
0
         # unset any extraneous fields
0
         while t < @tuple.fields
0
           @tuple.put(t, nil)
0
           t += 1
0
         end
0
-
0
+
0
         @total -= (cnt - replacement.size)
0
       end
0
 
0
@@ -260,7 +260,7 @@ class Array
0
     end
0
     return ent
0
   end
0
-
0
+
0
   # Appends the object to the end of the Array.
0
   # Returns self so several appends can be chained.
0
   def <<(obj)
0
@@ -269,7 +269,7 @@ class Array
0
     @tuple.put @start + @total, obj
0
     @total += 1
0
     self
0
- end
0
+ end
0
 
0
   # Creates a new Array containing only elements common to
0
   # both Arrays, without duplicates. Also known as a 'set
0
@@ -280,7 +280,7 @@ class Array
0
     out, set_include = [], {}
0
 
0
     other.each { |x| set_include[x] = [true, x] }
0
- each { |x|
0
+ each { |x|
0
       if set_include[x] and set_include[x].last.eql?(x)
0
         out << x
0
         set_include[x] = false
0
@@ -288,7 +288,7 @@ class Array
0
     }
0
 
0
     out
0
- end
0
+ end
0
 
0
   # Creates a new Array by combining the two Arrays' items,
0
   # without duplicates. Also known as a 'set union.'
0
@@ -296,7 +296,7 @@ class Array
0
     other = Type.coerce_to other, Array, :to_ary
0
 
0
     out, exclude = [], {}
0
-
0
+
0
     (self + other).each { |x|
0
       unless exclude[x]
0
         out << x
0
@@ -305,8 +305,8 @@ class Array
0
     }
0
 
0
     out
0
- end
0
-
0
+ end
0
+
0
   # Repetition operator when supplied a #to_int argument:
0
   # returns a new Array as a concatenation of the given number
0
   # of the original Arrays. With an argument that responds to
0
@@ -315,7 +315,7 @@ class Array
0
     if val.respond_to? :to_str
0
       return join(val)
0
 
0
- else
0
+ else
0
       # Aaargh stupid MRI's stupid specific stupid error stupid types stupid
0
       val = Type.coerce_to val, Fixnum, :to_int
0
 
0
@@ -325,8 +325,8 @@ class Array
0
       val.times { out.push(*self) }
0
       out
0
     end
0
- end
0
-
0
+ end
0
+
0
   # Create a concatenation of the two Arrays.
0
   def +(other)
0
     other = Type.coerce_to other, Array, :to_ary
0
@@ -336,9 +336,9 @@ class Array
0
     other.each { |e| out << e }
0
 
0
     out
0
- end
0
-
0
- # Creates a new Array that contains the items of the original
0
+ end
0
+
0
+ # Creates a new Array that contains the items of the original
0
   # Array that do not appear in the other Array, effectively
0
   # 'deducting' those items. The matching method is Hash-based.
0
   def -(other)
0
@@ -349,8 +349,8 @@ class Array
0
     each { |x| out << x unless exclude[x] }
0
 
0
     out
0
- end
0
-
0
+ end
0
+
0
   # Compares the two Arrays and returns -1, 0 or 1 depending
0
   # on whether the first one is 'smaller', 'equal' or 'greater'
0
   # in relation to the second. Two Arrays are equal only if all
0
@@ -360,11 +360,11 @@ class Array
0
   def <=>(other)
0
     other = Type.coerce_to other, Array, :to_ary
0
 
0
- size.times { |i|
0
+ size.times { |i|
0
       return 1 unless other.size > i
0
 
0
       diff = at(i) <=> other.at(i)
0
- return diff if diff != 0
0
+ return diff if diff != 0
0
     }
0
 
0
     return 1 if size > other.size
0
@@ -373,7 +373,7 @@ class Array
0
   end
0
 
0
   # The two Arrays are considered equal only if their
0
- # lengths are the same and each of their elements
0
+ # lengths are the same and each of their elements
0
   # are equal according to first_e == second_e . Both
0
   # Array subclasses and to_ary objects are accepted.
0
   def ==(other)
0
@@ -385,26 +385,26 @@ class Array
0
     return false unless size == other.size
0
 
0
     size.times { |i| return false unless @tuple.at(@start + i) == other.at(i) }
0
-
0
+
0
     true
0
- end
0
+ end
0
 
0
- # Assumes the Array contains other Arrays and searches through
0
+ # Assumes the Array contains other Arrays and searches through
0
   # it comparing the given object with the first element of each
0
- # contained Array using elem == obj. Returns the first contained
0
+ # contained Array using elem == obj. Returns the first contained
0
   # Array that matches (the first 'associated' Array) or nil.
0
   def assoc(obj)
0
     # FIX: use break when it works again
0
     found, res = nil, nil
0
 
0
- each { |elem|
0
+ each { |elem|
0
       if found.nil? and elem.kind_of? Array and elem.first == obj
0
         found, res = true, elem
0
       end
0
     }
0
 
0
     res
0
- end
0
+ end
0
 
0
   # Returns the element at the given index. If the
0
   # index is negative, counts from the end of the
0
@@ -418,20 +418,20 @@ class Array
0
     return nil if idx < 0 or idx >= @total
0
 
0
     @tuple.at @start + idx
0
- end
0
-
0
+ end
0
+
0
   # Removes all elements in the Array and leaves it empty
0
   def clear()
0
     @tuple = Tuple.new(1)
0
     @total = 0
0
     @start = 0
0