Symbol.st
author Claus Gittinger <cg@exept.de>
Wed, 13 May 1998 23:38:30 +0200
changeset 3443 d57ea75d3ac5
parent 3286 c6987c5f15a8
child 3659 87280610791f
permissions -rw-r--r--
oops - must send #initialize to all privateClasses.
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
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
String subclass:#Symbol
1020
c4de0381c847 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
    14
	instanceVariableNames:''
c4de0381c847 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
    15
	classVariableNames:''
c4de0381c847 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
    16
	poolDictionaries:''
c4de0381c847 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
    17
	category:'Collections-Text'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    20
!Symbol class methodsFor:'documentation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    21
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    22
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    23
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    24
 COPYRIGHT (c) 1988 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
    25
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    26
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    27
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    28
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    35
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    36
documentation
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    37
"
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    38
    Symbols represent unique strings - every symbol with same printString
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    39
    exists exactly once in the system; Symbols are used for selectors, global
345
claus
parents: 329
diff changeset
    40
    variable-keys etc. Symbols can also be used to represent things which are
claus
parents: 329
diff changeset
    41
    enumeration type values in other programming languages (since symbols are
370
claus
parents: 356
diff changeset
    42
    created at compile time, comparing them using == is a fast pointer compare).
345
claus
parents: 329
diff changeset
    43
claus
parents: 329
diff changeset
    44
    A symbol may not change its characters - i.e. it is constant over its lifetime.
claus
parents: 329
diff changeset
    45
    Other than that, symbols behave much like strings.
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
    46
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
    47
    [author:]
2200
a2b25d9e5cac MKSYMBOL has only 2 args
Claus Gittinger <cg@exept.de>
parents: 1864
diff changeset
    48
	Claus Gittinger
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    49
"
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    50
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    51
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    52
!Symbol class methodsFor:'instance creation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    53
62
e1b4369c61fb *** empty log message ***
claus
parents: 13
diff changeset
    54
basicNew:size
e1b4369c61fb *** empty log message ***
claus
parents: 13
diff changeset
    55
    "redefined to return a string instead of a symbol -
e1b4369c61fb *** empty log message ***
claus
parents: 13
diff changeset
    56
     this allows all copy methods inherited from String to
e1b4369c61fb *** empty log message ***
claus
parents: 13
diff changeset
    57
     return strings containing the symbols characters.
1020
c4de0381c847 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
    58
     Real symbols are only created with #intern: or #asSymbol."
62
e1b4369c61fb *** empty log message ***
claus
parents: 13
diff changeset
    59
e1b4369c61fb *** empty log message ***
claus
parents: 13
diff changeset
    60
    ^ String new:size
1020
c4de0381c847 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
    61
c4de0381c847 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
    62
    "Modified: 26.2.1996 / 12:51:38 / cg"
62
e1b4369c61fb *** empty log message ***
claus
parents: 13
diff changeset
    63
!
e1b4369c61fb *** empty log message ***
claus
parents: 13
diff changeset
    64
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    65
fromString:aString
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    66
    "same as intern: for Symbol, but may be used to create interned instances
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    67
     of subclasses.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    68
     Notice: this fails, if you try to intern an instance of a subclass, AND
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    69
     a symbol with the same name already exists. In this case, the original
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    70
     symbol is returned. To use it for enum-type symbols, make certain, that the
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    71
     names are unique (for example by including the classes name as a prefix-string)."
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    72
267
54bcd20b369d *** empty log message ***
claus
parents: 252
diff changeset
    73
    |sym len|
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    74
267
54bcd20b369d *** empty log message ***
claus
parents: 252
diff changeset
    75
    sym := aString asSymbolIfInterned.
54bcd20b369d *** empty log message ***
claus
parents: 252
diff changeset
    76
    sym notNil ifTrue:[
54bcd20b369d *** empty log message ***
claus
parents: 252
diff changeset
    77
	^ sym
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    78
    ].
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
     create a new uninterned instance first
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    82
    "
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    83
    len := aString size.
