rubinius-compiler 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -0
  3. data/lib/rubinius/compiler/compiled_file.rb +32 -32
  4. data/lib/rubinius/compiler/version.rb +2 -2
  5. data/rubinius-compiler.gemspec +6 -0
  6. data/spec/alias_spec.rb +39 -0
  7. data/spec/and_spec.rb +44 -0
  8. data/spec/array_spec.rb +110 -0
  9. data/spec/attrasgn_spec.rb +186 -0
  10. data/spec/back_ref_spec.rb +11 -0
  11. data/spec/call_spec.rb +580 -0
  12. data/spec/case_spec.rb +576 -0
  13. data/spec/cdecl_spec.rb +70 -0
  14. data/spec/class_spec.rb +120 -0
  15. data/spec/colon2_spec.rb +8 -0
  16. data/spec/colon3_spec.rb +8 -0
  17. data/spec/const_spec.rb +7 -0
  18. data/spec/custom/guards/profiler.rb +18 -0
  19. data/spec/custom/helpers/generator.rb +828 -0
  20. data/spec/custom/matchers/compile_as.rb +46 -0
  21. data/spec/custom/mspec.rb +15 -0
  22. data/spec/custom/runner/actions/debug.rb +10 -0
  23. data/spec/custom/runner/actions/gcstats.rb +17 -0
  24. data/spec/custom/runner/actions/memory.rb +11 -0
  25. data/spec/custom/runner/actions/parser.rb +14 -0
  26. data/spec/custom/runner/actions/profiler.rb +19 -0
  27. data/spec/custom/runner/relates.rb +86 -0
  28. data/spec/custom/utils/options.rb +40 -0
  29. data/spec/custom/utils/script.rb +50 -0
  30. data/spec/cvar_spec.rb +39 -0
  31. data/spec/cvasgn_spec.rb +33 -0
  32. data/spec/cvdecl_spec.rb +17 -0
  33. data/spec/defined_spec.rb +616 -0
  34. data/spec/defn_spec.rb +732 -0
  35. data/spec/defs_spec.rb +113 -0
  36. data/spec/dot2_spec.rb +16 -0
  37. data/spec/dot3_spec.rb +17 -0
  38. data/spec/dregx_spec.rb +160 -0
  39. data/spec/dstr_spec.rb +424 -0
  40. data/spec/dsym_spec.rb +18 -0
  41. data/spec/dxstr_spec.rb +24 -0
  42. data/spec/ensure_spec.rb +196 -0
  43. data/spec/false_spec.rb +7 -0
  44. data/spec/flip2_spec.rb +21 -0
  45. data/spec/flip3_spec.rb +12 -0
  46. data/spec/for_spec.rb +228 -0
  47. data/spec/gasgn_spec.rb +15 -0
  48. data/spec/generator/encode_spec.rb +34 -0
  49. data/spec/gvar_spec.rb +37 -0
  50. data/spec/hash_spec.rb +108 -0
  51. data/spec/iasgn_spec.rb +26 -0
  52. data/spec/if_spec.rb +415 -0
  53. data/spec/iter_spec.rb +1011 -0
  54. data/spec/lasgn_spec.rb +561 -0
  55. data/spec/lit_spec.rb +61 -0
  56. data/spec/masgn_spec.rb +1558 -0
  57. data/spec/match2_spec.rb +42 -0
  58. data/spec/match3_spec.rb +54 -0
  59. data/spec/match_spec.rb +29 -0
  60. data/spec/module_spec.rb +73 -0
  61. data/spec/nil_spec.rb +7 -0
  62. data/spec/not_spec.rb +47 -0
  63. data/spec/nth_ref_spec.rb +7 -0
  64. data/spec/op_asgn_spec.rb +563 -0
  65. data/spec/or_spec.rb +126 -0
  66. data/spec/postexe_spec.rb +11 -0
  67. data/spec/preexe_spec.rb +21 -0
  68. data/spec/regex_spec.rb +54 -0
  69. data/spec/rescue_spec.rb +763 -0
  70. data/spec/return_spec.rb +152 -0
  71. data/spec/sclass_spec.rb +138 -0
  72. data/spec/spec_helper.rb +12 -0
  73. data/spec/str_spec.rb +118 -0
  74. data/spec/super_spec.rb +170 -0
  75. data/spec/transforms/assembly_spec.rb +195 -0
  76. data/spec/transforms/block_given_spec.rb +75 -0
  77. data/spec/transforms/fast_coerce_spec.rb +112 -0
  78. data/spec/transforms/fast_new_spec.rb +255 -0
  79. data/spec/transforms/invoke_primitive_spec.rb +14 -0
  80. data/spec/transforms/kernel_methods_spec.rb +29 -0
  81. data/spec/transforms/primitive_spec.rb +33 -0
  82. data/spec/transforms/privately_spec.rb +24 -0
  83. data/spec/true_spec.rb +7 -0
  84. data/spec/undef_spec.rb +133 -0
  85. data/spec/until_spec.rb +254 -0
  86. data/spec/valias_spec.rb +11 -0
  87. data/spec/while_spec.rb +494 -0
  88. data/spec/xstr_spec.rb +10 -0
  89. data/spec/yield_spec.rb +92 -0
  90. data/spec/zsuper_spec.rb +63 -0
  91. metadata +258 -3
