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.
- checksums.yaml +4 -4
- data/.travis.yml +8 -0
- data/lib/rubinius/compiler/compiled_file.rb +32 -32
- data/lib/rubinius/compiler/version.rb +2 -2
- data/rubinius-compiler.gemspec +6 -0
- data/spec/alias_spec.rb +39 -0
- data/spec/and_spec.rb +44 -0
- data/spec/array_spec.rb +110 -0
- data/spec/attrasgn_spec.rb +186 -0
- data/spec/back_ref_spec.rb +11 -0
- data/spec/call_spec.rb +580 -0
- data/spec/case_spec.rb +576 -0
- data/spec/cdecl_spec.rb +70 -0
- data/spec/class_spec.rb +120 -0
- data/spec/colon2_spec.rb +8 -0
- data/spec/colon3_spec.rb +8 -0
- data/spec/const_spec.rb +7 -0
- data/spec/custom/guards/profiler.rb +18 -0
- data/spec/custom/helpers/generator.rb +828 -0
- data/spec/custom/matchers/compile_as.rb +46 -0
- data/spec/custom/mspec.rb +15 -0
- data/spec/custom/runner/actions/debug.rb +10 -0
- data/spec/custom/runner/actions/gcstats.rb +17 -0
- data/spec/custom/runner/actions/memory.rb +11 -0
- data/spec/custom/runner/actions/parser.rb +14 -0
- data/spec/custom/runner/actions/profiler.rb +19 -0
- data/spec/custom/runner/relates.rb +86 -0
- data/spec/custom/utils/options.rb +40 -0
- data/spec/custom/utils/script.rb +50 -0
- data/spec/cvar_spec.rb +39 -0
- data/spec/cvasgn_spec.rb +33 -0
- data/spec/cvdecl_spec.rb +17 -0
- data/spec/defined_spec.rb +616 -0
- data/spec/defn_spec.rb +732 -0
- data/spec/defs_spec.rb +113 -0
- data/spec/dot2_spec.rb +16 -0
- data/spec/dot3_spec.rb +17 -0
- data/spec/dregx_spec.rb +160 -0
- data/spec/dstr_spec.rb +424 -0
- data/spec/dsym_spec.rb +18 -0
- data/spec/dxstr_spec.rb +24 -0
- data/spec/ensure_spec.rb +196 -0
- data/spec/false_spec.rb +7 -0
- data/spec/flip2_spec.rb +21 -0
- data/spec/flip3_spec.rb +12 -0
- data/spec/for_spec.rb +228 -0
- data/spec/gasgn_spec.rb +15 -0
- data/spec/generator/encode_spec.rb +34 -0
- data/spec/gvar_spec.rb +37 -0
- data/spec/hash_spec.rb +108 -0
- data/spec/iasgn_spec.rb +26 -0
- data/spec/if_spec.rb +415 -0
- data/spec/iter_spec.rb +1011 -0
- data/spec/lasgn_spec.rb +561 -0
- data/spec/lit_spec.rb +61 -0
- data/spec/masgn_spec.rb +1558 -0
- data/spec/match2_spec.rb +42 -0
- data/spec/match3_spec.rb +54 -0
- data/spec/match_spec.rb +29 -0
- data/spec/module_spec.rb +73 -0
- data/spec/nil_spec.rb +7 -0
- data/spec/not_spec.rb +47 -0
- data/spec/nth_ref_spec.rb +7 -0
- data/spec/op_asgn_spec.rb +563 -0
- data/spec/or_spec.rb +126 -0
- data/spec/postexe_spec.rb +11 -0
- data/spec/preexe_spec.rb +21 -0
- data/spec/regex_spec.rb +54 -0
- data/spec/rescue_spec.rb +763 -0
- data/spec/return_spec.rb +152 -0
- data/spec/sclass_spec.rb +138 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/str_spec.rb +118 -0
- data/spec/super_spec.rb +170 -0
- data/spec/transforms/assembly_spec.rb +195 -0
- data/spec/transforms/block_given_spec.rb +75 -0
- data/spec/transforms/fast_coerce_spec.rb +112 -0
- data/spec/transforms/fast_new_spec.rb +255 -0
- data/spec/transforms/invoke_primitive_spec.rb +14 -0
- data/spec/transforms/kernel_methods_spec.rb +29 -0
- data/spec/transforms/primitive_spec.rb +33 -0
- data/spec/transforms/privately_spec.rb +24 -0
- data/spec/true_spec.rb +7 -0
- data/spec/undef_spec.rb +133 -0
- data/spec/until_spec.rb +254 -0
- data/spec/valias_spec.rb +11 -0
- data/spec/while_spec.rb +494 -0
- data/spec/xstr_spec.rb +10 -0
- data/spec/yield_spec.rb +92 -0
- data/spec/zsuper_spec.rb +63 -0
- metadata +258 -3
data/spec/match2_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
describe "A Match2 node" do
|
2
|
+
relates '/x/ =~ "blah"' do
|
3
|
+
compile do |g|
|
4
|
+
g.memoize do
|
5
|
+
g.push_cpath_top
|
6
|
+
g.find_const :Regexp
|
7
|
+
g.push_literal "x"
|
8
|
+
g.push 0
|
9
|
+
g.send :new, 2
|
10
|
+
end
|
11
|
+
|
12
|
+
g.push_literal "blah"
|
13
|
+
g.string_dup
|
14
|
+
g.send :=~, 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
relates <<-ruby do
|
19
|
+
x = "x"
|
20
|
+
/\#{x}/ =~ x
|
21
|
+
ruby
|
22
|
+
|
23
|
+
compile do |g|
|
24
|
+
g.push_literal "x"
|
25
|
+
g.string_dup
|
26
|
+
g.set_local 0
|
27
|
+
g.pop
|
28
|
+
|
29
|
+
g.push_cpath_top
|
30
|
+
g.find_const :Regexp
|
31
|
+
g.push_local 0
|
32
|
+
g.meta_to_s
|
33
|
+
g.string_build 1
|
34
|
+
|
35
|
+
g.push 0
|
36
|
+
g.send :new, 2
|
37
|
+
|
38
|
+
g.push_local 0
|
39
|
+
g.send :=~, 1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/match3_spec.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
describe "A Match3 node" do
|
2
|
+
relates '"blah" =~ /x/' do
|
3
|
+
compile do |g|
|
4
|
+
g.push_literal "blah"
|
5
|
+
g.string_dup
|
6
|
+
|
7
|
+
g.memoize do
|
8
|
+
g.push_cpath_top
|
9
|
+
g.find_const :Regexp
|
10
|
+
g.push_literal "x"
|
11
|
+
g.push 0
|
12
|
+
g.send :new, 2
|
13
|
+
end
|
14
|
+
|
15
|
+
g.send :=~, 1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
relates <<-ruby do
|
20
|
+
a = 'abc'
|
21
|
+
if a =~ /\#{a}/
|
22
|
+
1
|
23
|
+
end
|
24
|
+
ruby
|
25
|
+
|
26
|
+
compile do |g|
|
27
|
+
g.push_literal "abc"
|
28
|
+
g.string_dup
|
29
|
+
g.set_local 0
|
30
|
+
g.pop
|
31
|
+
g.push_local 0
|
32
|
+
|
33
|
+
g.push_cpath_top
|
34
|
+
g.find_const :Regexp
|
35
|
+
g.push_local 0
|
36
|
+
g.meta_to_s
|
37
|
+
g.string_build 1
|
38
|
+
|
39
|
+
g.push 0
|
40
|
+
g.send :new, 2
|
41
|
+
|
42
|
+
false_label = g.new_label
|
43
|
+
done = g.new_label
|
44
|
+
g.send :=~, 1
|
45
|
+
g.gif false_label
|
46
|
+
g.push 1
|
47
|
+
g.goto done
|
48
|
+
|
49
|
+
false_label.set!
|
50
|
+
g.push :nil
|
51
|
+
done.set!
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/spec/match_spec.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
describe "A Match node" do
|
2
|
+
relates "1 if /x/" do
|
3
|
+
compile do |g|
|
4
|
+
g.push_rubinius
|
5
|
+
g.find_const :Globals # FIX: find the other Globals, order flipped
|
6
|
+
g.push_literal :$_ # REFACTOR - we use this block a lot
|
7
|
+
g.send :[], 1
|
8
|
+
|
9
|
+
g.memoize do
|
10
|
+
g.push_cpath_top
|
11
|
+
g.find_const :Regexp
|
12
|
+
g.push_literal "x"
|
13
|
+
g.push 0
|
14
|
+
g.send :new, 2
|
15
|
+
end
|
16
|
+
|
17
|
+
f = g.new_label
|
18
|
+
t = g.new_label
|
19
|
+
|
20
|
+
g.send :=~, 1
|
21
|
+
g.gif f
|
22
|
+
g.push 1
|
23
|
+
g.goto t
|
24
|
+
f.set!
|
25
|
+
g.push :nil
|
26
|
+
t.set!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/module_spec.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
describe "A Module node" do
|
2
|
+
relates <<-ruby do
|
3
|
+
module X
|
4
|
+
def y
|
5
|
+
end
|
6
|
+
end
|
7
|
+
ruby
|
8
|
+
|
9
|
+
compile do |g|
|
10
|
+
in_module :X do |d|
|
11
|
+
d.in_method :y do |d2|
|
12
|
+
d2.push :nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
relates <<-ruby do
|
19
|
+
module ::Y
|
20
|
+
c
|
21
|
+
end
|
22
|
+
ruby
|
23
|
+
|
24
|
+
compile do |g|
|
25
|
+
g.push_rubinius
|
26
|
+
g.push_literal :Y
|
27
|
+
g.push_cpath_top
|
28
|
+
g.send :open_module_under, 2
|
29
|
+
|
30
|
+
d = new_generator(g, :Y)
|
31
|
+
g.create_block d
|
32
|
+
|
33
|
+
d.push_self
|
34
|
+
d.add_scope
|
35
|
+
d.push :self
|
36
|
+
d.send :c, 0, true
|
37
|
+
d.ret
|
38
|
+
|
39
|
+
g.swap
|
40
|
+
g.push_scope
|
41
|
+
g.push_true
|
42
|
+
g.send :call_under, 3
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
relates <<-ruby do
|
47
|
+
module X::Y
|
48
|
+
c
|
49
|
+
end
|
50
|
+
ruby
|
51
|
+
|
52
|
+
compile do |g|
|
53
|
+
in_module "X::Y" do |d|
|
54
|
+
d.push :self
|
55
|
+
d.send :c, 0, true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
relates <<-ruby do
|
61
|
+
"prevent the above from infecting rdoc"
|
62
|
+
|
63
|
+
module Graffle
|
64
|
+
end
|
65
|
+
ruby
|
66
|
+
|
67
|
+
compile do |g|
|
68
|
+
g.in_module :Graffle
|
69
|
+
g.pop
|
70
|
+
g.push :nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/spec/nil_spec.rb
ADDED
data/spec/not_spec.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
ruby_version_is ""..."1.9" do
|
2
|
+
describe "A Not node" do
|
3
|
+
relates "(not true)" do
|
4
|
+
compile do |g|
|
5
|
+
f = g.new_label
|
6
|
+
t = g.new_label
|
7
|
+
|
8
|
+
g.push :true
|
9
|
+
g.git f
|
10
|
+
|
11
|
+
g.push :true
|
12
|
+
g.goto t
|
13
|
+
|
14
|
+
f.set!
|
15
|
+
g.push :false
|
16
|
+
|
17
|
+
t.set!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
relates <<-ruby do
|
22
|
+
a = 1
|
23
|
+
b = !a
|
24
|
+
ruby
|
25
|
+
|
26
|
+
compile do |g|
|
27
|
+
invert = g.new_label
|
28
|
+
done = g.new_label
|
29
|
+
|
30
|
+
g.push 1
|
31
|
+
g.set_local 0
|
32
|
+
g.pop
|
33
|
+
|
34
|
+
g.push_local 0
|
35
|
+
g.git invert
|
36
|
+
g.push :true
|
37
|
+
g.goto done
|
38
|
+
|
39
|
+
invert.set!
|
40
|
+
g.push :false
|
41
|
+
|
42
|
+
done.set!
|
43
|
+
g.set_local 1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,563 @@
|
|
1
|
+
describe "An Op_asgn1 node" do
|
2
|
+
relates "a &&= 8" do
|
3
|
+
compile do |g|
|
4
|
+
fin = g.new_label
|
5
|
+
|
6
|
+
g.push_local 0
|
7
|
+
g.dup
|
8
|
+
g.gif fin
|
9
|
+
|
10
|
+
g.pop
|
11
|
+
g.push 8
|
12
|
+
g.set_local 0
|
13
|
+
|
14
|
+
fin.set!
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
relates "hsh[:blah] ||= 8" do
|
19
|
+
compile do |g|
|
20
|
+
found = g.new_label
|
21
|
+
fin = g.new_label
|
22
|
+
|
23
|
+
g.push :self
|
24
|
+
g.send :hsh, 0, true
|
25
|
+
g.push_literal :blah
|
26
|
+
g.dup_many 2
|
27
|
+
|
28
|
+
g.send :[], 1
|
29
|
+
g.dup
|
30
|
+
g.git found
|
31
|
+
|
32
|
+
g.pop
|
33
|
+
g.push 8
|
34
|
+
g.dup
|
35
|
+
g.move_down 3
|
36
|
+
g.send :[]=, 2
|
37
|
+
g.pop
|
38
|
+
g.goto fin
|
39
|
+
|
40
|
+
found.set!
|
41
|
+
|
42
|
+
g.move_down 2
|
43
|
+
g.pop_many 2
|
44
|
+
|
45
|
+
fin.set!
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
relates <<-ruby do
|
50
|
+
x = 1
|
51
|
+
hsh[x] ||= 8
|
52
|
+
ruby
|
53
|
+
|
54
|
+
compile do |g|
|
55
|
+
g.push 1
|
56
|
+
g.set_local 0
|
57
|
+
g.pop
|
58
|
+
|
59
|
+
found = g.new_label
|
60
|
+
fin = g.new_label
|
61
|
+
|
62
|
+
g.push :self
|
63
|
+
g.send :hsh, 0, true
|
64
|
+
g.push_local 0
|
65
|
+
g.dup_many 2
|
66
|
+
|
67
|
+
g.send :[], 1
|
68
|
+
g.dup
|
69
|
+
g.git found
|
70
|
+
|
71
|
+
g.pop
|
72
|
+
g.push 8
|
73
|
+
g.dup
|
74
|
+
g.move_down 3
|
75
|
+
g.send :[]=, 2
|
76
|
+
g.pop
|
77
|
+
g.goto fin
|
78
|
+
|
79
|
+
found.set!
|
80
|
+
|
81
|
+
g.move_down 2
|
82
|
+
g.pop_many 2
|
83
|
+
|
84
|
+
fin.set!
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
relates "hsh[:blah] &&= 8" do
|
89
|
+
compile do |g|
|
90
|
+
found = g.new_label
|
91
|
+
fin = g.new_label
|
92
|
+
|
93
|
+
g.push :self
|
94
|
+
g.send :hsh, 0, true
|
95
|
+
g.push_literal :blah
|
96
|
+
g.dup_many 2
|
97
|
+
|
98
|
+
g.send :[], 1
|
99
|
+
g.dup
|
100
|
+
g.gif found
|
101
|
+
|
102
|
+
g.pop
|
103
|
+
g.push 8
|
104
|
+
g.dup
|
105
|
+
g.move_down 3
|
106
|
+
g.send :[]=, 2
|
107
|
+
g.pop
|
108
|
+
g.goto fin
|
109
|
+
|
110
|
+
found.set!
|
111
|
+
|
112
|
+
g.move_down 2
|
113
|
+
g.pop_many 2
|
114
|
+
|
115
|
+
fin.set!
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
relates "hsh[:blah] ^= 8" do
|
121
|
+
compile do |g|
|
122
|
+
fin = g.new_label
|
123
|
+
|
124
|
+
g.push :self
|
125
|
+
g.send :hsh, 0, true
|
126
|
+
g.push_literal :blah
|
127
|
+
g.dup_many 2
|
128
|
+
|
129
|
+
g.send :[], 1
|
130
|
+
g.push 8
|
131
|
+
g.send :"^", 1
|
132
|
+
g.dup
|
133
|
+
g.move_down 3
|
134
|
+
g.send :[]=, 2
|
135
|
+
g.pop
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
relates "ary[0,1] += [4]" do
|
140
|
+
compile do |g|
|
141
|
+
g.push :self
|
142
|
+
g.send :ary, 0, true
|
143
|
+
g.push 0
|
144
|
+
g.push 1
|
145
|
+
g.dup_many 3
|
146
|
+
|
147
|
+
g.send :[], 2
|
148
|
+
|
149
|
+
g.push 4
|
150
|
+
g.make_array 1
|
151
|
+
g.send :"+", 1
|
152
|
+
g.dup
|
153
|
+
g.move_down 4
|
154
|
+
g.send :[]=, 3
|
155
|
+
g.pop
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
relates "x.val ||= 6" do
|
160
|
+
compile do |g|
|
161
|
+
fnd = g.new_label
|
162
|
+
fin = g.new_label
|
163
|
+
|
164
|
+
g.push :self
|
165
|
+
g.send :x, 0, true
|
166
|
+
g.dup
|
167
|
+
g.send :val, 0
|
168
|
+
g.dup
|
169
|
+
g.git fnd
|
170
|
+
|
171
|
+
g.pop
|
172
|
+
g.push 6
|
173
|
+
g.dup
|
174
|
+
g.move_down 2
|
175
|
+
g.send :val=, 1
|
176
|
+
g.pop
|
177
|
+
g.goto fin
|
178
|
+
|
179
|
+
fnd.set!
|
180
|
+
g.swap
|
181
|
+
g.pop
|
182
|
+
fin.set!
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
relates "x.val &&= 7" do
|
187
|
+
compile do |g|
|
188
|
+
fnd = g.new_label
|
189
|
+
fin = g.new_label
|
190
|
+
|
191
|
+
g.push :self
|
192
|
+
g.send :x, 0, true
|
193
|
+
g.dup
|
194
|
+
g.send :val, 0
|
195
|
+
g.dup
|
196
|
+
g.gif fnd
|
197
|
+
|
198
|
+
g.pop
|
199
|
+
g.push 7
|
200
|
+
g.dup
|
201
|
+
g.move_down 2
|
202
|
+
g.send :val=, 1
|
203
|
+
g.pop
|
204
|
+
g.goto fin
|
205
|
+
|
206
|
+
fnd.set!
|
207
|
+
g.swap
|
208
|
+
g.pop
|
209
|
+
fin.set!
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
describe "An Op_asgn2 node" do
|
216
|
+
relates "x.val ^= 8" do
|
217
|
+
compile do |g|
|
218
|
+
g.push :self
|
219
|
+
g.send :x, 0, true
|
220
|
+
g.dup
|
221
|
+
g.send :val, 0
|
222
|
+
g.push 8
|
223
|
+
g.send :"^", 1
|
224
|
+
g.dup
|
225
|
+
g.move_down 2
|
226
|
+
g.send :val=, 1
|
227
|
+
g.pop
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
relates "self.Bag ||= Bag.new" do
|
232
|
+
compile do |g|
|
233
|
+
t = g.new_label
|
234
|
+
f = g.new_label
|
235
|
+
|
236
|
+
g.push :self
|
237
|
+
g.dup
|
238
|
+
g.send :Bag, 0
|
239
|
+
g.dup
|
240
|
+
g.git t
|
241
|
+
g.pop
|
242
|
+
g.push_const :Bag
|
243
|
+
g.send :new, 0, false
|
244
|
+
g.dup
|
245
|
+
g.move_down 2
|
246
|
+
g.send :"Bag=", 1
|
247
|
+
g.pop
|
248
|
+
g.goto f
|
249
|
+
|
250
|
+
t.set!
|
251
|
+
|
252
|
+
g.swap
|
253
|
+
g.pop
|
254
|
+
|
255
|
+
f.set!
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
relates <<-ruby do
|
260
|
+
s = Struct.new(:var)
|
261
|
+
c = s.new(nil)
|
262
|
+
c.var ||= 20
|
263
|
+
c.var &&= 21
|
264
|
+
c.var += 22
|
265
|
+
c.d.e.f ||= 42
|
266
|
+
ruby
|
267
|
+
|
268
|
+
compile do |g|
|
269
|
+
l_or = g.new_label
|
270
|
+
l_and = g.new_label
|
271
|
+
l_plus = g.new_label
|
272
|
+
l_or2 = g.new_label
|
273
|
+
l_rhs = g.new_label
|
274
|
+
bottom = g.new_label
|
275
|
+
|
276
|
+
g.push_const :Struct
|
277
|
+
g.push_literal :var
|
278
|
+
g.send :new, 1, false
|
279
|
+
g.set_local 0
|
280
|
+
g.pop
|
281
|
+
|
282
|
+
g.push_local 0
|
283
|
+
g.push :nil
|
284
|
+
g.send :new, 1, false
|
285
|
+
g.set_local 1
|
286
|
+
g.pop
|
287
|
+
|
288
|
+
g.push_local 1
|
289
|
+
g.dup
|
290
|
+
g.send :var, 0
|
291
|
+
g.dup
|
292
|
+
g.git l_or
|
293
|
+
|
294
|
+
g.pop
|
295
|
+
g.push 20
|
296
|
+
g.dup
|
297
|
+
g.move_down 2
|
298
|
+
g.send :var=, 1
|
299
|
+
g.pop
|
300
|
+
g.goto l_and
|
301
|
+
|
302
|
+
l_or.set!
|
303
|
+
|
304
|
+
g.swap
|
305
|
+
g.pop
|
306
|
+
|
307
|
+
l_and.set!
|
308
|
+
|
309
|
+
g.pop
|
310
|
+
g.push_local 1
|
311
|
+
g.dup
|
312
|
+
g.send :var, 0
|
313
|
+
g.dup
|
314
|
+
g.gif l_plus
|
315
|
+
g.pop
|
316
|
+
g.push 21
|
317
|
+
g.dup
|
318
|
+
g.move_down 2
|
319
|
+
g.send :var=, 1
|
320
|
+
g.pop
|
321
|
+
g.goto l_or2
|
322
|
+
|
323
|
+
l_plus.set!
|
324
|
+
|
325
|
+
g.swap
|
326
|
+
g.pop
|
327
|
+
|
328
|
+
l_or2.set!
|
329
|
+
|
330
|
+
g.pop
|
331
|
+
g.push_local 1
|
332
|
+
g.dup
|
333
|
+
g.send :var, 0
|
334
|
+
g.push 22
|
335
|
+
g.send :+, 1
|
336
|
+
g.dup
|
337
|
+
g.move_down 2
|
338
|
+
g.send :var=, 1
|
339
|
+
g.pop
|
340
|
+
g.pop
|
341
|
+
|
342
|
+
g.push_local 1
|
343
|
+
g.send :d, 0, false
|
344
|
+
g.send :e, 0, false
|
345
|
+
g.dup
|
346
|
+
g.send :f, 0
|
347
|
+
g.dup
|
348
|
+
|
349
|
+
g.git l_rhs
|
350
|
+
|
351
|
+
g.pop
|
352
|
+
g.push 42
|
353
|
+
g.dup
|
354
|
+
g.move_down 2
|
355
|
+
g.send :f=, 1
|
356
|
+
g.pop
|
357
|
+
g.goto bottom
|
358
|
+
|
359
|
+
l_rhs.set!
|
360
|
+
|
361
|
+
g.swap
|
362
|
+
g.pop
|
363
|
+
|
364
|
+
bottom.set!
|
365
|
+
end
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe "An Op_asgn_and node" do
|
370
|
+
relates "@fetcher &&= new(Gem.configuration[:http_proxy])" do
|
371
|
+
compile do |g|
|
372
|
+
t = g.new_label
|
373
|
+
|
374
|
+
g.push_ivar :@fetcher
|
375
|
+
g.dup
|
376
|
+
g.gif t
|
377
|
+
g.pop
|
378
|
+
|
379
|
+
g.push :self
|
380
|
+
g.push_const :Gem
|
381
|
+
g.send :configuration, 0, false
|
382
|
+
|
383
|
+
g.push_literal :http_proxy
|
384
|
+
g.send :[], 1, false
|
385
|
+
|
386
|
+
g.send :new, 1, true
|
387
|
+
|
388
|
+
g.set_ivar :@fetcher
|
389
|
+
|
390
|
+
t.set!
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
relates <<-ruby do
|
395
|
+
a = 0
|
396
|
+
a &&= 2
|
397
|
+
ruby
|
398
|
+
|
399
|
+
compile do |g|
|
400
|
+
g.push 0
|
401
|
+
g.set_local 0
|
402
|
+
g.pop
|
403
|
+
|
404
|
+
g.push_local 0
|
405
|
+
g.dup
|
406
|
+
|
407
|
+
f = g.new_label
|
408
|
+
g.gif f
|
409
|
+
g.pop
|
410
|
+
g.push 2
|
411
|
+
g.set_local 0
|
412
|
+
|
413
|
+
f.set!
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
describe "An Op_asgn_or node" do
|
419
|
+
relates "@@var ||= 3" do
|
420
|
+
compile do |g|
|
421
|
+
done = g.new_label
|
422
|
+
notfound = g.new_label
|
423
|
+
|
424
|
+
g.push_scope
|
425
|
+
g.push_literal :@@var
|
426
|
+
g.send :class_variable_defined?, 1
|
427
|
+
g.gif notfound
|
428
|
+
|
429
|
+
g.push_scope
|
430
|
+
g.push_literal :@@var
|
431
|
+
g.send :class_variable_get, 1
|
432
|
+
g.dup
|
433
|
+
g.git done
|
434
|
+
g.pop
|
435
|
+
|
436
|
+
notfound.set!
|
437
|
+
g.push_scope
|
438
|
+
g.push_literal :@@var
|
439
|
+
g.push 3
|
440
|
+
g.send :class_variable_set, 2
|
441
|
+
|
442
|
+
done.set!
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
relates "a ||= 8" do
|
447
|
+
compile do |g|
|
448
|
+
fin = g.new_label
|
449
|
+
|
450
|
+
g.push_local 0
|
451
|
+
g.dup
|
452
|
+
g.git fin
|
453
|
+
|
454
|
+
g.pop
|
455
|
+
g.push 8
|
456
|
+
g.set_local 0
|
457
|
+
|
458
|
+
fin.set!
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
relates <<-ruby do
|
463
|
+
a ||= begin
|
464
|
+
b
|
465
|
+
rescue
|
466
|
+
c
|
467
|
+
end
|
468
|
+
ruby
|
469
|
+
|
470
|
+
compile do |g|
|
471
|
+
t = g.new_label
|
472
|
+
|
473
|
+
g.push_local 0
|
474
|
+
g.dup
|
475
|
+
g.git t
|
476
|
+
g.pop
|
477
|
+
|
478
|
+
for_rescue do |rb|
|
479
|
+
rb.body do
|
480
|
+
g.push :self
|
481
|
+
g.send :b, 0, true
|
482
|
+
end
|
483
|
+
|
484
|
+
rb.condition :StandardError, true do
|
485
|
+
g.push :self
|
486
|
+
g.send :c, 0, true
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
g.set_local 0
|
491
|
+
|
492
|
+
t.set!
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
relates "@fetcher ||= new(Gem.configuration[:http_proxy])" do
|
497
|
+
compile do |g|
|
498
|
+
t = g.new_label
|
499
|
+
|
500
|
+
g.push_ivar :@fetcher
|
501
|
+
g.dup
|
502
|
+
g.git t
|
503
|
+
g.pop
|
504
|
+
|
505
|
+
g.push :self
|
506
|
+
g.push_const :Gem
|
507
|
+
g.send :configuration, 0, false
|
508
|
+
|
509
|
+
g.push_literal :http_proxy
|
510
|
+
g.send :[], 1, false
|
511
|
+
|
512
|
+
g.send :new, 1, true
|
513
|
+
|
514
|
+
g.set_ivar :@fetcher
|
515
|
+
|
516
|
+
t.set!
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
relates "@v ||= { }" do
|
521
|
+
compile do |g|
|
522
|
+
t = g.new_label
|
523
|
+
|
524
|
+
g.push_ivar :@v
|
525
|
+
g.dup
|
526
|
+
g.git t
|
527
|
+
g.pop
|
528
|
+
|
529
|
+
g.push_cpath_top
|
530
|
+
g.find_const :Hash
|
531
|
+
g.push 0
|
532
|
+
g.send :new_from_literal, 1
|
533
|
+
|
534
|
+
g.set_ivar :@v
|
535
|
+
|
536
|
+
t.set!
|
537
|
+
end
|
538
|
+
end
|
539
|
+
|
540
|
+
relates <<-ruby do
|
541
|
+
a = 0
|
542
|
+
a ||= 1
|
543
|
+
ruby
|
544
|
+
|
545
|
+
compile do |g|
|
546
|
+
t = g.new_label
|
547
|
+
|
548
|
+
g.push 0
|
549
|
+
g.set_local 0
|
550
|
+
g.pop # FIX: lame
|
551
|
+
g.push_local 0
|
552
|
+
g.dup
|
553
|
+
g.git t
|
554
|
+
g.pop
|
555
|
+
|
556
|
+
g.push 1
|
557
|
+
|
558
|
+
g.set_local 0
|
559
|
+
|
560
|
+
t.set!
|
561
|
+
end
|
562
|
+
end
|
563
|
+
end
|