267
54bcd20b369d *** empty log message ***
claus
parents: 252
diff changeset
    84
    sym := super basicNew:len.
54bcd20b369d *** empty log message ***
claus
parents: 252
diff changeset
    85
    sym replaceFrom:1 to:len with:aString.
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    86
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    87
    "now, intern it"
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    88
%{
329
claus
parents: 314
diff changeset
    89
    sym = __INTERNSYMBOL(sym, (OBJ *)0, __context);
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    90
%}.
267
54bcd20b369d *** empty log message ***
claus
parents: 252
diff changeset
    91
    ^ sym
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    92
!
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
    93
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
    94
intern:aString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
    95
    "return a unique symbol with printname taken from the String-argument"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
    96
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
    97
%{  /* NOCONTEXT */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
    98
    OBJ newSymbol;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
    99
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   100
    if (__isSymbol(aString)) {
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   101
	RETURN (aString);
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   102
    }
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   103
    if (__isString(aString)) {
2200
a2b25d9e5cac MKSYMBOL has only 2 args
Claus Gittinger <cg@exept.de>
parents: 1864
diff changeset
   104
	newSymbol = __MKSYMBOL(__stringVal(aString), (OBJ *)0);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   105
	if (newSymbol != nil) {
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   106
	    RETURN (newSymbol);
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   107
	}
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   108
    }
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
    aString class ~~ String ifTrue:[
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   111
	"/
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   112
	"/ only allowed to intern strings
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   113
	"/
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   114
	^ self mustBeString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   115
    ].
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   116
    ^ ObjectMemory allocationFailureSignal raise.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   117
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   118
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   119
internCharacter:aCharacter
a27a279701f8 Initial revision
claus
parents:
diff changeset
   120
    "return a unique symbol with printname taken from the Character-argument"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   121
a27a279701f8 Initial revision
claus
parents:
diff changeset
   122
    ^ self intern:(aCharacter asString)
608
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
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   125
new:size
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   126
    "redefined to return a string instead of a symbol -
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   127
     this allows all copy methods inherited from String to
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   128
     return strings containing the symbols characters.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   129
     Real symbols are only created with intern: or asSymbol."
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   130
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   131
    ^ String new:size
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   132
! !
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   133
2570
26616a00d5aa added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2565
diff changeset
   134
!Symbol class methodsFor:'ST-80 compatibility'!
26616a00d5aa added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2565
diff changeset
   135
26616a00d5aa added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2565
diff changeset
   136
tableSize
26616a00d5aa added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2565
diff changeset
   137
    "return the size of the systems symbol table"
26616a00d5aa added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2565
diff changeset
   138
26616a00d5aa added #tableSize for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 2565
diff changeset
   139
    "/ claus: I ont know, if the returned value should be exact.
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
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   146
!Symbol class methodsFor:'binary storage'!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   147
1253
7265cbaa8ec9 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   148
binaryDefinitionFrom:stream manager:manager
7265cbaa8ec9 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   149
    "retrieve a symbol from a binary input stream (nonpublic interface)"
7265cbaa8ec9 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   150
7265cbaa8ec9 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   151
    ^ self intern:(super binaryDefinitionFrom:stream manager:manager)
7265cbaa8ec9 commentary
Claus Gittinger <cg@exept.de>
parents: 1219
diff changeset
   152
3086
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   153
    "Modified: / 2.11.1997 / 16:17:06 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   154
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   155
a27a279701f8 Initial revision
claus
parents:
diff changeset
   156
!Symbol class methodsFor:'queries'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   157
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   158
findInterned:aString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   159
    "for ST-80 compatibility - if the argument, aString is known
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   160
     as Symbol, return this symbol. Otherwise return nil."
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
    ^ aString asSymbolIfInterned
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   163
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   164
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   165
hasInterned:aString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   166
    "return true, if the argument, aString is known as Symbol;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   167
     false otherwise"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   168
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   169
    ^ aString knownAsSymbol
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   170
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   171
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   172
hasInterned:aString ifTrue:trueBlock
a27a279701f8 Initial revision
claus
parents:
diff changeset
   173
    "for ST-80 compatibility - if the argument, aString is known
a27a279701f8 Initial revision
claus
parents:
diff changeset
   174
     as Symbol, evaluate the block with the corresponding symbol
a27a279701f8 Initial revision
claus
parents:
diff changeset
   175
     as argument and return true; otherwise return false"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   176
275
a76029ddaa98 *** empty log message ***
claus
parents: 268
diff changeset
   177
    |sym|
a76029ddaa98 *** empty log message ***
claus
parents: 268
diff changeset
   178
a76029ddaa98 *** empty log message ***
claus
parents: 268
diff changeset
   179
    (sym := aString asSymbolIfInterned) notNil ifTrue:[
a76029ddaa98 *** empty log message ***
claus
parents: 268
diff changeset
   180
	trueBlock value:sym.
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
   181
	^ true
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   182
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   183
    ^ false
a27a279701f8 Initial revision
claus
parents:
diff changeset
   184
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   185
a27a279701f8 Initial revision
claus
parents:
diff changeset
   186
!Symbol methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   187
a27a279701f8 Initial revision
claus
parents:
diff changeset
   188
basicAt:index put:something
345
claus
parents: 329
diff changeset
   189
    "report an error if an interned symbol is about to be changed
1219
054f7eff0c30 commentary
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   190
     - interned symbols may NOT be changed.
054f7eff0c30 commentary
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   191
     For uninterned symbols, this is allowed."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   192
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   193
    self knownAsSymbol ifTrue:[
2200
a2b25d9e5cac MKSYMBOL has only 2 args
Claus Gittinger <cg@exept.de>
parents: 1864
diff changeset
   194
	self error:'interned symbols may not be changed'.
a2b25d9e5cac MKSYMBOL has only 2 args
Claus Gittinger <cg@exept.de>
parents: 1864
diff changeset
   195
	^ something
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   196
    ].
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   197
    "
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   198
     uninterned - allow change
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   199
    "
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   200
    ^ super basicAt:index put:something
1219
054f7eff0c30 commentary
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   201
054f7eff0c30 commentary
Claus Gittinger <cg@exept.de>
parents: 1138
diff changeset
   202
    "Modified: 19.4.1996 / 11:16:10 / cg"
252
   203
!
   204
   205
byteAt:index put:value
   206
    "report an error if interned - interned symbols may not be changed."
   207
   208
    ^ self basicAt:index put:(value asCharacter)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   209
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   210
3086
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   211
!Symbol methodsFor:'binary storage'!
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   212
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   213
storeBinaryDefinitionOn:stream manager:manager
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   214
    "append a binary representation of the receiver onto stream.
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   215
     Redefined since short Symbol can be stored with a special type code 
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   216
     in a more compact way.
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   217
     This is an internal interface for the binary storage mechanism."
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   218
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   219
    |myClass myBasicSize|
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   220
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   221
    "/ not for subclasses with named instVars.
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   222
    (myClass := self class) instSize ~~ 0 ifTrue:[
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   223
        ^ super storeBinaryDefinitionOn:stream manager:manager
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   224
    ].
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   225
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   226
    myBasicSize := self basicSize.
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   227
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   228
    "/ can use a more compact representation;
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   229
    "/ but not for subclasses ...
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   230
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   231
    ((myClass == Symbol) 
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   232
    and:[myBasicSize <= 255]) ifTrue:[
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   233
        "/ special encoding: <codeForSymbol> <len> <bytes> ...
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   234
        stream nextPut:(manager codeForSymbol); nextPut:myBasicSize.
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   235
    ] ifFalse:[
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   236
        manager putIdOfClass:myClass on:stream.
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   237
        stream nextNumber:4 put:myBasicSize.
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   238
    ].
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   239
    stream nextPutBytes:myBasicSize from:self startingAt:1.
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   240
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   241
    "Modified: / 2.11.1997 / 15:28:56 / cg"
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   242
    "Created: / 2.11.1997 / 16:13:47 / cg"
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   243
! !
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   244
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   245
!Symbol methodsFor:'comparing'!
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
   246
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   247
= something
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   248
    "return true, if the receiver and argument consist of the same characters.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   249
     Redefined here, for more efficient #= comparison of symbols 
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   250
     (which ought to be compared using #==).
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   251
     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
   252
     the inherited value compare."
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   253
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   254
%{   /* NOCONTEXT */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   255
    OBJ cls;
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   256
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   257
    if (! __isNonNilObject(something)) RETURN(false);
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   258
    if ((cls = __qClass(something)) == Symbol) {
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   259
	RETURN (self == something ? true : false);
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   260
    }
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   261
    if (cls == String) {
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   262
	RETURN (strcmp(__stringVal(self), __stringVal(something)) == 0 ? true : false); 
345
claus
parents: 329
diff changeset
   263
    }
claus
parents: 329
diff changeset
   264
%}.
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   265
    "fall back; could be a TwoByteString, or a collection of Characters"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   266
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   267
    ^ super = something
427
claus
parents: 384
diff changeset
   268
!
claus
parents: 384
diff changeset
   269
356
claus
parents: 345
diff changeset
   270
identityHash
claus
parents: 345
diff changeset
   271
    "interned symbols can return a better hash key"
claus
parents: 345
diff changeset
   272
claus
parents: 345
diff changeset
   273
%{  /* NOCONTEXT */
claus
parents: 345
diff changeset
   274
claus
parents: 345
diff changeset
   275
    REGISTER int g, val;
claus
parents: 345
diff changeset
   276
    REGISTER unsigned char *cp, *cp0;
claus
parents: 345
diff changeset
   277
    int l;
claus
parents: 345
diff changeset
   278
claus
parents: 345
diff changeset
   279
    if (__Class(self) == Symbol) {
375
claus
parents: 370
diff changeset
   280
	val = __GET_HASH(self);
356
claus
parents: 345
diff changeset
   281
	/*
claus
parents: 345
diff changeset
   282
	 * only do it, if I have no standard hash key
375
claus
parents: 370
diff changeset
   283
	 * assigned (which can only happen due to a #become:,
claus
parents: 370
diff changeset
   284
	 * or by creating a symbol uninterned, and interning it
claus
parents: 370
diff changeset
   285
	 * after it got a hashKey assigned.
356
claus
parents: 345
diff changeset
   286
	 */
claus
parents: 345
diff changeset
   287
	if (val == 0) {
1134
7cb7cd7ebeb8 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1125
diff changeset
   288
	    cp = __stringVal(self);
7cb7cd7ebeb8 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1125
diff changeset
   289
	    l = __stringSize(self);
356
claus
parents: 345
diff changeset
   290
        
claus
parents: 345
diff changeset
   291
	    /*
claus
parents: 345
diff changeset
   292
	     * this is the dragon-book algorithm
claus
parents: 345
diff changeset
   293
	     *
claus
parents: 345
diff changeset
   294
	     * the algorithm hashes pretty good:
claus
parents: 345
diff changeset
   295
	     *   with (currently) 9963 symbols in the system,
claus
parents: 345
diff changeset
   296
	     *   there are only about 200 hash key collisions.
claus
parents: 345
diff changeset
   297
	     *   where the maximum collision count in these 200
claus
parents: 345
diff changeset
   298
	     *   is 3. This means, that in most situations,
claus
parents: 345
diff changeset
   299
	     *   a single probe will find the right element in
claus
parents: 345
diff changeset
   300
	     *   a symbol-hashed collection.
claus
parents: 345
diff changeset
   301
	     */
claus
parents: 345
diff changeset
   302
	    val = 0;
claus
parents: 345
diff changeset
   303
	    for (cp0 = cp, cp += l - 1; cp >= cp0; cp--) {
claus
parents: 345
diff changeset
   304
		val = (val << 5) + (*cp & 0x1F);
claus
parents: 345
diff changeset
   305
		if (g = (val & 0x3E000000))
claus
parents: 345
diff changeset
   306
		    val ^= g >> 25 /* 23 */ /* 25 */;
claus
parents: 345
diff changeset
   307
		val &= 0x3FFFFFFF;
claus
parents: 345
diff changeset
   308
	    }
claus
parents: 345
diff changeset
   309
claus
parents: 345
diff changeset
   310
	    if (l) {
claus
parents: 345
diff changeset
   311
		l |= 1; 
claus
parents: 345
diff changeset
   312
		val = (val * l) & 0x3FFFFFFF;
claus
parents: 345
diff changeset
   313
	    }
375
claus
parents: 370
diff changeset
   314
	} else {
claus
parents: 370
diff changeset
   315
	    val <<= __HASH_SHIFT__;
356
claus
parents: 345
diff changeset
   316
	}
1134
7cb7cd7ebeb8 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1125
diff changeset
   317
	RETURN ( __MKSMALLINT(val) );
356
claus
parents: 345
diff changeset
   318
     }
claus
parents: 345
diff changeset
   319
%}.
claus
parents: 345
diff changeset
   320
     ^ super identityHash
370
claus
parents: 356
diff changeset
   321
!
claus
parents: 356
diff changeset
   322
claus
parents: 356
diff changeset
   323
~= something
claus
parents: 356
diff changeset
   324
    "return true, if the receiver and argument do not consist of the same characters.
claus
parents: 356
diff changeset
   325
     Redefined here, for more efficient #~= comparison of symbols 
claus
parents: 356
diff changeset
   326
     (which ought to be compared using #~~).
claus
parents: 356
diff changeset
   327
     If the argument is a symbol, we use a quick pointer compare, instead of
claus
parents: 356
diff changeset
   328
     the inherited value compare."
claus
parents: 356
diff changeset
   329
claus
parents: 356
diff changeset
   330
%{   /* NOCONTEXT */
claus
parents: 356
diff changeset
   331
    OBJ cls;
claus
parents: 356
diff changeset
   332
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   333
    if (! __isNonNilObject(something)) RETURN(true);    /* cannot be equal */
370
claus
parents: 356
diff changeset
   334
    if ((cls = __qClass(something)) == Symbol) {
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   335
	RETURN (self == something ? false : true);
370
claus
parents: 356
diff changeset
   336
    }
claus
parents: 356
diff changeset
   337
    if (cls == String) {
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   338
	RETURN (strcmp(__stringVal(self), __stringVal(something)) == 0 ? false : true);
370
claus
parents: 356
diff changeset
   339
    }
claus
parents: 356
diff changeset
   340
%}.
claus
parents: 356
diff changeset
   341
    "fall back; could be a TwoByteString, or a collection of Characters"
claus
parents: 356
diff changeset
   342
claus
parents: 356
diff changeset
   343
    ^ super ~= something
356
claus
parents: 345
diff changeset
   344
! !
claus
parents: 345
diff changeset
   345
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   346
!Symbol methodsFor:'converting'!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   347
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   348
asString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   349
    "return a string with printname taken from mine"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   350
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   351
%{  /* NOCONTEXT */
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   352
    OBJ s;
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   353
2565
90973ec63991 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2416
diff changeset
   354
    s = __MKSTRING_ST(self);
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   355
    if (s != nil) {
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   356
	RETURN (s);
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   357
    }
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   358
%}.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   359
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   360
     memory allocation (for the new string) failed.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   361
     When we arrive here, there was no memory, even after a garbage collect.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   362
     This means, that the VM wanted to get some more memory from the
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   363
     OS, which was not kind enough to give it.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   364
     Bad luck - you should increase the swap space on your machine,
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   365
     or if you have set a soft memoryLimit, increase it.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   366
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   367
    ^ ObjectMemory allocationFailureSignal raise.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   368
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   369
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   370
asSymbol
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   371
    "return the receiver as a symbol.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   372
     Since I am a symbol - just return myself"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   373
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   374
    ^ self
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
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   377
asSymbolIfInterned
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   378
    "return the receiver as a symbol if there is one.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   379
     Since I am a symbol - just return myself"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   380
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   381
    ^ self
2416
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   382
!
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   383
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   384
decodeAsLiteralArray
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   385
    "given a literalEncoding in the receiver,
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   386
     create & return the corresponding object.
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   387
     The inverse operation to #literalArrayEncoding."
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   388
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   389
    ^ self
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   390
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   391
    "Created: 25.2.1997 / 19:15:26 / cg"
588d5d510c10 literal encodings
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   392
    "Modified: 25.2.1997 / 19:17:40 / cg"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   393
! !
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
!Symbol methodsFor:'copying'!
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
copy
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   398
    "return a copy of myself
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   399
     - reimplemented here since symbols are unique and copy should
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   400
     return a new string with my characters."
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
deepCopy
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   406
    "return a copy of myself
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   407
     - reimplemented here since symbols are unique and copy should
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   408
     return a new string with my characters."
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   409
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   410
     ^ self
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   411
!
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
deepCopyUsing:aDictionary
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   414
    "return a copy of myself
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   415
     - reimplemented here since symbols are unique and copy should
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   416
     return a new string with my characters."
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   417
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   418
     ^ self
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   419
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   420
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   421
shallowCopy
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   422
    "return a copy of myself
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   423
     - reimplemented here since symbols are unique"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   424
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   425
     ^ self
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   426
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   427
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   428
simpleDeepCopy
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   429
    "return a copy of myself
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   430
     - reimplemented here since symbols are unique and copy should
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   431
     return a new string with my characters."
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   432
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   433
     ^ self
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   434
! !
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
!Symbol methodsFor:'printing & storing'!
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
displayString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   439
    "return a string for displaying the receiver"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   440
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   441
    ^ self storeString
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
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   444
printOn:aStream
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   445
    "append a printed representation of the receiver on aStream.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   446
     In contrast to ST-80, this does return the symbols characters
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   447
     without any leading #. Therefore, you can directly send symbols'
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   448
     printStrings to some output device. This is incompatible, but easier
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   449
     to use."
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
"/ ST-80 behavior:
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   452
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   453
"/  self storeOn:aStream
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
    aStream nextPutAll:self
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   456
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   457
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   458
printString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   459
    "return a printed representation of the receiver.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   460
     In contrast to ST-80, this does return the symbols characters
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   461
     without any leading #. Therefore, you can directly send symbols'
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   462
     printStrings to some output device. This is incompatible, but easier
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   463
     to use."
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
"/ ST-80 behavior:
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   466
"/  ^ self storeString
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 asString
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
storeOn:aStream
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   472
    "store myself on a stream"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   473
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   474
    aStream nextPutAll:(self storeString)
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   475
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   476
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   477
storeString
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   478
    "return a String for storing the receiver"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   479
3285
bd5827c97b21 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3086
diff changeset
   480
    |sz c|
1125
2bfcfb490837 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   481
2bfcfb490837 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   482
    (sz := self size) > 0 ifTrue:[  "/ sigh
3285
bd5827c97b21 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3086
diff changeset
   483
        (self at:1) isLetter ifTrue:[
bd5827c97b21 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3086
diff changeset
   484
            2 to:sz do:[:index |
bd5827c97b21 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3086
diff changeset
   485
                ((c := self at:index) isLetterOrDigit 
3286
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   486
                 or:[c == $: 
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   487
                     and:[index == sz 
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   488
                          or:[(self at:(index+1)) isLetterOrDigit]]]
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   489
                ) ifFalse:[
3285
bd5827c97b21 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3086
diff changeset
   490
                    ^ '#''' , self , ''''
bd5827c97b21 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3086
diff changeset
   491
                ].
bd5827c97b21 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3086
diff changeset
   492
            ].
bd5827c97b21 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3086
diff changeset
   493
            ^ '#' , self
bd5827c97b21 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3086
diff changeset
   494
        ]
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   495
    ].
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   496
    ^ '#''' , self , ''''
3285
bd5827c97b21 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3086
diff changeset
   497
3286
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   498
    "
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   499
      #abc
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   500
      #abc:
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   501
      #abc:def:
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   502
      #'abc::def'
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   503
      #'abc &^*'
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   504
      #'abcdef::'
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   505
    "
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   506
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   507
    "Modified: / 13.2.1998 / 22:06:15 / stefan"
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   508
! !
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   509
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   510
!Symbol methodsFor:'queries'!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   511
3086
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   512
isKeyword
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   513
    "return true, if the receiver is a keyword message selector"
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   514
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   515
    ^ self includes:$:
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   516
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   517
    "
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   518
     #at:put: isKeyword  
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   519
     #at: isKeyword      
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   520
     #+ isKeyword        
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   521
     #size isKeyword     
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   522
    "
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   523
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   524
    "Created: / 1.11.1997 / 12:34:55 / cg"
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   525
    "Modified: / 1.11.1997 / 12:36:37 / cg"
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   526
!
9da461bfbaa1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
   527
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   528
isSymbol 
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   529
    "return true, if the receiver is some kind of symbol.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   530
     Since I am a symbol, return always true"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   531
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   532
    ^ true
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   533
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   534
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   535
keywords
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   536
    "assuming the receiver is a keyword message selector,
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   537
     return the individual keywords (i.e. break it up at colons)
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   538
     and return these as a collection.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   539
     For binary and unary selectors, the result may be nonsense."
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   540
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   541
    |coll s part|
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   542
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   543
    coll := OrderedCollection new.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   544
    s := ReadStream on:self.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   545
    [s atEnd] whileFalse:[
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   546
	part := s through:$:.
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   547
	coll add:part
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   548
    ].
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   549
    ^ coll asArray
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   550
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   551
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   552
     #at:put: keywords  
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   553
     #at: keywords      
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   554
     #+ keywords        
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   555
     #size keywords     
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   556
    "
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   557
!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   558
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   559
species
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   560
    "when copying, or concatenating, return instances of this class"
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   561
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   562
    ^ String
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   563
! !
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
   564
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   565
!Symbol methodsFor:'system primitives'!
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   566
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   567
become:anotherObject
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   568
    "make all references to the receiver become references to anotherObject
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   569
     and vice-versa. For symbols, some special action is required, to
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   570
     correctly handle a become of the global dictionaries.
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   571
     Anyway: this is very dangerous - mysterous side-effects are to be
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   572
     expected.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   573
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   574
     Notice: because of the danger here, this method may report an error
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
   575
	     in future versions"
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   576
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   577
    (Smalltalk includesKey:self) ifTrue:[
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
   578
	super become:anotherObject.
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   579
%{
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
   580
	__rehashSystemDictionaries();
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   581
%}.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   582
    ] ifFalse:[
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
   583
	super become:anotherObject
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   584
    ]
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   585
!
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   586
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   587
becomeNil
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   588
    "make all references to the receiver become nil - effectively getting
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   589
     rid of the receiver. For symbols, this is not allowed, if the receiver
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   590
     is used as a key in some SytemDictionary.
95
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   591
     This can be a very dangerous operation - be warned.
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   592
d22739a0c6e9 *** empty log message ***
claus
parents: 88
diff changeset
   593
     Notice: because of the danger here, this method may report an error
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
   594
	     in future versions"
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   595
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   596
    (Smalltalk includesKey:self) ifTrue:[
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
   597
	self primitiveFailed
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   598
    ] ifFalse:[
159
514c749165c3 *** empty log message ***
claus
parents: 95
diff changeset
   599
	super becomeNil
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   600
    ]
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   601
! !
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   602
632
31498e8b424c version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   603
!Symbol class methodsFor:'documentation'!
31498e8b424c version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   604
31498e8b424c version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   605
version
3286
c6987c5f15a8 Do not need quotes in #storeString when a symbol contains a ':'.
Stefan Vogel <sv@exept.de>
parents: 3285
diff changeset
   606
    ^ '$Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.50 1998-02-13 21:53:20 stefan Exp $'
632
31498e8b424c version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   607
! !