forked from pharo-project/pharo
/
RBMethodNode.class.st
749 lines (631 loc) · 20.3 KB
/
RBMethodNode.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
"
RBMethodNode is the node that represents AST of a Smalltalk method.
Some properties aren't known to the parser creating this Object. For example, the scope value isn't known by parsing the code but only after doing a
semantic analysis. Likewise, the compilation context isn't needed until we try to do the semantic analysis.
Instance Variables:
arguments <SequenceableCollection of: RBVariableNode> the arguments to the method
body <BRSequenceNode> the body/statements of the method
nodeReplacements <Dictionary> a dictionary of oldNode -> newNode replacements
replacements <Collection of: RBStringReplacement> the collection of string replacements for each node replacement in the parse tree
selector <Symbol> the method name
keywordsPositions <IntegerArray | nil> the positions of the selector keywords
source <String> the source we compiled
scope <OCMethodScope | nil> the scope associated with this code of this method
pragmas < SequenceableCollection of: RBPragmaNodes > Nodes representing the pragma statements in this method
compilationContext <CCompilationContext | CompilationContext>
"
Class {
#name : #RBMethodNode,
#superclass : #RBProgramNode,
#instVars : [
'scope',
'selector',
'keywordsPositions',
'body',
'source',
'arguments',
'pragmas',
'replacements',
'nodeReplacements',
'compilationContext',
'bcToASTCache'
],
#category : #'AST-Core-Nodes'
}
{ #category : #'instance creation' }
RBMethodNode class >> selector: aSymbol arguments: valueNodes [
^(self new)
selector: aSymbol;
arguments: valueNodes;
yourself
]
{ #category : #'instance creation' }
RBMethodNode class >> selector: aSymbol arguments: variableNodes body: aSequenceNode [
^(self new)
arguments: variableNodes;
selector: aSymbol;
body: aSequenceNode;
yourself
]
{ #category : #'instance creation' }
RBMethodNode class >> selector: aSymbol body: aSequenceNode [
^self
selector: aSymbol
arguments: #()
body: aSequenceNode
]
{ #category : #'instance creation' }
RBMethodNode class >> selector: aSymbol keywordsPositions: positionList arguments: valueNodes [
^(self new)
selector: aSymbol
keywordsPositions: positionList
arguments: valueNodes;
yourself.
]
{ #category : #comparing }
RBMethodNode >> = anObject [
self == anObject ifTrue: [ ^ true ].
self class = anObject class ifFalse: [ ^ false ].
(self selector = anObject selector
and: [ self pragmas size = anObject pragmas size
and: [ self body = anObject body ] ])
ifFalse: [ ^ false ].
self arguments with: anObject arguments do: [ :first :second |
first = second
ifFalse: [ ^ false ] ].
self pragmas with: anObject pragmas do: [ :first :second |
first = second
ifFalse: [ ^ false ] ].
^ true
]
{ #category : #visiting }
RBMethodNode >> acceptVisitor: aProgramNodeVisitor [
^ aProgramNodeVisitor visitMethodNode: self
]
{ #category : #'adding/removing' }
RBMethodNode >> addNode: aNode [
^ body addNode: aNode
]
{ #category : #'adding/removing' }
RBMethodNode >> addPragma: aPragmaNode [
pragmas := pragmas copyWith: aPragmaNode.
aPragmaNode parent: self
]
{ #category : #replacing }
RBMethodNode >> addReplacement: aStringReplacement [
replacements ifNil: [^self].
replacements add: aStringReplacement
]
{ #category : #'adding/removing' }
RBMethodNode >> addReturn [
^ body addReturn
]
{ #category : #'adding/removing' }
RBMethodNode >> addSelfReturn [
^ body addSelfReturn
]
{ #category : #accessing }
RBMethodNode >> allArgumentVariables [
^(self argumentNames asOrderedCollection)
addAll: super allArgumentVariables;
yourself
]
{ #category : #accessing }
RBMethodNode >> allDefinedVariables [
^(self argumentNames asOrderedCollection)
addAll: super allDefinedVariables;
yourself
]
{ #category : #iterating }
RBMethodNode >> allSequenceNodes [
^ self allChildren select: #isSequence
]
{ #category : #accessing }
RBMethodNode >> allStatements [
"return the statements including variable definition."
^ self temporaries asOrderedCollection copy
addAll: super allStatements;
yourself
]
{ #category : #accessing }
RBMethodNode >> argumentNames [
^ self arguments collect: [:each | each name] as: Array
]
{ #category : #accessing }
RBMethodNode >> arguments [
^arguments
]
{ #category : #accessing }
RBMethodNode >> arguments: variableNodes [
arguments := variableNodes.
arguments do: [:each | each parent: self]
]
{ #category : #converting }
RBMethodNode >> asSequenceNode [
^body
]
{ #category : #accessing }
RBMethodNode >> body [
^body
]
{ #category : #accessing }
RBMethodNode >> body: stmtsNode [
body := stmtsNode.
body parent: self
]
{ #category : #'private-replacing' }
RBMethodNode >> changeSourceSelector: oldSelector keywordsIntervals: oldIntervals arguments: oldArguments [
"If this is the same number of arguments, we try a one to one replacement of selector parts and arguments. If this is not the c
ase try to rewrite the signature as a whole, what unfortunately drops the comments within the signature."
[ (oldIntervals size = self keywordsPositions size and: [ oldArguments size = arguments size ])
ifTrue: [
self selectorParts keysAndValuesDo: [ :index :part |
self addReplacement: (RBStringReplacement
replaceFrom: (oldIntervals at: index) first
to: (oldIntervals at: index) last
with: part) ].
oldArguments with: arguments do: [ :old :new |
self addReplacement: (RBStringReplacement
replaceFrom: old start
to: old stop
with: new name) ] ]
ifFalse: [
self addReplacement: (RBStringReplacement
replaceFrom: oldIntervals first first
to: (oldArguments notEmpty
ifTrue: [ oldArguments last stop ]
ifFalse: [ oldIntervals last last ])
with: (String streamContents: [ :stream |
self selectorParts keysAndValuesDo: [ :index :part |
index = 1 ifFalse: [ stream space ].
stream nextPutAll: part.
index <= arguments size
ifTrue: [ stream space; nextPutAll: (arguments at: index) name ] ] ])) ] ]
on: Error
do: [ :ex | ex return ]
]
{ #category : #accessing }
RBMethodNode >> children [
^ OrderedCollection new
addAll: arguments;
addAll: pragmas;
add: body;
yourself
]
{ #category : #replacing }
RBMethodNode >> clearReplacements [
replacements := nil
]
{ #category : #'accessing compiled method' }
RBMethodNode >> compilationContext [
^ compilationContext
]
{ #category : #'accessing compiled method' }
RBMethodNode >> compilationContext: aCompilationContext [
compilationContext := aCompilationContext.
]
{ #category : #completion }
RBMethodNode >> completionToken [
^ self selector
]
{ #category : #'accessing - conceptual' }
RBMethodNode >> conceptualArgumentSize [
"Return the cumulted length of the parameters (yes parameters are called arguments in Pharo - not good!). It does not count spaces and the selectors.
Note that this length is based on the tree structure and not the source code. It does not reflect the selection interval but the space the selector would take if displayed on a single line without any space."
^ self arguments
inject: 0
into: [ :sum :each | sum + each name size ]
]
{ #category : #'accessing - conceptual' }
RBMethodNode >> conceptualSelectorSize [
"Return the length of the selector. It does not take into length of parameters nor the spaces.
Note that this length is based on the tree structure and not the source code. It does not reflect the selection interval but the space the selector would take if displayed on a single line without any space."
^ selector size
]
{ #category : #'accessing - conceptual' }
RBMethodNode >> conceptualSignatureSize [
"Return the full length of the method signature (called with a strange name in Pharo: the patterned selector. Note that this length is based on the tree structure and not the source code. It does not reflect the selection interval but the space the signature would take if displayed on a single line."
"When we count foo: a b: b, we add three extras spaces so args size * 2 - 1"
^ self conceptualSelectorSize + self conceptualArgumentSize
+ (self arguments
ifNotEmpty: [ self arguments size * 2 - 1 ]
ifEmpty: [ 0 ])
]
{ #category : #matching }
RBMethodNode >> copyInContext: aDictionary [
^ self class new
selector: self selector;
arguments: (self arguments collect: [ :each | each copyInContext: aDictionary ]);
pragmas: (self pragmas isEmpty
ifTrue: [ aDictionary at: '-pragmas-' ifAbsent: [ #() ] ]
ifFalse: [ self copyList: self pragmas inContext: aDictionary ]);
body: (self body copyInContext: aDictionary);
source: (aDictionary at: '-source-' ifAbsentPut: [ self source ]);
yourself
]
{ #category : #accessing }
RBMethodNode >> decompileString [
^ self formattedCode
]
{ #category : #testing }
RBMethodNode >> defines: aName [
^ (arguments anySatisfy: [ :each | each name = aName ])
or: [ self pragmas anySatisfy: [ :pragma | pragma defines: aName ] ]
]
{ #category : #comparing }
RBMethodNode >> equalTo: anObject withMapping: aDictionary [
self class = anObject class ifFalse: [ ^ false ].
(self selector = anObject selector
and: [ self pragmas size = anObject pragmas size
and: [ self body equalTo: anObject body withMapping: aDictionary ] ])
ifFalse: [ ^ false ].
self arguments with: anObject arguments do: [ :first :second |
(first equalTo: second withMapping: aDictionary)
ifFalse: [ ^ false ].
aDictionary removeKey: first name ].
self pragmas with: anObject pragmas do: [ :first :second |
(first equalTo: second withMapping: aDictionary)
ifFalse: [ ^ false ] ].
^ true
]
{ #category : #'tree accessing' }
RBMethodNode >> extractSubtreeWith: aSourceCode [
| extractedTree |
extractedTree := self parserClass
parseExpression: aSourceCode
onError: [ :string :pos | ^ nil ].
extractedTree ifNil: [ ^ nil ].
(extractedTree isSequence and: [ extractedTree statements isEmpty ])
ifTrue: [ ^ nil ].
extractedTree := extractedTree isSequence
ifTrue:
[ RBParseTreeSearcher treeMatchingStatements: aSourceCode in: self ]
ifFalse:
[ RBParseTreeSearcher treeMatching: aSourceCode in: self ]. "or: [aTree isReturn]"
^ extractedTree
ifNotNil: [ extractedTree parent: (self parentOfSubtree: extractedTree) ]
]
{ #category : #accessing }
RBMethodNode >> firstPrecodeComment [
self comments ifEmpty: [ ^nil ].
^ self comments first contents
]
{ #category : #testing }
RBMethodNode >> hasArgumentNamed: aString [
^ self arguments anySatisfy: [ :argument| argument name = aString ]
]
{ #category : #testing }
RBMethodNode >> hasPragmaNamed: aSymbol [
self pragmaNamed: aSymbol ifAbsent: [ ^ false ].
^ true
]
{ #category : #testing }
RBMethodNode >> hasTemporaries [
^ self temporaries isNotEmpty
]
{ #category : #testing }
RBMethodNode >> hasTemporaryNamed: aString [
^ self temporaries anySatisfy: [ :temp| temp name = aString ]
]
{ #category : #comparing }
RBMethodNode >> hash [
^ ((self selector hash bitXor: (self hashForCollection: self arguments)) bitXor: (self hashForCollection: self pragmas)) bitXor: self body hash
]
{ #category : #initialization }
RBMethodNode >> initialize [
pragmas := #().
replacements := SortedCollection sortBlock:
[:a :b |
a startPosition < b startPosition
or: [a startPosition = b startPosition and: [a stopPosition < b stopPosition]]].
nodeReplacements := IdentityDictionary new
]
{ #category : #testing }
RBMethodNode >> isFaulty [
(self arguments anySatisfy: [:each | each isFaulty]) ifTrue:[ ^true].
(self pragmas anySatisfy: [:each | each isFaulty]) ifTrue:[ ^true].
^self body isFaulty
]
{ #category : #testing }
RBMethodNode >> isLast: aNode [
^body isLast: aNode
]
{ #category : #testing }
RBMethodNode >> isMethod [
^true
]
{ #category : #testing }
RBMethodNode >> isPrimitive [
^ self pragmas anySatisfy: [ :each | each isPrimitive ]
]
{ #category : #accessing }
RBMethodNode >> keywords [
^ selector keywords.
]
{ #category : #accessing }
RBMethodNode >> keywordsIntervals [
^selector keywords
with: self keywordsPositions
collect: [:keyword :start| start to: (start = 0 ifTrue: [ -1 ] ifFalse: [ start + keyword size - 1]) ]
]
{ #category : #accessing }
RBMethodNode >> keywordsPositions [
^keywordsPositions ifNil: [ (selector keywords collect: [:char| 0 ]) asIntegerArray ]
]
{ #category : #accessing }
RBMethodNode >> keywordsPositions: aPositionsList [
keywordsPositions := aPositionsList ifNotNil: [:list| list asIntegerArray ]
]
{ #category : #testing }
RBMethodNode >> lastIsReturn [
^body lastIsReturn
]
{ #category : #replacing }
RBMethodNode >> map: oldNode to: newNode [
nodeReplacements at: oldNode put: newNode
]
{ #category : #replacing }
RBMethodNode >> mappingFor: oldNode [
^nodeReplacements at: oldNode ifAbsent: [oldNode]
]
{ #category : #matching }
RBMethodNode >> match: aNode inContext: aDictionary [
self class = aNode class ifFalse: [ ^ false ].
aDictionary at: '-source-' put: aNode source.
self selector = aNode selector ifFalse: [ ^ false ].
^ (self matchList: arguments against: aNode arguments inContext: aDictionary)
and: [ (self matchPragmas: self pragmas against: aNode pragmas inContext: aDictionary)
and: [ body match: aNode body inContext: aDictionary ] ]
]
{ #category : #matching }
RBMethodNode >> matchPragmas: matchNodes against: pragmaNodes inContext: aDictionary [
matchNodes isEmpty ifTrue: [
aDictionary at: '-pragmas-' put: pragmaNodes.
^ true ].
^ matchNodes allSatisfy: [ :matchNode |
pragmaNodes anySatisfy: [ :pragmaNode |
matchNode match: pragmaNode inContext: aDictionary ] ]
]
{ #category : #'accessing compiled method' }
RBMethodNode >> method [
"return the method that I have been compiled for"
^self compilationContext ifNotNil: [ :ccntx |
ccntx compiledMethod ifNil: [ccntx getClass >> self selector]]
]
{ #category : #'accessing compiled method' }
RBMethodNode >> methodClass [
^ self compilationContext ifNotNil: [ :ctxt | ctxt getClass ]
]
{ #category : #'accessing compiled method' }
RBMethodNode >> methodClass: aClass [
compilationContext ifNil: [compilationContext := aClass compiler compilationContext].
self compilationContext class: aClass
]
{ #category : #accessing }
RBMethodNode >> methodNode [
^self
]
{ #category : #accessing }
RBMethodNode >> methodOrBlockNode [
^ self
]
{ #category : #accessing }
RBMethodNode >> newSource [
replacements ifNil: [^self formattedCode].
^[self reformatSource] on: Error do: [:ex | ex return: self formattedCode]
]
{ #category : #accessing }
RBMethodNode >> numArgs [
^self selector numArgs
]
{ #category : #testing }
RBMethodNode >> offsetIsComment: anOffset [
"check is the offset in the source part of a comment"
^ self allComments
anySatisfy: [ :comment | anOffset between: comment start and: comment stop ]
]
{ #category : #'tree accessing' }
RBMethodNode >> parentOfSubtree: subtree [
| sourceCode |
sourceCode := subtree formattedCode.
^ self allChildren reversed
detect: [ :e | e formattedCode includesSubstring: sourceCode ]
ifFound: [ :e | e parent ]
ifNone: [ nil ]
]
{ #category : #copying }
RBMethodNode >> postCopy [
super postCopy.
self arguments: (self arguments collect: [ :each | each copy ]).
self pragmas: (self pragmas collect: [ :each | each copy ]).
self body: self body copy
]
{ #category : #testing }
RBMethodNode >> pragmaNamed: aSymbol [
^ self pragmaNamed: aSymbol ifAbsent: [ KeyNotFound signalFor: aSymbol ]
]
{ #category : #testing }
RBMethodNode >> pragmaNamed: aSymbol ifAbsent: absentBlock [
^ self pragmas
detect: [ :pragma| pragma selector = aSymbol ]
ifNone: absentBlock
]
{ #category : #testing }
RBMethodNode >> pragmaNamed: aSymbol ifPresent: foundBlock [
^ self pragmas
detect: [ :pragma| pragma selector = aSymbol ]
ifFound: foundBlock
]
{ #category : #testing }
RBMethodNode >> pragmaNamed: aSymbol ifPresent: presentBlock ifAbsent: absentBlock [
^ self pragmas
detect: [ :pragma| pragma selector = aSymbol ]
ifFound: presentBlock
ifNone: absentBlock
]
{ #category : #accessing }
RBMethodNode >> pragmas [
^ pragmas
]
{ #category : #accessing }
RBMethodNode >> pragmas: aCollection [
pragmas := aCollection.
pragmas do: [ :each | each parent: self ]
]
{ #category : #printing }
RBMethodNode >> printOn: aStream [
aStream nextPutAll: self formattedCode
]
{ #category : #testing }
RBMethodNode >> references: aVariableName [
^body references: aVariableName
]
{ #category : #private }
RBMethodNode >> reformatSource [
| stream newSource newTree |
stream := (String new: source size + 100) writeStream.
stream
nextPutAll:
(source
copyFrom:
(replacements
inject: 1
into: [ :sum :each |
stream
nextPutAll: (source copyFrom: sum to: each startPosition - 1);
nextPutAll: each string.
each stopPosition + 1 ])
to: source size).
newSource := stream contents.
newTree := self parserClass parseFaultyMethod: newSource.
self = newTree
ifFalse: [ ^ self formattedCode ].
^ newSource
]
{ #category : #'adding/removing' }
RBMethodNode >> removePragma: aPragmaNode [
pragmas := pragmas copyWithout: aPragmaNode
]
{ #category : #'adding/removing' }
RBMethodNode >> removeSubtree: aTree [
^ aTree isReturn
ifTrue: [ RBParseTreeRewriter
replace: aTree formattedCode
with: '' in: self
onInterval: aTree sourceInterval ]
ifFalse: [ RBParseTreeRewriter
replaceStatements: aTree formattedCode
with: '' in: self
onInterval: aTree sourceInterval ]
]
{ #category : #accessing }
RBMethodNode >> renameSelector: newSelector andArguments: varNodeCollection [
| oldIntervals oldArguments oldSelector |
oldSelector := selector.
oldIntervals := self keywordsIntervals.
oldArguments := arguments.
self
arguments: varNodeCollection;
selector: newSelector.
self changeSourceSelector: oldSelector keywordsIntervals: oldIntervals arguments: oldArguments
]
{ #category : #replacing }
RBMethodNode >> replaceNode: aNode withNode: anotherNode [
aNode == body ifTrue: [self body: anotherNode].
self arguments: (arguments
collect: [:each | each == aNode ifTrue: [anotherNode] ifFalse: [each]])
]
{ #category : #accessing }
RBMethodNode >> scope [
^ scope
]
{ #category : #accessing }
RBMethodNode >> scope: aScopedNode [
scope := aScopedNode
]
{ #category : #accessing }
RBMethodNode >> selector [
^ selector
]
{ #category : #accessing }
RBMethodNode >> selector: aSelector [
keywordsPositions := nil.
selector := aSelector asSymbol.
]
{ #category : #initialization }
RBMethodNode >> selector: aSymbol keywordsPositions: positionList arguments: valueNodes [
self
arguments: valueNodes;
selector: aSymbol;
keywordsPositions: positionList.
]
{ #category : #accessing }
RBMethodNode >> selectorAndArgumentNames [
"Returns the selector and argument names portion of a method as a string"
^ self arguments
ifEmpty: [self keywords first]
ifNotEmpty: [| lastArgument |
lastArgument := self arguments last.
self source first: lastArgument start + (lastArgument name size - 1)]
]
{ #category : #accessing }
RBMethodNode >> selectorParts [
^ self keywords collect: [:each | each asSymbol]
]
{ #category : #accessing }
RBMethodNode >> source [
^source
]
{ #category : #accessing }
RBMethodNode >> source: anObject [
source := anObject
]
{ #category : #accessing }
RBMethodNode >> sourceCode [
"compatibility to MethodNode"
^source
]
{ #category : #accessing }
RBMethodNode >> start [
^ 1
]
{ #category : #accessing }
RBMethodNode >> statements [
^ self body statements
]
{ #category : #accessing }
RBMethodNode >> statements: aCollection [
self body statements: aCollection
]
{ #category : #accessing }
RBMethodNode >> stop [
^(self sourceCode ifNotNil: [:src | src] ifNil: [ self formattedCode ]) size
]
{ #category : #accessing }
RBMethodNode >> tempNames [
"compatibility method to old MethodNode"
self deprecated: 'This method was flagged for cleaning. We have the impression it might not be used so we are deprecating it. If you encounter this deprecation, please report with the scenario to reproduce.'.
^ self argumentNames, self temporaryNames
]
{ #category : #accessing }
RBMethodNode >> temporaries [
^ self body temporaries
]
{ #category : #accessing }
RBMethodNode >> temporaryNames [
^ self body temporaryNames
]
{ #category : #testing }
RBMethodNode >> uses: aNode [
^body == aNode and: [aNode lastIsReturn]
]
{ #category : #'tree accessing' }
RBMethodNode >> variableWith: aSymbol [
| matcher block |
matcher := RBParseTreeSearcher new.
block := [ :aNode :answer | aNode ].
matcher
matches: aSymbol do: block;
matchesArgument: aSymbol do: block.
^ matcher executeTree: self initialAnswer: nil
]