author | Stefan Vogel <sv@exept.de> |
Wed, 03 Sep 2003 18:00:18 +0200 | |
changeset 7600 | 5a3fee21c032 |
parent 7350 | a62d53937a6b |
child 7765 | c902ef825eeb |
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 |
||
3985 | 316 |
REGISTER unsigned int g, val; |
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 |
} |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
375 |
RETURN ( __MKSMALLINT(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 |
|
437 |
"return the receiver as a symbol. |
|
438 |
Since I am a symbol - just return myself" |
|
439 |
||
440 |
^ self |
|
441 |
! |
|
442 |
||
443 |
asSymbolIfInterned |
|
444 |
"return the receiver as a symbol if there is one. |
|
445 |
Since I am a symbol - just return myself" |
|
446 |
||
447 |
^ self |
|
2416 | 448 |
! |
449 |
||
450 |
decodeAsLiteralArray |
|
451 |
"given a literalEncoding in the receiver, |
|
452 |
create & return the corresponding object. |
|
453 |
The inverse operation to #literalArrayEncoding." |
|
454 |
||
455 |
^ self |
|
456 |
||
457 |
"Created: 25.2.1997 / 19:15:26 / cg" |
|
458 |
"Modified: 25.2.1997 / 19:17:40 / cg" |
|
608 | 459 |
! ! |
460 |
||
461 |
!Symbol methodsFor:'copying'! |
|
462 |
||
463 |
copy |
|
464 |
"return a copy of myself |
|
4729 | 465 |
- reimplemented here since symbols are immutable." |
608 | 466 |
|
467 |
^ self |
|
468 |
! |
|
469 |
||
3659 | 470 |
copyReplaceAll:oldElement with:newElement |
471 |
"return a copy of the receiver as a string, where all elements equal to oldElement |
|
472 |
have been replaced by newElement." |
|
473 |
||
6054
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
474 |
"/ 'Warning: #copyReplaceAll:with: will change semantics as defined in ANSI soon' errorPrintCR. |
3659 | 475 |
^ self asString replaceAll:oldElement with:newElement |
476 |
||
477 |
"Created: / 18.7.1998 / 23:03:38 / cg" |
|
478 |
! |
|
479 |
||
6054
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
480 |
copyReplacing:oldElement withObject:newElement |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
481 |
"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
|
482 |
have been replaced by newElement. |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
483 |
ANSI version of what used to be #copyReplaceAll:with:" |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
484 |
|
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
485 |
^ self asString replaceAll:oldElement with:newElement |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
486 |
! |
7719f857af51
added #copyReplacing:withObject: (ANSI)
Claus Gittinger <cg@exept.de>
parents:
6001
diff
changeset
|
487 |
|
608 | 488 |
deepCopy |
489 |
"return a copy of myself |
|
4729 | 490 |
- reimplemented here since symbols are immutable." |
608 | 491 |
|
492 |
^ self |
|
493 |
! |
|
494 |
||
495 |
deepCopyUsing:aDictionary |
|
496 |
"return a copy of myself |
|
4729 | 497 |
- reimplemented here since symbols are immutable." |
608 | 498 |
|
499 |
^ self |
|
500 |
! |
|
501 |
||
502 |
shallowCopy |
|
503 |
"return a copy of myself |
|
4729 | 504 |
- reimplemented here since symbols are immutable" |
608 | 505 |
|
506 |
^ self |
|
507 |
! |
|
508 |
||
509 |
simpleDeepCopy |
|
510 |
"return a copy of myself |
|
4729 | 511 |
- reimplemented here since symbols are immutable." |
608 | 512 |
|
513 |
^ self |
|
514 |
! ! |
|
515 |
||
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5434
diff
changeset
|
516 |
!Symbol methodsFor:'encoding'! |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5434
diff
changeset
|
517 |
|
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5434
diff
changeset
|
518 |
encodeOn:anEncoder with:aParameter |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5434
diff
changeset
|
519 |
|
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5434
diff
changeset
|
520 |
anEncoder encodeSymbol:self with:aParameter |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5434
diff
changeset
|
521 |
! ! |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5434
diff
changeset
|
522 |
|
608 | 523 |
!Symbol methodsFor:'printing & storing'! |
524 |
||
525 |
displayString |
|
526 |
"return a string for displaying the receiver" |
|
527 |
||
528 |
^ self storeString |
|
529 |
! |
|
530 |
||
531 |
printOn:aStream |
|
4392 | 532 |
"append a user printed representation of the receiver to aStream. |
533 |
The format is suitable for a human - not meant to be read back. |
|
534 |
||
608 | 535 |
In contrast to ST-80, this does return the symbols characters |
536 |
without any leading #. Therefore, you can directly send symbols' |
|
537 |
printStrings to some output device. This is incompatible, but easier |
|
538 |
to use." |
|
539 |
||
540 |
"/ ST-80 behavior: |
|
541 |
||
542 |
"/ self storeOn:aStream |
|
543 |
||
544 |
aStream nextPutAll:self |
|
545 |
! |
|
546 |
||
547 |
printString |
|
548 |
"return a printed representation of the receiver. |
|
549 |
In contrast to ST-80, this does return the symbols characters |
|
550 |
without any leading #. Therefore, you can directly send symbols' |
|
551 |
printStrings to some output device. This is incompatible, but easier |
|
552 |
to use." |
|
553 |
||
554 |
"/ ST-80 behavior: |
|
555 |
"/ ^ self storeString |
|
556 |
||
557 |
^ self asString |
|
558 |
! |
|
559 |
||
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
560 |
storeArrayElementOn:aStream |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
561 |
"store myself on a stream. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
562 |
i am stored as an array element, so the '#' may be omitted. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
563 |
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
|
564 |
|
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
565 |
|storeString| |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
566 |
|
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
567 |
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
|
568 |
(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
|
569 |
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
|
570 |
] ifFalse:[ |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
571 |
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
|
572 |
]. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
573 |
! |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
574 |
|
608 | 575 |
storeOn:aStream |
576 |
"store myself on a stream" |
|
577 |
||
578 |
aStream nextPutAll:(self storeString) |
|
579 |
! |
|
580 |
||
581 |
storeString |
|
582 |
"return a String for storing the receiver" |
|
583 |
||
4098 | 584 |
|sz "{Class: SmallInteger }" |
5941
e194c325bee8
storeString fixed for symbols like #'foo:bar'
Claus Gittinger <cg@exept.de>
parents:
5896
diff
changeset
|
585 |
c anyColon| |
1125 | 586 |
|
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
587 |
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
|
588 |
(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
|
589 |
anyColon := false. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
590 |
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
|
591 |
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
|
592 |
c == $: ifTrue:[ |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
593 |
(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
|
594 |
^ '#' , super storeString. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
595 |
]. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
596 |
anyColon := true. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
597 |
] ifFalse:[ |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
598 |
c isLetterOrDigit ifFalse:[ |
5185
15a129151b3b
fixed bug in storeString (must duplicate single quotes)
Claus Gittinger <cg@exept.de>
parents:
4987
diff
changeset
|
599 |
^ '#' , super storeString |
15a129151b3b
fixed bug in storeString (must duplicate single quotes)
Claus Gittinger <cg@exept.de>
parents:
4987
diff
changeset
|
600 |
]. |
15a129151b3b
fixed bug in storeString (must duplicate single quotes)
Claus Gittinger <cg@exept.de>
parents:
4987
diff
changeset
|
601 |
]. |
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
602 |
]. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
603 |
"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
|
604 |
(anyColon and:[c ~~ $:]) ifFalse:[ |
5185
15a129151b3b
fixed bug in storeString (must duplicate single quotes)
Claus Gittinger <cg@exept.de>
parents:
4987
diff
changeset
|
605 |
^ '#' , self |
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
606 |
]. |
608 | 607 |
]. |
5896 | 608 |
^ '#' , super storeString |
3285
bd5827c97b21
Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents:
3086
diff
changeset
|
609 |
|
3286
c6987c5f15a8
Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents:
3285
diff
changeset
|
610 |
" |
5896 | 611 |
#'abc' storeString |
612 |
#'abc:' storeString |
|
613 |
#'abc:def:' storeString |
|
4098 | 614 |
#'abc:def' storeString |
5896 | 615 |
#'abc::def' storeString |
616 |
#'abc &^*' storeString |
|
617 |
#'abcdef::' storeString |
|
618 |
#'hello''world' storeString |
|
619 |
#'' storeString |
|
620 |
#'''' storeString |
|
5185
15a129151b3b
fixed bug in storeString (must duplicate single quotes)
Claus Gittinger <cg@exept.de>
parents:
4987
diff
changeset
|
621 |
#'_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
|
622 |
#'123' storeString |
3286
c6987c5f15a8
Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents:
3285
diff
changeset
|
623 |
" |
608 | 624 |
! ! |
625 |
||
626 |
!Symbol methodsFor:'queries'! |
|
627 |
||
4987 | 628 |
isInfix |
629 |
"return true, if the receiver is a binary message selector" |
|
630 |
||
7350
a62d53937a6b
ansified (isAlphaNumeric -> isLetterOrDigit)
Claus Gittinger <cg@exept.de>
parents:
7301
diff
changeset
|
631 |
^ self first isLetterOrDigit not |
4987 | 632 |
|
633 |
" |
|
634 |
#at:put: isInfix |
|
635 |
#at: isInfix |
|
636 |
#+ isInfix |
|
637 |
#size isInfix |
|
638 |
" |
|
639 |
||
640 |
"Created: / 1.11.1997 / 12:34:55 / cg" |
|
641 |
"Modified: / 1.11.1997 / 12:36:37 / cg" |
|
642 |
! |
|
643 |
||
3086 | 644 |
isKeyword |
645 |
"return true, if the receiver is a keyword message selector" |
|
646 |
||
647 |
^ self includes:$: |
|
648 |
||
649 |
" |
|
650 |
#at:put: isKeyword |
|
651 |
#at: isKeyword |
|
652 |
#+ isKeyword |
|
653 |
#size isKeyword |
|
654 |
" |
|
655 |
||
656 |
"Created: / 1.11.1997 / 12:34:55 / cg" |
|
657 |
"Modified: / 1.11.1997 / 12:36:37 / cg" |
|
658 |
! |
|
659 |
||
608 | 660 |
isSymbol |
661 |
"return true, if the receiver is some kind of symbol. |
|
662 |
Since I am a symbol, return always true" |
|
663 |
||
664 |
^ true |
|
665 |
! |
|
666 |
||
667 |
keywords |
|
668 |
"assuming the receiver is a keyword message selector, |
|
669 |
return the individual keywords (i.e. break it up at colons) |
|
670 |
and return these as a collection. |
|
671 |
For binary and unary selectors, the result may be nonsense." |
|
672 |
||
673 |
|coll s part| |
|
674 |
||
675 |
coll := OrderedCollection new. |
|
676 |
s := ReadStream on:self. |
|
677 |
[s atEnd] whileFalse:[ |
|
678 |
part := s through:$:. |
|
679 |
coll add:part |
|
680 |
]. |
|
681 |
^ coll asArray |
|
682 |
||
683 |
" |
|
684 |
#at:put: keywords |
|
685 |
#at: keywords |
|
686 |
#+ keywords |
|
687 |
#size keywords |
|
688 |
" |
|
689 |
! |
|
690 |
||
691 |
species |
|
692 |
"when copying, or concatenating, return instances of this class" |
|
693 |
||
694 |
^ String |
|
695 |
! ! |
|
696 |
||
77 | 697 |
!Symbol methodsFor:'system primitives'! |
698 |
||
699 |
become:anotherObject |
|
700 |
"make all references to the receiver become references to anotherObject |
|
95 | 701 |
and vice-versa. For symbols, some special action is required, to |
702 |
correctly handle a become of the global dictionaries. |
|
77 | 703 |
Anyway: this is very dangerous - mysterous side-effects are to be |
95 | 704 |
expected. |
705 |
||
706 |
Notice: because of the danger here, this method may report an error |
|
159 | 707 |
in future versions" |
77 | 708 |
|
709 |
(Smalltalk includesKey:self) ifTrue:[ |
|
159 | 710 |
super become:anotherObject. |
77 | 711 |
%{ |
159 | 712 |
__rehashSystemDictionaries(); |
77 | 713 |
%}. |
714 |
] ifFalse:[ |
|
159 | 715 |
super become:anotherObject |
77 | 716 |
] |
717 |
! |
|
718 |
||
719 |
becomeNil |
|
720 |
"make all references to the receiver become nil - effectively getting |
|
95 | 721 |
rid of the receiver. For symbols, this is not allowed, if the receiver |
77 | 722 |
is used as a key in some SytemDictionary. |
95 | 723 |
This can be a very dangerous operation - be warned. |
724 |
||
725 |
Notice: because of the danger here, this method may report an error |
|
159 | 726 |
in future versions" |
77 | 727 |
|
728 |
(Smalltalk includesKey:self) ifTrue:[ |
|
159 | 729 |
self primitiveFailed |
77 | 730 |
] ifFalse:[ |
159 | 731 |
super becomeNil |
77 | 732 |
] |
733 |
! ! |
|
734 |
||
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
735 |
!Symbol methodsFor:'tracing'! |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
736 |
|
4682 | 737 |
traceInto:aRequestor level:level from:referrer |
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
738 |
"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
|
739 |
|
4682 | 740 |
^ aRequestor traceSymbol:self level:level from:referrer |
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
741 |
|
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
742 |
|
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
743 |
! ! |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
744 |
|
632 | 745 |
!Symbol class methodsFor:'documentation'! |
746 |
||
747 |
version |
|
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
748 |
^ '$Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.74 2003-09-03 16:00:18 stefan Exp $' |
632 | 749 |
! ! |