rubinius-ast 1.3.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubinius/ast/constants.rb +2 -3
- data/lib/rubinius/ast/control_flow.rb +4 -27
- data/lib/rubinius/ast/data.rb +1 -1
- data/lib/rubinius/ast/definitions.rb +31 -16
- data/lib/rubinius/ast/encoding.rb +2 -7
- data/lib/rubinius/ast/exceptions.rb +1 -1
- data/lib/rubinius/ast/file.rb +1 -5
- data/lib/rubinius/ast/grapher.rb +1 -1
- data/lib/rubinius/ast/literals.rb +2 -15
- data/lib/rubinius/ast/node.rb +1 -3
- data/lib/rubinius/ast/operators.rb +18 -124
- data/lib/rubinius/ast/self.rb +1 -1
- data/lib/rubinius/ast/sends.rb +5 -24
- data/lib/rubinius/ast/transforms.rb +6 -3
- data/lib/rubinius/ast/values.rb +4 -184
- data/lib/rubinius/ast/variables.rb +113 -216
- data/lib/rubinius/ast/version.rb +2 -2
- data/rubinius-ast.gemspec +2 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c50ef0b73b000204cb9e7a73a1c6efdeacd9477e
|
4
|
+
data.tar.gz: c2c2532d06bf487f2ca3ace10dea8eec45a263bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23aba6963dd1e3e42d6721772ae6387e4ea3a176c54f847d6762185e3f50fb064021ffb213e12bb9301baf407610a3d7c06fd998bf345a4f12930098cedf44a3
|
7
|
+
data.tar.gz: e0b18cf80a291e1be52329e750396e57a872efe6d2027baba9dd55e4f163d047dbdb2f39a600dbb4f616d584f2fcb74cd7a67ecd40507ab2dc765993f973a7b2
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: us-ascii -*-
|
2
2
|
|
3
|
-
module
|
3
|
+
module Rubinius::ToolSet.current::TS
|
4
4
|
module AST
|
5
5
|
|
6
6
|
class TypeConstant < Node
|
@@ -204,8 +204,7 @@ module CodeTools
|
|
204
204
|
pos(g)
|
205
205
|
|
206
206
|
if g.state.op_asgn?
|
207
|
-
g.
|
208
|
-
g.find_const :Runtime
|
207
|
+
g.push_literal Compiler::Runtime
|
209
208
|
g.push_literal @name
|
210
209
|
g.push_scope
|
211
210
|
g.send :find_constant_for_op_asign_or, 2
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: us-ascii -*-
|
2
2
|
|
3
|
-
module
|
3
|
+
module Rubinius::ToolSet.current::TS
|
4
4
|
module AST
|
5
5
|
class Case < Node
|
6
6
|
attr_accessor :whens, :else
|
@@ -28,10 +28,6 @@ module CodeTools
|
|
28
28
|
done.set!
|
29
29
|
end
|
30
30
|
|
31
|
-
def defined(g)
|
32
|
-
g.push :nil
|
33
|
-
end
|
34
|
-
|
35
31
|
def receiver_sexp
|
36
32
|
nil
|
37
33
|
end
|
@@ -209,8 +205,7 @@ module CodeTools
|
|
209
205
|
g.dup
|
210
206
|
@condition.bytecode(g)
|
211
207
|
g.cast_array
|
212
|
-
g.
|
213
|
-
g.find_const :Runtime
|
208
|
+
g.push_literal Compiler::Runtime
|
214
209
|
g.rotate(3)
|
215
210
|
g.send :matches_when, 2
|
216
211
|
g.git body
|
@@ -272,16 +267,14 @@ module CodeTools
|
|
272
267
|
end
|
273
268
|
|
274
269
|
def get_flip_flop(g, index)
|
275
|
-
g.
|
276
|
-
g.find_const :Runtime
|
270
|
+
g.push_literal Compiler::Runtime
|
277
271
|
g.push_scope
|
278
272
|
g.push_literal index
|
279
273
|
g.send(:get_flip_flop, 2)
|
280
274
|
end
|
281
275
|
|
282
276
|
def set_flip_flop(g, index, value)
|
283
|
-
g.
|
284
|
-
g.find_const :Runtime
|
277
|
+
g.push_literal Compiler::Runtime
|
285
278
|
g.push_scope
|
286
279
|
g.push_literal index
|
287
280
|
g.push_literal value
|
@@ -335,10 +328,6 @@ module CodeTools
|
|
335
328
|
done.set!
|
336
329
|
end
|
337
330
|
|
338
|
-
def defined(g)
|
339
|
-
g.push :nil
|
340
|
-
end
|
341
|
-
|
342
331
|
def to_sexp
|
343
332
|
else_sexp = @else.kind_of?(NilLiteral) ? nil : @else.to_sexp
|
344
333
|
[:if, @condition.to_sexp, @body.to_sexp, else_sexp]
|
@@ -416,10 +405,6 @@ module CodeTools
|
|
416
405
|
g.pop_modifiers
|
417
406
|
end
|
418
407
|
|
419
|
-
def defined(g)
|
420
|
-
g.push :nil
|
421
|
-
end
|
422
|
-
|
423
408
|
def sexp_name
|
424
409
|
:while
|
425
410
|
end
|
@@ -566,10 +551,6 @@ module CodeTools
|
|
566
551
|
end
|
567
552
|
end
|
568
553
|
|
569
|
-
def defined(g)
|
570
|
-
g.push :nil
|
571
|
-
end
|
572
|
-
|
573
554
|
def sexp_name
|
574
555
|
:break
|
575
556
|
end
|
@@ -706,10 +687,6 @@ module CodeTools
|
|
706
687
|
end
|
707
688
|
end
|
708
689
|
|
709
|
-
def defined(g)
|
710
|
-
g.push :nil
|
711
|
-
end
|
712
|
-
|
713
690
|
def to_sexp
|
714
691
|
sexp = [:return]
|
715
692
|
sexp << @value.to_sexp if @value
|
data/lib/rubinius/ast/data.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: us-ascii -*-
|
2
2
|
|
3
|
-
module
|
3
|
+
module Rubinius::ToolSet.current::TS
|
4
4
|
module AST
|
5
5
|
class Alias < Node
|
6
6
|
attr_accessor :to, :from
|
@@ -330,15 +330,7 @@ module CodeTools
|
|
330
330
|
@required.size
|
331
331
|
end
|
332
332
|
|
333
|
-
|
334
|
-
arity = required_args
|
335
|
-
|
336
|
-
if @splat or not @optional.empty?
|
337
|
-
arity = -(arity + 1)
|
338
|
-
end
|
339
|
-
|
340
|
-
arity
|
341
|
-
end
|
333
|
+
alias_method :arity, :required_args
|
342
334
|
|
343
335
|
def post_args
|
344
336
|
0
|
@@ -447,11 +439,17 @@ module CodeTools
|
|
447
439
|
splat = nil
|
448
440
|
end
|
449
441
|
|
442
|
+
@post = []
|
450
443
|
if post
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
444
|
+
post.each do |arg|
|
445
|
+
case arg
|
446
|
+
when MultipleAssignment
|
447
|
+
@post << PatternArguments.from_masgn(arg)
|
448
|
+
when Symbol
|
449
|
+
@post << arg
|
450
|
+
names << arg
|
451
|
+
end
|
452
|
+
end
|
455
453
|
end
|
456
454
|
|
457
455
|
if block
|
@@ -501,8 +499,18 @@ module CodeTools
|
|
501
499
|
|
502
500
|
@defaults.map_arguments scope if @defaults
|
503
501
|
scope.new_local @splat if @splat.kind_of? Symbol
|
504
|
-
|
502
|
+
|
503
|
+
@post.each do |arg|
|
504
|
+
case arg
|
505
|
+
when PatternArguments
|
506
|
+
arg.map_arguments scope
|
507
|
+
when Symbol
|
508
|
+
scope.new_local arg
|
509
|
+
end
|
510
|
+
end
|
511
|
+
|
505
512
|
scope.assign_local_reference @block_arg if @block_arg
|
513
|
+
|
506
514
|
end
|
507
515
|
|
508
516
|
def bytecode(g)
|
@@ -516,9 +524,15 @@ module CodeTools
|
|
516
524
|
g.pop
|
517
525
|
end
|
518
526
|
end
|
519
|
-
|
520
527
|
@defaults.bytecode(g) if @defaults
|
521
528
|
@block_arg.bytecode(g) if @block_arg
|
529
|
+
@post.each do |arg|
|
530
|
+
if arg.kind_of? PatternArguments
|
531
|
+
arg.argument.position_bytecode(g)
|
532
|
+
arg.bytecode(g)
|
533
|
+
g.pop
|
534
|
+
end
|
535
|
+
end
|
522
536
|
g.state.check_for_locals = true
|
523
537
|
end
|
524
538
|
end
|
@@ -560,6 +574,7 @@ module CodeTools
|
|
560
574
|
n = node.splat
|
561
575
|
case n
|
562
576
|
when EmptySplat
|
577
|
+
array << SplatPatternVariable.new(n.line, :*)
|
563
578
|
when SplatAssignment, SplatWrapped, SplatArray
|
564
579
|
array << SplatPatternVariable.new(n.value.line, n.value.name)
|
565
580
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: us-ascii -*-
|
2
2
|
|
3
|
-
module
|
3
|
+
module Rubinius::ToolSet.current::TS
|
4
4
|
module AST
|
5
5
|
class Encoding < Node
|
6
6
|
attr_accessor :name
|
@@ -13,16 +13,11 @@ module CodeTools
|
|
13
13
|
def bytecode(g)
|
14
14
|
pos(g)
|
15
15
|
|
16
|
-
g.
|
17
|
-
g.find_const :Runtime
|
16
|
+
g.push_literal Compiler::Runtime
|
18
17
|
g.push_literal @name
|
19
18
|
g.send :get_encoding, 1
|
20
19
|
end
|
21
20
|
|
22
|
-
def defined(g)
|
23
|
-
g.push_literal "expression"
|
24
|
-
end
|
25
|
-
|
26
21
|
def to_sexp
|
27
22
|
[:encoding, @name]
|
28
23
|
end
|
data/lib/rubinius/ast/file.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: us-ascii -*-
|
2
2
|
|
3
|
-
module
|
3
|
+
module Rubinius::ToolSet.current::TS
|
4
4
|
module AST
|
5
5
|
class File < Node
|
6
6
|
def bytecode(g)
|
@@ -10,10 +10,6 @@ module CodeTools
|
|
10
10
|
g.send :active_path, 0
|
11
11
|
end
|
12
12
|
|
13
|
-
def defined(g)
|
14
|
-
g.push_literal "expression"
|
15
|
-
end
|
16
|
-
|
17
13
|
def to_sexp
|
18
14
|
[:file]
|
19
15
|
end
|
data/lib/rubinius/ast/grapher.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: us-ascii -*-
|
2
2
|
|
3
|
-
module
|
3
|
+
module Rubinius::ToolSet.current::TS
|
4
4
|
module AST
|
5
5
|
class ArrayLiteral < Node
|
6
6
|
attr_accessor :body
|
@@ -446,21 +446,8 @@ module CodeTools
|
|
446
446
|
end
|
447
447
|
|
448
448
|
def defined(g)
|
449
|
-
f = g.new_label
|
450
|
-
done = g.new_label
|
451
|
-
|
452
|
-
@array.each do |x|
|
453
|
-
x.value_defined(g, f)
|
454
|
-
g.pop
|
455
|
-
end
|
456
|
-
|
457
449
|
g.push_literal "expression"
|
458
|
-
g.
|
459
|
-
|
460
|
-
f.set!
|
461
|
-
g.push :nil
|
462
|
-
|
463
|
-
done.set!
|
450
|
+
g.string_dup
|
464
451
|
end
|
465
452
|
|
466
453
|
def sexp_name
|
data/lib/rubinius/ast/node.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: us-ascii -*-
|
2
2
|
|
3
|
-
module
|
3
|
+
module Rubinius::ToolSet.current::TS
|
4
4
|
module AST
|
5
5
|
class Node
|
6
6
|
attr_accessor :line
|
@@ -64,7 +64,6 @@ module CodeTools
|
|
64
64
|
blk.total_args = arguments.total_args
|
65
65
|
blk.splat_index = arguments.splat_index
|
66
66
|
blk.block_index = arguments.block_index
|
67
|
-
blk.arity = arguments.arity
|
68
67
|
|
69
68
|
blk
|
70
69
|
end
|
@@ -80,7 +79,6 @@ module CodeTools
|
|
80
79
|
meth.total_args = arguments.total_args
|
81
80
|
meth.splat_index = arguments.splat_index
|
82
81
|
meth.block_index = arguments.block_index
|
83
|
-
meth.arity = arguments.arity
|
84
82
|
end
|
85
83
|
|
86
84
|
meth
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: us-ascii -*-
|
2
2
|
|
3
|
-
module
|
3
|
+
module Rubinius::ToolSet.current::TS
|
4
4
|
module AST
|
5
5
|
class And < Node
|
6
6
|
attr_accessor :left, :right
|
@@ -28,35 +28,8 @@ module CodeTools
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def defined(g)
|
31
|
-
t = g.new_label
|
32
|
-
f = g.new_label
|
33
|
-
done = g.new_label
|
34
|
-
|
35
|
-
case @left
|
36
|
-
when GlobalVariableAccess, InstanceVariableAccess
|
37
|
-
g.goto t
|
38
|
-
else
|
39
|
-
@left.value_defined(g, f)
|
40
|
-
g.pop
|
41
|
-
end
|
42
|
-
|
43
|
-
case @right
|
44
|
-
when GlobalVariableAccess, InstanceVariableAccess
|
45
|
-
g.goto t
|
46
|
-
else
|
47
|
-
@right.value_defined(g, f)
|
48
|
-
g.pop
|
49
|
-
end
|
50
|
-
|
51
|
-
t.set!
|
52
31
|
g.push_literal "expression"
|
53
32
|
g.string_dup
|
54
|
-
g.goto done
|
55
|
-
|
56
|
-
f.set!
|
57
|
-
g.push :nil
|
58
|
-
|
59
|
-
done.set!
|
60
33
|
end
|
61
34
|
|
62
35
|
def sexp_name
|
@@ -129,7 +102,7 @@ module CodeTools
|
|
129
102
|
end
|
130
103
|
end
|
131
104
|
|
132
|
-
class
|
105
|
+
class OpAssign1 < Node
|
133
106
|
attr_accessor :receiver, :op, :arguments, :value
|
134
107
|
|
135
108
|
def initialize(line, receiver, arguments, op, value)
|
@@ -173,7 +146,6 @@ module CodeTools
|
|
173
146
|
if @op == :or or @op == :and
|
174
147
|
fnd = g.new_label
|
175
148
|
fin = g.new_label
|
176
|
-
assign = g.new_label
|
177
149
|
|
178
150
|
# We dup the value from [] to leave it as the value of the
|
179
151
|
# expression
|
@@ -190,25 +162,8 @@ module CodeTools
|
|
190
162
|
|
191
163
|
# The receiver and arguments are still on the stack
|
192
164
|
|
193
|
-
old_break = g.break
|
194
|
-
new_break = g.new_label
|
195
|
-
g.break = new_break
|
196
|
-
|
197
165
|
@value.bytecode(g)
|
198
166
|
|
199
|
-
g.goto assign
|
200
|
-
|
201
|
-
new_break.set!
|
202
|
-
if old_break
|
203
|
-
g.pop_many recv_stack + 1
|
204
|
-
g.push :nil
|
205
|
-
g.goto old_break
|
206
|
-
end
|
207
|
-
|
208
|
-
g.break = old_break
|
209
|
-
|
210
|
-
assign.set!
|
211
|
-
|
212
167
|
# retain the rhs as the expression value
|
213
168
|
g.dup
|
214
169
|
g.move_down recv_stack + 1
|
@@ -233,30 +188,11 @@ module CodeTools
|
|
233
188
|
|
234
189
|
fin.set!
|
235
190
|
else
|
236
|
-
assign = g.new_label
|
237
|
-
|
238
|
-
old_break = g.break
|
239
|
-
new_break = g.new_label
|
240
|
-
g.break = new_break
|
241
|
-
|
242
191
|
# @op is something like + or -
|
243
192
|
# We pull in @value to the stack
|
244
193
|
@value.bytecode(g)
|
245
194
|
# X: 3 TOS
|
246
195
|
|
247
|
-
g.goto assign
|
248
|
-
|
249
|
-
new_break.set!
|
250
|
-
if old_break
|
251
|
-
g.pop_many recv_stack + 2
|
252
|
-
g.push :nil
|
253
|
-
g.goto old_break
|
254
|
-
end
|
255
|
-
|
256
|
-
g.break = old_break
|
257
|
-
|
258
|
-
assign.set!
|
259
|
-
|
260
196
|
# ... then call it as an argument to @or, called on the return
|
261
197
|
# from [].
|
262
198
|
# X: 2 + 3
|
@@ -279,26 +215,18 @@ module CodeTools
|
|
279
215
|
else
|
280
216
|
g.send :[]=, @arguments.size + 1
|
281
217
|
end
|
282
|
-
|
283
218
|
g.pop
|
284
219
|
end
|
285
220
|
end
|
286
221
|
|
287
222
|
def to_sexp
|
288
223
|
arguments = [:arglist] + @arguments.to_sexp
|
289
|
-
|
290
|
-
when :or
|
291
|
-
op = :"||"
|
292
|
-
when :and
|
293
|
-
op = :"&&"
|
294
|
-
else
|
295
|
-
op = @op
|
296
|
-
end
|
224
|
+
op = @op == :or ? :"||" : :"&&"
|
297
225
|
[:op_asgn1, @receiver.to_sexp, arguments, op, @value.to_sexp]
|
298
226
|
end
|
299
227
|
end
|
300
228
|
|
301
|
-
class
|
229
|
+
class OpAssign2 < Node
|
302
230
|
attr_accessor :receiver, :name, :assign, :op, :value
|
303
231
|
|
304
232
|
def initialize(line, receiver, name, op, value)
|
@@ -313,7 +241,7 @@ module CodeTools
|
|
313
241
|
def bytecode(g)
|
314
242
|
pos(g)
|
315
243
|
|
316
|
-
# X: h
|
244
|
+
# X: h[:a] += 3, given h.a == 2
|
317
245
|
@receiver.bytecode(g)
|
318
246
|
# X: TOS = h
|
319
247
|
g.dup
|
@@ -323,7 +251,6 @@ module CodeTools
|
|
323
251
|
if @op == :or or @op == :and
|
324
252
|
fnd = g.new_label
|
325
253
|
fin = g.new_label
|
326
|
-
assign = g.new_label
|
327
254
|
|
328
255
|
g.dup
|
329
256
|
if @op == :or
|
@@ -334,26 +261,8 @@ module CodeTools
|
|
334
261
|
|
335
262
|
# Remove the copy of 2 and push @value on the stack
|
336
263
|
g.pop
|
337
|
-
|
338
|
-
old_break = g.break
|
339
|
-
new_break = g.new_label
|
340
|
-
g.break = new_break
|
341
|
-
|
342
264
|
@value.bytecode(g)
|
343
265
|
|
344
|
-
g.goto assign
|
345
|
-
|
346
|
-
new_break.set!
|
347
|
-
if old_break
|
348
|
-
g.pop_many 2
|
349
|
-
g.push :nil
|
350
|
-
g.goto old_break
|
351
|
-
end
|
352
|
-
|
353
|
-
g.break = old_break
|
354
|
-
|
355
|
-
assign.set!
|
356
|
-
|
357
266
|
# Retain the this value to use as the expression value
|
358
267
|
g.dup
|
359
268
|
g.move_down 2
|
@@ -372,27 +281,7 @@ module CodeTools
|
|
372
281
|
|
373
282
|
fin.set!
|
374
283
|
else
|
375
|
-
assign = g.new_label
|
376
|
-
|
377
|
-
old_break = g.break
|
378
|
-
new_break = g.new_label
|
379
|
-
g.break = new_break
|
380
|
-
|
381
284
|
@value.bytecode(g)
|
382
|
-
|
383
|
-
g.goto assign
|
384
|
-
|
385
|
-
new_break.set!
|
386
|
-
if old_break
|
387
|
-
g.pop_many 3
|
388
|
-
g.push :nil
|
389
|
-
g.goto old_break
|
390
|
-
end
|
391
|
-
|
392
|
-
g.break = old_break
|
393
|
-
|
394
|
-
assign.set!
|
395
|
-
|
396
285
|
# X: TOS = 3
|
397
286
|
# X: 2 + 3
|
398
287
|
g.send @op, 1
|
@@ -410,14 +299,7 @@ module CodeTools
|
|
410
299
|
end
|
411
300
|
|
412
301
|
def to_sexp
|
413
|
-
|
414
|
-
when :or
|
415
|
-
op = :"||"
|
416
|
-
when :and
|
417
|
-
op = :"&&"
|
418
|
-
else
|
419
|
-
op = @op
|
420
|
-
end
|
302
|
+
op = @op == :or ? :"||" : :"&&"
|
421
303
|
[:op_asgn2, @receiver.to_sexp, :"#{@name}=", op, @value.to_sexp]
|
422
304
|
end
|
423
305
|
end
|
@@ -469,5 +351,17 @@ module CodeTools
|
|
469
351
|
:op_asgn_or
|
470
352
|
end
|
471
353
|
end
|
354
|
+
|
355
|
+
class OpAssignOr19 < OpAssignOr
|
356
|
+
def bytecode(g)
|
357
|
+
pos(g)
|
358
|
+
|
359
|
+
g.state.push_op_asgn
|
360
|
+
@left.or_bytecode(g) do
|
361
|
+
g.state.pop_op_asgn
|
362
|
+
@right.bytecode(g)
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
472
366
|
end
|
473
367
|
end
|