forked from pharo-project/pharo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RBProgramNode.extension.st
137 lines (111 loc) · 3.55 KB
/
RBProgramNode.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
130
131
132
133
134
135
136
137
Extension { #name : #RBProgramNode }
{ #category : #'*Reflectivity' }
RBProgramNode >> afterHooks [
^self propertyAt: #afterHooks ifAbsent: #()
]
{ #category : #'*Reflectivity' }
RBProgramNode >> afterLinks [
^ self links select: [ :each | each control == #after ]
]
{ #category : #'*Reflectivity' }
RBProgramNode >> allAfterAreWeak [
self hasMetalink ifFalse: [^false].
self isMessage ifFalse: [^false]. "only sends are weak"
^self afterLinks allSatisfy: [ :link | link hasOption: #optionWeakAfter ].
]
{ #category : #'*Reflectivity' }
RBProgramNode >> availableReifications [
^RFReification subclasses
select: [ :e | e entities includesAny: self class withAllSuperclasses ]
thenCollect: #key
]
{ #category : #'*Reflectivity' }
RBProgramNode >> beforeHooks [
^self propertyAt: #beforeHooks ifAbsentPut: OrderedCollection new
]
{ #category : #'*Reflectivity' }
RBProgramNode >> beforeLinks [
^ self links select: [ :each | each control == #before ]
]
{ #category : #'*Reflectivity' }
RBProgramNode >> clearReflectivityAnnotations [
self removeProperty: #preambles ifAbsent: [ ].
self removeProperty: #beforeHooks ifAbsent: [ ].
self removeProperty: #afterHooks ifAbsent: [ ].
self removeProperty: #insteadHooks ifAbsent: [ ].
]
{ #category : #'*Reflectivity' }
RBProgramNode >> hasBeenExecuted [
^self propertyAt: #tagExecuted ifAbsent: false
]
{ #category : #'*Reflectivity' }
RBProgramNode >> hasMetalink [
^self hasProperty: #links
]
{ #category : #'*Reflectivity' }
RBProgramNode >> hasMetalink: aMetaLink [
^self links isNotNil and: [(self links includes: aMetaLink)]
]
{ #category : #'*Reflectivity' }
RBProgramNode >> hasMetalinkAfter [
self hasMetalink ifFalse: [^false].
^self afterLinks isNotEmpty
]
{ #category : #'*Reflectivity' }
RBProgramNode >> hasMetalinkBefore [
self hasMetalink ifFalse: [^false].
^self beforeLinks isNotEmpty
]
{ #category : #'*Reflectivity' }
RBProgramNode >> hasMetalinkInstead [
self hasMetalink ifFalse: [^false].
^self insteadLinks isNotEmpty
]
{ #category : #'*Reflectivity' }
RBProgramNode >> insteadHooks [
^self propertyAt: #insteadHooks ifAbsent: #()
]
{ #category : #'*Reflectivity' }
RBProgramNode >> insteadLinks [
^ self links select: [ :each | each control == #instead ]
]
{ #category : #'*Reflectivity' }
RBProgramNode >> invalidate [
self methodNode method invalidate.
]
{ #category : #'*Reflectivity' }
RBProgramNode >> link: aMetaLink [
(aMetaLink checkForCompatibilityWith: self) ifFalse: [ self error: 'link requests reification that can not be provided by this node' ].
(self propertyAt: #links ifAbsentPut: [ OrderedCollection new ]) add: aMetaLink.
aMetaLink installOn: self.
self clearReflectivityAnnotations.
self methodNode method installLink: aMetaLink.
]
{ #category : #'*Reflectivity' }
RBProgramNode >> links [
^self propertyAt: #links ifAbsent: nil
]
{ #category : #'*Reflectivity' }
RBProgramNode >> nodesWithLinks [
^ self allChildren select: [ :e | e links isNotNil ]
]
{ #category : #'*Reflectivity' }
RBProgramNode >> postambles [
^self propertyAt: #postambles ifAbsent: #()
]
{ #category : #'*Reflectivity' }
RBProgramNode >> preambles [
^self propertyAt: #preambles ifAbsent: #()
]
{ #category : #'*Reflectivity' }
RBProgramNode >> removeLink: aMetaLink [
self hasMetalink ifFalse: [ ^ self ].
self links remove: aMetaLink ifAbsent: [].
self links ifEmpty: [ self removeProperty: #links ].
self clearReflectivityAnnotations.
self methodNode method removeLink: aMetaLink.
]
{ #category : #'*Reflectivity' }
RBProgramNode >> tagExecuted [
^self propertyAt: #tagExecuted put: true
]