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
@@ -0,0 +1,11 @@
1
+ describe "A Valias node" do
2
+ relates "alias $y $x" do
3
+ compile do |g|
4
+ g.push_rubinius
5
+ g.find_const :Globals
6
+ g.push_literal :$x
7
+ g.push_literal :$y
8
+ g.send :add_alias, 2
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,494 @@
1
+ describe "A While node" do
2
+ pre_while = lambda do |g|
3
+ top = g.new_label
4
+ rdo = g.new_label
5
+ brk = g.new_label
6
+ post = g.new_label
7
+ bottom = g.new_label
8
+
9
+ g.push_modifiers
10
+
11
+ top.set!
12
+ g.push :self
13
+ g.send :a, 0, true
14
+ g.gif bottom
15
+
16
+ rdo.set!
17
+ g.push :self
18
+ g.send :b, 0, true
19
+ g.push 1
20
+ g.send :+, 1, false
21
+
22
+ post.set!
23
+ g.pop
24
+ g.check_interrupts
25
+ g.goto top
26
+
27
+ bottom.set!
28
+ g.push :nil
29
+
30
+ brk.set!
31
+ g.pop_modifiers
32
+ end
33
+
34
+ relates <<-ruby do
35
+ while a
36
+ b + 1
37
+ end
38
+ ruby
39
+
40
+ compile(&pre_while)
41
+ end
42
+
43
+ ruby_version_is "1.9" do
44
+ while_not = lambda do |g|
45
+ top = g.new_label
46
+ rdo = g.new_label
47
+ brk = g.new_label
48
+ post = g.new_label
49
+ bottom = g.new_label
50
+
51
+ g.push_modifiers
52
+
53
+ top.set!
54
+ g.push :self
55
+ g.send :a, 0, true
56
+ g.send :"!", 0, false
57
+ g.gif bottom
58
+
59
+ rdo.set!
60
+ g.push :self
61
+ g.send :b, 0, true
62
+ g.push 1
63
+ g.send :+, 1, false
64
+
65
+ post.set!
66
+ g.pop
67
+ g.check_interrupts
68
+ g.goto top
69
+
70
+ bottom.set!
71
+ g.push :nil
72
+
73
+ brk.set!
74
+ g.pop_modifiers
75
+ end
76
+
77
+ relates <<-ruby do
78
+ while not a
79
+ b + 1
80
+ end
81
+ ruby
82
+
83
+ compile(&while_not)
84
+ end
85
+
86
+ relates "b + 1 while not a" do
87
+ compile(&while_not)
88
+ end
89
+
90
+ relates <<-ruby do
91
+ begin
92
+ b + 1
93
+ end while not a
94
+ ruby
95
+
96
+ compile do |g|
97
+ top = g.new_label
98
+ brk = g.new_label
99
+ post = g.new_label
100
+ bottom = g.new_label
101
+
102
+ g.push_modifiers
103
+
104
+ top.set!
105
+
106
+ g.push :self
107
+ g.send :b, 0, true
108
+ g.push 1
109
+ g.send :+, 1, false
110
+
111
+ post.set!
112
+ g.pop
113
+ g.check_interrupts
114
+
115
+ g.push :self
116
+ g.send :a, 0, true
117
+ g.send :"!", 0, false
118
+ g.gif bottom
119
+
120
+ g.goto top
121
+
122
+ bottom.set!
123
+ g.push :nil
124
+
125
+ brk.set!
126
+ g.pop_modifiers
127
+ end
128
+ end
129
+ end
130
+
131
+ relates <<-ruby do
132
+ while 1
133
+ next 2
134
+ end
135
+ ruby
136
+
137
+ compile do |g|
138
+ top = g.new_label
139
+ rdo = g.new_label
140
+ brk = g.new_label
141
+ post = g.new_label
142
+ bottom = g.new_label
143
+
144
+ g.push_modifiers
145
+
146
+ top.set!
147
+ g.push 1
148
+ g.gif bottom
149
+
150
+ rdo.set!
151
+ g.push 2
152
+ g.goto post
153
+
154
+ post.set!
155
+ g.pop
156
+ g.check_interrupts
157
+ g.goto top
158
+
159
+ bottom.set!
160
+ g.push :nil
161
+
162
+ brk.set!
163
+ g.pop_modifiers
164
+ end
165
+ end
166
+
167
+ relates <<-ruby do
168
+ a = x
169
+ while a.b
170
+ 1
171
+ end
172
+ ruby
173
+
174
+ compile do |g|
175
+ top = g.new_label
176
+ rdo = g.new_label
177
+ brk = g.new_label
178
+ post = g.new_label
179
+ bottom = g.new_label
180
+
181
+ g.push :self
182
+ g.send :x, 0, true
183
+ g.set_local 0
184
+ g.pop
185
+
186
+ g.push_modifiers
187
+ top.set!
188
+
189
+ g.push_local 0
190
+ g.send :b, 0, false
191
+ g.gif bottom
192
+
193
+ rdo.set!
194
+ g.push 1
195
+
196
+ post.set!
197
+ g.pop
198
+ g.check_interrupts
199
+ g.goto top
200
+
201
+ bottom.set!
202
+ g.push :nil
203
+
204
+ brk.set!
205
+ g.pop_modifiers
206
+ end
207
+ end
208
+
209
+ relates "b + 1 while a" do
210
+ compile(&pre_while)
211
+ end
212
+
213
+ ruby_version_is ""..."1.9" do
214
+ relates <<-ruby do
215
+ until not a
216
+ b + 1
217
+ end
218
+ ruby
219
+
220
+ compile(&pre_while)
221
+ end
222
+
223
+ relates "b + 1 until not a" do
224
+ compile(&pre_while)
225
+ end
226
+ end
227
+
228
+ post_while = lambda do |g|
229
+ top = g.new_label
230
+ brk = g.new_label
231
+ post = g.new_label
232
+ bottom = g.new_label
233
+
234
+ g.push_modifiers
235
+
236
+ top.set!
237
+
238
+ g.push :self
239
+ g.send :b, 0, true
240
+ g.push 1
241
+ g.send :+, 1, false
242
+
243
+ post.set!
244
+ g.pop
245
+ g.check_interrupts
246
+
247
+ g.push :self
248
+ g.send :a, 0, true
249
+ g.gif bottom
250
+
251
+ g.goto top
252
+
253
+ bottom.set!
254
+ g.push :nil
255
+
256
+ brk.set!
257
+ g.pop_modifiers
258
+ end
259
+
260
+ relates <<-ruby do
261
+ begin
262
+ b + 1
263
+ end while a
264
+ ruby
265
+
266
+ compile(&post_while)
267
+ end
268
+
269
+ ruby_version_is ""..."1.9" do
270
+ relates <<-ruby do
271
+ begin
272
+ b + 1
273
+ end until not a
274
+ ruby
275
+
276
+ compile(&post_while)
277
+ end
278
+ end
279
+
280
+ nil_condition = lambda do |g|
281
+ top = g.new_label
282
+ rdo = g.new_label
283
+ brk = g.new_label
284
+ post = g.new_label
285
+ bottom = g.new_label
286
+
287
+ g.push_modifiers
288
+
289
+ top.set!
290
+ g.push :nil
291
+ g.gif bottom
292
+
293
+ rdo.set!
294
+ g.push :self
295
+ g.send :a, 0, true
296
+
297
+ post.set!
298
+ g.pop
299
+ g.check_interrupts
300
+ g.goto top
301
+
302
+ bottom.set!
303
+ g.push :nil
304
+
305
+ brk.set!
306
+ g.pop_modifiers
307
+ end
308
+
309
+ relates "a while ()" do
310
+ compile(&nil_condition)
311
+ end
312
+
313
+ relates <<-ruby do
314
+ while ()
315
+ a
316
+ end
317
+ ruby
318
+
319
+ compile(&nil_condition)
320
+ end
321
+
322
+ ruby_version_is ""..."1.9" do
323
+ relates "a until not ()" do
324
+ compile(&nil_condition)
325
+ end
326
+
327
+ relates <<-ruby do
328
+ until not ()
329
+ a
330
+ end
331
+ ruby
332
+
333
+ compile(&nil_condition)
334
+ end
335
+
336
+ relates "a until ! ()" do
337
+ compile(&nil_condition)
338
+ end
339
+
340
+ relates <<-ruby do
341
+ until ! ()
342
+ a
343
+ end
344
+ ruby
345
+
346
+ compile(&nil_condition)
347
+ end
348
+
349
+ end
350
+
351
+ relates <<-ruby do
352
+ while 1
353
+ 2
354
+ break :brk
355
+ end
356
+ ruby
357
+
358
+ compile do |g|
359
+ top = g.new_label
360
+ rdo = g.new_label
361
+ brk = g.new_label
362
+ post = g.new_label
363
+ bottom = g.new_label
364
+
365
+ g.push_modifiers
366
+ top.set!
367
+
368
+ g.push 1
369
+ g.gif bottom
370
+
371
+ rdo.set!
372
+ g.push 2
373
+ g.pop
374
+ g.push_literal :brk
375
+ g.goto brk
376
+
377
+ post.set!
378
+ g.pop
379
+ g.check_interrupts
380
+ g.goto top
381
+
382
+ bottom.set!
383
+ g.push :nil
384
+
385
+ brk.set!
386
+ g.pop_modifiers
387
+ end
388
+ end
389
+
390
+ relates <<-ruby do
391
+ while 1
392
+ begin
393
+ 2
394
+ break :brk
395
+ rescue
396
+ 3
397
+ end
398
+ end
399
+ ruby
400
+
401
+ compile do |g|
402
+ top = g.new_label
403
+ post = g.new_label
404
+ bottom = g.new_label
405
+ brk = g.break = g.new_label
406
+
407
+ g.push_modifiers
408
+ top.set!
409
+
410
+ g.push 1
411
+ g.gif bottom
412
+
413
+ # redo
414
+ g.new_label.set!
415
+
416
+ g.for_rescue do |rb|
417
+ rb.body do
418
+ g.push 2
419
+ g.pop
420
+ g.push_literal :brk
421
+ rb.break
422
+ end
423
+
424
+ rb.condition :StandardError, true do
425
+ g.push 3
426
+ end
427
+ end
428
+
429
+ post.set!
430
+ g.pop
431
+ g.check_interrupts
432
+ g.goto top
433
+
434
+ bottom.set!
435
+ g.push :nil
436
+
437
+ brk.set!
438
+ g.pop_modifiers
439
+ end
440
+
441
+ end
442
+
443
+ relates <<-ruby do
444
+ while 1
445
+ begin
446
+ 2
447
+ rescue
448
+ 3
449
+ break :brk
450
+ end
451
+ end
452
+ ruby
453
+
454
+ compile do |g|
455
+ top = g.new_label
456
+ post = g.new_label
457
+ bottom = g.new_label
458
+ brk = g.break = g.new_label
459
+
460
+ g.push_modifiers
461
+ top.set!
462
+
463
+ g.push 1
464
+ g.gif bottom
465
+
466
+ # redo
467
+ g.new_label.set!
468
+
469
+ g.for_rescue do |rb|
470
+ rb.body do
471
+ g.push 2
472
+ end
473
+
474
+ rb.condition :StandardError, true do
475
+ g.push 3
476
+ g.pop
477
+ g.push_literal :brk
478
+ rb.break
479
+ end
480
+ end
481
+
482
+ post.set!
483
+ g.pop
484
+ g.check_interrupts
485
+ g.goto top
486
+
487
+ bottom.set!
488
+ g.push :nil
489
+
490
+ brk.set!
491
+ g.pop_modifiers
492
+ end
493
+ end
494
+ end