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