data/spec/lit_spec.rb ADDED
@@ -0,0 +1,61 @@
1
+ describe "A Lit node" do
2
+ relates "0b1111" do
3
+ compile do |g|
4
+ g.push 15
5
+ end
6
+ end
7
+
8
+ relates "1.1" do
9
+ compile do |g|
10
+ g.push_literal 1.1
11
+ end
12
+ end
13
+
14
+ relates "0xffffffffffffffff" do
15
+ compile do |g|
16
+ g.push_literal 18446744073709551615
17
+ end
18
+ end
19
+
20
+ relates "0xffff_ffff_ffff_ffff" do
21
+ compile do |g|
22
+ g.push_literal 18446744073709551615
23
+ end
24
+ end
25
+
26
+ relates "07654" do
27
+ compile do |g|
28
+ g.push 4012
29
+ end
30
+ end
31
+
32
+ relates "-1" do
33
+ compile do |g|
34
+ g.push(-1)
35
+ end
36
+ end
37
+
38
+ relates "1" do
39
+ compile do |g|
40
+ g.push 1
41
+ end
42
+ end
43
+
44
+ relates "8000_0000" do
45
+ compile do |g|
46
+ g.push 80000000
47
+ end
48
+ end
49
+
50
+ relates ":x" do
51
+ compile do |g|
52
+ g.push_literal :x
53
+ end
54
+ end
55
+
56
+ relates ":\"*args\"" do
57
+ compile do |g|
58
+ g.push_literal :"*args"
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,1558 @@
1
+ describe "A Masgn node" do
2
+ relates "a, b.c = b.c, true" do
3
+ compile do |g|
4
+ g.push :self
5
+ g.send :b, 0, true
6
+ g.send :c, 0, false
7
+ g.push :true
8
+
9
+ g.dup_many 2
10
+ g.make_array 2
11
+ g.move_down 2
12
+
13
+ g.rotate 2
14
+
15
+ g.set_local 0
16
+ g.pop
17
+
18
+ g.push :self
19
+ g.send :b, 0, true
20
+ g.swap
21
+ g.send :c=, 1, false
22
+
23
+ g.pop
24
+ end
25
+ end
26
+
27
+ relates "a, b = 1, 2, 3" do
28
+ compile do |g|
29
+ g.push 1
30
+ g.push 2
31
+ g.push 3
32
+
33
+ g.dup_many 3
34
+ g.make_array 3
35
+ g.move_down 3
36
+
37
+ g.rotate 3
38
+
39
+ g.set_local 0
40
+ g.pop
41
+ g.set_local 1
42
+ g.pop
43
+
44
+ g.pop # no set_local since the LHS is smaller than the RHS
45
+ end
46
+ end
47
+
48
+ relates "a, b = c, d" do
49
+ compile do |g|
50
+ g.push :self
51
+ g.send :c, 0, true
52
+ g.push :self
53
+ g.send :d, 0, true
54
+
55
+ g.dup_many 2
56
+ g.make_array 2
57
+ g.move_down 2
58
+
59
+ g.rotate 2
60
+
61
+ g.set_local 0
62
+ g.pop
63
+
64
+ g.set_local 1
65
+ g.pop
66
+ end
67
+ end
68
+
69
+ ruby_version_is ""..."1.9" do
70
+ relates "a, b, *c = 1, 2, *[3, 4]" do
71
+ compile do |g|
72
+ g.push 1
73
+ g.push 2
74
+ g.make_array 2
75
+ g.push 3
76
+ g.push 4
77
+ g.make_array 2
78
+ g.cast_array
79
+ g.send :+, 1
80
+ g.cast_array
81
+ g.dup
82
+
83
+ g.shift_array
84
+ g.set_local 0
85
+ g.pop
86
+
87
+ g.shift_array
88
+ g.set_local 1
89
+ g.pop
90
+
91
+ g.cast_array
92
+ g.set_local 2
93
+ g.pop
94
+ end
95
+ end
96
+ end
97
+
98
+ ruby_version_is "1.9" do
99
+ relates "a, b, *c = 1, 2, *[3, 4]" do
100
+ compile do |g|
101
+ g.push 1
102
+ g.push 2
103
+ g.push 3
104
+ g.push 4
105
+
106
+ g.dup_many 4
107
+ g.make_array 4
108
+ g.move_down 4
109
+
110
+ g.make_array 2
111
+ g.rotate 3
112
+
113
+ g.set_local 0
114
+ g.pop
115
+
116
+ g.set_local 1
117
+ g.pop
118
+
119
+ g.cast_array
120
+ g.set_local 2
121
+ g.pop
122
+ end
123
+ end
124
+ end
125
+
126
+ relates "a.b, a.c, _ = q" do
127
+ compile do |g|
128
+ g.push :self
129
+ g.send :q, 0, true
130
+ g.cast_multi_value
131
+
132
+ g.dup
133
+
134
+ g.shift_array
135
+ g.push :self
136
+ g.send :a, 0, true
137
+ g.swap
138
+ g.send :b=, 1, false
139
+ g.pop
140
+
141
+ g.shift_array
142
+ g.push :self
143
+ g.send :a, 0, true
144
+ g.swap
145
+ g.send :c=, 1, false
146
+ g.pop
147
+
148
+ g.shift_array
149
+ g.set_local 0
150
+ g.pop
151
+
152
+ g.pop
153
+ end
154
+ end
155
+
156
+ relates <<-ruby do
157
+ a, i, j = [], 1, 2
158
+ a[i], a[j] = a[j], a[i]
159
+ ruby
160
+
161
+ compile do |g|
162
+ g.make_array 0
163
+ g.push 1
164
+ g.push 2
165
+
166
+ g.dup_many 3
167
+ g.make_array 3
168
+ g.move_down 3
169
+
170
+ g.rotate 3
171
+
172
+ g.set_local 0
173
+ g.pop
174
+
175
+ g.set_local 1
176
+ g.pop
177
+
178
+ g.set_local 2
179
+ g.pop
180
+
181
+ g.pop
182
+
183
+ g.push_local 0
184
+ g.push_local 2
185
+ g.send :[], 1, false
186
+ g.push_local 0
187
+ g.push_local 1
188
+ g.send :[], 1, false
189
+
190
+ g.dup_many 2
191
+ g.make_array 2
192
+ g.move_down 2
193
+
194
+ g.rotate 2
195
+
196
+ g.push_local 0
197
+ g.swap
198
+ g.push_local 1
199
+ g.swap
200
+ g.send :[]=, 2, false
201
+ g.pop
202
+
203
+ g.push_local 0
204
+ g.swap
205
+ g.push_local 2
206
+ g.swap
207
+ g.send :[]=, 2, false
208
+ g.pop
209
+ end
210
+ end
211
+
212
+ relates <<-ruby do
213
+ c, d, e, f = [], 1, 2, 3
214
+ a, *b = c[d] = f(e, f, c)
215
+ ruby
216
+
217
+ compile do |g|
218
+ g.make_array 0
219
+ g.push 1
220
+ g.push 2
221
+ g.push 3
222
+
223
+ g.dup_many 4
224
+ g.make_array 4
225
+ g.move_down 4
226
+
227
+ g.rotate 4
228
+
229
+ g.set_local 0
230
+ g.pop
231
+ g.set_local 1
232
+ g.pop
233
+ g.set_local 2
234
+ g.pop
235
+ g.set_local 3
236
+ g.pop
237
+
238
+ g.pop
239
+
240
+ g.push_local 0
241
+ g.push_local 1
242
+ g.push :self
243
+ g.push_local 2
244
+ g.push_local 3
245
+ g.push_local 0
246
+ g.send :f, 3, true
247
+
248
+ g.dup
249
+ g.move_down 3
250
+ g.send :[]=, 2, false
251
+ g.pop
252
+
253
+ g.cast_multi_value
254
+ g.dup
255
+
256
+ g.shift_array
257
+ g.set_local 4
258
+ g.pop
259
+ g.cast_array
260
+ g.set_local 5
261
+ g.pop
262
+ end
263
+ end
264
+
265
+ relates "a, b.c = d, e" do
266
+ compile do |g|
267
+ g.push :self
268
+ g.send :d, 0, true
269
+ g.push :self
270
+ g.send :e, 0, true
271
+
272
+ g.dup_many 2
273
+ g.make_array 2
274
+ g.move_down 2
275
+
276
+ g.rotate 2
277
+
278
+ g.set_local 0
279
+ g.pop
280
+
281
+ g.push :self
282
+ g.send :b, 0, true
283
+ g.swap
284
+ g.send :c=, 1, false
285
+
286
+ g.pop
287
+ end
288
+ end
289
+
290
+ relates "*a.m = *b" do
291
+ compile do |g|
292
+ g.push :self
293
+ g.send :b, 0, true
294
+ g.cast_array
295
+ g.dup
296
+
297
+ g.push :self
298
+ g.send :a, 0, true
299
+ g.swap
300
+ g.send :m=, 1, false
301
+
302
+ g.pop
303
+ end
304
+ end
305
+
306
+ relates "*a.m = b" do
307
+ compile do |g|
308
+ g.push :self
309
+ g.send :b, 0, true
310
+
311
+ array = g.new_label
312
+ g.cast_multi_value
313
+ g.cast_array
314
+ g.dup
315
+ g.dup
316
+ g.push_cpath_top
317
+ g.find_const :Array
318
+ g.swap
319
+ g.kind_of
320
+ g.git array
321
+
322
+ g.make_array 1
323
+
324
+ array.set!
325
+ g.push :self
326
+ g.send :a, 0, true
327
+ g.swap
328
+ g.send :m=, 1, false
329
+ g.pop
330
+ end
331
+ end
332
+
333
+ relates "t, *a[:m] = b" do
334
+ compile do |g|
335
+ ary = g.new_label
336
+ assign = g.new_label
337
+
338
+ g.push :self
339
+ g.send :b, 0, true
340
+
341
+ g.cast_multi_value
342
+ g.dup
343
+
344
+ g.shift_array
345
+ g.set_local 0
346
+ g.pop
347
+
348
+ g.cast_array
349
+ g.push :self
350
+ g.send :a, 0, true
351
+ g.swap
352
+ g.push_literal :m
353
+ g.swap
354
+ g.send :[]=, 2, false
355
+ g.pop
356
+ end
357
+ end
358
+
359
+ relates "A, B, C = 1, 2, 3" do
360
+ compile do |g|
361
+ g.push 1
362
+ g.push 2
363
+ g.push 3
364
+
365
+ g.dup_many 3
366
+ g.make_array 3
367
+ g.move_down 3
368
+
369
+ g.rotate 3
370
+
371
+ g.push_scope
372
+ g.swap
373
+ g.push_literal :A
374
+ g.swap
375
+ g.send :const_set, 2
376
+ g.pop
377
+
378
+ g.push_scope
379
+ g.swap
380
+ g.push_literal :B
381
+ g.swap
382
+ g.send :const_set, 2
383
+ g.pop
384
+
385
+ g.push_scope
386
+ g.swap
387
+ g.push_literal :C
388
+ g.swap
389
+ g.send :const_set, 2
390
+ g.pop
391
+ end
392
+ end
393
+
394
+ relates "* = 1, 2" do
395
+ compile do |g|
396
+ g.push 1
397
+ g.push 2
398
+
399
+ g.make_array 2
400
+ g.dup
401
+
402
+ g.pop
403
+ end
404
+ end
405
+
406
+ relates "*$a = b" do
407
+ compile do |g|
408
+ g.push :self
409
+ g.send :b, 0, true
410
+
411
+ array = g.new_label
412
+ g.cast_multi_value
413
+ g.cast_array
414
+ g.dup
415
+ g.dup
416
+ g.push_cpath_top
417
+ g.find_const :Array
418
+ g.swap
419
+ g.kind_of
420
+ g.git array
421
+
422
+ g.make_array 1
423
+
424
+ array.set!
425
+ g.push_rubinius
426
+ g.find_const :Globals
427
+ g.swap
428
+ g.push_literal :$a
429
+ g.swap
430
+ g.send :[]=, 2
431
+ g.pop
432
+ end
433
+ end
434
+
435
+ relates "*$a = *b" do
436
+ compile do |g|
437
+ g.push :self
438
+ g.send :b, 0, true
439
+ g.cast_array
440
+ g.dup
441
+ g.push_rubinius
442
+ g.find_const :Globals
443
+ g.swap
444
+ g.push_literal :$a
445
+ g.swap
446
+ g.send :[]=, 2
447
+ g.pop
448
+ end
449
+ end
450
+
451
+ relates "a, @b = c, d" do
452
+ compile do |g|
453
+ g.push :self
454
+ g.send :c, 0, true
455
+ g.push :self
456
+ g.send :d, 0, true
457
+
458
+ g.dup_many 2
459
+ g.make_array 2
460
+ g.move_down 2
461
+
462
+ g.rotate 2
463
+
464
+ g.set_local 0
465
+ g.pop
466
+
467
+ g.set_ivar :@b
468
+ g.pop
469
+ end
470
+ end
471
+
472
+ relates "*@a = b" do
473
+ compile do |g|
474
+ ary = g.new_label
475
+ assign = g.new_label
476
+
477
+ g.push :self
478
+ g.send :b, 0, true
479
+
480
+ array = g.new_label
481
+ g.cast_multi_value
482
+ g.cast_array
483
+ g.dup
484
+ g.dup
485
+ g.push_cpath_top
486
+ g.find_const :Array
487
+ g.swap
488
+ g.kind_of
489
+ g.git array
490
+
491
+ g.make_array 1
492
+
493
+ array.set!
494
+ g.set_ivar :@a
495
+
496
+ g.pop
497
+ end
498
+ end
499
+
500
+ relates "*@a = *b" do
501
+ compile do |g|
502
+ g.push :self
503
+ g.send :b, 0, true
504
+ g.cast_array
505
+ g.dup
506
+ g.set_ivar :@a
507
+ g.pop
508
+ end
509
+ end
510
+
511
+ relates "@a, $b = 1, 2" do
512
+ compile do |g|
513
+ g.push 1
514
+ g.push 2
515
+
516
+ g.dup_many 2
517
+ g.make_array 2
518
+ g.move_down 2
519
+
520
+ g.rotate 2
521
+
522
+ g.set_ivar :@a
523
+ g.pop
524
+
525
+ g.push_rubinius
526
+ g.find_const :Globals
527
+ g.swap
528
+ g.push_literal :$b
529
+ g.swap
530
+ g.send :[]=, 2
531
+
532
+ g.pop
533
+ end
534
+ end
535
+
536
+ relates "a, b = (@a = 1), @a" do
537
+ compile do |g|
538
+ g.push 1
539
+ g.set_ivar :@a
540
+ g.push_ivar :@a
541
+
542
+ g.dup_many 2
543
+ g.make_array 2
544
+ g.move_down 2
545
+
546
+ g.rotate 2
547
+
548
+ g.set_local 0
549
+ g.pop
550
+ g.set_local 1
551
+ g.pop
552
+ end
553
+ end
554
+
555
+ relates "@@a, @@b = 1, 2" do
556
+ compile do |g|
557
+ g.push 1
558
+ g.push 2
559
+
560
+ g.dup_many 2
561
+ g.make_array 2
562
+ g.move_down 2
563
+
564
+ g.rotate 2
565
+
566
+ g.push_scope
567
+ g.swap
568
+ g.push_literal :@@a
569
+ g.swap
570
+ g.send :class_variable_set, 2
571
+ g.pop
572
+
573
+ g.push_scope
574
+ g.swap
575
+ g.push_literal :@@b
576
+ g.swap
577
+ g.send :class_variable_set, 2
578
+ g.pop
579
+ end
580
+ end
581
+
582
+ relates "a, b, *c = 1, 2, 3" do
583
+ compile do |g|
584
+ g.push 1
585
+ g.push 2
586
+ g.push 3
587
+
588
+ g.dup_many 3
589
+ g.make_array 3
590
+ g.move_down 3
591
+
592
+ g.make_array 1
593
+
594
+ g.rotate 3
595
+
596
+ g.set_local 0
597
+ g.pop
598
+
599
+ g.set_local 1
600
+ g.pop
601
+
602
+ g.cast_array
603
+ g.set_local 2
604
+ g.pop
605
+ end
606
+ end
607
+
608
+ relates "a, b, *c = 1, 2" do
609
+ compile do |g|
610
+ g.push 1
611
+ g.push 2
612
+
613
+ g.dup_many 2
614
+ g.make_array 2
615
+ g.move_down 2
616
+
617
+ g.make_array 0
618
+
619
+ g.rotate 3
620
+
621
+ g.set_local 0
622
+ g.pop
623
+
624
+ g.set_local 1
625
+ g.pop
626
+
627
+ g.cast_array
628
+ g.set_local 2
629
+ g.pop
630
+ end
631
+ end
632
+
633
+ relates "a, b, c, *d = 1, 2" do
634
+ compile do |g|
635
+ g.push 1
636
+ g.push 2
637
+
638
+ g.dup_many 2
639
+ g.make_array 2
640
+ g.move_down 2
641
+
642
+ g.push :nil
643
+ g.make_array 0
644
+
645
+ g.rotate 4
646
+
647
+ g.set_local 0
648
+ g.pop
649
+
650
+ g.set_local 1
651
+ g.pop
652
+
653
+ g.set_local 2
654
+ g.pop
655
+
656
+ g.cast_array
657
+ g.set_local 3
658
+ g.pop
659
+ end
660
+ end
661
+
662
+ relates "a, b, c = *d" do
663
+ compile do |g|
664
+ g.push :self
665
+ g.send :d, 0, true
666
+
667
+ g.cast_array
668
+ g.dup
669
+
670
+ g.shift_array
671
+ g.set_local 0
672
+ g.pop
673
+
674
+ g.shift_array
675
+ g.set_local 1
676
+ g.pop
677
+
678
+ g.shift_array
679
+ g.set_local 2
680
+ g.pop
681
+
682
+ g.pop
683
+ end
684
+ end
685
+
686
+ relates "a, b, c = 1, *d" do
687
+ compile do |g|
688
+ g.push 1
689
+ g.make_array 1
690
+
691
+ g.push :self
692
+ g.send :d, 0, true
693
+ g.cast_array
694
+
695
+ g.send :+, 1
696
+ g.cast_array
697
+
698
+ g.dup
699
+
700
+ g.shift_array
701
+ g.set_local 0
702
+ g.pop
703
+
704
+ g.shift_array
705
+ g.set_local 1
706
+ g.pop
707
+
708
+ g.shift_array
709
+ g.set_local 2
710
+ g.pop
711
+
712
+ g.pop
713
+ end
714
+ end
715
+
716
+ relates "a, b, *c = *d" do
717
+ compile do |g|
718
+ g.push :self
719
+ g.send :d, 0, true
720
+
721
+ g.cast_array
722
+ g.dup
723
+
724
+ g.shift_array
725
+ g.set_local 0
726
+ g.pop
727
+
728
+ g.shift_array
729
+ g.set_local 1
730
+ g.pop
731
+
732
+ g.cast_array
733
+ g.set_local 2
734
+ g.pop
735
+ end
736
+ end
737
+
738
+ relates "*a = 1, 2, 3" do
739
+ compile do |g|
740
+ g.push 1
741
+ g.push 2
742
+ g.push 3
743
+
744
+ g.make_array 3
745
+ g.set_local 0
746
+ g.dup
747
+
748
+ g.pop
749
+ end
750
+ end
751
+
752
+ relates "*a = b" do
753
+ compile do |g|
754
+ g.push :self
755
+ g.send :b, 0, true
756
+
757
+ array = g.new_label
758
+ g.cast_multi_value
759
+ g.cast_array
760
+ g.dup
761
+ g.dup
762
+ g.push_cpath_top
763
+ g.find_const :Array
764
+ g.swap
765
+ g.kind_of
766
+ g.git array
767
+
768
+ g.make_array 1
769
+
770
+ array.set!
771
+ g.set_local 0
772
+
773
+ g.pop
774
+ end
775
+ end
776
+
777
+ relates "*a = *b" do
778
+ compile do |g|
779
+ g.push :self
780
+ g.send :b, 0, true
781
+ g.cast_array
782
+ g.dup
783
+ g.set_local 0
784
+ g.pop
785
+ end
786
+ end
787
+
788
+ relates "a, (b, c) = [1, [2, 3]]" do
789
+ compile do |g|
790
+ g.push 1
791
+ g.push 2
792
+ g.push 3
793
+ g.make_array 2
794
+ g.make_array 2
795
+ g.cast_multi_value
796
+ g.dup
797
+
798
+ g.shift_array
799
+ g.set_local 0
800
+ g.pop
801
+
802
+ g.shift_array
803
+ g.cast_array
804
+ g.shift_array
805
+ g.set_local 1
806
+ g.pop
807
+
808
+ g.shift_array
809
+ g.set_local 2
810
+ g.pop
811
+
812
+ g.pop
813
+ g.pop
814
+ end
815
+ end
816
+
817
+ relates "a, = *[[[1]]]" do
818
+ compile do |g|
819
+ g.push 1
820
+ g.make_array 1
821
+ g.make_array 1
822
+ g.make_array 1
823
+ g.dup
824
+ g.shift_array
825
+ g.set_local 0
826
+ g.pop
827
+ g.pop
828
+ end
829
+ end
830
+
831
+ relates "a, b, * = c" do
832
+ compile do |g|
833
+ g.push :self
834
+ g.send :c, 0, true
835
+ g.cast_multi_value
836
+ g.dup
837
+
838
+ g.shift_array
839
+ g.set_local 0
840
+ g.pop
841
+
842
+ g.shift_array
843
+ g.set_local 1
844
+ g.pop
845
+
846
+ g.pop
847
+ end
848
+ end
849
+
850
+ relates "a, b, = c" do
851
+ compile do |g|
852
+ g.push :self
853
+ g.send :c, 0, true
854
+ g.cast_multi_value
855
+ g.dup
856
+
857
+ g.shift_array
858
+ g.set_local 0
859
+ g.pop
860
+
861
+ g.shift_array
862
+ g.set_local 1
863
+ g.pop
864
+
865
+ g.pop
866
+ end
867
+ end
868
+
869
+ relates "a, b, c = m d" do
870
+ compile do |g|
871
+ g.push :self
872
+ g.push :self
873
+ g.send :d, 0, true
874
+ g.send :m, 1, true
875
+ g.cast_multi_value
876
+ g.dup
877
+ g.shift_array
878
+ g.set_local 0
879
+ g.pop
880
+ g.shift_array
881
+ g.set_local 1
882
+ g.pop
883
+ g.shift_array
884
+ g.set_local 2
885
+ g.pop
886
+ g.pop
887
+ end
888
+ end
889
+
890
+ relates "a, b, *c = d, e, f, g" do
891
+ compile do |g|
892
+ g.push :self
893
+ g.send :d, 0, true
894
+ g.push :self
895
+ g.send :e, 0, true
896
+ g.push :self
897
+ g.send :f, 0, true
898
+ g.push :self
899
+ g.send :g, 0, true
900
+
901
+ g.dup_many 4
902
+ g.make_array 4
903
+ g.move_down 4
904
+
905
+ g.make_array 2
906
+
907
+ g.rotate 3
908
+
909
+ g.set_local 0
910
+ g.pop
911
+
912
+ g.set_local 1
913
+ g.pop
914
+
915
+ g.cast_array
916
+ g.set_local 2
917
+ g.pop
918
+ end
919
+ end
920
+
921
+ relates "a, b, *c = d.e(\"f\")" do
922
+ compile do |g|
923
+ g.push :self
924
+ g.send :d, 0, true
925
+ g.push_literal "f"
926
+ g.string_dup
927
+ g.send :e, 1, false
928
+
929
+ g.cast_multi_value
930
+ g.dup
931
+
932
+ g.shift_array
933
+ g.set_local 0
934
+ g.pop
935
+
936
+ g.shift_array
937
+ g.set_local 1
938
+ g.pop
939
+
940
+ g.cast_array
941
+ g.set_local 2
942
+ g.pop
943
+ end
944
+ end
945
+
946
+ relates "a, b, *c = d" do
947
+ compile do |g|
948
+ g.push :self
949
+ g.send :d, 0, true
950
+
951
+ g.cast_multi_value
952
+ g.dup
953
+
954
+ g.shift_array
955
+ g.set_local 0
956
+ g.pop
957
+
958
+ g.shift_array
959
+ g.set_local 1
960
+ g.pop
961
+
962
+ g.cast_array
963
+ g.set_local 2
964
+ g.pop
965
+ end
966
+ end
967
+
968
+ relates "a, b = c" do
969
+ compile do |g|
970
+ g.push :self
971
+ g.send :c, 0, true
972
+ g.cast_multi_value
973
+ g.dup
974
+
975
+ g.shift_array
976
+ g.set_local 0
977
+ g.pop
978
+
979
+ g.shift_array
980
+ g.set_local 1
981
+ g.pop
982
+
983
+ g.pop
984
+ end
985
+ end
986
+
987
+ relates <<-ruby do
988
+ m do
989
+ a, b = 1, 2
990
+ next
991
+ end
992
+ ruby
993
+
994
+ compile do |g|
995
+ g.push :self
996
+ g.in_block_send :m, :none do |d|
997
+ d.push 1
998
+ d.push 2
999
+ d.dup_many 2
1000
+ d.make_array 2
1001
+ d.move_down 2
1002
+ d.rotate 2
1003
+ d.set_local 0
1004
+ d.pop
1005
+ d.set_local 1
1006
+ d.pop
1007
+ d.pop
1008
+ d.push :nil
1009
+ d.ret
1010
+ end
1011
+ end
1012
+ end
1013
+
1014
+ relates "a, (b, c) = 1" do
1015
+ compile do |g|
1016
+ g.push 1
1017
+ g.cast_multi_value
1018
+ g.dup
1019
+
1020
+ g.shift_array
1021
+ g.set_local 0
1022
+ g.pop
1023
+
1024
+ g.shift_array
1025
+ g.cast_array
1026
+
1027
+ g.shift_array
1028
+ g.set_local 1
1029
+ g.pop
1030
+
1031
+ g.shift_array
1032
+ g.set_local 2
1033
+ g.pop
1034
+
1035
+ g.pop
1036
+ g.pop
1037
+ end
1038
+ end
1039
+
1040
+ relates "a, (b, c) = *1" do
1041
+ compile do |g|
1042
+ g.push 1
1043
+ g.cast_array
1044
+ g.dup
1045
+
1046
+ g.shift_array
1047
+ g.set_local 0
1048
+ g.pop
1049
+
1050
+ g.shift_array
1051
+ g.cast_array
1052
+
1053
+ g.shift_array
1054
+ g.set_local 1
1055
+ g.pop
1056
+
1057
+ g.shift_array
1058
+ g.set_local 2
1059
+ g.pop
1060
+
1061
+ g.pop
1062
+ g.pop
1063
+ end
1064
+ end
1065
+
1066
+ relates "a, (b, c) = 1, 2, 3" do
1067
+ compile do |g|
1068
+ g.push 1
1069
+ g.push 2
1070
+ g.push 3
1071
+
1072
+ g.dup_many 3
1073
+ g.make_array 3
1074
+ g.move_down 3
1075
+
1076
+ g.rotate 3
1077
+
1078
+ g.set_local 0
1079
+ g.pop
1080
+
1081
+ g.cast_array
1082
+
1083
+ g.shift_array
1084
+ g.set_local 1
1085
+ g.pop
1086
+
1087
+ g.shift_array
1088
+ g.set_local 2
1089
+ g.pop
1090
+
1091
+ g.pop
1092
+ g.pop
1093
+ end
1094
+ end
1095
+
1096
+ relates "a, (b, *c), d = 1, 2, 3, 4" do
1097
+ compile do |g|
1098
+ g.push 1
1099
+ g.push 2
1100
+ g.push 3
1101
+ g.push 4
1102
+
1103
+ g.dup_many 4
1104
+ g.make_array 4
1105
+ g.move_down 4
1106
+
1107
+ g.rotate 4
1108
+
1109
+ g.set_local 0
1110
+ g.pop
1111
+
1112
+ g.cast_array
1113
+
1114
+ g.shift_array
1115
+ g.set_local 1
1116
+ g.pop
1117
+
1118
+ ary = g.new_label
1119
+ assign = g.new_label
1120
+
1121
+ g.dup
1122
+ g.push_cpath_top
1123
+ g.find_const :Array
1124
+ g.swap
1125
+ g.kind_of
1126
+ g.git assign
1127
+ g.make_array 1
1128
+
1129
+ assign.set!
1130
+ g.set_local 2
1131
+ g.pop
1132
+
1133
+ g.set_local 3
1134
+ g.pop
1135
+
1136
+ g.pop
1137
+ end
1138
+ end
1139
+
1140
+ relates "a, (b, c) = 1, *2" do
1141
+ compile do |g|
1142
+ g.push 1
1143
+ g.make_array 1
1144
+ g.push 2
1145
+ g.cast_array
1146
+ g.send :+, 1
1147
+ g.cast_array
1148
+ g.dup
1149
+
1150
+ g.shift_array
1151
+ g.set_local 0
1152
+ g.pop
1153
+
1154
+ g.shift_array
1155
+ g.cast_array
1156
+
1157
+ g.shift_array
1158
+ g.set_local 1
1159
+ g.pop
1160
+
1161
+ g.shift_array
1162
+ g.set_local 2
1163
+ g.pop
1164
+
1165
+ g.pop
1166
+ g.pop
1167
+ end
1168
+ end
1169
+
1170
+ relates "a, (b, *c) = 1" do
1171
+ compile do |g|
1172
+ g.push 1
1173
+ g.cast_multi_value
1174
+ g.dup
1175
+
1176
+ g.shift_array
1177
+ g.set_local 0
1178
+ g.pop
1179
+
1180
+ g.shift_array
1181
+ g.cast_array
1182
+
1183
+ g.shift_array
1184
+ g.set_local 1
1185
+ g.pop
1186
+
1187
+ assign = g.new_label
1188
+
1189
+ g.dup
1190
+ g.push_cpath_top
1191
+ g.find_const :Array
1192
+ g.swap
1193
+ g.kind_of
1194
+ g.git assign
1195
+ g.make_array 1
1196
+
1197
+ assign.set!
1198
+ g.set_local 2
1199
+
1200
+ g.pop
1201
+ g.pop
1202
+ end
1203
+ end
1204
+
1205
+ relates "a, (b, *c) = 1, 2" do
1206
+ compile do |g|
1207
+ g.push 1
1208
+ g.push 2
1209
+
1210
+ g.dup_many 2
1211
+ g.make_array 2
1212
+ g.move_down 2
1213
+
1214
+ g.rotate 2
1215
+
1216
+ g.set_local 0
1217
+ g.pop
1218
+
1219
+ g.cast_array
1220
+
1221
+ g.shift_array
1222
+ g.set_local 1
1223
+ g.pop
1224
+
1225
+ assign = g.new_label
1226
+
1227
+ g.dup
1228
+ g.push_cpath_top
1229
+ g.find_const :Array
1230
+ g.swap
1231
+ g.kind_of
1232
+ g.git assign
1233
+ g.make_array 1
1234
+
1235
+ assign.set!
1236
+ g.set_local 2
1237
+
1238
+ g.pop
1239
+ end
1240
+ end
1241
+
1242
+ relates "a, (b, *c) = *1" do
1243
+ compile do |g|
1244
+ g.push 1
1245
+ g.cast_array
1246
+ g.dup
1247
+
1248
+ g.shift_array
1249
+ g.set_local 0
1250
+ g.pop
1251
+
1252
+ g.shift_array
1253
+ g.cast_array
1254
+
1255
+ g.shift_array
1256
+ g.set_local 1
1257
+ g.pop
1258
+
1259
+ assign = g.new_label
1260
+
1261
+ g.dup
1262
+ g.push_cpath_top
1263
+ g.find_const :Array
1264
+ g.swap
1265
+ g.kind_of
1266
+ g.git assign
1267
+ g.make_array 1
1268
+
1269
+ assign.set!
1270
+ g.set_local 2
1271
+ g.pop
1272
+
1273
+ g.pop
1274
+ end
1275
+ end
1276
+
1277
+ relates "a, (b, *c) = 1, *2" do
1278
+ compile do |g|
1279
+ g.push 1
1280
+ g.make_array 1
1281
+ g.push 2
1282
+ g.cast_array
1283
+ g.send :+, 1
1284
+
1285
+ g.cast_array
1286
+ g.dup
1287
+
1288
+ g.shift_array
1289
+ g.set_local 0
1290
+ g.pop
1291
+
1292
+ g.shift_array
1293
+ g.cast_array
1294
+
1295
+ g.shift_array
1296
+ g.set_local 1
1297
+ g.pop
1298
+
1299
+ assign = g.new_label
1300
+
1301
+ g.dup
1302
+ g.push_cpath_top
1303
+ g.find_const :Array
1304
+ g.swap
1305
+ g.kind_of
1306
+ g.git assign
1307
+ g.make_array 1
1308
+
1309
+ assign.set!
1310
+ g.set_local 2
1311
+ g.pop
1312
+
1313
+ g.pop
1314
+ end
1315
+ end
1316
+
1317
+ relates "a, (*b) = 1" do
1318
+ compile do |g|
1319
+ g.push 1
1320
+ g.cast_multi_value
1321
+ g.dup
1322
+
1323
+ g.shift_array
1324
+ g.set_local 0
1325
+ g.pop
1326
+
1327
+ assign = g.new_label
1328
+
1329
+ g.shift_array
1330
+ g.dup
1331
+ g.push_cpath_top
1332
+ g.find_const :Array
1333
+ g.swap
1334
+ g.kind_of
1335
+ g.git assign
1336
+ g.make_array 1
1337
+
1338
+ assign.set!
1339
+ g.set_local 1
1340
+ g.pop
1341
+
1342
+ g.pop
1343
+ end
1344
+ end
1345
+
1346
+ relates "a, (*b) = 1, 2" do
1347
+ compile do |g|
1348
+ g.push 1
1349
+ g.push 2
1350
+
1351
+ g.dup_many 2
1352
+ g.make_array 2
1353
+ g.move_down 2
1354
+
1355
+ g.rotate 2
1356
+
1357
+ g.set_local 0
1358
+ g.pop
1359
+
1360
+ assign = g.new_label
1361
+
1362
+ g.dup
1363
+ g.push_cpath_top
1364
+ g.find_const :Array
1365
+ g.swap
1366
+ g.kind_of
1367
+ g.git assign
1368
+ g.make_array 1
1369
+
1370
+ assign.set!
1371
+ g.set_local 1
1372
+ g.pop
1373
+ end
1374
+ end
1375
+
1376
+ relates "a, (*b) = *1" do
1377
+ compile do |g|
1378
+ g.push 1
1379
+ g.cast_array
1380
+ g.dup
1381
+
1382
+ g.shift_array
1383
+ g.set_local 0
1384
+ g.pop
1385
+
1386
+ assign = g.new_label
1387
+
1388
+ g.shift_array
1389
+ g.dup
1390
+ g.push_cpath_top
1391
+ g.find_const :Array
1392
+ g.swap
1393
+ g.kind_of
1394
+ g.git assign
1395
+ g.make_array 1
1396
+
1397
+ assign.set!
1398
+ g.set_local 1
1399
+ g.pop
1400
+
1401
+ g.pop
1402
+ end
1403
+ end
1404
+
1405
+ relates "a, (*b) = 1, *2" do
1406
+ compile do |g|
1407
+ g.push 1
1408
+ g.make_array 1
1409
+ g.push 2
1410
+ g.cast_array
1411
+ g.send :+, 1
1412
+ g.cast_array
1413
+ g.dup
1414
+
1415
+ g.shift_array
1416
+ g.set_local 0
1417
+ g.pop
1418
+
1419
+ g.shift_array
1420
+
1421
+ assign = g.new_label
1422
+
1423
+ g.dup
1424
+ g.push_cpath_top
1425
+ g.find_const :Array
1426
+ g.swap
1427
+ g.kind_of
1428
+ g.git assign
1429
+ g.make_array 1
1430
+
1431
+ assign.set!
1432
+ g.set_local 1
1433
+ g.pop
1434
+
1435
+ g.pop
1436
+ end
1437
+ end
1438
+
1439
+ relates "a, b = nil, lambda { a = 7 }" do
1440
+ compile do |g|
1441
+ g.push :nil
1442
+
1443
+ g.push :self
1444
+ g.in_block_send :lambda, :none do |d|
1445
+ d.push 7
1446
+ d.set_local_depth 1, 0
1447
+ end
1448
+
1449
+ g.dup_many 2
1450
+ g.make_array 2
1451
+ g.move_down 2
1452
+
1453
+ g.rotate 2
1454
+
1455
+ g.set_local 0
1456
+ g.pop
1457
+
1458
+ g.set_local 1
1459
+ g.pop
1460
+ end
1461
+ end
1462
+
1463
+ relates "a, *b = lambda { b = 8 }, nil" do
1464
+ compile do |g|
1465
+ g.push :self
1466
+ g.in_block_send :lambda, :none do |d|
1467
+ d.push 8
1468
+ d.set_local_depth 1, 1
1469
+ end
1470
+
1471
+ g.push :nil
1472
+
1473
+ g.dup_many 2
1474
+ g.make_array 2
1475
+ g.move_down 2
1476
+
1477
+ g.make_array 1
1478
+ g.rotate 2
1479
+
1480
+ g.set_local 0
1481
+ g.pop
1482
+
1483
+ g.cast_array
1484
+ g.set_local 1
1485
+ g.pop
1486
+ end
1487
+ end
1488
+
1489
+ relates "*a = lambda { a = 8 }" do
1490
+ compile do |g|
1491
+ g.push :self
1492
+ g.in_block_send :lambda, :none do |d|
1493
+ d.push 8
1494
+ d.set_local_depth 1, 0
1495
+ end
1496
+
1497
+ array = g.new_label
1498
+ g.cast_multi_value
1499
+ g.cast_array
1500
+ g.dup
1501
+ g.dup
1502
+ g.push_cpath_top
1503
+ g.find_const :Array
1504
+ g.swap
1505
+ g.kind_of
1506
+ g.git array
1507
+
1508
+ g.make_array 1
1509
+
1510
+ array.set!
1511
+ g.set_local 0
1512
+
1513
+ g.pop
1514
+ end
1515
+ end
1516
+
1517
+ relates "a, (b, *c), d = lambda { b = d }, [], nil" do
1518
+ compile do |g|
1519
+ g.push :self
1520
+ g.in_block_send :lambda, :none do |d|
1521
+ d.push_local_depth 1, 3
1522
+ d.set_local_depth 1, 1
1523
+ end
1524
+
1525
+ g.make_array 0
1526
+ g.push :nil
1527
+
1528
+ g.dup_many 3
1529
+ g.make_array 3
1530
+ g.move_down 3
1531
+
1532
+ g.rotate 3
1533
+
1534
+ g.set_local 0
1535
+ g.pop
1536
+
1537
+ g.cast_array
1538
+ g.shift_array
1539
+ g.set_local 1
1540
+ g.pop
1541
+ g.dup
1542
+ g.push_cpath_top
1543
+ g.find_const :Array
1544
+ g.swap
1545
+ g.kind_of
1546
+
1547
+ is_array = g.new_label
1548
+ g.git is_array
1549
+ g.make_array 1
1550
+ is_array.set!
1551
+
1552
+ g.set_local 2
1553
+ g.pop
1554
+ g.set_local 3
1555
+ g.pop
1556
+ end
1557
+ end
1558
+ end