forked from pharo-project/pharo
/
Variable.extension.st
129 lines (108 loc) · 3.19 KB
/
Variable.extension.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
Extension { #name : #Variable }
{ #category : #'*Reflectivity' }
Variable >> afterHooks [
^self propertyAt: #afterHooks ifAbsent: #()
]
{ #category : #'*Reflectivity' }
Variable >> afterLinks [
^ self links select: [ :each | each control == #after ]
]
{ #category : #'*Reflectivity' }
Variable >> assignmentNodes [
^self astNodes
select: [ :each | each isWrite ]
thenCollect: [ :each | each parent ]
]
{ #category : #'*Reflectivity' }
Variable >> astNodes [
"by default we search the usingMethods for all AST nodes"
^self usingMethods flatCollect: [ :method |
method variableNodes select: [: each| each binding variable == self ]]
]
{ #category : #'*Reflectivity' }
Variable >> availableReifications [
^RFReification subclasses
select: [ :e | e entities includesAny: self class withAllSuperclasses ]
thenCollect: #key
]
{ #category : #'*Reflectivity' }
Variable >> beforeHooks [
^self propertyAt: #beforeHooks ifAbsentPut: OrderedCollection new
]
{ #category : #'*Reflectivity' }
Variable >> beforeLinks [
^ self links select: [ :each | each control == #before ]
]
{ #category : #'*Reflectivity' }
Variable >> clearReflectivityAnnotations [
self removeProperty: #preambles ifAbsent: [ ].
self removeProperty: #beforeHooks ifAbsent: [ ].
self removeProperty: #afterHooks ifAbsent: [ ].
self removeProperty: #insteadHooks ifAbsent: [ ].
]
{ #category : #'*Reflectivity' }
Variable >> hasMetalink [
^ self hasProperty: #links
]
{ #category : #'*Reflectivity' }
Variable >> hasMetalinkAfter [
self hasMetalink
ifFalse: [ ^ false ].
^ self afterLinks isNotEmpty
]
{ #category : #'*Reflectivity' }
Variable >> hasMetalinkBefore [
self hasMetalink ifFalse: [ ^ false ].
^ self beforeLinks isNotEmpty
]
{ #category : #'*Reflectivity' }
Variable >> hasMetalinkInstead [
self hasMetalink
ifFalse: [ ^ false ].
^ self insteadLinks isNotEmpty
]
{ #category : #'*Reflectivity' }
Variable >> insteadHooks [
^self propertyAt: #insteadHooks ifAbsent: #()
]
{ #category : #'*Reflectivity' }
Variable >> insteadLinks [
^ self links select: [ :each | each control == #instead ]
]
{ #category : #'*Reflectivity' }
Variable >> link: aMetaLink [
| methods |
(aMetaLink checkForCompatibilityWith: self) ifFalse: [ self error: 'link requests reification that can not be provided by this node' ].
methods := self usingMethods.
(self propertyAt: #links ifAbsentPut: [ OrderedCollection new ]) add: aMetaLink.
aMetaLink installOnVariable: self.
methods
do: [ :method |
method
createTwin;
invalidate.
method installLink: aMetaLink ]
]
{ #category : #'*Reflectivity' }
Variable >> links [
^self propertyAt: #links ifAbsent: #()
]
{ #category : #'*Reflectivity' }
Variable >> postambles [
^ self propertyAt: #postambles ifAbsent: #()
]
{ #category : #'*Reflectivity' }
Variable >> preambles [
^ self propertyAt: #preambles ifAbsent: #()
]
{ #category : #'*Reflectivity' }
Variable >> readNodes [
^ self astNodes select: [ :each | each isRead ]
]
{ #category : #'*Reflectivity' }
Variable >> removeLink: aMetaLink [
self links remove: aMetaLink.
self usingMethods do: [:method | method removeLink: aMetaLink].
self links ifEmpty: [ self removeProperty: #links ].
self clearReflectivityAnnotations.
]