author | Claus Gittinger <cg@exept.de> |
Thu, 27 Jun 2019 16:34:40 +0200 | |
changeset 24379 | 852be153b0ec |
parent 24223 | 3d930eb1a7ae |
permissions | -rw-r--r-- |
23242 | 1 |
"{ Encoding: utf8 }" |
2 |
||
13403 | 3 |
" |
13479 | 4 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
13403 | 5 |
All Rights Reserved |
6 |
||
13479 | 7 |
Permission is hereby granted, free of charge, to any person |
8 |
obtaining a copy of this software and associated documentation |
|
9 |
files (the 'Software'), to deal in the Software without |
|
10 |
restriction, including without limitation the rights to use, |
|
11 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
12 |
copies of the Software, and to permit persons to whom the |
|
13 |
Software is furnished to do so, subject to the following |
|
14 |
conditions: |
|
15 |
||
16 |
The above copyright notice and this permission notice shall be |
|
17 |
included in all copies or substantial portions of the Software. |
|
18 |
||
19 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
20 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
21 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
22 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
23 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
24 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
25 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
26 |
OTHER DEALINGS IN THE SOFTWARE. |
|
13403 | 27 |
" |
28 |
"{ Package: 'stx:libbasic' }" |
|
29 |
||
17300 | 30 |
"{ NameSpace: Smalltalk }" |
31 |
||
13403 | 32 |
Object subclass:#Annotation |
14501 | 33 |
instanceVariableNames:'key arguments' |
13403 | 34 |
classVariableNames:'' |
35 |
poolDictionaries:'' |
|
36 |
category:'Kernel-Extensions' |
|
37 |
! |
|
38 |
||
23315 | 39 |
Annotation subclass:#JavaScriptSelector |
40 |
instanceVariableNames:'' |
|
41 |
classVariableNames:'CachedAnnotatedMethods' |
|
42 |
poolDictionaries:'' |
|
43 |
privateIn:Annotation |
|
44 |
! |
|
45 |
||
13403 | 46 |
Annotation subclass:#NameSpace |
14501 | 47 |
instanceVariableNames:'' |
13403 | 48 |
classVariableNames:'' |
49 |
poolDictionaries:'' |
|
50 |
privateIn:Annotation |
|
51 |
! |
|
52 |
||
53 |
Annotation subclass:#Resource |
|
14501 | 54 |
instanceVariableNames:'' |
23242 | 55 |
classVariableNames:'SharedSimpleResources' |
13403 | 56 |
poolDictionaries:'' |
57 |
privateIn:Annotation |
|
58 |
! |
|
59 |
||
60 |
Annotation subclass:#Unknown |
|
14501 | 61 |
instanceVariableNames:'method' |
13403 | 62 |
classVariableNames:'' |
63 |
poolDictionaries:'' |
|
64 |
privateIn:Annotation |
|
65 |
! |
|
66 |
||
67 |
!Annotation class methodsFor:'documentation'! |
|
68 |
||
69 |
copyright |
|
70 |
" |
|
13479 | 71 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
13403 | 72 |
All Rights Reserved |
73 |
||
13479 | 74 |
Permission is hereby granted, free of charge, to any person |
75 |
obtaining a copy of this software and associated documentation |
|
76 |
files (the 'Software'), to deal in the Software without |
|
77 |
restriction, including without limitation the rights to use, |
|
78 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
79 |
copies of the Software, and to permit persons to whom the |
|
80 |
Software is furnished to do so, subject to the following |
|
81 |
conditions: |
|
82 |
||
83 |
The above copyright notice and this permission notice shall be |
|
84 |
included in all copies or substantial portions of the Software. |
|
85 |
||
86 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
87 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
88 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
89 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
90 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
91 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
92 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
93 |
OTHER DEALINGS IN THE SOFTWARE. |
|
13403 | 94 |
" |
14430 | 95 |
! |
96 |
||
97 |
documentation |
|
98 |
" |
|
99 |
I represent an occurrence of a pragma in a compiled method. |
|
22021 | 100 |
|
23315 | 101 |
A pragma is a literal message pattern that occurs between angle brackets |
102 |
at the start of a method before or after any temporaries. |
|
103 |
||
14430 | 104 |
A common example is the primitive pragma: |
105 |
<primitive: 123 errorCode: 'errorCode'> |
|
14447
20f864eaec94
comment/format in: #documentation
Claus Gittinger <cg@exept.de>
parents:
14430
diff
changeset
|
106 |
but you can add your own and use them as metadata attached to a method. |
22021 | 107 |
|
14447
20f864eaec94
comment/format in: #documentation
Claus Gittinger <cg@exept.de>
parents:
14430
diff
changeset
|
108 |
Because pragmas are messages one can browse senders and implementors and perform them. |
20f864eaec94
comment/format in: #documentation
Claus Gittinger <cg@exept.de>
parents:
14430
diff
changeset
|
109 |
One can query a method for its pragmas by sending it the pragmas message, which answers an Array of instances of me, |
14430 | 110 |
one for each pragma in the method. |
111 |
I can provide information about the defining class, method, its selector, |
|
112 |
as well as the information about the pragma keyword and its arguments. See the two 'accessing' protocols for details. |
|
113 |
'accessing-method' provides information about the method the pragma is found in, |
|
114 |
while 'accessing-pragma' is about the pragma itself. |
|
115 |
Instances are retrieved using one of the pragma search methods of the 'finding' protocol on the class side. |
|
22021 | 116 |
|
14430 | 117 |
To browse all methods with pragmas in the system evaluate |
22021 | 118 |
SystemBrowser default browseAllSelect: [:m| m pragmas notEmpty] |
119 |
or: |
|
120 |
Smalltalk browseAllSelect: [:m| m pragmas notEmpty] |
|
121 |
||
122 |
(in Squeak/Pharo): to browse all nonprimitive methods with pragmas evaluate |
|
123 |
SystemBrowser default browseAllSelect: [:m| m primitive isZero and: [m pragmas notEmpty]] |
|
22030 | 124 |
|
125 |
knownPragmas |
|
126 |
context flagging: |
|
127 |
<context: #return> |
|
128 |
tells the compiler that this context will be returned through |
|
129 |
via 'thisContext sender ... sender return' from a lower context. |
|
130 |
The compiler's will create a returnable context |
|
23315 | 131 |
(i.e. prevent context optimizations/eliminations) |
22021 | 132 |
|
22030 | 133 |
exception handling: |
134 |
<exception: #handle> |
|
135 |
marks contexts as exception handlers. |
|
136 |
||
137 |
<exception: #unwind> |
|
138 |
marks contexts which contain unwind actions |
|
139 |
||
140 |
<exception: #raise> |
|
141 |
marks contexts which raise an exception |
|
22021 | 142 |
|
22030 | 143 |
misc: |
144 |
<resource: #skipInDebuggersWalkBack> |
|
145 |
will not be shown in the debugger |
|
22021 | 146 |
|
22030 | 147 |
<resource: #style (...)> |
148 |
affected by style sheet |
|
22021 | 149 |
|
22030 | 150 |
<resource: #obsolete> |
151 |
marks obsolete methods |
|
22029 | 152 |
|
22030 | 153 |
<modifier: #super> |
154 |
must be called if redefined i.e. redefiners MUST do a super-send |
|
22021 | 155 |
|
22030 | 156 |
<inspector2Tab> |
157 |
<postLoad> |
|
158 |
<swizzle: selector> |
|
22022 | 159 |
|
22030 | 160 |
<category: '...'> |
161 |
GNU-smalltalk's way of defining method categories |
|
14430 | 162 |
" |
13403 | 163 |
! ! |
164 |
||
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
165 |
!Annotation class methodsFor:'initialization'! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
166 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
167 |
initialize |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
168 |
"Invoked at system start or when the class is dynamically loaded." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
169 |
|
13670 | 170 |
Smalltalk at:#Pragma put:self. |
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
171 |
|
13670 | 172 |
"Modified: / 09-09-2011 / 07:16:26 / cg" |
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
173 |
! ! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
174 |
|
13403 | 175 |
!Annotation class methodsFor:'instance creation'! |
176 |
||
23315 | 177 |
javaScript:aSymbolOrString |
178 |
^ Annotation::JavaScriptSelector javaScriptSelector:aSymbolOrString |
|
13403 | 179 |
|
23315 | 180 |
"Created: / 29-08-2018 / 10:17:40 / Claus Gittinger" |
13625
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
181 |
! |
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
182 |
|
23242 | 183 |
nameSpace:aString |
14262 | 184 |
|
23242 | 185 |
^Annotation::NameSpace nameSpaceName:aString |
14262 | 186 |
|
187 |
"Created: / 19-05-2010 / 16:01:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
188 |
"Created: / 26-07-2012 / 23:05:28 / cg" |
|
23242 | 189 |
"Modified (format): / 29-07-2018 / 14:55:44 / Claus Gittinger" |
14262 | 190 |
! |
191 |
||
13403 | 192 |
namespace: aString |
14262 | 193 |
<resource: #obsolete> |
13403 | 194 |
|
14501 | 195 |
^ self nameSpace:aString |
13403 | 196 |
|
197 |
"Created: / 19-05-2010 / 16:01:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
198 |
! |
|
199 |
||
23242 | 200 |
resource:type |
22022 | 201 |
"resource method - returns menu, spec or image, |
202 |
or accesses/uses the viewStyle" |
|
203 |
||
23242 | 204 |
^Annotation::Resource type:type value:nil |
13403 | 205 |
|
206 |
"Created: / 16-07-2010 / 11:31:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
22022 | 207 |
"Modified (comment): / 16-07-2017 / 13:23:47 / cg" |
23242 | 208 |
"Modified (format): / 29-07-2018 / 14:55:50 / Claus Gittinger" |
13403 | 209 |
! |
210 |
||
18751 | 211 |
resource:type values:value |
22022 | 212 |
"resource method - returns menu, spec or image, |
213 |
or accesses/uses the viewStyle" |
|
214 |
||
23242 | 215 |
^ Annotation::Resource type:type value:value |
13403 | 216 |
|
217 |
"Created: / 16-07-2010 / 11:31:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
22022 | 218 |
"Modified (comment): / 16-07-2017 / 13:23:53 / cg" |
23242 | 219 |
"Modified: / 29-07-2018 / 14:50:49 / Claus Gittinger" |
13403 | 220 |
! ! |
221 |
||
16134 | 222 |
!Annotation class methodsFor:'finding'! |
14500 | 223 |
|
17645 | 224 |
allInMethod: aMethod |
225 |
"VisualWorks compatibility. |
|
226 |
Answer a collection of all pragmas found in the given method" |
|
227 |
||
228 |
^ aMethod annotations |
|
229 |
! |
|
230 |
||
16134 | 231 |
allNamed:aSymbol |
232 |
"Answer a collection of all pragmas found in all methods of all classes whose keyword is aSymbol." |
|
233 |
||
19820 | 234 |
^ Array |
235 |
streamContents: [ :stream | |
|
236 |
Smalltalk allClassesDo:[:eachClass | |
|
237 |
self withPragmasIn: eachClass do: [ :pragma | |
|
238 |
pragma keyword = aSymbol ifTrue: [ |
|
239 |
stream nextPut: pragma |
|
240 |
] |
|
241 |
] |
|
242 |
] |
|
243 |
]. |
|
16134 | 244 |
|
245 |
" |
|
246 |
Annotation allNamed:'worldMenu' |
|
247 |
" |
|
248 |
! |
|
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
249 |
|
19820 | 250 |
allNamed:aSymbol from:aSubClass to:aSuperClass |
251 |
"Answer a collection of all pragmas found in methods of all classes |
|
252 |
between aSubClass and aSuperClass (inclusive) whose keyword is aSymbol." |
|
253 |
||
254 |
^ Array |
|
255 |
streamContents:[:stream | |
|
256 |
aSubClass withAllSuperclassesDo:[:class | |
|
257 |
self withPragmasIn:class do:[:pragma | |
|
258 |
pragma keyword = aSymbol ifTrue: [ |
|
259 |
stream nextPut: pragma |
|
260 |
] |
|
261 |
]. |
|
262 |
aSuperClass = class ifTrue: [ |
|
263 |
^ stream contents |
|
264 |
] |
|
265 |
] |
|
266 |
]. |
|
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
267 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
268 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
269 |
allNamed: aSymbol from: aSubClass to: aSuperClass sortedByArgument: anInteger |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
270 |
"Answer a collection of all pragmas found in methods of all classes between aSubClass and aSuperClass (inclusive) whose keyword is aSymbol, sorted according to argument anInteger." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
271 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
272 |
^ self allNamed: aSymbol from: aSubClass to: aSuperClass sortedUsing: [ :a :b | (a argumentAt: anInteger) < (b argumentAt: anInteger) ]. |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
273 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
274 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
275 |
allNamed: aSymbol from: aSubClass to: aSuperClass sortedUsing: aSortBlock |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
276 |
"Answer a collection of all pragmas found in methods of all classes between aSubClass and aSuperClass (inclusive) whose keyword is aSymbol, sorted according to aSortBlock." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
277 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
278 |
^ (self allNamed: aSymbol from: aSubClass to: aSuperClass) sort: aSortBlock. |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
279 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
280 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
281 |
allNamed: aSymbol in: aClass |
19820 | 282 |
"Answer a collection of all pragmas found in methods of aClass whose keyword is aSymbol." |
283 |
||
284 |
^ Array |
|
285 |
streamContents: [ :stream | |
|
286 |
self withPragmasIn: aClass do: [ :pragma | |
|
287 |
pragma keyword = aSymbol ifTrue: [ |
|
288 |
stream nextPut: pragma |
|
289 |
] |
|
290 |
] |
|
291 |
]. |
|
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
292 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
293 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
294 |
allNamed: aSymbol in: aClass sortedByArgument: anInteger |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
295 |
"Answer a collection of all pragmas found in methods of aClass whose keyword is aSymbol, sorted according to argument anInteger." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
296 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
297 |
^ self allNamed: aSymbol in: aClass sortedUsing: [ :a :b | (a argumentAt: anInteger) < (b argumentAt: anInteger) ]. |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
298 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
299 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
300 |
allNamed: aSymbol in: aClass sortedUsing: aSortBlock |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
301 |
"Answer a collection of all pragmas found in methods of aClass whose keyword is aSymbol, sorted according to aSortBlock." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
302 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
303 |
^ (self allNamed: aSymbol in: aClass) sort: aSortBlock. |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
304 |
! ! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
305 |
|
22022 | 306 |
!Annotation class methodsFor:'instance creation - basic'! |
307 |
||
23315 | 308 |
for:aMethod selector:aSelector arguments:anArray |
309 |
^ (self new) |
|
310 |
setMethod:aMethod; |
|
311 |
setKeyword:aSelector; |
|
312 |
setArguments:anArray; |
|
313 |
yourself |
|
314 |
||
315 |
"Modified (format): / 29-08-2018 / 10:32:45 / Claus Gittinger" |
|
22022 | 316 |
! |
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
317 |
|
23315 | 318 |
key:key arguments:arguments |
319 |
"/ cg: do not react on all those methods inherited from Object (such as inline:) |
|
320 |
"/ (self respondsTo: key) |
|
321 |
||
322 |
(self class includesSelector:key) ifTrue:[ |
|
323 |
^ self perform:key withArguments:arguments |
|
324 |
]. |
|
325 |
^ Annotation::Unknown key:key arguments:arguments |
|
326 |
||
327 |
"Created: / 19-05-2010 / 16:47:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
328 |
"Modified: / 02-07-2010 / 16:22:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
329 |
"Modified (format): / 16-07-2017 / 13:23:00 / cg" |
|
330 |
"Modified: / 29-07-2018 / 14:52:13 / Claus Gittinger" |
|
331 |
"Modified (format): / 29-08-2018 / 10:32:38 / Claus Gittinger" |
|
332 |
! |
|
333 |
||
334 |
keyword:aSymbol arguments:anArray |
|
335 |
^ (self new) |
|
336 |
setKeyword:aSymbol; |
|
337 |
setArguments:anArray; |
|
338 |
yourself. |
|
339 |
||
340 |
"Modified (format): / 29-08-2018 / 10:32:31 / Claus Gittinger" |
|
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
341 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
342 |
|
22022 | 343 |
method:method key:key arguments:arguments |
344 |
"/ cg: do not react on all those methods inherited from Object (such as inline:) |
|
345 |
"/ (self respondsTo: key) |
|
346 |
(self class includesSelector:key) ifTrue: [ |
|
23315 | 347 |
^ self perform:key withArguments:arguments |
22022 | 348 |
]. |
23315 | 349 |
^ Annotation::Unknown new method:method key:key arguments:arguments |
22022 | 350 |
|
351 |
"Created: / 19-05-2010 / 16:47:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
352 |
"Modified: / 02-07-2010 / 16:22:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
353 |
"Created: / 05-09-2011 / 04:39:17 / cg" |
|
354 |
"Modified (format): / 16-07-2017 / 13:22:53 / cg" |
|
23315 | 355 |
"Modified: / 29-08-2018 / 10:32:17 / Claus Gittinger" |
22022 | 356 |
! ! |
357 |
||
358 |
!Annotation class methodsFor:'private'! |
|
359 |
||
23315 | 360 |
withPragmasIn:aClass do:aBlock |
361 |
aClass |
|
362 |
selectorsAndMethodsDo:[:selector :method | method annotationsDo:aBlock ]. |
|
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
363 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
364 |
"Modified: / 20-08-2011 / 21:31:49 / cg" |
23315 | 365 |
"Modified (format): / 29-08-2018 / 10:32:58 / Claus Gittinger" |
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
366 |
! ! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
367 |
|
13403 | 368 |
!Annotation methodsFor:'accessing'! |
369 |
||
14501 | 370 |
arguments |
371 |
^ arguments |
|
372 |
! |
|
373 |
||
13403 | 374 |
first |
375 |
||
376 |
^self key |
|
377 |
||
378 |
"Created: / 10-07-2010 / 21:38:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
379 |
! |
|
380 |
||
381 |
key |
|
14501 | 382 |
^ key |
13403 | 383 |
! ! |
384 |
||
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
385 |
!Annotation methodsFor:'accessing-method'! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
386 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
387 |
method |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
388 |
"Answer the compiled-method containing the pragma." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
389 |
|
22701 | 390 |
self halt:'unimplemented' |
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
391 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
392 |
"Modified: / 21-08-2011 / 12:44:37 / cg" |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
393 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
394 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
395 |
methodClass |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
396 |
"Answer the class of the method containing the pragma." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
397 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
398 |
^ self method methodClass |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
399 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
400 |
"Modified: / 21-08-2011 / 12:44:47 / cg" |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
401 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
402 |
|
17694 | 403 |
methodSelector |
404 |
"Answer the selector of the method containing the pragma. |
|
405 |
Added to not confuse this with the selector (i.e. key) of the pragma's message pattern." |
|
406 |
||
407 |
^ self method selector |
|
408 |
||
409 |
"Modified: / 21-08-2011 / 12:45:20 / cg" |
|
410 |
! |
|
411 |
||
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
412 |
selector |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
413 |
"Answer the selector of the method containing the pragma. |
17694 | 414 |
Do not confuse this with the selector (i.e. key) of the pragma's message pattern. |
415 |
(use methodSelector, to make this clear)" |
|
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
416 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
417 |
^ self method selector |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
418 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
419 |
"Modified: / 21-08-2011 / 12:45:20 / cg" |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
420 |
! ! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
421 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
422 |
!Annotation methodsFor:'accessing-pragma'! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
423 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
424 |
argumentAt: anInteger |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
425 |
"Answer one of the arguments of the pragma." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
426 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
427 |
^ self arguments at: anInteger. |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
428 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
429 |
|
24223 | 430 |
argumentAt:anInteger ifAbsent:exceptionValue |
431 |
"Answer one of the arguments of the pragma or exceptionValue's value if not present." |
|
432 |
||
433 |
^ self arguments at: anInteger ifAbsent:exceptionValue. |
|
434 |
||
435 |
"Created: / 29-05-2019 / 00:46:47 / Claus Gittinger" |
|
436 |
! |
|
437 |
||
18432 | 438 |
argumentCount |
439 |
"Answer the number of arguments in the pragma." |
|
440 |
||
441 |
^ self arguments size. |
|
442 |
! |
|
443 |
||
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
444 |
message |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
445 |
"Answer the message of the receiving pragma." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
446 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
447 |
^ Message selector: self keyword arguments: self arguments. |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
448 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
449 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
450 |
numArgs |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
451 |
"Answer the number of arguments in the pragma." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
452 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
453 |
^ self arguments size. |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
454 |
! ! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
455 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
456 |
!Annotation methodsFor:'comparing'! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
457 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
458 |
analogousCodeTo: anObject |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
459 |
^self class == anObject class |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
460 |
and: [self keyword == anObject keyword |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
461 |
and: [self arguments = anObject arguments]] |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
462 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
463 |
"Modified: / 21-08-2011 / 12:45:37 / cg" |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
464 |
! ! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
465 |
|
13625
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
466 |
!Annotation methodsFor:'compatibility - squeak'! |
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
467 |
|
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
468 |
keyword |
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
469 |
^ self key |
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
470 |
|
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
471 |
"Created: / 05-09-2011 / 04:34:26 / cg" |
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
472 |
! ! |
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
473 |
|
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
474 |
!Annotation methodsFor:'initialization'! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
475 |
|
17300 | 476 |
key:keyArg |
477 |
key := keyArg. |
|
478 |
! |
|
479 |
||
14501 | 480 |
key:keyArg arguments:argumentsArg |
481 |
key := keyArg. |
|
482 |
arguments := argumentsArg. |
|
483 |
! |
|
484 |
||
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
485 |
setArguments: anArray |
14501 | 486 |
arguments := anArray |
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
487 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
488 |
"Modified: / 21-08-2011 / 12:45:51 / cg" |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
489 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
490 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
491 |
setKeyword: aSymbol |
14501 | 492 |
key := aSymbol |
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
493 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
494 |
"Modified: / 21-08-2011 / 12:46:06 / cg" |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
495 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
496 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
497 |
setMethod: aCompiledMethod |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
498 |
self subclassResponsibility |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
499 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
500 |
"Modified: / 21-08-2011 / 12:46:16 / cg" |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
501 |
! ! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
502 |
|
23225 | 503 |
!Annotation methodsFor:'printing & storing'! |
13403 | 504 |
|
505 |
printOn:aStream |
|
20217 | 506 |
"append a printed representation of the receiver to the argument, aStream" |
13403 | 507 |
|
508 |
self storeOn:aStream. |
|
509 |
||
510 |
"Modified: / 19-05-2010 / 16:25:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
23225 | 511 |
! |
13403 | 512 |
|
513 |
storeOn:aStream |
|
14501 | 514 |
"superclass Annotation says that I am responsible to implement this method" |
13403 | 515 |
|
14501 | 516 |
aStream nextPutAll: '(Annotation key: '. |
517 |
key storeOn: aStream. |
|
518 |
aStream nextPutAll: ' arguments: '. |
|
519 |
arguments storeOn: aStream. |
|
520 |
aStream nextPut: $). |
|
13403 | 521 |
|
14501 | 522 |
"Modified: / 19-05-2010 / 16:46:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13403 | 523 |
! ! |
524 |
||
525 |
!Annotation methodsFor:'processing'! |
|
526 |
||
527 |
annotatesClass: aClass |
|
23315 | 528 |
"Nothing to do" |
13403 | 529 |
|
530 |
"Created: / 20-05-2010 / 11:15:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
23315 | 531 |
"Modified: / 29-08-2018 / 10:12:21 / Claus Gittinger" |
13403 | 532 |
! |
533 |
||
23315 | 534 |
annotatesMethod:aMethod |
535 |
"Nothing to do" |
|
13403 | 536 |
|
537 |
"Created: / 20-05-2010 / 11:15:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
23315 | 538 |
"Modified: / 29-08-2018 / 10:12:49 / Claus Gittinger" |
539 |
! |
|
540 |
||
541 |
installedInMethod:aMethod |
|
542 |
"called right after being added to a method's annotations. |
|
543 |
Can be redefined in concrete annotation classes to do something with the |
|
544 |
method or class" |
|
545 |
||
546 |
"/ intentionally left blank here |
|
547 |
^ self |
|
548 |
||
549 |
"Created: / 29-08-2018 / 10:30:39 / Claus Gittinger" |
|
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
550 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
551 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
552 |
sendTo: anObject |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
553 |
"Send the pragma keyword together with its arguments to anObject and answer the result." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
554 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
555 |
^ anObject perform: self keyword withArguments: self arguments |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
556 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
557 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
558 |
withArgumentsDo: aBlock |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
559 |
"Pass the arguments of the receiving pragma into aBlock and answer the result." |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
560 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
561 |
^ aBlock valueWithArguments: self arguments |
13403 | 562 |
! ! |
563 |
||
14254 | 564 |
!Annotation methodsFor:'queries'! |
565 |
||
566 |
refersToLiteral: anObject |
|
16264 | 567 |
"return true if the receiver or recursively any array element in the |
568 |
receiver refers to aLiteral (i.e. a deep search)" |
|
569 |
||
14501 | 570 |
(anObject == key) ifTrue:[ ^ true ]. |
571 |
(anObject == arguments) ifTrue:[ ^ true ]. |
|
572 |
arguments isArray ifTrue:[ ^ arguments refersToLiteral: anObject]. |
|
14254 | 573 |
^ false |
574 |
||
14501 | 575 |
"Created: / 26-07-2012 / 15:57:43 / cg" |
576 |
! |
|
577 |
||
578 |
refersToLiteralMatching: aMatchString |
|
579 |
(key isSymbol and:[aMatchString match:key])ifTrue:[ ^ true ]. |
|
580 |
(arguments isSymbol and:[aMatchString match:arguments])ifTrue:[ ^ true ]. |
|
581 |
arguments isArray ifTrue:[ ^ arguments refersToLiteralMatching: aMatchString]. |
|
582 |
^ false |
|
583 |
||
584 |
"Created: / 26-07-2012 / 16:00:58 / cg" |
|
14254 | 585 |
! ! |
586 |
||
13403 | 587 |
!Annotation methodsFor:'testing'! |
588 |
||
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
589 |
hasLiteral: aLiteral |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
590 |
^self keyword == aLiteral |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
591 |
or: [self arguments hasLiteral: aLiteral] |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
592 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
593 |
"Modified: / 21-08-2011 / 12:46:44 / cg" |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
594 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
595 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
596 |
hasLiteralSuchThat: aBlock |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
597 |
"Answer true if litBlock returns true for any literal in the receiver, even if embedded in further array structure. |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
598 |
This method is only intended for private use by CompiledMethod hasLiteralSuchThat:" |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
599 |
^(aBlock value: self keyword) |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
600 |
or: [self arguments hasLiteralSuchThat: aBlock] |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
601 |
|
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
602 |
"Modified: / 21-08-2011 / 12:46:31 / cg" |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
603 |
! |
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
604 |
|
23315 | 605 |
isJavaScriptSelector |
606 |
"true if this is a (wellknown) javascript selector annotation" |
|
607 |
||
608 |
^ false |
|
609 |
||
610 |
"Created: / 29-08-2018 / 10:10:56 / Claus Gittinger" |
|
611 |
! |
|
612 |
||
14212 | 613 |
isResource |
23315 | 614 |
"true if this is a (wellknown) resource annotation" |
615 |
||
14212 | 616 |
^ false |
617 |
||
618 |
"Created: / 18-07-2012 / 19:28:39 / cg" |
|
23315 | 619 |
"Modified (comment): / 29-08-2018 / 10:13:27 / Claus Gittinger" |
14212 | 620 |
! |
621 |
||
13403 | 622 |
isUnknown |
23315 | 623 |
"true if this is a (non-wellknown) other annotation" |
624 |
||
13403 | 625 |
^ false |
23315 | 626 |
|
627 |
"Modified (comment): / 29-08-2018 / 10:13:50 / Claus Gittinger" |
|
628 |
! ! |
|
629 |
||
630 |
!Annotation::JavaScriptSelector class methodsFor:'documentation'! |
|
631 |
||
632 |
documentation |
|
633 |
" |
|
634 |
I define an alternative selector to be installed in the class' |
|
635 |
method dictionary, in order to allow for regular javaScript function names |
|
636 |
to be used (in addition to smalltalk names). |
|
637 |
For example, a smalltalk method named |
|
638 |
foo:arg1 bar:arg2 baz:arg3 |
|
639 |
could be annotated as foo/3 in order to be seen and callable in javascript as |
|
640 |
foo(arg1, arg2, arg3) |
|
641 |
||
642 |
[author:] |
|
643 |
Claus Gittinger |
|
644 |
" |
|
645 |
! ! |
|
646 |
||
647 |
!Annotation::JavaScriptSelector methodsFor:'accessing'! |
|
648 |
||
649 |
javaScriptSelector |
|
650 |
^ arguments at:1 |
|
651 |
||
652 |
"Created: / 29-08-2018 / 10:16:04 / Claus Gittinger" |
|
653 |
! |
|
654 |
||
655 |
javaScriptSelector:aSymbolOrString |
|
656 |
key := #'javaScript:'. |
|
657 |
arguments := Array with:aSymbolOrString asSymbol. |
|
658 |
||
659 |
"Created: / 29-08-2018 / 10:16:54 / Claus Gittinger" |
|
660 |
! ! |
|
661 |
||
662 |
!Annotation::JavaScriptSelector methodsFor:'testing'! |
|
663 |
||
664 |
isJavaScriptSelector |
|
665 |
"true if this is a (wellknown) javascript selector annotation" |
|
666 |
||
667 |
^ true |
|
668 |
||
669 |
"Created: / 29-08-2018 / 10:15:07 / Claus Gittinger" |
|
13403 | 670 |
! ! |
671 |
||
23242 | 672 |
!Annotation::NameSpace class methodsFor:'instance creation'! |
673 |
||
674 |
nameSpaceName:aString |
|
675 |
^ self new nameSpaceName:aString |
|
676 |
||
677 |
"Created: / 29-07-2018 / 14:51:26 / Claus Gittinger" |
|
678 |
! ! |
|
679 |
||
13403 | 680 |
!Annotation::NameSpace methodsFor:'accessing'! |
681 |
||
682 |
key |
|
683 |
||
684 |
^#namespace: |
|
685 |
||
686 |
"Created: / 19-05-2010 / 16:23:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
687 |
! |
|
688 |
||
689 |
nameSpace |
|
14501 | 690 |
^ arguments first |
13403 | 691 |
! |
692 |
||
693 |
nameSpace:something |
|
14501 | 694 |
arguments := Array with:something. |
13403 | 695 |
! ! |
696 |
||
697 |
!Annotation::NameSpace methodsFor:'initialization'! |
|
698 |
||
699 |
nameSpaceName: aString |
|
700 |
||
701 |
self nameSpace: (NameSpace name: aString) |
|
702 |
||
703 |
"Created: / 19-05-2010 / 16:02:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
704 |
! ! |
|
705 |
||
706 |
!Annotation::NameSpace methodsFor:'printing & storing'! |
|
707 |
||
708 |
storeOn:aStream |
|
709 |
"superclass Annotation says that I am responsible to implement this method" |
|
710 |
||
711 |
aStream nextPutAll: '(Annotation namespace: '. |
|
14501 | 712 |
self nameSpace name storeOn: aStream. |
13403 | 713 |
aStream nextPut:$) |
714 |
||
715 |
"Modified: / 19-05-2010 / 16:27:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
716 |
! ! |
|
717 |
||
718 |
!Annotation::NameSpace methodsFor:'processing'! |
|
719 |
||
720 |
annotatesMethod:aMethod |
|
721 |
||
722 |
aMethod lookupObject: NamespaceAwareLookup instance |
|
723 |
||
724 |
"Modified: / 20-05-2010 / 11:18:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
725 |
! ! |
|
726 |
||
23242 | 727 |
!Annotation::Resource class methodsFor:'documentation'! |
728 |
||
729 |
documentation |
|
730 |
" |
|
731 |
documentation to be added. |
|
732 |
||
733 |
[author:] |
|
734 |
Claus Gittinger |
|
735 |
||
736 |
[instance variables:] |
|
737 |
||
738 |
[class variables:] |
|
739 |
||
740 |
[see also:] |
|
741 |
||
742 |
" |
|
743 |
! ! |
|
744 |
||
745 |
!Annotation::Resource class methodsFor:'instance creation'! |
|
746 |
||
747 |
type:type value:value |
|
748 |
(value isNil) ifTrue:[ |
|
749 |
SharedSimpleResources isNil ifTrue:[ |
|
750 |
SharedSimpleResources := IdentityDictionary new. |
|
751 |
]. |
|
752 |
^ SharedSimpleResources at:type ifAbsentPut:[self new type:type value:value] |
|
753 |
]. |
|
754 |
^ self new type:type value:value |
|
755 |
||
756 |
"Created: / 29-07-2018 / 14:50:33 / Claus Gittinger" |
|
757 |
! ! |
|
758 |
||
13403 | 759 |
!Annotation::Resource methodsFor:'accessing'! |
760 |
||
14501 | 761 |
type |
762 |
^ arguments at:1 |
|
13403 | 763 |
! |
764 |
||
14501 | 765 |
type:typeArg value:valueArg |
766 |
valueArg isNil ifTrue:[ |
|
767 |
key := #'resource:'. |
|
768 |
arguments := Array with:typeArg. |
|
769 |
] ifFalse:[ |
|
18751 | 770 |
key := #'resource:values:'. |
14501 | 771 |
arguments := Array with:typeArg with:valueArg. |
772 |
]. |
|
13403 | 773 |
! |
774 |
||
775 |
value |
|
14501 | 776 |
arguments size > 1 ifTrue:[ |
777 |
^ arguments at:2 |
|
778 |
]. |
|
779 |
^ nil |
|
13403 | 780 |
! ! |
781 |
||
782 |
!Annotation::Resource methodsFor:'printing & storing'! |
|
783 |
||
784 |
storeOn:aStream |
|
785 |
aStream nextPutAll: '(Annotation resource: '. |
|
14501 | 786 |
self type storeOn: aStream. |
787 |
self value notNil ifTrue: [ |
|
14254 | 788 |
aStream nextPutAll: ' value: '. |
14501 | 789 |
self value storeOn: aStream |
14254 | 790 |
]. |
13403 | 791 |
aStream nextPut:$) |
792 |
||
793 |
"Modified: / 16-07-2010 / 11:36:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13837 | 794 |
"Modified: / 29-11-2011 / 11:19:06 / cg" |
14254 | 795 |
"Modified (format): / 26-07-2012 / 15:59:14 / cg" |
13403 | 796 |
! ! |
797 |
||
14212 | 798 |
!Annotation::Resource methodsFor:'testing'! |
799 |
||
800 |
isResource |
|
801 |
^ true |
|
802 |
||
803 |
"Created: / 18-07-2012 / 19:28:46 / cg" |
|
804 |
! ! |
|
805 |
||
23242 | 806 |
!Annotation::Unknown class methodsFor:'instance creation'! |
807 |
||
808 |
key:key arguments:arguments |
|
809 |
^ self new key:key arguments:arguments |
|
810 |
||
811 |
"Created: / 29-07-2018 / 14:52:00 / Claus Gittinger" |
|
812 |
! ! |
|
813 |
||
13403 | 814 |
!Annotation::Unknown methodsFor:'accessing'! |
815 |
||
14501 | 816 |
method |
817 |
^ method |
|
818 |
||
819 |
"Created: / 05-09-2011 / 04:38:33 / cg" |
|
13403 | 820 |
! |
821 |
||
14501 | 822 |
setMethod:aMethod |
823 |
method := aMethod |
|
13625
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
824 |
|
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
825 |
"Created: / 05-09-2011 / 04:38:33 / cg" |
13403 | 826 |
! ! |
827 |
||
828 |
!Annotation::Unknown methodsFor:'initialization'! |
|
829 |
||
13625
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
830 |
method:methodArg key:keyArg arguments:argumentsArg |
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
831 |
method := methodArg. |
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
832 |
key := keyArg. |
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
833 |
arguments := argumentsArg. |
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
834 |
|
fffe5dbb451b
added: #method:key:arguments:
Claus Gittinger <cg@exept.de>
parents:
13613
diff
changeset
|
835 |
"Created: / 05-09-2011 / 04:39:50 / cg" |
13403 | 836 |
! ! |
837 |
||
14254 | 838 |
!Annotation::Unknown methodsFor:'queries'! |
839 |
||
840 |
refersToLiteral: anObject |
|
841 |
(anObject == method) ifTrue:[ ^ true ]. |
|
14501 | 842 |
^ super refersToLiteral: anObject |
14254 | 843 |
! |
844 |
||
845 |
refersToLiteralMatching: aMatchString |
|
846 |
(method isSymbol and:[aMatchString match:method])ifTrue:[ ^ true ]. |
|
14501 | 847 |
^ super refersToLiteralMatching: aMatchString |
14254 | 848 |
|
849 |
"Created: / 26-07-2012 / 16:00:58 / cg" |
|
850 |
! ! |
|
851 |
||
13403 | 852 |
!Annotation::Unknown methodsFor:'testing'! |
853 |
||
854 |
isUnknown |
|
855 |
^ true |
|
856 |
! ! |
|
857 |
||
858 |
!Annotation class methodsFor:'documentation'! |
|
859 |
||
13670 | 860 |
version |
18751 | 861 |
^ '$Header$' |
13670 | 862 |
! |
863 |
||
13479 | 864 |
version_CVS |
18751 | 865 |
^ '$Header$' |
13479 | 866 |
! |
867 |
||
13403 | 868 |
version_SVN |
18751 | 869 |
^ '$Id$' |
13403 | 870 |
! ! |
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
871 |
|
16134 | 872 |
|
13613
f3c2a2ac07a1
Pragma (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
873 |
Annotation initialize! |