author | Claus Gittinger <cg@exept.de> |
Mon, 06 Mar 2006 09:59:24 +0100 | |
changeset 9231 | 19a4fcc9c300 |
parent 8913 | b9498d27a554 |
child 9647 | 67697176654d |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
5434 | 13 |
"{ Package: 'stx:libbasic' }" |
14 |
||
3985 | 15 |
String variableByteSubclass:#Symbol |
1020 | 16 |
instanceVariableNames:'' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Collections-Text' |
|
1 | 20 |
! |
21 |
||
77 | 22 |
!Symbol class methodsFor:'documentation'! |
1 | 23 |
|
88 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 27 |
All Rights Reserved |
88 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
77 | 38 |
documentation |
39 |
" |
|
40 |
Symbols represent unique strings - every symbol with same printString |
|
41 |
exists exactly once in the system; Symbols are used for selectors, global |
|
345 | 42 |
variable-keys etc. Symbols can also be used to represent things which are |
43 |
enumeration type values in other programming languages (since symbols are |
|
370 | 44 |
created at compile time, comparing them using == is a fast pointer compare). |
345 | 45 |
|
46 |
A symbol may not change its characters - i.e. it is constant over its lifetime. |
|
47 |
Other than that, symbols behave much like strings. |
|
1290 | 48 |
|
49 |
[author:] |
|
2200 | 50 |
Claus Gittinger |
77 | 51 |
" |
52 |
! ! |
|
1 | 53 |
|
77 | 54 |
!Symbol class methodsFor:'instance creation'! |
1 | 55 |
|
62 | 56 |
basicNew:size |
57 |
"redefined to return a string instead of a symbol - |
|
58 |
this allows all copy methods inherited from String to |
|
59 |
return strings containing the symbols characters. |
|
1020 | 60 |
Real symbols are only created with #intern: or #asSymbol." |
62 | 61 |
|
62 |
^ String new:size |
|
1020 | 63 |
|
64 |
"Modified: 26.2.1996 / 12:51:38 / cg" |
|
62 | 65 |
! |
66 |
||
77 | 67 |
fromString:aString |
68 |
"same as intern: for Symbol, but may be used to create interned instances |
|
69 |
of subclasses. |
|
70 |
Notice: this fails, if you try to intern an instance of a subclass, AND |
|
71 |
a symbol with the same name already exists. In this case, the original |
|
72 |
symbol is returned. To use it for enum-type symbols, make certain, that the |
|
73 |
names are unique (for example by including the classes name as a prefix-string)." |
|
74 |
||
267 | 75 |
|sym len| |
77 | 76 |
|
267 | 77 |
sym := aString asSymbolIfInterned. |
78 |
sym notNil ifTrue:[ |
|
79 |
^ sym |
|
77 | 80 |
]. |
81 |
||
82 |
" |
|
83 |
create a new uninterned instance first |
|
84 |
" |
|
85 |
len := aString size. |
|
267 | 86 |
sym := super basicNew:len. |
87 |
sym replaceFrom:1 to:len with:aString. |
|
77 | 88 |
|
89 |
"now, intern it" |
|
90 |
%{ |
|
329 | 91 |
sym = __INTERNSYMBOL(sym, (OBJ *)0, __context); |
77 | 92 |
%}. |
267 | 93 |
^ sym |
77 | 94 |
! |
95 |
||
608 | 96 |
intern:aString |
97 |
"return a unique symbol with printname taken from the String-argument" |
|
98 |
||
99 |
%{ /* NOCONTEXT */ |
|
100 |
OBJ newSymbol; |
|
101 |
||
102 |
if (__isSymbol(aString)) { |
|
103 |
RETURN (aString); |
|
104 |
} |
|
105 |
if (__isString(aString)) { |
|
2200 | 106 |
newSymbol = __MKSYMBOL(__stringVal(aString), (OBJ *)0); |
608 | 107 |
if (newSymbol != nil) { |
108 |
RETURN (newSymbol); |
|
109 |
} |
|
110 |
} |
|
111 |
%}. |
|
112 |
aString class ~~ String ifTrue:[ |
|
113 |
"/ |
|
114 |
"/ only allowed to intern strings |
|
115 |
"/ |
|
116 |
^ self mustBeString |
|
117 |
]. |
|
118 |
^ ObjectMemory allocationFailureSignal raise. |
|
119 |
! |
|
120 |
||
1 | 121 |
internCharacter:aCharacter |
122 |
"return a unique symbol with printname taken from the Character-argument" |
|
123 |
||
124 |
^ self intern:(aCharacter asString) |
|
608 | 125 |
! |
126 |
||
127 |
new:size |
|
128 |
"redefined to return a string instead of a symbol - |
|
129 |
this allows all copy methods inherited from String to |
|
130 |
return strings containing the symbols characters. |
|
131 |
Real symbols are only created with intern: or asSymbol." |
|
132 |
||
133 |
^ String new:size |
|
134 |
! ! |
|
135 |
||
7301 | 136 |
!Symbol class methodsFor:'Compatibility-ST80'! |
2570
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
137 |
|
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
138 |
tableSize |
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
139 |
"return the size of the systems symbol table" |
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
140 |
|
4838 | 141 |
"/ claus: I dont know, if the returned value should be exact. |
142 |
"/ the number below is just arbitrary ... |
|
2570
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
143 |
|
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
144 |
^ 10000 |
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
145 |
|
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
146 |
"Created: 18.4.1997 / 20:52:20 / cg" |
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
147 |
! ! |
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
148 |
|
608 | 149 |
!Symbol class methodsFor:'binary storage'! |
150 |
||
1253 | 151 |
binaryDefinitionFrom:stream manager:manager |
152 |
"retrieve a symbol from a binary input stream (nonpublic interface)" |
|
153 |
||
154 |
^ self intern:(super binaryDefinitionFrom:stream manager:manager) |
|
155 |
||
3086 | 156 |
"Modified: / 2.11.1997 / 16:17:06 / cg" |
1 | 157 |
! ! |
158 |
||
159 |
!Symbol class methodsFor:'queries'! |
|
160 |
||
608 | 161 |
findInterned:aString |
162 |
"for ST-80 compatibility - if the argument, aString is known |
|
163 |
as Symbol, return this symbol. Otherwise return nil." |
|
164 |
||
165 |
^ aString asSymbolIfInterned |
|
166 |
! |
|
167 |
||
168 |
hasInterned:aString |
|
169 |
"return true, if the argument, aString is known as Symbol; |
|
170 |
false otherwise" |
|
171 |
||
172 |
^ aString knownAsSymbol |
|
173 |
! |
|
174 |
||
1 | 175 |
hasInterned:aString ifTrue:trueBlock |
176 |
"for ST-80 compatibility - if the argument, aString is known |
|
177 |
as Symbol, evaluate the block with the corresponding symbol |
|
178 |
as argument and return true; otherwise return false" |
|
179 |
||
275 | 180 |
|sym| |
181 |
||
182 |
(sym := aString asSymbolIfInterned) notNil ifTrue:[ |
|
183 |
trueBlock value:sym. |
|
159 | 184 |
^ true |
1 | 185 |
]. |
186 |
^ false |
|
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
187 |
! |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
188 |
|
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
189 |
hasSharedInstances |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
190 |
"return true if this class has shared instances, that is, instances |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
191 |
with the same value are identical. |
4654 | 192 |
True returned here - there is only one of each symbol (per contents)." |
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
193 |
|
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
194 |
^ true |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
195 |
|
1 | 196 |
! ! |
197 |
||
7261 | 198 |
!Symbol methodsFor:'Compatibility-VW'! |
7153 | 199 |
|
200 |
<< catalogID |
|
201 |
"create and return a new UserMessage, with the receiver as key, |
|
202 |
and the argument as cataglogID. |
|
203 |
VW compatibility." |
|
204 |
||
205 |
^ UserMessage key:self catalogID:catalogID |
|
206 |
||
207 |
" |
|
208 |
(#theFooMessage << #myMessages) |
|
209 |
(#theFooMessage << #myMessages >> 'cannot read subclass of metaclass') |
|
210 |
(#theFooMessage >> 'cannot read subclass of metaclass') |
|
211 |
" |
|
212 |
! |
|
213 |
||
214 |
>> aString |
|
215 |
"create and return a new UserMessage, with the receiver as key, |
|
216 |
and the argument as defaultString. |
|
217 |
VW compatibility." |
|
218 |
||
219 |
^ UserMessage key:self defaultString:aString |
|
220 |
||
221 |
" |
|
222 |
(#theFooMessage << #myMessages) |
|
223 |
(#theFooMessage << #myMessages >> 'cannot read subclass of metaclass') |
|
224 |
(#theFooMessage >> 'cannot read subclass of metaclass') |
|
225 |
" |
|
226 |
! ! |
|
227 |
||
1 | 228 |
!Symbol methodsFor:'accessing'! |
229 |
||
230 |
basicAt:index put:something |
|
345 | 231 |
"report an error if an interned symbol is about to be changed |
1219 | 232 |
- interned symbols may NOT be changed. |
233 |
For uninterned symbols, this is allowed." |
|
1 | 234 |
|
77 | 235 |
self knownAsSymbol ifTrue:[ |
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
236 |
self error:'interned symbols may not be changed'. |
77 | 237 |
]. |
238 |
" |
|
239 |
uninterned - allow change |
|
240 |
" |
|
241 |
^ super basicAt:index put:something |
|
1219 | 242 |
|
243 |
"Modified: 19.4.1996 / 11:16:10 / cg" |
|
252 | 244 |
! |
245 |
||
246 |
byteAt:index put:value |
|
247 |
"report an error if interned - interned symbols may not be changed." |
|
248 |
||
249 |
^ self basicAt:index put:(value asCharacter) |
|
1 | 250 |
! ! |
251 |
||
3086 | 252 |
!Symbol methodsFor:'binary storage'! |
253 |
||
254 |
storeBinaryDefinitionOn:stream manager:manager |
|
255 |
"append a binary representation of the receiver onto stream. |
|
256 |
Redefined since short Symbol can be stored with a special type code |
|
257 |
in a more compact way. |
|
258 |
This is an internal interface for the binary storage mechanism." |
|
259 |
||
260 |
|myClass myBasicSize| |
|
261 |
||
262 |
"/ not for subclasses with named instVars. |
|
263 |
(myClass := self class) instSize ~~ 0 ifTrue:[ |
|
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
264 |
^ super storeBinaryDefinitionOn:stream manager:manager |
3086 | 265 |
]. |
266 |
||
267 |
myBasicSize := self basicSize. |
|
268 |
||
269 |
"/ can use a more compact representation; |
|
270 |
"/ but not for subclasses ... |
|
271 |
||
272 |
((myClass == Symbol) |
|
273 |
and:[myBasicSize <= 255]) ifTrue:[ |
|
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
274 |
"/ special encoding: <codeForSymbol> <len> <bytes> ... |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
275 |
stream nextPut:(manager codeForSymbol); nextPut:myBasicSize. |
3086 | 276 |
] ifFalse:[ |
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
277 |
manager putIdOfClass:myClass on:stream. |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
278 |
stream nextNumber:4 put:myBasicSize. |
3086 | 279 |
]. |
280 |
stream nextPutBytes:myBasicSize from:self startingAt:1. |
|
281 |
||
282 |
"Modified: / 2.11.1997 / 15:28:56 / cg" |
|
283 |
"Created: / 2.11.1997 / 16:13:47 / cg" |
|
284 |
! ! |
|
285 |
||
608 | 286 |
!Symbol methodsFor:'comparing'! |
159 | 287 |
|
608 | 288 |
= something |
289 |
"return true, if the receiver and argument consist of the same characters. |
|
290 |
Redefined here, for more efficient #= comparison of symbols |
|
291 |
(which ought to be compared using #==). |
|
292 |
If the argument is a symbol, we use a quick pointer compare, instead of |
|
293 |
the inherited value compare." |
|
13 | 294 |
|
608 | 295 |
%{ /* NOCONTEXT */ |
296 |
OBJ cls; |
|
13 | 297 |
|
608 | 298 |
if (! __isNonNilObject(something)) RETURN(false); |
299 |
if ((cls = __qClass(something)) == Symbol) { |
|
300 |
RETURN (self == something ? true : false); |
|
301 |
} |
|
302 |
if (cls == String) { |
|
303 |
RETURN (strcmp(__stringVal(self), __stringVal(something)) == 0 ? true : false); |
|
345 | 304 |
} |
305 |
%}. |
|
608 | 306 |
"fall back; could be a TwoByteString, or a collection of Characters" |
1 | 307 |
|
608 | 308 |
^ super = something |
427 | 309 |
! |
310 |
||
356 | 311 |
identityHash |
312 |
"interned symbols can return a better hash key" |
|
313 |
||
314 |
%{ /* NOCONTEXT */ |
|
315 |
||
8913 | 316 |
REGISTER unsigned INT g, val; |
3985 | 317 |
REGISTER unsigned char *cp, *ce; |
356 | 318 |
int l; |
319 |
||
320 |
if (__Class(self) == Symbol) { |
|
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
321 |
val = __GET_HASH(self); |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
322 |
/* |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
323 |
* only do it, if I have no standard hash key |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
324 |
* assigned (which can only happen due to a #become:, |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
325 |
* or by creating a symbol uninterned, and interning it |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
326 |
* after it got a hashKey assigned. |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
327 |
*/ |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
328 |
if (val == 0) { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
329 |
cp = __stringVal(self); |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
330 |
l = __stringSize(self); |
356 | 331 |
|
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
332 |
/* |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
333 |
* this is the dragon-book algorithm |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
334 |
* We have tested 5-bit shifts as well: |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
335 |
* |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
336 |
* ST/X Symbols: 17807 |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
337 |
* Hashkey collisions (4bit): 14 0.07% |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
338 |
* Hashkey collisions (5bit): 300 1.68% |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
339 |
*/ |
356 | 340 |
|
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
341 |
if (l > 0) { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
342 |
val = cp[0]; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
343 |
if (l > 1) { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
344 |
val = (val << 4) + cp[1]; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
345 |
if (l > 2) { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
346 |
val = (val << 4) + cp[2]; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
347 |
if (l > 3) { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
348 |
val = (val << 4) + cp[3]; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
349 |
if (l > 4) { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
350 |
val = (val << 4) + cp[4]; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
351 |
if (l > 5) { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
352 |
val = (val << 4) + cp[5]; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
353 |
if (l > 6) { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
354 |
val = (val << 4) + cp[6]; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
355 |
for (ce = cp + l, cp += 7; cp < ce; cp++) { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
356 |
if (g = (val & 0xF0000000)) { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
357 |
val ^= g >> 24; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
358 |
val ^= g; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
359 |
} |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
360 |
val = (val << 4) + *cp; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
361 |
} |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
362 |
} |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
363 |
} |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
364 |
} |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
365 |
} |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
366 |
} |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
367 |
} |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
368 |
} else { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
369 |
val = 0; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
370 |
} |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
371 |
val = (val * 31415821) & 0x3fffffff; |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
372 |
} else { |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
373 |
val = __MAKE_HASH__(val); |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
374 |
} |
8913 | 375 |
RETURN ( __mkSmallInteger(val) ); |
356 | 376 |
} |
377 |
%}. |
|
378 |
^ super identityHash |
|
3985 | 379 |
|
380 |
" |
|
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
381 |
|hashColl hashSet| |
3985 | 382 |
|
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
383 |
hashColl := OrderedCollection new:20000. |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
384 |
Symbol allInstancesDo:[:instance | |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
385 |
hashColl add:instance identityHash |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
386 |
]. |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
387 |
hashSet := hashColl asSet. |
3985 | 388 |
|
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
389 |
Transcript showCR:'Symbols: ', hashColl size printString, |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
390 |
' unique hash keys: ', hashSet size printString, |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
391 |
' collisions:', (hashColl size - hashSet size) printString. |
3985 | 392 |
" |
393 |
||
370 | 394 |
! |
395 |
||
396 |
~= something |
|
397 |
"return true, if the receiver and argument do not consist of the same characters. |
|
398 |
Redefined here, for more efficient #~= comparison of symbols |
|
399 |
(which ought to be compared using #~~). |
|
400 |
If the argument is a symbol, we use a quick pointer compare, instead of |
|
401 |
the inherited value compare." |
|
402 |
||
403 |
%{ /* NOCONTEXT */ |
|
404 |
OBJ cls; |
|
405 |
||
379 | 406 |
if (! __isNonNilObject(something)) RETURN(true); /* cannot be equal */ |
370 | 407 |
if ((cls = __qClass(something)) == Symbol) { |
379 | 408 |
RETURN (self == something ? false : true); |
370 | 409 |
} |
410 |
if (cls == String) { |
|
379 | 411 |
RETURN (strcmp(__stringVal(self), __stringVal(something)) == 0 ? false : true); |
370 | 412 |
} |
413 |
%}. |
|
414 |
"fall back; could be a TwoByteString, or a collection of Characters" |
|
415 |
||
416 |
^ super ~= something |
|
356 | 417 |
! ! |
418 |
||
608 | 419 |
!Symbol methodsFor:'converting'! |
420 |
||
421 |
asString |
|
422 |
"return a string with printname taken from mine" |
|
423 |
||
424 |
%{ /* NOCONTEXT */ |
|
425 |
OBJ s; |
|
426 |
||
2565 | 427 |
s = __MKSTRING_ST(self); |
608 | 428 |
if (s != nil) { |
5434 | 429 |
RETURN (s); |
608 | 430 |
} |
431 |
%}. |
|
5434 | 432 |
^ (String new:(self size)) |
433 |
replaceFrom:1 with:self startingAt:1 |
|
608 | 434 |
! |
435 |
||
436 |
asSymbol |
|
9231 | 437 |
"Return a unique symbol with the name taken from the receivers characters. |
608 | 438 |
Since I am a symbol - just return myself" |
439 |
||
440 |
^ self |
|
441 |
! |
|
442 |
||
443 |
asSymbolIfInterned |
|
9231 | 444 |
"If a symbol with the receivers characters is already known, return it. Otherwise, return nil. |
608 | 445 |
Since I am a symbol - just return myself" |
446 |
||
447 |
^ self |
|
448 |
! ! |
|
449 |
||
450 |
!Symbol methodsFor:'copying'! |
|
451 |
||
452 |
copy |
|
453 |
"return a copy of myself |
|
4729 | 454 |
- reimplemented here since symbols are immutable." |
608 | 455 |
|
456 |
^ self |
|
457 |
! |
|
458 |
||
3659 | 459 |
copyReplaceAll:oldElement with:newElement |
460 |
"return a copy of the receiver as a string, where all elements equal to oldElement |
|
461 |
have been replaced by newElement." |
|
462 |
||
6054
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
463 |
"/ 'Warning: #copyReplaceAll:with: will change semantics as defined in ANSI soon' errorPrintCR. |
3659 | 464 |
^ self asString replaceAll:oldElement with:newElement |
465 |
||
466 |
"Created: / 18.7.1998 / 23:03:38 / cg" |
|
467 |
! |
|
468 |
||
6054
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
469 |
copyReplacing:oldElement withObject:newElement |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
470 |
"return a copy of the receiver, where all elements equal to oldElement |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
471 |
have been replaced by newElement. |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
472 |
ANSI version of what used to be #copyReplaceAll:with:" |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
473 |
|
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
474 |
^ self asString replaceAll:oldElement with:newElement |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
475 |
! |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
476 |
|
608 | 477 |
deepCopy |
478 |
"return a copy of myself |
|
4729 | 479 |
- reimplemented here since symbols are immutable." |
608 | 480 |
|
481 |
^ self |
|
482 |
! |
|
483 |
||
484 |
deepCopyUsing:aDictionary |
|
8383 | 485 |
"return a deep copy of myself |
4729 | 486 |
- reimplemented here since symbols are immutable." |
608 | 487 |
|
488 |
^ self |
|
489 |
! |
|
490 |
||
491 |
shallowCopy |
|
492 |
"return a copy of myself |
|
4729 | 493 |
- reimplemented here since symbols are immutable" |
608 | 494 |
|
495 |
^ self |
|
496 |
! |
|
497 |
||
498 |
simpleDeepCopy |
|
499 |
"return a copy of myself |
|
4729 | 500 |
- reimplemented here since symbols are immutable." |
608 | 501 |
|
502 |
^ self |
|
503 |
! ! |
|
504 |
||
505 |
!Symbol methodsFor:'printing & storing'! |
|
506 |
||
507 |
displayString |
|
508 |
"return a string for displaying the receiver" |
|
509 |
||
510 |
^ self storeString |
|
511 |
! |
|
512 |
||
513 |
printOn:aStream |
|
4392 | 514 |
"append a user printed representation of the receiver to aStream. |
515 |
The format is suitable for a human - not meant to be read back. |
|
516 |
||
608 | 517 |
In contrast to ST-80, this does return the symbols characters |
518 |
without any leading #. Therefore, you can directly send symbols' |
|
519 |
printStrings to some output device. This is incompatible, but easier |
|
520 |
to use." |
|
521 |
||
522 |
"/ ST-80 behavior: |
|
523 |
||
524 |
"/ self storeOn:aStream |
|
525 |
||
526 |
aStream nextPutAll:self |
|
527 |
! |
|
528 |
||
529 |
printString |
|
530 |
"return a printed representation of the receiver. |
|
531 |
In contrast to ST-80, this does return the symbols characters |
|
532 |
without any leading #. Therefore, you can directly send symbols' |
|
533 |
printStrings to some output device. This is incompatible, but easier |
|
534 |
to use." |
|
535 |
||
536 |
"/ ST-80 behavior: |
|
537 |
"/ ^ self storeString |
|
538 |
||
539 |
^ self asString |
|
540 |
! |
|
541 |
||
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
542 |
storeArrayElementOn:aStream |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
543 |
"store myself on a stream. |
8368 | 544 |
I am stored as an array element, so the '#' may be omitted sometimes. |
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
545 |
Take care for special symbols" |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
546 |
|
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
547 |
|storeString| |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
548 |
|
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
549 |
storeString := self storeString. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
550 |
(self == #true or:[self == #false or:[self == #nil or:[(storeString at:2) == $']]]) ifTrue:[ |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
551 |
aStream nextPutAll:storeString. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
552 |
] ifFalse:[ |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
553 |
aStream nextPutAll:self. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
554 |
]. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
555 |
! |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
556 |
|
608 | 557 |
storeOn:aStream |
558 |
"store myself on a stream" |
|
559 |
||
560 |
aStream nextPutAll:(self storeString) |
|
561 |
! |
|
562 |
||
563 |
storeString |
|
564 |
"return a String for storing the receiver" |
|
565 |
||
4098 | 566 |
|sz "{Class: SmallInteger }" |
5941
e194c325bee8
storeString fixed for symbols like #'foo:bar'
Claus Gittinger <cg@exept.de>
parents:
5896
diff
changeset
|
567 |
c anyColon| |
1125 | 568 |
|
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
569 |
sz := self size. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
570 |
(sz ~~ 0 and:[(self at:1) isLetter]) ifTrue:[ |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
571 |
anyColon := false. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
572 |
2 to:sz do:[:index | |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
573 |
c := self at:index. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
574 |
c == $: ifTrue:[ |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
575 |
(index == sz or:[(self at:(index+1)) isLetterOrDigit]) ifFalse:[ |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
576 |
^ '#' , super storeString. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
577 |
]. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
578 |
anyColon := true. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
579 |
] ifFalse:[ |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
580 |
c isLetterOrDigit ifFalse:[ |
5185
15a129151b3b
fixed bug in storeString (must duplicate single quotes)
Claus Gittinger <cg@exept.de>
parents:
4987
diff
changeset
|
581 |
^ '#' , super storeString |
15a129151b3b
fixed bug in storeString (must duplicate single quotes)
Claus Gittinger <cg@exept.de>
parents:
4987
diff
changeset
|
582 |
]. |
15a129151b3b
fixed bug in storeString (must duplicate single quotes)
Claus Gittinger <cg@exept.de>
parents:
4987
diff
changeset
|
583 |
]. |
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
584 |
]. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
585 |
"no colon in symbol or symbol ends with a colon" |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
586 |
(anyColon and:[c ~~ $:]) ifFalse:[ |
5185
15a129151b3b
fixed bug in storeString (must duplicate single quotes)
Claus Gittinger <cg@exept.de>
parents:
4987
diff
changeset
|
587 |
^ '#' , self |
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
588 |
]. |
608 | 589 |
]. |
5896 | 590 |
^ '#' , super storeString |
3285
bd5827c97b21
Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents:
3086
diff
changeset
|
591 |
|
3286
c6987c5f15a8
Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents:
3285
diff
changeset
|
592 |
" |
5896 | 593 |
#'abc' storeString |
594 |
#'abc:' storeString |
|
595 |
#'abc:def:' storeString |
|
4098 | 596 |
#'abc:def' storeString |
5896 | 597 |
#'abc::def' storeString |
598 |
#'abc &^*' storeString |
|
599 |
#'abcdef::' storeString |
|
600 |
#'hello''world' storeString |
|
601 |
#'' storeString |
|
602 |
#'''' storeString |
|
5185
15a129151b3b
fixed bug in storeString (must duplicate single quotes)
Claus Gittinger <cg@exept.de>
parents:
4987
diff
changeset
|
603 |
#'_hello' storeString |
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
604 |
#'123' storeString |
3286
c6987c5f15a8
Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents:
3285
diff
changeset
|
605 |
" |
608 | 606 |
! ! |
607 |
||
608 |
!Symbol methodsFor:'queries'! |
|
609 |
||
4987 | 610 |
isInfix |
611 |
"return true, if the receiver is a binary message selector" |
|
612 |
||
7350
a62d53937a6b
ansified (isAlphaNumeric -> isLetterOrDigit)
Claus Gittinger <cg@exept.de>
parents:
7301
diff
changeset
|
613 |
^ self first isLetterOrDigit not |
4987 | 614 |
|
615 |
" |
|
616 |
#at:put: isInfix |
|
617 |
#at: isInfix |
|
618 |
#+ isInfix |
|
619 |
#size isInfix |
|
620 |
" |
|
621 |
||
622 |
"Created: / 1.11.1997 / 12:34:55 / cg" |
|
623 |
"Modified: / 1.11.1997 / 12:36:37 / cg" |
|
624 |
! |
|
625 |
||
3086 | 626 |
isKeyword |
627 |
"return true, if the receiver is a keyword message selector" |
|
628 |
||
629 |
^ self includes:$: |
|
630 |
||
631 |
" |
|
632 |
#at:put: isKeyword |
|
633 |
#at: isKeyword |
|
634 |
#+ isKeyword |
|
635 |
#size isKeyword |
|
636 |
" |
|
637 |
||
638 |
"Created: / 1.11.1997 / 12:34:55 / cg" |
|
639 |
"Modified: / 1.11.1997 / 12:36:37 / cg" |
|
640 |
! |
|
641 |
||
608 | 642 |
isSymbol |
643 |
"return true, if the receiver is some kind of symbol. |
|
644 |
Since I am a symbol, return always true" |
|
645 |
||
646 |
^ true |
|
647 |
! |
|
648 |
||
649 |
keywords |
|
650 |
"assuming the receiver is a keyword message selector, |
|
651 |
return the individual keywords (i.e. break it up at colons) |
|
652 |
and return these as a collection. |
|
653 |
For binary and unary selectors, the result may be nonsense." |
|
654 |
||
655 |
|coll s part| |
|
656 |
||
657 |
coll := OrderedCollection new. |
|
658 |
s := ReadStream on:self. |
|
659 |
[s atEnd] whileFalse:[ |
|
660 |
part := s through:$:. |
|
661 |
coll add:part |
|
662 |
]. |
|
663 |
^ coll asArray |
|
664 |
||
665 |
" |
|
666 |
#at:put: keywords |
|
667 |
#at: keywords |
|
668 |
#+ keywords |
|
669 |
#size keywords |
|
670 |
" |
|
671 |
! |
|
672 |
||
673 |
species |
|
674 |
"when copying, or concatenating, return instances of this class" |
|
675 |
||
676 |
^ String |
|
677 |
! ! |
|
678 |
||
77 | 679 |
!Symbol methodsFor:'system primitives'! |
680 |
||
681 |
become:anotherObject |
|
682 |
"make all references to the receiver become references to anotherObject |
|
95 | 683 |
and vice-versa. For symbols, some special action is required, to |
684 |
correctly handle a become of the global dictionaries. |
|
77 | 685 |
Anyway: this is very dangerous - mysterous side-effects are to be |
95 | 686 |
expected. |
687 |
||
688 |
Notice: because of the danger here, this method may report an error |
|
159 | 689 |
in future versions" |
77 | 690 |
|
691 |
(Smalltalk includesKey:self) ifTrue:[ |
|
159 | 692 |
super become:anotherObject. |
77 | 693 |
%{ |
159 | 694 |
__rehashSystemDictionaries(); |
77 | 695 |
%}. |
696 |
] ifFalse:[ |
|
159 | 697 |
super become:anotherObject |
77 | 698 |
] |
699 |
! |
|
700 |
||
701 |
becomeNil |
|
702 |
"make all references to the receiver become nil - effectively getting |
|
95 | 703 |
rid of the receiver. For symbols, this is not allowed, if the receiver |
7765 | 704 |
is used as a key in some SystemDictionary. |
95 | 705 |
This can be a very dangerous operation - be warned. |
706 |
||
707 |
Notice: because of the danger here, this method may report an error |
|
7765 | 708 |
in future versions" |
77 | 709 |
|
710 |
(Smalltalk includesKey:self) ifTrue:[ |
|
7765 | 711 |
self primitiveFailed |
77 | 712 |
] ifFalse:[ |
7765 | 713 |
super becomeNil |
77 | 714 |
] |
715 |
! ! |
|
716 |
||
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
717 |
!Symbol methodsFor:'tracing'! |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
718 |
|
4682 | 719 |
traceInto:aRequestor level:level from:referrer |
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
720 |
"double dispatch into tracer, passing my type implicitely in the selector" |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
721 |
|
4682 | 722 |
^ aRequestor traceSymbol:self level:level from:referrer |
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
723 |
|
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
724 |
|
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
725 |
! ! |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
726 |
|
8395
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
727 |
!Symbol methodsFor:'visiting'! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
728 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
729 |
acceptVisitor:aVisitor with:aParameter |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
730 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
731 |
^ aVisitor visitSymbol:self with:aParameter |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
732 |
! ! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
733 |
|
632 | 734 |
!Symbol class methodsFor:'documentation'! |
735 |
||
736 |
version |
|
9231 | 737 |
^ '$Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.81 2006-03-06 08:59:24 cg Exp $' |
632 | 738 |
! ! |