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