-
Notifications
You must be signed in to change notification settings - Fork 67
/
MLPluginAccessorDepthCalculator.class.st
61 lines (55 loc) · 2.27 KB
/
MLPluginAccessorDepthCalculator.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
Class {
#name : #MLPluginAccessorDepthCalculator,
#superclass : #MLAccessorDepthCalculator,
#instVars : [
'inProgressSelectors'
],
#category : #Melchor
}
{ #category : #'spur primitive compilation' }
MLPluginAccessorDepthCalculator >> accessorChainsForMethod: method interpreterClass: interpreterClass [
inProgressSelectors := Set new.
^[super accessorChainsForMethod: method interpreterClass: interpreterClass] ensure:
[inProgressSelectors := nil]
]
{ #category : #'spur primitive compilation' }
MLPluginAccessorDepthCalculator >> accessorDepthDeterminationFollowsSelfSends [
^true
]
{ #category : #'spur primitive compilation' }
MLPluginAccessorDepthCalculator >> accessorsAndAssignmentsForSubMethodNamed: selector actuals: actualParameters depth: depth interpreterClass: interpreterClass into: aTrinaryBlock [
"Evaluate aTrinaryBlock with the root accessor sends, accessor sends and assignments in the sub-method named selector."
| method map |
(inProgressSelectors includes: selector) ifTrue:
[^nil].
inProgressSelectors add: selector.
method := codeGenerator methodNamed: selector.
method ifNil:
[^nil].
map := Dictionary new.
method args do: [:var| map at: var put: depth asString, var].
method allLocals do: [:var| map at: var put: depth asString, var].
^self accessorsAndAssignmentsForMethod: (method copy renameVariablesUsing: map)
actuals: actualParameters
depth: depth + 1
interpreterClass: interpreterClass
into: aTrinaryBlock
]
{ #category : #'spur primitive compilation' }
MLPluginAccessorDepthCalculator >> actualsForMethod: aTMethod [
"Normal primitives have no arguments, but translated primitives do.
Override to answer actuals for translated primitives."
^(aTMethod args size - 1 to: 0 by: -1) collect:
[:i|
TSendNode new
setSelector: #stackValue:
receiver: (TVariableNode new setName: 'interpreterProxy')
arguments: {TConstantNode value: i}]
]
{ #category : #'spur primitive compilation' }
MLPluginAccessorDepthCalculator >> isObjectAccessor: selector given: interpreterClass [
"Override to include the selectors transformed into accessors for translated primitives.
InterpreterPlugin browseTranslatedPrimitives"
^(#(asciiValue at: at:put: basicAt: size) includes: selector)
or: [super isObjectAccessor: selector given: interpreterClass]
]