author | Patrik Svestka <patrik.svestka@gmail.com> |
Thu, 02 Dec 2021 12:27:29 +0100 | |
branch | jv |
changeset 25440 | 039a5cea86c3 |
parent 25420 | a18d0d048b1f |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
23107 | 3 |
COPYRIGHT (c) 2009-2010 Jan Vrany |
4 |
COPYRIGHT (c) 2015 Jan Vrany |
|
159 | 5 |
All Rights Reserved |
1 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
5434 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
17512 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
3985 | 18 |
String variableByteSubclass:#Symbol |
1020 | 19 |
instanceVariableNames:'' |
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Collections-Text' |
|
1 | 23 |
! |
24 |
||
77 | 25 |
!Symbol class methodsFor:'documentation'! |
1 | 26 |
|
88 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
23107 | 30 |
COPYRIGHT (c) 2009-2010 Jan Vrany |
31 |
COPYRIGHT (c) 2015 Jan Vrany |
|
159 | 32 |
All Rights Reserved |
88 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
77 | 43 |
documentation |
44 |
" |
|
45 |
Symbols represent unique strings - every symbol with same printString |
|
46 |
exists exactly once in the system; Symbols are used for selectors, global |
|
345 | 47 |
variable-keys etc. Symbols can also be used to represent things which are |
48 |
enumeration type values in other programming languages (since symbols are |
|
370 | 49 |
created at compile time, comparing them using == is a fast pointer compare). |
345 | 50 |
|
51 |
A symbol may not change its characters - i.e. it is constant over its lifetime. |
|
52 |
Other than that, symbols behave much like strings. |
|
1290 | 53 |
|
17512 | 54 |
The most prominent use of symbols is as key for message sending: methods are stored |
55 |
in a classes method dictionary, where symbols are used as key to map names to methods. |
|
56 |
Also, symbols are used as key to map class names (global names) to actual class objects. |
|
57 |
||
58 |
Special ST/X feature: |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
59 |
The ST/X VM method lookup supports selector namespaces for method extensions. |
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
60 |
This means, that a class may contain method extensions in another namespace, |
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
61 |
which are only seen and invoked if called from a class within that namespace. |
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
62 |
Technically, this is done by storing the method under a special namespace-selector, |
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
63 |
which is a symbol consisting of the user visible name, prefixed by ':<ns>::'. |
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
64 |
The VM's method lookup algorithm contains special handling code for such constructs. |
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
65 |
Thus, if two methods are stored as 'foo' and ':NS::foo' are present in a class, |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
66 |
any send of 'foo' from wíthin the NS-namespace will invoke the second method. |
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
67 |
Any other send will invoke the first one. |
17512 | 68 |
|
69 |
||
1290 | 70 |
[author:] |
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
71 |
Claus Gittinger |
77 | 72 |
" |
73 |
! ! |
|
1 | 74 |
|
77 | 75 |
!Symbol class methodsFor:'instance creation'! |
1 | 76 |
|
62 | 77 |
basicNew:size |
78 |
"redefined to return a string instead of a symbol - |
|
79 |
this allows all copy methods inherited from String to |
|
80 |
return strings containing the symbols characters. |
|
1020 | 81 |
Real symbols are only created with #intern: or #asSymbol." |
62 | 82 |
|
83 |
^ String new:size |
|
1020 | 84 |
|
85 |
"Modified: 26.2.1996 / 12:51:38 / cg" |
|
62 | 86 |
! |
87 |
||
77 | 88 |
fromString:aString |
89 |
"same as intern: for Symbol, but may be used to create interned instances |
|
90 |
of subclasses. |
|
91 |
Notice: this fails, if you try to intern an instance of a subclass, AND |
|
92 |
a symbol with the same name already exists. In this case, the original |
|
93 |
symbol is returned. To use it for enum-type symbols, make certain, that the |
|
94 |
names are unique (for example by including the classes name as a prefix-string)." |
|
95 |
||
267 | 96 |
|sym len| |
77 | 97 |
|
267 | 98 |
sym := aString asSymbolIfInterned. |
99 |
sym notNil ifTrue:[ |
|
100 |
^ sym |
|
77 | 101 |
]. |
102 |
||
103 |
" |
|
104 |
create a new uninterned instance first |
|
105 |
" |
|
106 |
len := aString size. |
|
267 | 107 |
sym := super basicNew:len. |
108 |
sym replaceFrom:1 to:len with:aString. |
|
77 | 109 |
|
110 |
"now, intern it" |
|
111 |
%{ |
|
329 | 112 |
sym = __INTERNSYMBOL(sym, (OBJ *)0, __context); |
77 | 113 |
%}. |
267 | 114 |
^ sym |
77 | 115 |
! |
116 |
||
608 | 117 |
intern:aString |
118 |
"return a unique symbol with printname taken from the String-argument" |
|
119 |
||
120 |
%{ /* NOCONTEXT */ |
|
121 |
OBJ newSymbol; |
|
122 |
||
123 |
if (__isSymbol(aString)) { |
|
13882
187a02bd5c99
OUCH: back to old hash; crashes Certificate compare in expecco (WHY??????=
Claus Gittinger <cg@exept.de>
parents:
13881
diff
changeset
|
124 |
RETURN (aString); |
608 | 125 |
} |
12473
828e275ddf8b
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
11859
diff
changeset
|
126 |
if (__isStringLike(aString)) { |
13882
187a02bd5c99
OUCH: back to old hash; crashes Certificate compare in expecco (WHY??????=
Claus Gittinger <cg@exept.de>
parents:
13881
diff
changeset
|
127 |
newSymbol = __MKSYMBOL(__stringVal(aString), (OBJ *)0); |
187a02bd5c99
OUCH: back to old hash; crashes Certificate compare in expecco (WHY??????=
Claus Gittinger <cg@exept.de>
parents:
13881
diff
changeset
|
128 |
if (newSymbol != nil) { |
187a02bd5c99
OUCH: back to old hash; crashes Certificate compare in expecco (WHY??????=
Claus Gittinger <cg@exept.de>
parents:
13881
diff
changeset
|
129 |
RETURN (newSymbol); |
187a02bd5c99
OUCH: back to old hash; crashes Certificate compare in expecco (WHY??????=
Claus Gittinger <cg@exept.de>
parents:
13881
diff
changeset
|
130 |
} |
608 | 131 |
} |
132 |
%}. |
|
12473
828e275ddf8b
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
11859
diff
changeset
|
133 |
(aString class ~~ String and:[aString class ~~ ImmutableString]) ifTrue:[ |
13882
187a02bd5c99
OUCH: back to old hash; crashes Certificate compare in expecco (WHY??????=
Claus Gittinger <cg@exept.de>
parents:
13881
diff
changeset
|
134 |
"only allowed to intern strings" |
187a02bd5c99
OUCH: back to old hash; crashes Certificate compare in expecco (WHY??????=
Claus Gittinger <cg@exept.de>
parents:
13881
diff
changeset
|
135 |
^ self mustBeString |
608 | 136 |
]. |
20706
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
137 |
^ AllocationFailure raise. |
608 | 138 |
! |
139 |
||
1 | 140 |
internCharacter:aCharacter |
141 |
"return a unique symbol with printname taken from the Character-argument" |
|
142 |
||
143 |
^ self intern:(aCharacter asString) |
|
608 | 144 |
! |
145 |
||
146 |
new:size |
|
147 |
"redefined to return a string instead of a symbol - |
|
148 |
this allows all copy methods inherited from String to |
|
149 |
return strings containing the symbols characters. |
|
150 |
Real symbols are only created with intern: or asSymbol." |
|
151 |
||
152 |
^ String new:size |
|
153 |
! ! |
|
154 |
||
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
155 |
!Symbol class methodsFor:'Javascript support'! |
2570
26616a00d5aa
added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2565
diff
changeset
|
156 |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
157 |
for:argument |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
158 |
"Symbol.for(string) is the same as ST's string asSymbol" |
21017 | 159 |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
160 |
^ argument asSymbol |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
161 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
162 |
"Created: / 05-03-2019 / 09:55:55 / Claus Gittinger" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
163 |
! ! |
21017 | 164 |
|
1 | 165 |
!Symbol class methodsFor:'queries'! |
166 |
||
608 | 167 |
findInterned:aString |
168 |
"for ST-80 compatibility - if the argument, aString is known |
|
169 |
as Symbol, return this symbol. Otherwise return nil." |
|
170 |
||
171 |
^ aString asSymbolIfInterned |
|
172 |
! |
|
173 |
||
174 |
hasInterned:aString |
|
175 |
"return true, if the argument, aString is known as Symbol; |
|
176 |
false otherwise" |
|
177 |
||
178 |
^ aString knownAsSymbol |
|
179 |
! |
|
180 |
||
1 | 181 |
hasInterned:aString ifTrue:trueBlock |
182 |
"for ST-80 compatibility - if the argument, aString is known |
|
183 |
as Symbol, evaluate the block with the corresponding symbol |
|
184 |
as argument and return true; otherwise return false" |
|
185 |
||
275 | 186 |
|sym| |
187 |
||
188 |
(sym := aString asSymbolIfInterned) notNil ifTrue:[ |
|
189 |
trueBlock value:sym. |
|
159 | 190 |
^ true |
1 | 191 |
]. |
192 |
^ false |
|
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 |
|
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
195 |
hasSharedInstances |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
196 |
"return true if this class can share instances when stored binary, |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
197 |
that is, instances with the same value can be stored by reference. |
4654 | 198 |
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
|
199 |
|
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
200 |
^ true |
1 | 201 |
! ! |
202 |
||
11819 | 203 |
!Symbol methodsFor:'Compatibility-Squeak'! |
204 |
||
13690 | 205 |
precedence |
206 |
"the precedence in an expression; 0 is highest; |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
207 |
unary < binary < keyword" |
13690 | 208 |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
209 |
self size == 0 |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
210 |
ifTrue: [^ 0]. |
13690 | 211 |
self first isLetter |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
212 |
ifFalse: [^ 2]. |
13690 | 213 |
self last = $: |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
214 |
ifTrue: [^ 3]. |
13690 | 215 |
^ 1 |
216 |
||
217 |
" |
|
13882
187a02bd5c99
OUCH: back to old hash; crashes Certificate compare in expecco (WHY??????=
Claus Gittinger <cg@exept.de>
parents:
13881
diff
changeset
|
218 |
self assert:(#foo precedence < #+ precedence). |
13690 | 219 |
self assert:(#+ precedence < #key: precedence). |
220 |
self assert:(#foo precedence < #key: precedence). |
|
221 |
" |
|
222 |
||
223 |
"Created: / 12-09-2011 / 14:53:54 / cg" |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
224 |
"Modified: / 15-03-2019 / 13:35:53 / Stefan Vogel" |
11819 | 225 |
! ! |
226 |
||
7261 | 227 |
!Symbol methodsFor:'Compatibility-VW'! |
7153 | 228 |
|
229 |
<< catalogID |
|
230 |
"create and return a new UserMessage, with the receiver as key, |
|
231 |
and the argument as cataglogID. |
|
232 |
VW compatibility." |
|
233 |
||
234 |
^ UserMessage key:self catalogID:catalogID |
|
235 |
||
236 |
" |
|
11859 | 237 |
(#theFooMessage << #myMessages) |
238 |
(#theFooMessage << #myMessages >> 'cannot read subclass of metaclass') |
|
239 |
(#theFooMessage >> 'cannot read subclass of metaclass') |
|
7153 | 240 |
" |
241 |
! |
|
242 |
||
243 |
>> aString |
|
244 |
"create and return a new UserMessage, with the receiver as key, |
|
245 |
and the argument as defaultString. |
|
246 |
VW compatibility." |
|
247 |
||
11859 | 248 |
^ UserMessage key:self defaultString:aString |
7153 | 249 |
|
250 |
" |
|
11859 | 251 |
(#theFooMessage << #myMessages) |
252 |
(#theFooMessage << #myMessages >> 'cannot read subclass of metaclass') |
|
253 |
(#theFooMessage >> 'cannot read subclass of metaclass') |
|
7153 | 254 |
" |
255 |
! ! |
|
256 |
||
1 | 257 |
!Symbol methodsFor:'accessing'! |
258 |
||
259 |
basicAt:index put:something |
|
345 | 260 |
"report an error if an interned symbol is about to be changed |
1219 | 261 |
- interned symbols may NOT be changed. |
262 |
For uninterned symbols, this is allowed." |
|
1 | 263 |
|
77 | 264 |
self knownAsSymbol ifTrue:[ |
16890
8fa6938075c2
refer to the VM's internal symbol hash algorithm,
Claus Gittinger <cg@exept.de>
parents:
16774
diff
changeset
|
265 |
self noModificationError. |
8fa6938075c2
refer to the VM's internal symbol hash algorithm,
Claus Gittinger <cg@exept.de>
parents:
16774
diff
changeset
|
266 |
"Even if you hit continue - you cannot change symbols. |
8fa6938075c2
refer to the VM's internal symbol hash algorithm,
Claus Gittinger <cg@exept.de>
parents:
16774
diff
changeset
|
267 |
Raise again non-resumable" |
8fa6938075c2
refer to the VM's internal symbol hash algorithm,
Claus Gittinger <cg@exept.de>
parents:
16774
diff
changeset
|
268 |
NoModificationError raiseWith:self errorString:' - interned symbols cannot be changed'. |
77 | 269 |
]. |
270 |
" |
|
271 |
uninterned - allow change |
|
272 |
" |
|
273 |
^ super basicAt:index put:something |
|
1219 | 274 |
|
275 |
"Modified: 19.4.1996 / 11:16:10 / cg" |
|
13423 | 276 |
! |
277 |
||
278 |
nameSpace |
|
16735 | 279 |
"if I have the format of a namespace-selector, |
280 |
retrieve the namespace. Otherwise, return nil. |
|
18619 | 281 |
Also return nil, if that namespace does not exist (in contrast to nameSpacePart). |
282 |
Namespace selectors have a special, fix defined format, which is also known in the VM. |
|
16735 | 283 |
They must be of the form :<ns>::<sel>, |
17512 | 284 |
where <ns> is the namespace and <sel> is the raw selector. |
285 |
This special format (a symbol starting with a colon) was chosen, because almost every other selector |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
286 |
is legal, and this can be checked quickly by just looking at the first character." |
16735 | 287 |
|
17516 | 288 |
|nsPart| |
289 |
||
290 |
nsPart := self nameSpaceAndSelectorParts first. |
|
18619 | 291 |
nsPart isNil ifTrue:[^ nil]. |
17516 | 292 |
^ Smalltalk at:nsPart asSymbol |
16735 | 293 |
|
294 |
" |
|
295 |
#':foo:' nameSpace -> nil (bad format) |
|
296 |
#':foo::bar' nameSpace -> nil (non existing) |
|
17516 | 297 |
#':Tools::bar' nameSpace -> Tools |
18619 | 298 |
#'bar' nameSpace -> nil |
299 |
#'bar:' nameSpace -> nil |
|
16735 | 300 |
" |
13423 | 301 |
|
302 |
"Created: / 20-07-2010 / 10:41:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
303 |
! |
|
304 |
||
305 |
nameSpaceAndSelector |
|
16735 | 306 |
"return a two element tuple consisting of the namespace and the raw selector. |
307 |
If I do not have the format of a namespace-selector, or the namespace is non-existing, |
|
308 |
the first element of the returned tuple will be nil. |
|
18619 | 309 |
Namespace selectors have a special, fix defined format, which is also known in the VM. |
16735 | 310 |
They must be of the form :<ns>::<sel>, |
17512 | 311 |
where <ns> is the namespace and <sel> is the raw selector. |
312 |
This special format (a symbol starting with a colon) was chosen, because almost every other selector |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
313 |
is legal, and this can be checked quickly by just looking at the first character." |
16735 | 314 |
|
17516 | 315 |
|parts ns| |
13423 | 316 |
|
317 |
self isNameSpaceSelector ifFalse:[ |
|
18701 | 318 |
^ Array with:nil with:self |
13423 | 319 |
]. |
17516 | 320 |
parts := self nameSpaceAndSelectorParts. |
321 |
ns := Smalltalk at:parts first asSymbol. |
|
322 |
^ Array with:ns with:parts second |
|
13423 | 323 |
|
16735 | 324 |
" |
325 |
#':foo:bar' nameSpaceAndSelector -> #(nil #':foo:bar') |
|
326 |
#':foo::bar' nameSpaceAndSelector -> #(nil #bar) |
|
327 |
#':Tools::foo' nameSpaceAndSelector -> #(Tools (* NameSpace *) #foo) |
|
328 |
" |
|
329 |
||
13423 | 330 |
"Created: / 20-07-2010 / 10:23:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
331 |
! |
|
332 |
||
17516 | 333 |
nameSpaceAndSelectorParts |
334 |
"return a two element tuple consisting of the namespace name and the raw selector. |
|
18701 | 335 |
If I do not have the format of a namespace-selector, |
17516 | 336 |
the first element of the returned tuple will be nil. |
18619 | 337 |
Namespace selectors have a special, fix defined format, which is also known in the VM. |
17516 | 338 |
They must be of the form :<ns>::<sel>, |
339 |
where <ns> is the namespace and <sel> is the raw selector. |
|
340 |
This special format (a symbol starting with a colon) was chosen, because almost every other selector |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
341 |
is legal, and this can be checked quickly by just looking at the first character." |
17516 | 342 |
|
343 |
|nsPart selPart idx| |
|
344 |
||
345 |
self isNameSpaceSelector ifFalse:[ |
|
18701 | 346 |
^ Array with:nil with:self |
17516 | 347 |
]. |
348 |
idx := self indexOf:$: startingAt:3. |
|
349 |
nsPart := self copyFrom:2 to:idx - 1. |
|
350 |
selPart := self copyFrom:idx + 2. |
|
351 |
^ Array with:nsPart with:selPart asSymbol |
|
352 |
||
353 |
" |
|
18619 | 354 |
#':foo:bar' nameSpaceAndSelectorParts -> #(nil #':foo:bar') |
355 |
#':foo:bar' nameSpaceAndSelector -> #(nil #':foo:bar') |
|
356 |
||
357 |
#':foo::bar' nameSpaceAndSelectorParts -> #('foo' #bar) |
|
358 |
#':foo::bar' nameSpaceAndSelector -> #(nil #bar) |
|
359 |
||
360 |
#'bar' nameSpaceAndSelectorParts -> #(nil #bar) |
|
361 |
#'bar' nameSpaceAndSelector -> #(nil #bar) |
|
362 |
||
363 |
#':Tools::foo' nameSpaceAndSelectorParts -> #('Tools' #foo) |
|
364 |
#':Tools::foo' nameSpaceAndSelector -> #(Tools (* NameSpace *) #foo) |
|
17516 | 365 |
" |
366 |
||
367 |
"Created: / 20-07-2010 / 10:23:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
368 |
! |
|
369 |
||
370 |
nameSpacePart |
|
371 |
"if I have the format of a namespace-selector, |
|
372 |
retrieve the namespace name. Otherwise, return nil. |
|
18619 | 373 |
Namespace selectors have a special, fix defined format, which is also known in the VM. |
17516 | 374 |
They must be of the form :<ns>::<sel>, |
375 |
where <ns> is the namespace and <sel> is the raw selector. |
|
376 |
This special format (a symbol starting with a colon) was chosen, because almost every other selector |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
377 |
is legal, and this can be checked quickly by just looking at the first character." |
17516 | 378 |
|
379 |
^ self nameSpaceAndSelectorParts first. |
|
380 |
||
381 |
" |
|
382 |
#':foo:' nameSpacePart -> nil (bad format) |
|
383 |
#':foo::bar' nameSpacePart -> 'foo' |
|
384 |
#':Tools::bar' nameSpacePart -> 'Tools' |
|
385 |
" |
|
386 |
! |
|
387 |
||
13423 | 388 |
selector |
17512 | 389 |
<resource: #obsolete> |
390 |
||
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
391 |
"if I have the format of a namespace-selector, retrieve the raw selector. |
17512 | 392 |
Otherwise, return myself. |
393 |
Namespace selectors have a special, fix defined format, which is also known in the VM. |
|
16735 | 394 |
They must be of the form :<ns>::<sel>, |
17512 | 395 |
where <ns> is the namespace and <sel> is the raw selector. |
20706
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
396 |
This special format (a symbol starting with a colon) was chosen, |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
397 |
because almost every other selector is legal, |
19714 | 398 |
and this can be checked quickly in the VM, by just looking at the first character." |
17512 | 399 |
|
400 |
self obsoleteMethodWarning:'use selectorWithoutNameSpace'. |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
401 |
^ self selectorWithoutNameSpace |
17512 | 402 |
! |
403 |
||
404 |
selectorWithoutNameSpace |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
405 |
"if I have the format of a namespace-selector, retrieve the raw selector. |
17512 | 406 |
Otherwise, return myself. |
407 |
Namespace selectors have a special, fix defined format, which is also known in the VM. |
|
408 |
They must be of the form :<ns>::<sel>, |
|
409 |
where <ns> is the namespace and <sel> is the raw selector. |
|
410 |
This special format (a symbol starting with a colon) was chosen, because almost every other selector |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
411 |
is legal, and this can be checked quickly by just looking at the first character." |
16735 | 412 |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
413 |
|idx| |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
414 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
415 |
self isNameSpaceSelector ifFalse:[ |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
416 |
"avoid copy" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
417 |
^ self |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
418 |
]. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
419 |
idx := self indexOf:$: startingAt:3. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
420 |
^ self copyFrom:idx + 2. |
16735 | 421 |
|
422 |
" |
|
17516 | 423 |
#':foo:' selectorWithoutNameSpace -> #':foo:' (bad format) |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
424 |
#':foo::bar' selectorWithoutNameSpace -> #bar |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
425 |
#':Tools::bar' selectorWithoutNameSpace -> #bar |
16735 | 426 |
" |
13423 | 427 |
|
428 |
"Created: / 20-07-2010 / 10:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
429 |
"Modified (format): / 08-05-2019 / 14:47:24 / Stefan Vogel" |
1 | 430 |
! ! |
431 |
||
608 | 432 |
!Symbol methodsFor:'comparing'! |
159 | 433 |
|
608 | 434 |
= something |
435 |
"return true, if the receiver and argument consist of the same characters. |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
436 |
Redefined here, for more efficient comparison of symbols |
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
437 |
(which can to be compared using #==). |
608 | 438 |
If the argument is a symbol, we use a quick pointer compare, instead of |
439 |
the inherited value compare." |
|
13 | 440 |
|
608 | 441 |
%{ /* NOCONTEXT */ |
18701 | 442 |
#ifdef __SCHTEAM__ |
443 |
if (something.isSymbol()) { |
|
444 |
return context._RETURN ( self == something ? STObject.True : STObject.False ); |
|
445 |
} |
|
446 |
if (something.isSTString()) { |
|
447 |
return context._RETURN ( something.isStringEqual(self) ? STObject.True : STObject.False ); |
|
448 |
} |
|
449 |
if (something == STObject.Nil) { |
|
450 |
return context._RETURN_false ( ); |
|
451 |
} |
|
452 |
#else |
|
608 | 453 |
OBJ cls; |
13 | 454 |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
455 |
if (something == self) RETURN(true); |
608 | 456 |
if (! __isNonNilObject(something)) RETURN(false); |
457 |
if ((cls = __qClass(something)) == Symbol) { |
|
18360
21b8e3adff85
can avoid a string compare sometimes when comparing symbols
Claus Gittinger <cg@exept.de>
parents:
17516
diff
changeset
|
458 |
RETURN (false); |
608 | 459 |
} |
14658 | 460 |
if (cls == String || cls == ImmutableString) { |
16890
8fa6938075c2
refer to the VM's internal symbol hash algorithm,
Claus Gittinger <cg@exept.de>
parents:
16774
diff
changeset
|
461 |
RETURN (strcmp(__stringVal(self), __stringVal(something)) == 0 ? true : false); |
345 | 462 |
} |
18701 | 463 |
#endif |
345 | 464 |
%}. |
608 | 465 |
"fall back; could be a TwoByteString, or a collection of Characters" |
1 | 466 |
|
608 | 467 |
^ super = something |
427 | 468 |
! |
469 |
||
356 | 470 |
identityHash |
471 |
"interned symbols can return a better hash key" |
|
472 |
||
13881 | 473 |
%{ /* NOCONTEXT */ |
474 |
||
16891
93560afff48f
oops - hashes should fit into a smallInt
Claus Gittinger <cg@exept.de>
parents:
16890
diff
changeset
|
475 |
REGISTER unsigned int val; // yes: only 32 bit |
356 | 476 |
|
14651 | 477 |
if (__qIsSymbol(self)) { |
20706
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
478 |
val = __GET_HASH(self); |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
479 |
/* |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
480 |
* only do it, if I have no standard hash key |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
481 |
* assigned (which can only happen due to a #become:, |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
482 |
* or by creating a symbol uninterned, and interning it |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
483 |
* after it got a hashKey assigned. |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
484 |
*/ |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
485 |
if (val == 0) { |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
486 |
extern unsigned int __symbolHash(char *); |
14651 | 487 |
|
20706
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
488 |
val = __symbolHash(__stringVal(self)); |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
489 |
// make sure, it fits into a smallInt |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
490 |
val = (val ^ (val >> 30)) & 0x3FFFFFFF; |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
491 |
} else { |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
492 |
val = __MAKE_HASH__(val); |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
493 |
} |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
494 |
RETURN ( __mkSmallInteger(val) ); |
14651 | 495 |
} |
356 | 496 |
%}. |
14651 | 497 |
|
498 |
^ super identityHash. |
|
3985 | 499 |
|
500 |
" |
|
20706
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
501 |
|hashColl hashSet| |
3985 | 502 |
|
20706
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
503 |
hashColl := OrderedCollection new:20000. |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
504 |
Symbol allInstancesDo:[:instance | |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
505 |
hashColl add:instance identityHash |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
506 |
]. |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
507 |
hashSet := hashColl asSet. |
3985 | 508 |
|
20706
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
509 |
Transcript showCR:'Symbols: ', hashColl size printString, |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
510 |
' unique hash keys: ', hashSet size printString, |
009b8269bd08
we have class based exceptions - use them
Claus Gittinger <cg@exept.de>
parents:
19714
diff
changeset
|
511 |
' collisions:', (hashColl size - hashSet size) printString. |
3985 | 512 |
" |
13881 | 513 |
|
514 |
"Modified (comment): / 26-12-2011 / 14:32:10 / cg" |
|
370 | 515 |
! |
516 |
||
517 |
~= something |
|
518 |
"return true, if the receiver and argument do not consist of the same characters. |
|
11859 | 519 |
Redefined here, for more efficient #~= comparison of symbols |
370 | 520 |
(which ought to be compared using #~~). |
521 |
If the argument is a symbol, we use a quick pointer compare, instead of |
|
522 |
the inherited value compare." |
|
523 |
||
524 |
%{ /* NOCONTEXT */ |
|
18701 | 525 |
#ifdef __SCHTEAM__ |
526 |
if (something.isSymbol()) { |
|
527 |
return context._RETURN ( self == something ? STObject.False : STObject.True ); |
|
528 |
} |
|
529 |
if (something.isSTString()) { |
|
530 |
return context._RETURN ( something.isStringEqual(self) ? STObject.False : STObject.True ); |
|
531 |
} |
|
532 |
if (something == STObject.Nil) { |
|
533 |
return context._RETURN_true ( ); |
|
534 |
} |
|
535 |
#else |
|
370 | 536 |
OBJ cls; |
537 |
||
379 | 538 |
if (! __isNonNilObject(something)) RETURN(true); /* cannot be equal */ |
370 | 539 |
if ((cls = __qClass(something)) == Symbol) { |
16890
8fa6938075c2
refer to the VM's internal symbol hash algorithm,
Claus Gittinger <cg@exept.de>
parents:
16774
diff
changeset
|
540 |
RETURN (self == something ? false : true); |
370 | 541 |
} |
14658 | 542 |
if (cls == String || cls == ImmutableString) { |
16890
8fa6938075c2
refer to the VM's internal symbol hash algorithm,
Claus Gittinger <cg@exept.de>
parents:
16774
diff
changeset
|
543 |
RETURN (strcmp(__stringVal(self), __stringVal(something)) == 0 ? false : true); |
370 | 544 |
} |
18701 | 545 |
#endif |
370 | 546 |
%}. |
547 |
"fall back; could be a TwoByteString, or a collection of Characters" |
|
548 |
||
549 |
^ super ~= something |
|
356 | 550 |
! ! |
551 |
||
608 | 552 |
!Symbol methodsFor:'converting'! |
553 |
||
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
554 |
asClass |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
555 |
"return the class named after me" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
556 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
557 |
^ (Smalltalk classNamed:self) ifNil:[ NotFoundError raiseErrorString:'No such class: ',self ] |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
558 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
559 |
" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
560 |
#Array asClass |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
561 |
#Foo asClass |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
562 |
" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
563 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
564 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
565 |
asClassIfAbsent:exceptionValue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
566 |
"return the class named after me" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
567 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
568 |
^ (Smalltalk classNamed:self) ifNil:exceptionValue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
569 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
570 |
" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
571 |
#Array asClassIfAbsent:123 |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
572 |
#Foo asClassIfAbsent:123 |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
573 |
" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
574 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
575 |
"Created: / 10-10-2018 / 00:41:21 / Claus Gittinger" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
576 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
577 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
578 |
asImmutableCollection |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
579 |
"I am immutable" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
580 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
581 |
^ self |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
582 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
583 |
"Created: / 15-03-2019 / 13:50:55 / Stefan Vogel" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
584 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
585 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
586 |
asImmutableString |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
587 |
"I am immutable" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
588 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
589 |
^ self |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
590 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
591 |
"Created: / 15-03-2019 / 13:50:44 / Stefan Vogel" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
592 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
593 |
|
608 | 594 |
asString |
595 |
"return a string with printname taken from mine" |
|
596 |
||
597 |
%{ /* NOCONTEXT */ |
|
598 |
OBJ s; |
|
599 |
||
2565 | 600 |
s = __MKSTRING_ST(self); |
608 | 601 |
if (s != nil) { |
11859 | 602 |
RETURN (s); |
608 | 603 |
} |
604 |
%}. |
|
5434 | 605 |
^ (String new:(self size)) |
11859 | 606 |
replaceFrom:1 with:self startingAt:1 |
608 | 607 |
! |
608 |
||
609 |
asSymbol |
|
19467 | 610 |
"Return a unique symbol with the name taken from the receiver's characters. |
608 | 611 |
Since I am a symbol - just return myself" |
612 |
||
613 |
^ self |
|
614 |
! |
|
615 |
||
616 |
asSymbolIfInterned |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
617 |
"If a symbol with the receiver's characters is already known, return it. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
618 |
Otherwise, return nil. |
608 | 619 |
Since I am a symbol - just return myself" |
620 |
||
621 |
^ self |
|
21017 | 622 |
! |
623 |
||
624 |
asSymbolIfInternedOrSelf |
|
625 |
^ self |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
626 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
627 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
628 |
beImmutable |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
629 |
"I am already immutable" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
630 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
631 |
^ self |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
632 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
633 |
"Created: / 15-03-2019 / 12:46:53 / Stefan Vogel" |
608 | 634 |
! ! |
635 |
||
636 |
!Symbol methodsFor:'copying'! |
|
637 |
||
638 |
copy |
|
639 |
"return a copy of myself |
|
4729 | 640 |
- reimplemented here since symbols are immutable." |
608 | 641 |
|
642 |
^ self |
|
643 |
! |
|
644 |
||
645 |
deepCopy |
|
646 |
"return a copy of myself |
|
4729 | 647 |
- reimplemented here since symbols are immutable." |
608 | 648 |
|
649 |
^ self |
|
650 |
! |
|
651 |
||
10950 | 652 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
8383 | 653 |
"return a deep copy of myself |
4729 | 654 |
- reimplemented here since symbols are immutable." |
608 | 655 |
|
656 |
^ self |
|
657 |
! |
|
658 |
||
659 |
shallowCopy |
|
660 |
"return a copy of myself |
|
10581 | 661 |
- reimplemented here since symbols are immutable and unique, |
662 |
so we return the receiver." |
|
608 | 663 |
|
664 |
^ self |
|
10581 | 665 |
|
666 |
"Modified: / 31-05-2007 / 15:32:30 / cg" |
|
608 | 667 |
! |
668 |
||
669 |
simpleDeepCopy |
|
670 |
"return a copy of myself |
|
4729 | 671 |
- reimplemented here since symbols are immutable." |
608 | 672 |
|
673 |
^ self |
|
674 |
! ! |
|
675 |
||
16154 | 676 |
!Symbol methodsFor:'evaluation'! |
677 |
||
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
678 |
value:anObject |
19605 | 679 |
"this is sent by collection enumeration methods, |
680 |
if a symbol is given instead of a block as loop-block argument" |
|
681 |
||
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
682 |
^ anObject perform:self. |
19605 | 683 |
|
684 |
" |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
685 |
this enables the elegant construct: |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
686 |
#(1 2 3 4 5 6 7) collect:#negated |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
687 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
688 |
but also, as a side effect, this ugly thing (if the arg understands the receiver): |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
689 |
#negated value:#(1 2 3 4 5 6 7) |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
690 |
" |
19605 | 691 |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
692 |
"Created: / 07-03-2019 / 17:11:23 / Stefan Vogel" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
693 |
"Modified (format): / 15-03-2019 / 13:39:32 / Stefan Vogel" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
694 |
"Modified (comment): / 30-05-2019 / 15:01:59 / Claus Gittinger" |
19605 | 695 |
! |
696 |
||
16154 | 697 |
value: el value:arg |
16890
8fa6938075c2
refer to the VM's internal symbol hash algorithm,
Claus Gittinger <cg@exept.de>
parents:
16774
diff
changeset
|
698 |
"this is sent by collection enumeration methods, |
16155 | 699 |
if a symbol is given instead of a block as loop-block argument" |
16154 | 700 |
|
701 |
^ el perform:self with:arg. |
|
702 |
||
703 |
" |
|
704 |
this allows us to say: |
|
705 |
||
706 |
#(1 2 3 4) with:#(10 20 30 40) collect: #+ |
|
707 |
" |
|
708 |
! ! |
|
709 |
||
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
710 |
!Symbol methodsFor:'printing & storing'! |
14651 | 711 |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
712 |
displayString |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
713 |
"return a string used when displaying the receiver in a view; |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
714 |
for example an Inspector. This is usually the same as printString, |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
715 |
but sometimes redefined for a better look." |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
716 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
717 |
^ self storeString |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
718 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
719 |
"Created: / 31-01-2018 / 09:01:45 / stefan" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
720 |
! |
608 | 721 |
|
722 |
printOn:aStream |
|
4392 | 723 |
"append a user printed representation of the receiver to aStream. |
724 |
The format is suitable for a human - not meant to be read back. |
|
725 |
||
608 | 726 |
In contrast to ST-80, this does return the symbols characters |
727 |
without any leading #. Therefore, you can directly send symbols' |
|
728 |
printStrings to some output device. This is incompatible, but easier |
|
729 |
to use." |
|
730 |
||
731 |
"/ ST-80 behavior: |
|
732 |
||
733 |
"/ self storeOn:aStream |
|
734 |
||
735 |
aStream nextPutAll:self |
|
736 |
! |
|
737 |
||
738 |
printString |
|
739 |
"return a printed representation of the receiver. |
|
740 |
In contrast to ST-80, this does return the symbols characters |
|
741 |
without any leading #. Therefore, you can directly send symbols' |
|
742 |
printStrings to some output device. This is incompatible, but easier |
|
743 |
to use." |
|
744 |
||
745 |
"/ ST-80 behavior: |
|
746 |
"/ ^ self storeString |
|
747 |
||
748 |
^ self asString |
|
749 |
! |
|
750 |
||
751 |
storeOn:aStream |
|
752 |
"store myself on a stream" |
|
753 |
||
754 |
aStream nextPutAll:(self storeString) |
|
755 |
! |
|
756 |
||
757 |
storeString |
|
758 |
"return a String for storing the receiver" |
|
759 |
||
11859 | 760 |
|sz "{Class: SmallInteger }" |
5941
e194c325bee8
storeString fixed for symbols like #'foo:bar'
Claus Gittinger <cg@exept.de>
parents:
5896
diff
changeset
|
761 |
c anyColon| |
1125 | 762 |
|
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7350
diff
changeset
|
763 |
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
|
764 |
(sz ~~ 0 and:[(self at:1) isLetter]) ifTrue:[ |
11859 | 765 |
anyColon := false. |
766 |
2 to:sz do:[:index | |
|
767 |
c := self at:index. |
|
768 |
c == $: ifTrue:[ |
|
769 |
(index == sz or:[(self at:(index+1)) isLetterOrDigit]) ifFalse:[ |
|
770 |
^ '#' , super storeString. |
|
771 |
]. |
|
772 |
anyColon := true. |
|
773 |
] ifFalse:[ |
|
774 |
c isLetterOrDigit ifFalse:[ |
|
775 |
^ '#' , super storeString |
|
776 |
]. |
|
777 |
]. |
|
778 |
]. |
|
779 |
"no colon in symbol or symbol ends with a colon" |
|
780 |
(anyColon and:[c ~~ $:]) ifFalse:[ |
|
781 |
^ '#' , self |
|
782 |
]. |
|
608 | 783 |
]. |
5896 | 784 |
^ '#' , super storeString |
3285
bd5827c97b21
Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents:
3086
diff
changeset
|
785 |
|
3286
c6987c5f15a8
Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents:
3285
diff
changeset
|
786 |
" |
11859 | 787 |
#'abc' storeString |
788 |
#'abc:' storeString |
|
789 |
#'abc:def:' storeString |
|
790 |
#'abc:def' storeString |
|
791 |
#'abc::def' storeString |
|
792 |
#'abc &^*' storeString |
|
793 |
#'abcdef::' storeString |
|
794 |
#'hello''world' storeString |
|
795 |
#'' storeString |
|
796 |
#'''' storeString |
|
797 |
#'_hello' storeString |
|
798 |
#'123' storeString |
|
3286
c6987c5f15a8
Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents:
3285
diff
changeset
|
799 |
" |
608 | 800 |
! ! |
801 |
||
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
802 |
!Symbol methodsFor:'private array element printing'! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
803 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
804 |
displayArrayElementOn:aStream |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
805 |
"Display myself as an Array element on a stream. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
806 |
I am displayed as an array element, so the '#' may be omitted sometimes. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
807 |
Take care for special symbols" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
808 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
809 |
self storeArrayElementOn:aStream. "storeString is same as printString" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
810 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
811 |
"Created: / 29-03-2019 / 12:00:50 / stefan" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
812 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
813 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
814 |
printArrayElementOn:aStream |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
815 |
"Print myself as an Array element on a stream. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
816 |
I am printed as an array element, so the '#' may be omitted sometimes. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
817 |
Take care for special symbols" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
818 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
819 |
self storeArrayElementOn:aStream. "storeString is same as printString" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
820 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
821 |
"Created: / 29-03-2019 / 11:56:25 / stefan" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
822 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
823 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
824 |
storeArrayElementOn:aStream |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
825 |
"store myself on a stream. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
826 |
I am stored as an array element, so the '#' may be omitted sometimes. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
827 |
Take care for special symbols" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
828 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
829 |
|storeString| |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
830 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
831 |
storeString := self storeString. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
832 |
(self == #true or:[self == #false or:[self == #nil or:[(storeString at:2) == $']]]) ifTrue:[ |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
833 |
aStream nextPutAll:storeString. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
834 |
] ifFalse:[ |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
835 |
aStream nextPutAll:self. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
836 |
]. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
837 |
! ! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
838 |
|
608 | 839 |
!Symbol methodsFor:'queries'! |
840 |
||
841 |
species |
|
842 |
"when copying, or concatenating, return instances of this class" |
|
843 |
||
844 |
^ String |
|
845 |
! ! |
|
846 |
||
77 | 847 |
!Symbol methodsFor:'system primitives'! |
848 |
||
849 |
become:anotherObject |
|
850 |
"make all references to the receiver become references to anotherObject |
|
95 | 851 |
and vice-versa. For symbols, some special action is required, to |
852 |
correctly handle a become of the global dictionaries. |
|
77 | 853 |
Anyway: this is very dangerous - mysterous side-effects are to be |
95 | 854 |
expected. |
855 |
||
856 |
Notice: because of the danger here, this method may report an error |
|
159 | 857 |
in future versions" |
77 | 858 |
|
859 |
(Smalltalk includesKey:self) ifTrue:[ |
|
159 | 860 |
super become:anotherObject. |
77 | 861 |
%{ |
159 | 862 |
__rehashSystemDictionaries(); |
77 | 863 |
%}. |
864 |
] ifFalse:[ |
|
159 | 865 |
super become:anotherObject |
77 | 866 |
] |
867 |
! |
|
868 |
||
869 |
becomeNil |
|
870 |
"make all references to the receiver become nil - effectively getting |
|
95 | 871 |
rid of the receiver. For symbols, this is not allowed, if the receiver |
7765 | 872 |
is used as a key in some SystemDictionary. |
95 | 873 |
This can be a very dangerous operation - be warned. |
874 |
||
875 |
Notice: because of the danger here, this method may report an error |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
876 |
in future versions" |
77 | 877 |
|
878 |
(Smalltalk includesKey:self) ifTrue:[ |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
879 |
self noModificationError. |
77 | 880 |
] ifFalse:[ |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
881 |
super becomeNil |
77 | 882 |
] |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
883 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
884 |
"Modified: / 15-03-2019 / 13:30:41 / Stefan Vogel" |
13388 | 885 |
! |
886 |
||
887 |
grow:newSize |
|
13389 | 888 |
"blocked" |
13388 | 889 |
|
13389 | 890 |
self fixedSizeError |
13388 | 891 |
|
892 |
"Created: / 20-06-2011 / 14:57:36 / cg" |
|
13389 | 893 |
! |
894 |
||
895 |
removeAll |
|
896 |
"blocked" |
|
897 |
||
898 |
self fixedSizeError |
|
899 |
||
900 |
"Created: / 20-06-2011 / 14:59:02 / cg" |
|
77 | 901 |
! ! |
902 |
||
16774 | 903 |
!Symbol methodsFor:'testing'! |
904 |
||
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
905 |
isImmutable |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
906 |
"return true, if the receiver is immutable. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
907 |
Since I am a symbol, return always true" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
908 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
909 |
^ true |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
910 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
911 |
"Created: / 15-03-2019 / 13:58:56 / Stefan Vogel" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
912 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
913 |
|
16774 | 914 |
isSingleByteString |
915 |
"returns true only for strings and immutable strings. |
|
916 |
Must replace foo isMemberOf:String and foo class == String" |
|
917 |
||
918 |
^ false |
|
21127 | 919 |
! |
920 |
||
921 |
isSymbol |
|
922 |
"return true, if the receiver is some kind of symbol. |
|
923 |
Since I am a symbol, return always true" |
|
924 |
||
925 |
^ true |
|
16774 | 926 |
! ! |
927 |
||
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
928 |
!Symbol methodsFor:'tracing'! |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
929 |
|
4682 | 930 |
traceInto:aRequestor level:level from:referrer |
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
931 |
"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
|
932 |
|
4682 | 933 |
^ aRequestor traceSymbol:self level:level from:referrer |
4651
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
934 |
|
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
935 |
|
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
936 |
! ! |
18a6ac30b36f
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
937 |
|
8395
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
938 |
!Symbol methodsFor:'visiting'! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
939 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
940 |
acceptVisitor:aVisitor with:aParameter |
16735 | 941 |
"dispatch for visitor pattern; send #visitSymbol:with: to aVisitor" |
8395
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
942 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
943 |
^ aVisitor visitSymbol:self with:aParameter |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
944 |
! ! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
945 |
|
632 | 946 |
!Symbol class methodsFor:'documentation'! |
947 |
||
16155 | 948 |
version |
18619 | 949 |
^ '$Header$' |
16155 | 950 |
! |
951 |
||
13423 | 952 |
version_CVS |
18619 | 953 |
^ '$Header$' |
12473
828e275ddf8b
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
11859
diff
changeset
|
954 |
! |
828e275ddf8b
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
11859
diff
changeset
|
955 |
|
13423 | 956 |
version_SVN |
15524 | 957 |
^ '$ Id: Symbol.st 10648 2011-06-23 15:55:10Z vranyj1 $' |
632 | 958 |
! ! |
21017 | 959 |