Class.st
changeset 153 22f4c4bcc93f
parent 139 19ccaf2031c8
child 155 edd7fc34e104
equal deleted inserted replaced
152:a66572e855b6 153:22f4c4bcc93f
     1 "
     1 "
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     3                All Rights Reserved
     3 	       All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 ClassDescription subclass:#Class
    13 ClassDescription subclass:#Class
    14        instanceVariableNames:'classvars comment subclasses classFileName package'
    14        instanceVariableNames:'classvars comment subclasses classFileName package'
    15        classVariableNames:'UpdatingChanges'
    15        classVariableNames:'UpdatingChanges FileOutErrorSignal'
    16        poolDictionaries:''
    16        poolDictionaries:''
    17        category:'Kernel-Classes'
    17        category:'Kernel-Classes'
    18 !
    18 !
    19 
    19 
    20 Class comment:'
    20 Class comment:'
    21 COPYRIGHT (c) 1989 by Claus Gittinger
    21 COPYRIGHT (c) 1989 by Claus Gittinger
    22               All Rights Reserved
    22 	      All Rights Reserved
    23 
    23 
    24 $Header: /cvs/stx/stx/libbasic/Class.st,v 1.18 1994-08-23 23:07:34 claus Exp $
    24 $Header: /cvs/stx/stx/libbasic/Class.st,v 1.19 1994-09-29 20:38:11 claus Exp $
    25 '!
    25 '!
    26 
    26 
    27 !Class class methodsFor:'documentation'!
    27 !Class class methodsFor:'documentation'!
    28 
    28 
    29 copyright
    29 copyright
    30 "
    30 "
    31  COPYRIGHT (c) 1989 by Claus Gittinger
    31  COPYRIGHT (c) 1989 by Claus Gittinger
    32                All Rights Reserved
    32 	       All Rights Reserved
    33 
    33 
    34  This software is furnished under a license and may be used
    34  This software is furnished under a license and may be used
    35  only in accordance with the terms of that license and with the
    35  only in accordance with the terms of that license and with the
    36  inclusion of the above copyright notice.   This software may not
    36  inclusion of the above copyright notice.   This software may not
    37  be provided or otherwise made available to, or used by, any
    37  be provided or otherwise made available to, or used by, any
    40 "
    40 "
    41 !
    41 !
    42 
    42 
    43 version
    43 version
    44 "
    44 "
    45 $Header: /cvs/stx/stx/libbasic/Class.st,v 1.18 1994-08-23 23:07:34 claus Exp $
    45 $Header: /cvs/stx/stx/libbasic/Class.st,v 1.19 1994-09-29 20:38:11 claus Exp $
    46 "
    46 "
    47 !
    47 !
    48 
    48 
    49 documentation
    49 documentation
    50 "
    50 "
    58     Behavior - to excludes all name, source info etc., 
    58     Behavior - to excludes all name, source info etc., 
    59     however, normally all classes are subclasses of Class.
    59     however, normally all classes are subclasses of Class.
    60 
    60 
    61     Instance variables:
    61     Instance variables:
    62 
    62 
    63         classvars       <String>        the names of the class variables
    63 	classvars       <String>        the names of the class variables
    64         comment         <String>        the classes comment
    64 	comment         <String>        the classes comment
    65         subclasses      <Collection>    cached collection of subclasses
    65 	subclasses      <Collection>    cached collection of subclasses
    66                                         (currently unused - but will be soon)
    66 					(currently unused - but will be soon)
    67         classFileName   <String>        the file (or nil) where the classes
    67 	classFileName   <String>        the file (or nil) where the classes
    68                                         sources are found (currently not used)
    68 					sources are found (currently not used)
    69         package         <Symbol>        the package, in which the class was defined
    69 	package         <Symbol>        the package, in which the class was defined
    70 
    70 
    71     Class variables:
    71     Class variables:
    72 
    72 
    73         UpdatingChanges <Boolean>       true if the changes-file shall be updated
    73 	UpdatingChanges <Boolean>       true if the changes-file shall be updated
    74                                         (except during startup and when filing in, this flag
    74 					(except during startup and when filing in, this flag
    75                                          is usually true)
    75 					 is usually true)
    76 
    76 
    77     WARNING: layout known by compiler and runtime system
    77     WARNING: layout known by compiler and runtime system
    78 "
    78 "
    79 ! !
    79 ! !
    80 
    80 
    84     "the classvariable 'UpdatingChanges' controls if changes are put
    84     "the classvariable 'UpdatingChanges' controls if changes are put
    85      into the changes-file; normally this variable is set to true, but
    85      into the changes-file; normally this variable is set to true, but
    86      (for example) during fileIn or when changes are applied, it is set to false
    86      (for example) during fileIn or when changes are applied, it is set to false
    87      to avoid putting too much junk into the changes-file."
    87      to avoid putting too much junk into the changes-file."
    88      
    88      
    89     UpdatingChanges := true
    89     UpdatingChanges := true.
       
    90     FileOutErrorSignal isNil ifTrue:[
       
    91 	Object initialize.
       
    92 
       
    93 	FileOutErrorSignal := Object errorSignal newSignalMayProceed:false.
       
    94 	FileOutErrorSignal nameClass:self message:#fileOutErrorSignal.
       
    95 	FileOutErrorSignal notifierString:'error during fileOut'.
       
    96     ]
       
    97 ! !
       
    98 
       
    99 !Class class methodsFor:'signal access'!
       
   100 
       
   101 fileOutErrorSignal
       
   102     ^ FileOutErrorSignal
    90 ! !
   103 ! !
    91 
   104 
    92 !Class class methodsFor:'creating new classes'!
   105 !Class class methodsFor:'creating new classes'!
    93 
   106 
    94 new
   107 new
    96 
   109 
    97     |newClass|
   110     |newClass|
    98 
   111 
    99     newClass := super new.
   112     newClass := super new.
   100     newClass setComment:(self comment)
   113     newClass setComment:(self comment)
   101                category:(self category).
   114 	       category:(self category).
   102     ^ newClass
   115     ^ newClass
   103 ! !
   116 ! !
   104 
   117 
   105 !Class methodsFor:'subclass creation'!
   118 !Class methodsFor:'subclass creation'!
   106 
   119 
   107 subclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   120 subclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   108     "create a new class as a subclass of an existing class (the receiver).
   121     "create a new class as a subclass of an existing class (the receiver).
   109      The subclass will have indexed variables if the receiving-class has."
   122      The subclass will have indexed variables if the receiving-class has."
   110 
   123 
   111     self isVariable ifFalse:[
   124     self isVariable ifFalse:[
   112         ^ self class
   125 	^ self class
   113             name:t
   126 	    name:t
   114             inEnvironment:Smalltalk
   127 	    inEnvironment:Smalltalk
   115             subclassOf:self
   128 	    subclassOf:self
   116             instanceVariableNames:f
   129 	    instanceVariableNames:f
   117             variable:false
   130 	    variable:false
   118             words:true
   131 	    words:true
   119             pointers:true
   132 	    pointers:true
   120             classVariableNames:d
   133 	    classVariableNames:d
   121             poolDictionaries:s
   134 	    poolDictionaries:s
   122             category:cat
   135 	    category:cat
   123             comment:nil
   136 	    comment:nil
   124             changed:false
   137 	    changed:false
   125     ].
   138     ].
   126     self isBytes ifTrue:[
   139     self isBytes ifTrue:[
   127         ^ self
   140 	^ self
   128             variableByteSubclass:t
   141 	    variableByteSubclass:t
   129             instanceVariableNames:f
   142 	    instanceVariableNames:f
   130             classVariableNames:d
   143 	    classVariableNames:d
   131             poolDictionaries:s
   144 	    poolDictionaries:s
   132             category:cat
   145 	    category:cat
   133     ].
   146     ].
   134     self isLongs ifTrue:[
   147     self isLongs ifTrue:[
   135         ^ self
   148 	^ self
   136             variableLongSubclass:t
   149 	    variableLongSubclass:t
   137             instanceVariableNames:f
   150 	    instanceVariableNames:f
   138             classVariableNames:d
   151 	    classVariableNames:d
   139             poolDictionaries:s
   152 	    poolDictionaries:s
   140             category:cat
   153 	    category:cat
   141     ].
   154     ].
   142     self isFloats ifTrue:[
   155     self isFloats ifTrue:[
   143         ^ self
   156 	^ self
   144             variableFloatSubclass:t
   157 	    variableFloatSubclass:t
   145             instanceVariableNames:f
   158 	    instanceVariableNames:f
   146             classVariableNames:d
   159 	    classVariableNames:d
   147             poolDictionaries:s
   160 	    poolDictionaries:s
   148             category:cat
   161 	    category:cat
   149     ].
   162     ].
   150     self isDoubles ifTrue:[
   163     self isDoubles ifTrue:[
   151         ^ self
   164 	^ self
   152             variableDoubleSubclass:t
   165 	    variableDoubleSubclass:t
   153             instanceVariableNames:f
   166 	    instanceVariableNames:f
   154             classVariableNames:d
   167 	    classVariableNames:d
   155             poolDictionaries:s
   168 	    poolDictionaries:s
   156             category:cat
   169 	    category:cat
   157     ].
   170     ].
   158     self isWords ifTrue:[
   171     self isWords ifTrue:[
   159         ^ self
   172 	^ self
   160             variableWordSubclass:t
   173 	    variableWordSubclass:t
   161             instanceVariableNames:f
   174 	    instanceVariableNames:f
   162             classVariableNames:d
   175 	    classVariableNames:d
   163             poolDictionaries:s
   176 	    poolDictionaries:s
   164             category:cat
   177 	    category:cat
   165     ].
   178     ].
   166     ^ self
   179     ^ self
   167         variableSubclass:t
   180 	variableSubclass:t
   168         instanceVariableNames:f
   181 	instanceVariableNames:f
   169         classVariableNames:d
   182 	classVariableNames:d
   170         poolDictionaries:s
   183 	poolDictionaries:s
   171         category:cat
   184 	category:cat
   172 !
   185 !
   173 
   186 
   174 variableSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   187 variableSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   175     "create a new class as a subclass of an existing class (the receiver) 
   188     "create a new class as a subclass of an existing class (the receiver) 
   176      in which the subclass has indexable pointer variables"
   189      in which the subclass has indexable pointer variables"
   177 
   190 
   178     self isVariable ifTrue:[
   191     self isVariable ifTrue:[
   179         self isPointers ifFalse:[
   192 	self isPointers ifFalse:[
   180             ^ self error:
   193 	    ^ self error:
   181                 'cannot make a variable pointer subclass of a variable non-pointer class'
   194 		'cannot make a variable pointer subclass of a variable non-pointer class'
   182         ]
   195 	]
   183     ].
   196     ].
   184 
   197 
   185     ^ self class
   198     ^ self class
   186         name:t
   199 	name:t
   187         inEnvironment:Smalltalk
   200 	inEnvironment:Smalltalk
   188         subclassOf:self
   201 	subclassOf:self
   189         instanceVariableNames:f
   202 	instanceVariableNames:f
   190         variable:true
   203 	variable:true
   191         words:false
   204 	words:false
   192         pointers:true
   205 	pointers:true
   193         classVariableNames:d
   206 	classVariableNames:d
   194         poolDictionaries:s
   207 	poolDictionaries:s
   195         category:cat
   208 	category:cat
   196         comment:nil
   209 	comment:nil
   197         changed:false
   210 	changed:false
   198 !
   211 !
   199 
   212 
   200 variableByteSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   213 variableByteSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   201     "create a new class as a subclass of an existing class (the receiver) 
   214     "create a new class as a subclass of an existing class (the receiver) 
   202      in which the subclass has indexable byte-sized nonpointer variables"
   215      in which the subclass has indexable byte-sized nonpointer variables"
   203 
   216 
   204     self isVariable ifTrue:[
   217     self isVariable ifTrue:[
   205         self isBytes ifFalse:[
   218 	self isBytes ifFalse:[
   206             ^ self error:
   219 	    ^ self error:
   207                 'cannot make a variable byte subclass of a variable non-byte class'
   220 		'cannot make a variable byte subclass of a variable non-byte class'
   208         ].
   221 	].
   209     ].
   222     ].
   210 
   223 
   211     ^ self class
   224     ^ self class
   212         name:t
   225 	name:t
   213         inEnvironment:Smalltalk
   226 	inEnvironment:Smalltalk
   214         subclassOf:self
   227 	subclassOf:self
   215         instanceVariableNames:f
   228 	instanceVariableNames:f
   216         variable:true
   229 	variable:true
   217         words:false
   230 	words:false
   218         pointers:false
   231 	pointers:false
   219         classVariableNames:d
   232 	classVariableNames:d
   220         poolDictionaries:s
   233 	poolDictionaries:s
   221         category:cat
   234 	category:cat
   222         comment:nil
   235 	comment:nil
   223         changed:false
   236 	changed:false
   224 !
   237 !
   225 
   238 
   226 variableWordSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   239 variableWordSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   227     "create a new class as a subclass of an existing class (the receiver) 
   240     "create a new class as a subclass of an existing class (the receiver) 
   228      in which the subclass has indexable word-sized nonpointer variables"
   241      in which the subclass has indexable word-sized nonpointer variables"
   229 
   242 
   230     self isVariable ifTrue:[
   243     self isVariable ifTrue:[
   231         self isWords ifFalse:[
   244 	self isWords ifFalse:[
   232             ^ self error:
   245 	    ^ self error:
   233                 'cannot make a variable word subclass of a variable non-word class'
   246 		'cannot make a variable word subclass of a variable non-word class'
   234         ].
   247 	].
   235     ].
   248     ].
   236 
   249 
   237     ^ self class
   250     ^ self class
   238         name:t
   251 	name:t
   239         inEnvironment:Smalltalk
   252 	inEnvironment:Smalltalk
   240         subclassOf:self
   253 	subclassOf:self
   241         instanceVariableNames:f
   254 	instanceVariableNames:f
   242         variable:true
   255 	variable:true
   243         words:true
   256 	words:true
   244         pointers:false
   257 	pointers:false
   245         classVariableNames:d
   258 	classVariableNames:d
   246         poolDictionaries:s
   259 	poolDictionaries:s
   247         category:cat
   260 	category:cat
   248         comment:nil
   261 	comment:nil
   249         changed:false
   262 	changed:false
   250 !
   263 !
   251 
   264 
   252 variableLongSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   265 variableLongSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   253     "create a new class as a subclass of an existing class (the receiver) 
   266     "create a new class as a subclass of an existing class (the receiver) 
   254      in which the subclass has indexable long-sized nonpointer variables"
   267      in which the subclass has indexable long-sized nonpointer variables"
   255 
   268 
   256     self isVariable ifTrue:[
   269     self isVariable ifTrue:[
   257         self isLongs ifFalse:[
   270 	self isLongs ifFalse:[
   258             ^ self error:
   271 	    ^ self error:
   259                 'cannot make a variable long subclass of a variable non-long class'
   272 		'cannot make a variable long subclass of a variable non-long class'
   260         ].
   273 	].
   261     ].
   274     ].
   262 
   275 
   263     ^ self class
   276     ^ self class
   264         name:t
   277 	name:t
   265         inEnvironment:Smalltalk
   278 	inEnvironment:Smalltalk
   266         subclassOf:self
   279 	subclassOf:self
   267         instanceVariableNames:f
   280 	instanceVariableNames:f
   268         variable:#long 
   281 	variable:#long 
   269         words:false
   282 	words:false
   270         pointers:false
   283 	pointers:false
   271         classVariableNames:d
   284 	classVariableNames:d
   272         poolDictionaries:s
   285 	poolDictionaries:s
   273         category:cat
   286 	category:cat
   274         comment:nil
   287 	comment:nil
   275         changed:false
   288 	changed:false
   276 !
   289 !
   277 
   290 
   278 variableFloatSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   291 variableFloatSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   279 
   292 
   280     "create a new class as a subclass of an existing class (the receiver) 
   293     "create a new class as a subclass of an existing class (the receiver) 
   281      in which the subclass has indexable float-sized nonpointer variables"
   294      in which the subclass has indexable float-sized nonpointer variables"
   282 
   295 
   283     self isVariable ifTrue:[
   296     self isVariable ifTrue:[
   284         self isFloats ifFalse:[
   297 	self isFloats ifFalse:[
   285             ^ self error:
   298 	    ^ self error:
   286                 'cannot make a variable float subclass of a variable non-float class'
   299 		'cannot make a variable float subclass of a variable non-float class'
   287         ].
   300 	].
   288     ].
   301     ].
   289 
   302 
   290     ^ self class
   303     ^ self class
   291         name:t
   304 	name:t
   292         inEnvironment:Smalltalk
   305 	inEnvironment:Smalltalk
   293         subclassOf:self
   306 	subclassOf:self
   294         instanceVariableNames:f
   307 	instanceVariableNames:f
   295         variable:#float 
   308 	variable:#float 
   296         words:false
   309 	words:false
   297         pointers:false
   310 	pointers:false
   298         classVariableNames:d
   311 	classVariableNames:d
   299         poolDictionaries:s
   312 	poolDictionaries:s
   300         category:cat
   313 	category:cat
   301         comment:nil
   314 	comment:nil
   302         changed:false
   315 	changed:false
   303 !
   316 !
   304 
   317 
   305 variableDoubleSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   318 variableDoubleSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s category:cat
   306 
   319 
   307     "create a new class as a subclass of an existing class (the receiver) 
   320     "create a new class as a subclass of an existing class (the receiver) 
   308      in which the subclass has indexable double-sized nonpointer variables"
   321      in which the subclass has indexable double-sized nonpointer variables"
   309 
   322 
   310     self isVariable ifTrue:[
   323     self isVariable ifTrue:[
   311         self isDoubles ifFalse:[
   324 	self isDoubles ifFalse:[
   312             ^ self error:
   325 	    ^ self error:
   313                 'cannot make a variable double subclass of a variable non-double class'
   326 		'cannot make a variable double subclass of a variable non-double class'
   314         ].
   327 	].
   315     ].
   328     ].
   316 
   329 
   317     ^ self class
   330     ^ self class
   318         name:t
   331 	name:t
   319         inEnvironment:Smalltalk
   332 	inEnvironment:Smalltalk
   320         subclassOf:self
   333 	subclassOf:self
   321         instanceVariableNames:f
   334 	instanceVariableNames:f
   322         variable:#double 
   335 	variable:#double 
   323         words:false
   336 	words:false
   324         pointers:false
   337 	pointers:false
   325         classVariableNames:d
   338 	classVariableNames:d
   326         poolDictionaries:s
   339 	poolDictionaries:s
   327         category:cat
   340 	category:cat
   328         comment:nil
   341 	comment:nil
   329         changed:false
   342 	changed:false
   330 ! !
   343 ! !
   331 
   344 
   332 !Class methodsFor:'ST/V subclass creation'!
   345 !Class methodsFor:'ST/V subclass creation'!
   333 
   346 
   334 subclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s
   347 subclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s
   335     "this method allows fileIn of ST/V classes 
   348     "this method allows fileIn of ST/V classes 
   336      (which seem to have no category)"
   349      (which seem to have no category)"
   337 
   350 
   338     ^ self subclass:t 
   351     ^ self subclass:t 
   339            instanceVariableNames:f
   352 	   instanceVariableNames:f
   340            classVariableNames:d
   353 	   classVariableNames:d
   341            poolDictionaries:s
   354 	   poolDictionaries:s
   342            category:'ST/V classes'
   355 	   category:'ST/V classes'
   343 !
   356 !
   344 
   357 
   345 variableByteSubclass:t classVariableNames:d poolDictionaries:s
   358 variableByteSubclass:t classVariableNames:d poolDictionaries:s
   346     "this method allows fileIn of ST/V variable byte classes 
   359     "this method allows fileIn of ST/V variable byte classes 
   347      (which seem to have no category and no instvars)"
   360      (which seem to have no category and no instvars)"
   348 
   361 
   349     ^ self variableByteSubclass:t 
   362     ^ self variableByteSubclass:t 
   350            instanceVariableNames:''
   363 	   instanceVariableNames:''
   351            classVariableNames:d
   364 	   classVariableNames:d
   352            poolDictionaries:s
   365 	   poolDictionaries:s
   353            category:'ST/V classes'
   366 	   category:'ST/V classes'
   354 !
   367 !
   355 
   368 
   356 variableSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s
   369 variableSubclass:t instanceVariableNames:f classVariableNames:d poolDictionaries:s
   357     "this method allows fileIn of ST/V variable pointer classes 
   370     "this method allows fileIn of ST/V variable pointer classes 
   358      (which seem to have no category)"
   371      (which seem to have no category)"
   359 
   372 
   360     ^ self variableSubclass:t 
   373     ^ self variableSubclass:t 
   361            instanceVariableNames:f
   374 	   instanceVariableNames:f
   362            classVariableNames:d
   375 	   classVariableNames:d
   363            poolDictionaries:s
   376 	   poolDictionaries:s
   364            category:'ST/V classes'
   377 	   category:'ST/V classes'
   365 ! !
   378 ! !
   366 
   379 
   367 !Class methodsFor:'accessing'!
   380 !Class methodsFor:'accessing'!
   368 
   381 
   369 classVariableString
   382 classVariableString
   371      Only names of class variables defined in this class are in the
   384      Only names of class variables defined in this class are in the
   372      returned string."
   385      returned string."
   373 
   386 
   374     classvars isNil ifTrue:[^ ''].
   387     classvars isNil ifTrue:[^ ''].
   375     ^ classvars
   388     ^ classvars
       
   389 
       
   390     "
       
   391      Object classVariableString 
       
   392      Float classVariableString  
       
   393     "
   376 !
   394 !
   377 
   395 
   378 classVarNames
   396 classVarNames
   379     "return a collection of the class variable name-strings.
   397     "return a collection of the class variable name-strings.
   380      Only names of class variables defined in this class are included
   398      Only names of class variables defined in this class are included
   381      in the returned collection - use allClassVarNames, to get all known names."
   399      in the returned collection - use allClassVarNames, to get all known names."
   382 
   400 
   383     classvars isNil ifTrue:[
   401     classvars isNil ifTrue:[
   384         ^ OrderedCollection new
   402 	^ OrderedCollection new
   385     ].
   403     ].
   386     ^ classvars asCollectionOfWords
   404     ^ classvars asCollectionOfWords
   387 
   405 
   388     "Object classVarNames"
   406     "
   389     "Float classVarNames"
   407      Object classVarNames 
       
   408      Float classVarNames
       
   409     "
       
   410 !
       
   411 
       
   412 classVarAt:aSymbol
       
   413     "return the value of a class variable.
       
   414      Currently, this returns nil if there is no such classvar -
       
   415      this may change."
       
   416 
       
   417     "
       
   418      this hides the (current) implementation of classVariables
       
   419      from the outside world. Currently, classvars are stored in
       
   420      the Smalltalk dictionary with a funny name, since there are
       
   421      no classPools yet.
       
   422     "
       
   423     ^ Smalltalk at:(self name , ':' , aSymbol) asSymbol
       
   424 !
       
   425 
       
   426 classVarAt:aSymbol put:something
       
   427     "store something in a classvariable.
       
   428      Currently this creates a global with a funny name if no such
       
   429      classVar exists - this may change."
       
   430 
       
   431     "
       
   432      this hides the (current) implementation of classVariables
       
   433      from the outside world. Currently, classvars are stored in
       
   434      the Smalltalk dictionary with a funny name, since there are
       
   435      no classPools yet.
       
   436     "
       
   437     Smalltalk at:(self name , ':' , aSymbol) asSymbol put:something.
   390 !
   438 !
   391 
   439 
   392 allClassVarNames
   440 allClassVarNames
   393     "return a collection of all the class variable name-strings
   441     "return a collection of all the class variable name-strings
   394      this includes all superclass-class variables"
   442      this includes all superclass-class variables"
   395 
   443 
   396     ^ self addAllClassVarNamesTo:(OrderedCollection new)
   444     ^ self addAllClassVarNamesTo:(OrderedCollection new)
   397 
   445 
   398     "Float allClassVarNames"
   446     "
       
   447      Float allClassVarNames
       
   448     "
   399 !
   449 !
   400 
   450 
   401 comment
   451 comment
   402     "return the comment (aString) of the class"
   452     "return the comment (aString) of the class"
   403 
   453 
   404     ^ comment
   454     ^ comment
   405 !
   455 
       
   456     "
       
   457      Object comment 
       
   458     "
       
   459 !          
   406 
   460 
   407 setComment:aString
   461 setComment:aString
   408     "set the comment of the class to be the argument, aString;
   462     "set the comment of the class to be the argument, aString;
   409      do NOT create a change record"
   463      do NOT create a change record"
   410 
   464 
   411     comment := aString
   465     comment := aString
   412 !
   466 !
   413 
   467 
   414 comment:aString
   468 comment:aString
   415     "set the comment of the class to be the argument, aString;
   469     "set the comment of the class to be the argument, aString;
   416      create a change record"
   470      create a change record and notify dependents."
       
   471 
       
   472     |oldComment|
   417 
   473 
   418     comment ~= aString ifTrue:[
   474     comment ~= aString ifTrue:[
   419         comment := aString.
   475 	oldComment := comment.
   420         self addChangeRecordForClassComment:self
   476 	comment := aString.
       
   477 	self changed:#comment with:oldComment.
       
   478 	self addChangeRecordForClassComment:self.
   421     ]
   479     ]
   422 !
   480 !
   423 
   481 
   424 classFileName
   482 classFileName
   425     "return the name of the file from which the class was compiled"
   483     "return the name of the file from which the class was compiled.
       
   484      This is currently NOT used."
   426 
   485 
   427     ^ classFileName
   486     ^ classFileName
   428 !
   487 !
   429 
   488 
   430 definition
   489 definition
   434 
   493 
   435     s := WriteStream on:(String new).
   494     s := WriteStream on:(String new).
   436     self fileOutDefinitionOn:s.
   495     self fileOutDefinitionOn:s.
   437     ^ s contents
   496     ^ s contents
   438 
   497 
   439     "Object definition"
   498     "
   440     "Point definition"
   499      Object definition 
       
   500      Point definition  
       
   501     "
   441 !
   502 !
   442 
   503 
   443 sharedPools
   504 sharedPools
   444     "ST/X does not (currently) support pools"
   505     "ST/X does not (currently) support pools"
   445 
   506 
   453     comment := com.
   514     comment := com.
   454     category := categoryStringOrSymbol asSymbol
   515     category := categoryStringOrSymbol asSymbol
   455 !
   516 !
   456 
   517 
   457 setClassVariableString:aString
   518 setClassVariableString:aString
   458     "set the classes classvarnames string. This is a dangerous
   519     "set the classes classvarnames string. 
   459      (low level) operation, since the classvariables are not really
   520      This is a dangerous (low level) operation, since the 
   460      created."
   521      classvariables are not really created or updated. Also,
       
   522      NO change record is written."
   461 
   523 
   462     classvars := aString
   524     classvars := aString
   463 !
   525 !
   464 
   526 
   465 classVariableString:aString
   527 classVariableString:aString
   466     "set the classes classvarnames string;
   528     "set the classes classvarnames string; 
   467      initialize new class variables with nil, 
   529      Initialize new class variables with nil, clear and remove old ones. 
   468      clear and remove old ones. No change record is written."
   530      No change record is written and no classes are recompiled."
   469 
   531 
   470     |prevVarNames varNames|
   532     |prevVarNames varNames|
   471 
   533 
   472     "ignore for metaclasses except the one"
   534     "ignore for metaclasses except the one"
   473     (self isMeta) ifTrue:[
   535     (self isMeta) ifTrue:[
   474         (self == Metaclass) ifFalse:[
   536 	(self == Metaclass) ifFalse:[
   475             ^ self
   537 	    ^ self
   476         ]
   538 	]
   477     ].
   539     ].
   478     (classvars = aString) ifFalse:[
   540     (classvars = aString) ifFalse:[
   479         prevVarNames := self classVarNames.
   541 	prevVarNames := self classVarNames.
   480         classvars := aString.
   542 	classvars := aString.
   481         varNames := self classVarNames.
   543 	varNames := self classVarNames.
   482 
   544 
   483         "new ones get initialized to nil;
   545 	"new ones get initialized to nil;
   484          - old ones are nilled and removed from Smalltalk"
   546 	 - old ones are nilled and removed from Smalltalk"
   485 
   547 
   486         varNames do:[:aName |
   548 	varNames do:[:aName |
   487             (prevVarNames includes:aName) ifFalse:[
   549 	    (prevVarNames includes:aName) ifFalse:[
   488                 "a new one"
   550 		"a new one"
   489                 Smalltalk at:(self name , ':' , aName) asSymbol put:nil.
   551 		self classVarAt:aName put:nil.
   490             ] ifTrue:[
   552 	    ] ifTrue:[
   491                 prevVarNames remove:aName
   553 		prevVarNames remove:aName
   492             ]
   554 	    ]
   493         ].
   555 	].
   494         "left overs are gone"
   556 	"left overs are gone"
   495         prevVarNames do:[:aName |
   557 	prevVarNames do:[:aName |
   496             Smalltalk at:(self name , ':' , aName) asSymbol put:nil.
   558 	    self classVarAt:aName put:nil.
   497             Smalltalk removeKey:(self name , ':' , aName) asSymbol
   559 	    Smalltalk removeKey:(self name , ':' , aName) asSymbol.
   498         ].
   560 	].
   499         Smalltalk changed
   561 	Smalltalk changed
   500     ]
   562     ]
   501 !
   563 !
   502 
   564 
   503 addClassVarName:aString
   565 addClassVarName:aString
   504     "add a class variable if not already there"
   566     "add a class variable if not already there and initialize it with nil.
       
   567      Also write a change record and notify dependents.
       
   568      BUG: Currently, no recompilation is done - this will change."
   505 
   569 
   506     (self classVarNames includes:aString) ifFalse:[
   570     (self classVarNames includes:aString) ifFalse:[
   507         self classVariableString:(self classVariableString , ' ' , aString)
   571 	self classVariableString:(self classVariableString , ' ' , aString).
       
   572 	self addChangeRecordForClass:self.
       
   573 	self changed:#definition.
       
   574     ]
       
   575 !
       
   576 
       
   577 removeClassVarName:aString
       
   578     "remove a class variable if not already there.
       
   579      Also write a change record and notify dependents.
       
   580      BUG: Currently, no recompilation is done - this will change."
       
   581 
       
   582     |names newNames|
       
   583 
       
   584     names := self classVarNames.
       
   585     (names includes:aString) ifTrue:[
       
   586 	newNames := ''.
       
   587 	names do:[:nm | nm ~= aString ifTrue:[newNames := newNames , nm , ' ']].
       
   588 	self classVariableString:newNames withoutSpaces.
       
   589 	self addChangeRecordForClass:self.
       
   590 	self changed:#definition.
   508     ]
   591     ]
   509 !
   592 !
   510 
   593 
   511 renameCategory:oldCategory to:newCategory
   594 renameCategory:oldCategory to:newCategory
   512     "change methods categories"
   595     "rename a category (changes category of those methods).
       
   596      Append a change record and notifies dependents."
   513 
   597 
   514     |any|
   598     |any|
   515 
   599 
   516     any := false.
   600     any := false.
   517     methodArray do:[:aMethod |
   601     methodArray do:[:aMethod |
   518         aMethod category = oldCategory ifTrue:[
   602 	aMethod category = oldCategory ifTrue:[
   519             aMethod category:newCategory.
   603 	    aMethod category:newCategory.
   520             any := true.
   604 	    any := true.
   521         ]
   605 	]
   522     ].
   606     ].
   523     any ifTrue:[
   607     any ifTrue:[
   524         self addChangeRecordForRenameCategory:oldCategory to:newCategory
   608 	self addChangeRecordForRenameCategory:oldCategory to:newCategory.
       
   609 	self changed:#methodCategory.
   525     ]
   610     ]
   526 ! !
   611 ! !
   527 
   612 
   528 !Class methodsFor:'adding/removing'!
   613 !Class methodsFor:'adding/removing'!
   529 
   614 
   530 addSelector:newSelector withMethod:newMethod
   615 addSelector:newSelector withMethod:newMethod
   531     "add the method given by 2nd argument under the selector given by
   616     "add the method given by 2nd argument under the selector given by
   532      1st argument to the methodDictionary. 
   617      1st argument to the methodDictionary. 
   533      Append a change record to the changes file."
   618      Append a change record to the changes file and tell dependents."
   534 
   619 
   535     (super addSelector:newSelector withMethod:newMethod) ifTrue:[
   620     (super addSelector:newSelector withMethod:newMethod) ifTrue:[
   536         self addChangeRecordForMethod:newMethod
   621 	self addChangeRecordForMethod:newMethod
   537     ]
   622     ]
   538 !
   623 !
   539 
   624 
   540 removeSelector:aSelector
   625 removeSelector:aSelector
   541     "remove the selector, aSelector and its associated method 
   626     "remove the selector, aSelector and its associated method 
   542      from the methodDictionary.
   627      from the methodDictionary.
   543      Append a change record to the changes file."
   628      Append a change record to the changes file and tell dependents."
   544 
   629 
   545     (super removeSelector:aSelector) ifTrue:[
   630     (super removeSelector:aSelector) ifTrue:[
   546         self addChangeRecordForRemoveSelector:aSelector
   631 	self addChangeRecordForRemoveSelector:aSelector.
       
   632 	self changed:#methodDictionary with:aSelector.
   547     ]
   633     ]
   548 ! !
   634 ! !
   549 
   635 
   550 !Class methodsFor:'changes management'!
   636 !Class methodsFor:'changes management'!
   551 
   637 
   563     "return a Stream for the changes file"
   649     "return a Stream for the changes file"
   564 
   650 
   565     |aStream|
   651     |aStream|
   566 
   652 
   567     UpdatingChanges ifTrue:[
   653     UpdatingChanges ifTrue:[
   568         aStream := FileStream oldFileNamed:'changes'.
   654 	aStream := FileStream oldFileNamed:'changes'.
   569         aStream isNil ifTrue:[
   655 	aStream isNil ifTrue:[
   570             aStream := FileStream newFileNamed:'changes'.
   656 	    aStream := FileStream newFileNamed:'changes'.
   571             aStream isNil ifTrue:[
   657 	    aStream isNil ifTrue:[
   572                 self error:'cannot update changes file'.
   658 		self error:'cannot update changes file'.
   573                 ^ nil
   659 		^ nil
   574             ]
   660 	    ]
   575         ].
   661 	].
   576         aStream setToEnd
   662 	aStream setToEnd
   577     ].
   663     ].
   578     ^ aStream
   664     ^ aStream
   579 !
   665 !
   580 
   666 
   581 sourcesStream
   667 sourcesStream
   582     "return a Stream for the sources file"
   668     "return a Stream for the sources file"
   583 
   669 
   584     |aStream|
   670     |aStream|
   585 
   671 
   586     UpdatingChanges ifTrue:[
   672     UpdatingChanges ifTrue:[
   587         aStream := FileStream oldFileNamed:('st.sou').
   673 	aStream := FileStream oldFileNamed:('st.sou').
   588         aStream isNil ifTrue:[
   674 	aStream isNil ifTrue:[
   589             aStream := FileStream newFileNamed:'st.sou'.
   675 	    aStream := FileStream newFileNamed:'st.sou'.
   590             aStream isNil ifTrue:[
   676 	    aStream isNil ifTrue:[
   591                 Transcript showCr:'cannot update sources file'.
   677 		Transcript showCr:'cannot update sources file'.
   592                 ^ nil
   678 		^ nil
   593             ]
   679 	    ]
   594         ].
   680 	].
   595         aStream setToEnd
   681 	aStream setToEnd
   596     ].
   682     ].
   597     ^ aStream
   683     ^ aStream
   598 !
   684 !
   599 
   685 
   600 addChangeRecordForMethod:aMethod
   686 addChangeRecordForMethod:aMethod
   602 
   688 
   603     |aStream|
   689     |aStream|
   604 
   690 
   605     aStream := self changesStream.
   691     aStream := self changesStream.
   606     aStream notNil ifTrue:[
   692     aStream notNil ifTrue:[
   607         self fileOutMethod:aMethod on:aStream.
   693 	self fileOutMethod:aMethod on:aStream.
   608         aStream cr.
   694 	aStream cr.
   609         aStream close.
   695 	aStream close.
   610 
   696 
   611         "this test allows a smalltalk without Projects/ChangeSets"
   697 	"this test allows a smalltalk without Projects/ChangeSets"
   612         Project notNil ifTrue:[
   698 	Project notNil ifTrue:[
   613             Project addMethodChange:aMethod in:self
   699 	    Project addMethodChange:aMethod in:self
   614         ]
   700 	]
   615     ]
   701     ]
   616 !
   702 !
   617 
   703 
   618 addChangeRecordForRemoveSelector:aSelector
   704 addChangeRecordForRemoveSelector:aSelector
   619     "add a method-remove-record to the changes file"
   705     "add a method-remove-record to the changes file"
   620 
   706 
   621     |aStream|
   707     |aStream|
   622 
   708 
   623     aStream := self changesStream.
   709     aStream := self changesStream.
   624     aStream notNil ifTrue:[
   710     aStream notNil ifTrue:[
   625         self printClassNameOn:aStream.
   711 	self printClassNameOn:aStream.
   626         aStream nextPutAll:(' removeSelector:#' , aSelector).
   712 	aStream nextPutAll:(' removeSelector:#' , aSelector).
   627         aStream nextPut:(aStream class chunkSeparator).
   713 	aStream nextPut:(aStream class chunkSeparator).
   628         aStream cr.
   714 	aStream cr.
   629         aStream close
   715 	aStream close
   630     ]
   716     ]
   631 !
   717 !
   632 
   718 
   633 addChangeRecordForClass:aClass
   719 addChangeRecordForClass:aClass
   634     "add a class-definition-record to the changes file"
   720     "add a class-definition-record to the changes file"
   635 
   721 
   636     |aStream|
   722     |aStream|
   637 
   723 
   638     aStream := self changesStream.
   724     aStream := self changesStream.
   639     aStream notNil ifTrue:[
   725     aStream notNil ifTrue:[
   640         aClass fileOutDefinitionOn:aStream.
   726 	aClass fileOutDefinitionOn:aStream.
   641         aStream nextPut:(aStream class chunkSeparator).
   727 	aStream nextPut:(aStream class chunkSeparator).
   642         aStream cr.
   728 	aStream cr.
   643         aStream close
   729 	aStream close
   644     ]
   730     ]
   645 !
   731 !
   646 
   732 
   647 addChangeRecordForClassInstvars:aClass
   733 addChangeRecordForClassInstvars:aClass
   648     "add a class-instvars-record to the changes file"
   734     "add a class-instvars-record to the changes file"
   649 
   735 
   650     |aStream|
   736     |aStream|
   651 
   737 
   652     aStream := self changesStream.
   738     aStream := self changesStream.
   653     aStream notNil ifTrue:[
   739     aStream notNil ifTrue:[
   654         aClass fileOutClassInstVarDefinitionOn:aStream.
   740 	aClass fileOutClassInstVarDefinitionOn:aStream.
   655         aStream nextPut:(aStream class chunkSeparator).
   741 	aStream nextPut:(aStream class chunkSeparator).
   656         aStream cr.
   742 	aStream cr.
   657         aStream close
   743 	aStream close
   658     ]
   744     ]
   659 !
   745 !
   660 
   746 
   661 addChangeRecordForClassComment:aClass
   747 addChangeRecordForClassComment:aClass
   662     "add a class-comment-record to the changes file"
   748     "add a class-comment-record to the changes file"
   663 
   749 
   664     |aStream|
   750     |aStream|
   665 
   751 
   666     aStream := self changesStream.
   752     aStream := self changesStream.
   667     aStream notNil ifTrue:[
   753     aStream notNil ifTrue:[
   668         aClass fileOutCommentOn:aStream.
   754 	aClass fileOutCommentOn:aStream.
   669         aStream nextPut:(aStream class chunkSeparator).
   755 	aStream nextPut:(aStream class chunkSeparator).
   670         aStream cr.
   756 	aStream cr.
   671         aStream close
   757 	aStream close
   672     ]
   758     ]
   673 !
   759 !
   674 
   760 
   675 addChangeRecordForClassRename:oldName to:newName
   761 addChangeRecordForClassRename:oldName to:newName
   676     "add a class-rename-record to the changes file"
   762     "add a class-rename-record to the changes file"
   677 
   763 
   678     |aStream|
   764     |aStream|
   679 
   765 
   680     aStream := self changesStream.
   766     aStream := self changesStream.
   681     aStream notNil ifTrue:[
   767     aStream notNil ifTrue:[
   682         aStream nextPutAll:('Smalltalk renameClass:' , oldName , ' to:''' , newName , '''').
   768 	aStream nextPutAll:('Smalltalk renameClass:' , oldName , ' to:''' , newName , '''').
   683         aStream nextPut:(aStream class chunkSeparator).
   769 	aStream nextPut:(aStream class chunkSeparator).
   684         aStream cr.
   770 	aStream cr.
   685         aStream close
   771 	aStream close
   686     ]
   772     ]
   687 !
   773 !
   688 
   774 
   689 addChangeRecordForClassRemove:oldName
   775 addChangeRecordForClassRemove:oldName
   690     "add a class-remove-record to the changes file"
   776     "add a class-remove-record to the changes file"
   691 
   777 
   692     |aStream|
   778     |aStream|
   693 
   779 
   694     aStream := self changesStream.
   780     aStream := self changesStream.
   695     aStream notNil ifTrue:[
   781     aStream notNil ifTrue:[
   696         aStream nextPutAll:('Smalltalk removeClass:' , oldName).
   782 	aStream nextPutAll:('Smalltalk removeClass:' , oldName).
   697         aStream nextPut:(aStream class chunkSeparator).
   783 	aStream nextPut:(aStream class chunkSeparator).
   698         aStream cr.
   784 	aStream cr.
   699         aStream close
   785 	aStream close
   700     ]
   786     ]
   701 !
   787 !
   702 
   788 
   703 addChangeRecordForRenameCategory:oldCategory to:newCategory
   789 addChangeRecordForRenameCategory:oldCategory to:newCategory
   704     "add a category-rename record to the changes file"
   790     "add a category-rename record to the changes file"
   705 
   791 
   706     |aStream|
   792     |aStream|
   707 
   793 
   708     aStream := self changesStream.
   794     aStream := self changesStream.
   709     aStream notNil ifTrue:[
   795     aStream notNil ifTrue:[
   710         self printClassNameOn:aStream.
   796 	self printClassNameOn:aStream.
   711         aStream nextPutAll:(' renameCategory:' , oldCategory storeString).
   797 	aStream nextPutAll:(' renameCategory:' , oldCategory storeString).
   712         aStream nextPutAll:(' to:' , newCategory storeString).
   798 	aStream nextPutAll:(' to:' , newCategory storeString).
   713         aStream nextPut:(aStream class chunkSeparator).
   799 	aStream nextPut:(aStream class chunkSeparator).
   714         aStream cr.
   800 	aStream cr.
   715         aStream close
   801 	aStream close
   716     ]
   802     ]
   717 !
   803 !
   718 
   804 
   719 addChangeRecordForChangeCategory
   805 addChangeRecordForChangeCategory
   720     "add a category change record to the changes file"
   806     "add a category change record to the changes file"
   721 
   807 
   722     |aStream|
   808     |aStream|
   723 
   809 
   724     aStream := self changesStream.
   810     aStream := self changesStream.
   725     aStream notNil ifTrue:[
   811     aStream notNil ifTrue:[
   726         self printClassNameOn:aStream.
   812 	self printClassNameOn:aStream.
   727         aStream nextPutAll:(' category:' , category storeString).
   813 	aStream nextPutAll:(' category:' , category storeString).
   728         aStream nextPut:(aStream class chunkSeparator).
   814 	aStream nextPut:(aStream class chunkSeparator).
   729         aStream cr.
   815 	aStream cr.
   730         aStream close
   816 	aStream close
   731     ]
   817     ]
   732 !
   818 !
   733 
   819 
   734 addChangeRecordForSnapshot:aFileName
   820 addChangeRecordForSnapshot:aFileName
   735     "add a snapshot-record to the changes file"
   821     "add a snapshot-record to the changes file"
   736 
   822 
   737     |aStream|
   823     |aStream|
   738 
   824 
   739     aStream := self changesStream.
   825     aStream := self changesStream.
   740     aStream notNil ifTrue:[
   826     aStream notNil ifTrue:[
   741         aStream nextPutAll:('''---- snapshot ' , aFileName , ' ',
   827 	aStream nextPutAll:('''---- snapshot ' , aFileName , ' ',
   742                             Date today printString , ' ' ,
   828 			    Date today printString , ' ' ,
   743                             Time now printString ,
   829 			    Time now printString ,
   744                             ' ----''!!').
   830 			    ' ----''!!').
   745         aStream cr.
   831 	aStream cr.
   746         aStream close
   832 	aStream close
   747     ]
   833     ]
   748 ! !
   834 ! !
   749 
   835 
   750 !Class methodsFor:'compiling'!
   836 !Class methodsFor:'compiling'!
   751 
   837 
   764 !
   850 !
   765 
   851 
   766 recompileMethodsAccessingAny:setOfNames
   852 recompileMethodsAccessingAny:setOfNames
   767     "recompile all methods accessing a variable from setOfNames"
   853     "recompile all methods accessing a variable from setOfNames"
   768 
   854 
       
   855     self recompileMethodsAccessingAny:setOfNames orSuper:false 
       
   856 !
       
   857 
       
   858 recompileMethodsAccessingAny:setOfNames orSuper:superBoolean
       
   859     "recompile all methods accessing a variable from setOfNames,
       
   860      or super (if superBoolean is true)"
       
   861 
   769     |p|
   862     |p|
   770 
   863 
   771     selectorArray do:[:aSelector |
   864     selectorArray do:[:aSelector |
   772         |m|
   865 	|m|
   773 
   866 
   774         m := self compiledMethodAt:aSelector.
   867 	m := self compiledMethodAt:aSelector.
   775         p := Parser parseMethod:(m source) in:self.
   868 	p := Parser parseMethod:(m source) in:self.
   776         (p isNil or:[p usedVars notNil and:[p usedVars includesAny:setOfNames]]) ifTrue:[
   869 	(p isNil 
   777             self recompile:aSelector
   870 	 or:[(p usedVars notNil and:[p usedVars includesAny:setOfNames])
   778         ]
   871 	 or:[superBoolean and:[p usesSuper]]]) ifTrue:[
       
   872 	    self recompile:aSelector
       
   873 	]
   779     ]
   874     ]
   780 !
   875 !
   781 
   876 
   782 recompile:aSelector
   877 recompile:aSelector
   783     "recompile the method associated with the argument, aSelector;
   878     "recompile the method associated with the argument, aSelector;
   786 
   881 
   787     |cat code upd|
   882     |cat code upd|
   788 
   883 
   789     upd := Class updateChanges:false.
   884     upd := Class updateChanges:false.
   790     [
   885     [
   791         cat := (self compiledMethodAt:aSelector) category.
   886 	cat := (self compiledMethodAt:aSelector) category.
   792         code := self sourceCodeAt:aSelector.
   887 	code := self sourceCodeAt:aSelector.
   793         self compiler compile:code forClass:self inCategory:cat
   888 	self compiler compile:code forClass:self inCategory:cat
   794     ] valueNowOrOnUnwindDo:[
   889     ] valueNowOrOnUnwindDo:[
   795         Class updateChanges:upd
   890 	Class updateChanges:upd
   796     ]
   891     ]
   797 !
   892 !
   798 
   893 
   799 recompile
   894 recompile
   800     "recompile all methods
   895     "recompile all methods
   801      used when a class changes instances and therefore all methods
   896      used when a class changes instances and therefore all methods
   802      have to be recompiled"
   897      have to be recompiled"
   803 
   898 
   804     selectorArray do:[:aSelector |
   899     selectorArray do:[:aSelector |
   805         self recompile:aSelector
   900 	self recompile:aSelector
   806     ]
   901     ]
   807 !
   902 !
   808 
   903 
   809 recompileAll
   904 recompileAll
   810     "recompile this class and all subclasses"
   905     "recompile this class and all subclasses"
   812     |classes|
   907     |classes|
   813 
   908 
   814     classes := self subclasses.
   909     classes := self subclasses.
   815     self recompile.
   910     self recompile.
   816     classes do:[:aClass |
   911     classes do:[:aClass |
   817         aClass recompileAll
   912 	aClass recompileAll
   818     ]
   913     ]
   819 !
   914 !
   820 
   915 
   821 recompileInvalidatedMethods:trap
   916 recompileInvalidatedMethods:trap
   822     "recompile all invalidated methods"
   917     "recompile all invalidated methods"
   825 
   920 
   826     trapCode := trap code.
   921     trapCode := trap code.
   827     trapByteCode := trap byteCode.
   922     trapByteCode := trap byteCode.
   828 
   923 
   829     selectorArray do:[:aSelector |
   924     selectorArray do:[:aSelector |
   830         |m|
   925 	|m|
   831 
   926 
   832         m := self compiledMethodAt:aSelector.
   927 	m := self compiledMethodAt:aSelector.
   833         ((m code == trapCode) and:[m byteCode == trapByteCode]) ifTrue:[
   928 	((m code == trapCode) and:[m byteCode == trapByteCode]) ifTrue:[
   834             self recompile:aSelector
   929 	    self recompile:aSelector
   835         ]
   930 	]
   836     ]
   931     ]
   837 ! !
   932 ! !
   838 
   933 
   839 !Class methodsFor:'queries'!
   934 !Class methodsFor:'queries'!
   840 
   935 
   851 
   946 
   852     |newList cat|
   947     |newList cat|
   853 
   948 
   854     newList := OrderedCollection new.
   949     newList := OrderedCollection new.
   855     methodArray do:[:aMethod |
   950     methodArray do:[:aMethod |
   856         cat := aMethod category.
   951 	cat := aMethod category.
   857         newList indexOf:cat ifAbsent:[newList add:cat]
   952 	newList indexOf:cat ifAbsent:[newList add:cat]
   858     ].
   953     ].
   859     ^ newList
   954     ^ newList
   860 !
   955 !
   861 
   956 
   862 allCategories
   957 allCategories
   871 addAllClassVarNamesTo:aCollection
   966 addAllClassVarNamesTo:aCollection
   872     "helper - add the name-strings of the class variables and of the class-vars
   967     "helper - add the name-strings of the class variables and of the class-vars
   873      of all superclasses to the argument, aCollection. Return aCollection"
   968      of all superclasses to the argument, aCollection. Return aCollection"
   874 
   969 
   875     (superclass notNil) ifTrue:[
   970     (superclass notNil) ifTrue:[
   876         superclass addAllClassVarNamesTo:aCollection
   971 	superclass addAllClassVarNamesTo:aCollection
   877     ].
   972     ].
   878     classvars notNil ifTrue:[
   973     classvars notNil ifTrue:[
   879         aCollection addAll:(classvars asCollectionOfWords).
   974 	aCollection addAll:(classvars asCollectionOfWords).
   880     ].
   975     ].
   881     ^ aCollection
   976     ^ aCollection
   882 !
   977 !
   883 
   978 
   884 addCategoriesTo:aCollection
   979 addCategoriesTo:aCollection
   885     "helper - add categories to the argument, aCollection"
   980     "helper - add categories to the argument, aCollection"
   886 
   981 
   887     |cat|
   982     |cat|
   888 
   983 
   889     methodArray do:[:aMethod |
   984     methodArray do:[:aMethod |
   890         cat := aMethod category.
   985 	cat := aMethod category.
   891         (aCollection detect:[:element | cat = element]
   986 	(aCollection detect:[:element | cat = element]
   892                      ifNone:[nil])
   987 		     ifNone:[nil])
   893             isNil ifTrue:[
   988 	    isNil ifTrue:[
   894                 aCollection add:cat
   989 		aCollection add:cat
   895         ]
   990 	]
   896     ].
   991     ].
   897     ^ aCollection
   992     ^ aCollection
   898 !
   993 !
   899 
   994 
   900 addAllCategoriesTo:aCollection
   995 addAllCategoriesTo:aCollection
   901     "helper - add categories and all superclasses categories
   996     "helper - add categories and all superclasses categories
   902      to the argument, aCollection"
   997      to the argument, aCollection"
   903 
   998 
   904     (superclass notNil) ifTrue:[
   999     (superclass notNil) ifTrue:[
   905         superclass addAllCategoriesTo:aCollection
  1000 	superclass addAllCategoriesTo:aCollection
   906     ].
  1001     ].
   907     ^ self addCategoriesTo:aCollection
  1002     ^ self addCategoriesTo:aCollection
   908 ! !
  1003 ! !
   909 
  1004 
   910 !Class methodsFor:'fileIn interface'!
  1005 !Class methodsFor:'fileIn interface'!
   955      The c-function has the name cFunctionNameString, and expects parameters as specified in
  1050      The c-function has the name cFunctionNameString, and expects parameters as specified in
   956      argTypeArray. The functions return value has a type as specified by returnType.
  1051      argTypeArray. The functions return value has a type as specified by returnType.
   957      Warning: this interface is EXPERIMENTAL - it may change or even be removed."
  1052      Warning: this interface is EXPERIMENTAL - it may change or even be removed."
   958 
  1053 
   959     StubGenerator createStubFor:selector calling:cFunctionNameString 
  1054     StubGenerator createStubFor:selector calling:cFunctionNameString 
   960                            args:argTypeArray returning:returnType
  1055 			   args:argTypeArray returning:returnType
   961                              in:self                          
  1056 			     in:self                          
   962 
  1057 
   963     "
  1058     "
   964      Object subclass:#CInterface
  1059      Object subclass:#CInterface
   965             instanceVariableNames:''
  1060 	    instanceVariableNames:''
   966             classVariableNames:''
  1061 	    classVariableNames:''
   967             poolDictionaries:''
  1062 	    poolDictionaries:''
   968             category:'Examples'.
  1063 	    category:'Examples'.
   969 
  1064 
   970      CInterface cInterfaceFunction:#printfOn:format:withFloat: 
  1065      CInterface cInterfaceFunction:#printfOn:format:withFloat: 
   971                            calling:'fprintf' 
  1066 			   calling:'fprintf' 
   972                               args:#(ExternalStream String Float) 
  1067 			      args:#(ExternalStream String Float) 
   973                          returning:#SmallInteger.
  1068 			 returning:#SmallInteger.
   974 
  1069 
   975      CInterface printfOn:Stdout format:'this is a float: %g' withFloat:(Float pi). Stdout cr  
  1070      CInterface printfOn:Stdout format:'this is a float: %g' withFloat:(Float pi). Stdout cr  
   976     "
  1071     "
   977 ! !
  1072 ! !
   978 
  1073 
   982     "append an expression on aStream, which defines my comment"
  1077     "append an expression on aStream, which defines my comment"
   983 
  1078 
   984     aStream nextPutAll:name.
  1079     aStream nextPutAll:name.
   985     aStream nextPutAll:' comment:'.
  1080     aStream nextPutAll:' comment:'.
   986     comment isNil ifTrue:[
  1081     comment isNil ifTrue:[
   987         aStream nextPutAll:''''''
  1082 	aStream nextPutAll:''''''
   988     ] ifFalse:[
  1083     ] ifFalse:[
   989         aStream nextPutAll:(comment storeString)
  1084 	aStream nextPutAll:(comment storeString)
   990     ].
  1085     ].
   991     aStream cr
  1086     aStream cr
   992 !
  1087 !
   993 
  1088 
   994 fileOutDefinitionOn:aStream
  1089 fileOutDefinitionOn:aStream
   999     "take care of nil-superclass"
  1094     "take care of nil-superclass"
  1000     superclass isNil ifTrue:[
  1095     superclass isNil ifTrue:[
  1001 "/      previous versions of stc were not able to compile nil-subclasses;
  1096 "/      previous versions of stc were not able to compile nil-subclasses;
  1002 "/      after 2.10, it can ...
  1097 "/      after 2.10, it can ...
  1003 "/        line := 'Object "nil"'.
  1098 "/        line := 'Object "nil"'.
  1004         line := 'nil'
  1099 	line := 'nil'
  1005     ] ifFalse:[
  1100     ] ifFalse:[
  1006         line := (superclass name)
  1101 	line := (superclass name)
  1007     ].
  1102     ].
  1008     superclass isNil ifTrue:[
  1103     superclass isNil ifTrue:[
  1009         isVar := self isVariable
  1104 	isVar := self isVariable
  1010     ] ifFalse:[
  1105     ] ifFalse:[
  1011         "I cant remember what this is for ?"
  1106 	"I cant remember what this is for ?"
  1012         isVar := (self isVariable and:[superclass isVariable not])
  1107 	isVar := (self isVariable and:[superclass isVariable not])
  1013     ].
  1108     ].
  1014     isVar ifTrue:[
  1109     isVar ifTrue:[
  1015         self isBytes ifTrue:[
  1110 	self isBytes ifTrue:[
  1016             line := line , ' variableByteSubclass:#'
  1111 	    line := line , ' variableByteSubclass:#'
  1017         ] ifFalse:[
  1112 	] ifFalse:[
  1018             self isWords ifTrue:[
  1113 	    self isWords ifTrue:[
  1019                 line := line , ' variableWordSubclass:#'
  1114 		line := line , ' variableWordSubclass:#'
  1020             ] ifFalse:[
  1115 	    ] ifFalse:[
  1021                 self isLongs ifTrue:[
  1116 		self isLongs ifTrue:[
  1022                     line := line , ' variableLongSubclass:#'
  1117 		    line := line , ' variableLongSubclass:#'
  1023                 ] ifFalse:[
  1118 		] ifFalse:[
  1024                     self isFloats ifTrue:[
  1119 		    self isFloats ifTrue:[
  1025                         line := line , ' variableFloatSubclass:#'
  1120 			line := line , ' variableFloatSubclass:#'
  1026                     ] ifFalse:[
  1121 		    ] ifFalse:[
  1027                         self isDoubles ifTrue:[
  1122 			self isDoubles ifTrue:[
  1028                             line := line , ' variableDoubleSubclass:#'
  1123 			    line := line , ' variableDoubleSubclass:#'
  1029                         ] ifFalse:[
  1124 			] ifFalse:[
  1030                             line := line , ' variableSubclass:#'
  1125 			    line := line , ' variableSubclass:#'
  1031                         ]
  1126 			]
  1032                     ]
  1127 		    ]
  1033                 ]
  1128 		]
  1034             ]
  1129 	    ]
  1035         ]
  1130 	]
  1036     ] ifFalse:[
  1131     ] ifFalse:[
  1037         line := line , ' subclass:#'
  1132 	line := line , ' subclass:#'
  1038     ].
  1133     ].
  1039     line := line , name.
  1134     line := line , name.
  1040     aStream nextPutAll:line.
  1135     aStream nextPutAll:line.
  1041 
  1136 
  1042     aStream crTab. 
  1137     aStream crTab. 
  1053     aStream nextPutAll:' poolDictionaries:'''''.
  1148     aStream nextPutAll:' poolDictionaries:'''''.
  1054 
  1149 
  1055     aStream crTab.
  1150     aStream crTab.
  1056     aStream nextPutAll:' category:'.
  1151     aStream nextPutAll:' category:'.
  1057     category isNil ifTrue:[
  1152     category isNil ifTrue:[
  1058         aStream nextPutAll:''''''
  1153 	aStream nextPutAll:''''''
  1059     ] ifFalse:[
  1154     ] ifFalse:[
  1060         aStream nextPutAll:(category asString storeString)
  1155 	aStream nextPutAll:(category asString storeString)
  1061     ].
  1156     ].
  1062     aStream cr
  1157     aStream cr
  1063 !
  1158 !
  1064 
  1159 
  1065 fileOutClassInstVarDefinitionOn:aStream
  1160 fileOutClassInstVarDefinitionOn:aStream
  1071 !
  1166 !
  1072 
  1167 
  1073 fileOutCategory:aCategory on:aStream
  1168 fileOutCategory:aCategory on:aStream
  1074     "file out all methods belonging to aCategory, aString onto aStream"
  1169     "file out all methods belonging to aCategory, aString onto aStream"
  1075 
  1170 
  1076     |nMethods count sep|
  1171     |nMethods count sep source|
  1077 
  1172 
  1078     methodArray notNil ifTrue:[
  1173     methodArray notNil ifTrue:[
  1079         nMethods := 0.
  1174 	nMethods := 0.
  1080         methodArray do:[:aMethod |
  1175 	methodArray do:[:aMethod |
  1081             (aCategory = aMethod category) ifTrue:[
  1176 	    (aCategory = aMethod category) ifTrue:[
  1082                 nMethods := nMethods + 1
  1177 		nMethods := nMethods + 1
  1083             ]
  1178 	    ]
  1084         ].
  1179 	].
  1085         sep := aStream class chunkSeparator.
  1180 	sep := aStream class chunkSeparator.
  1086         (nMethods ~~ 0) ifTrue:[
  1181 	(nMethods ~~ 0) ifTrue:[
  1087             aStream nextPut:sep.
  1182 	    aStream nextPut:sep.
  1088             self printClassNameOn:aStream.
  1183 	    self printClassNameOn:aStream.
  1089             aStream nextPutAll:' methodsFor:'''.
  1184 	    aStream nextPutAll:' methodsFor:'''.
  1090             aCategory notNil ifTrue:[
  1185 	    aCategory notNil ifTrue:[
  1091                 aStream nextPutAll:aCategory
  1186 		aStream nextPutAll:aCategory
  1092             ].
  1187 	    ].
  1093             aStream nextPut:$'. aStream nextPut:sep. aStream cr.
  1188 	    aStream nextPut:$'. aStream nextPut:sep. aStream cr.
  1094             aStream cr.
  1189 	    aStream cr.
  1095             count := 1.
  1190 	    count := 1.
  1096             methodArray do:[:aMethod |
  1191 	    methodArray do:[:aMethod |
  1097                 (aCategory = aMethod category) ifTrue:[
  1192 		(aCategory = aMethod category) ifTrue:[
  1098                     aStream nextChunkPut:(aMethod source).
  1193 		    source := aMethod source.
  1099                     (count ~~ nMethods) ifTrue:[
  1194 		    source isNil ifTrue:[
  1100                         aStream cr.
  1195 			FileOutErrorSignal raiseRequestWith:'no source for method'
  1101                         aStream cr
  1196 		    ] ifFalse:[
  1102                     ].
  1197 			aStream nextChunkPut:(aMethod source).
  1103                     count := count + 1
  1198 		    ].
  1104                 ]
  1199 		    (count ~~ nMethods) ifTrue:[
  1105             ].
  1200 			aStream cr.
  1106             aStream space.
  1201 			aStream cr
  1107             aStream nextPut:sep.
  1202 		    ].
  1108             aStream cr
  1203 		    count := count + 1
  1109         ]
  1204 		]
       
  1205 	    ].
       
  1206 	    aStream space.
       
  1207 	    aStream nextPut:sep.
       
  1208 	    aStream cr
       
  1209 	]
  1110     ]
  1210     ]
  1111 !
  1211 !
  1112 
  1212 
  1113 fileOutMethod:aMethod on:aStream
  1213 fileOutMethod:aMethod on:aStream
  1114     "file out the method, aMethod onto aStream"
  1214     "file out the method, aMethod onto aStream"
  1115 
  1215 
  1116     |cat sep|
  1216     |cat sep source|
  1117 
  1217 
  1118     methodArray notNil ifTrue:[
  1218     methodArray notNil ifTrue:[
  1119         sep := aStream class chunkSeparator.
  1219 	sep := aStream class chunkSeparator.
  1120         aStream nextPut:sep.
  1220 	aStream nextPut:sep.
  1121         self printClassNameOn:aStream.
  1221 	self printClassNameOn:aStream.
  1122         aStream nextPutAll:' methodsFor:'''.
  1222 	aStream nextPutAll:' methodsFor:'''.
  1123         cat := aMethod category.
  1223 	cat := aMethod category.
  1124         cat notNil ifTrue:[
  1224 	cat notNil ifTrue:[
  1125             aStream nextPutAll:cat
  1225 	    aStream nextPutAll:cat
  1126         ].
  1226 	].
  1127         aStream nextPut:$'.
  1227 	aStream nextPut:$'.
  1128         aStream nextPut:sep.
  1228 	aStream nextPut:sep.
  1129         aStream cr.
  1229 	aStream cr.
  1130         aStream cr.
  1230 	aStream cr.
  1131         aStream nextChunkPut:(aMethod source).
  1231 	source := aMethod source.
  1132         aStream space.
  1232 	source isNil ifTrue:[
  1133         aStream nextPut:sep.
  1233 	    FileOutErrorSignal 
  1134         aStream cr
  1234 		raiseRequestWith:self
       
  1235 		errorString:('no source for method: ' ,
       
  1236 			     self name , '>>' ,
       
  1237 			     (self selectorForMethod:aMethod))
       
  1238 	] ifFalse:[
       
  1239 	    aStream nextChunkPut:(aMethod source).
       
  1240 	].
       
  1241 	aStream space.
       
  1242 	aStream nextPut:sep.
       
  1243 	aStream cr
  1135     ]
  1244     ]
  1136 !
  1245 !
  1137 
  1246 
  1138 fileOutOn:aStream
  1247 fileOutOn:aStream
  1139     "file out my definition and all methods onto aStream"
  1248     "file out my definition and all methods onto aStream"
  1143     "
  1252     "
  1144      if there is a copyright method, add a copyright
  1253      if there is a copyright method, add a copyright
  1145      at the beginning
  1254      at the beginning
  1146     "
  1255     "
  1147     (self class selectorArray includes:#copyright) ifTrue:[
  1256     (self class selectorArray includes:#copyright) ifTrue:[
  1148         "
  1257 	"
  1149          get the copyright methods source,
  1258 	 get the copyright methods source,
  1150          and insert at beginning.
  1259 	 and insert at beginning.
  1151         "
  1260 	"
  1152         copyrightText := (self class compiledMethodAt:#copyright) source.
  1261 	copyrightText := (self class compiledMethodAt:#copyright) source.
  1153         copyrightText isNil ifTrue:[
  1262 	copyrightText isNil ifTrue:[
  1154             "
  1263 	    "
  1155              no source available - trigger an error
  1264 	     no source available - trigger an error
  1156             "
  1265 	    "
  1157             self error:'no source for class ' , name , ' available. Cannot fileOut'.
  1266 	    self error:'no source for class ' , name , ' available. Cannot fileOut'.
  1158             ^ self
  1267 	    ^ self
  1159         ].
  1268 	].
  1160         copyrightText := copyrightText asCollectionOfLines.
  1269 	copyrightText := copyrightText asCollectionOfLines.
  1161         copyrightText := copyrightText copyFrom:2 to:(copyrightText size).
  1270 	copyrightText := copyrightText copyFrom:2 to:(copyrightText size).
  1162         copyrightText do:[:line | aStream nextPutAll:line. aStream cr.].
  1271 	copyrightText do:[:line | aStream nextPutAll:line. aStream cr.].
  1163     ].
  1272     ].
  1164 
  1273 
  1165     sep := aStream class chunkSeparator.
  1274     sep := aStream class chunkSeparator.
  1166     "
  1275     "
  1167      first, a timestamp
  1276      first, a timestamp
  1180     aStream cr.
  1289     aStream cr.
  1181     "
  1290     "
  1182      optional classInstanceVariables
  1291      optional classInstanceVariables
  1183     "
  1292     "
  1184     self class instanceVariableString isBlank ifFalse:[
  1293     self class instanceVariableString isBlank ifFalse:[
  1185         self fileOutClassInstVarDefinitionOn:aStream.
  1294 	self fileOutClassInstVarDefinitionOn:aStream.
  1186         aStream nextPut:sep. 
  1295 	aStream nextPut:sep. 
  1187         aStream cr.
  1296 	aStream cr.
  1188         aStream cr
  1297 	aStream cr
  1189     ].
  1298     ].
  1190 
  1299 
  1191     "
  1300     "
  1192      a comment - if any
  1301      a comment - if any
  1193     "
  1302     "
  1194     comment notNil ifTrue:[
  1303     comment notNil ifTrue:[
  1195         aStream nextPutAll:name.
  1304 	aStream nextPutAll:name.
  1196         aStream nextPutAll:' comment:'.
  1305 	aStream nextPutAll:' comment:'.
  1197         aStream nextPutAll:(comment storeString).
  1306 	aStream nextPutAll:(comment storeString).
  1198         aStream nextPut:sep.
  1307 	aStream nextPut:sep.
  1199         aStream cr.
  1308 	aStream cr.
  1200         aStream cr
  1309 	aStream cr
  1201     ].
  1310     ].
  1202 
  1311 
  1203     "
  1312     "
  1204      methods from all categories in metaclass
  1313      methods from all categories in metaclass
  1205     "
  1314     "
  1206     collectionOfCategories := self class categories.
  1315     collectionOfCategories := self class categories.
  1207     collectionOfCategories notNil ifTrue:[
  1316     collectionOfCategories notNil ifTrue:[
  1208         collectionOfCategories do:[:aCategory |
  1317 	collectionOfCategories do:[:aCategory |
  1209             self class fileOutCategory:aCategory on:aStream.
  1318 	    self class fileOutCategory:aCategory on:aStream.
  1210             aStream cr
  1319 	    aStream cr
  1211         ]
  1320 	]
  1212     ].
  1321     ].
  1213     "
  1322     "
  1214      methods from all categories in myself
  1323      methods from all categories in myself
  1215     "
  1324     "
  1216     collectionOfCategories := self categories.
  1325     collectionOfCategories := self categories.
  1217     collectionOfCategories notNil ifTrue:[
  1326     collectionOfCategories notNil ifTrue:[
  1218         collectionOfCategories do:[:aCategory |
  1327 	collectionOfCategories do:[:aCategory |
  1219             self fileOutCategory:aCategory on:aStream.
  1328 	    self fileOutCategory:aCategory on:aStream.
  1220             aStream cr
  1329 	    aStream cr
  1221         ]
  1330 	]
  1222     ].
  1331     ].
  1223     "
  1332     "
  1224      optionally an initialize message
  1333      optionally an initialize message
  1225     "
  1334     "
  1226     (self class implements:#initialize) ifTrue:[
  1335     (self class implements:#initialize) ifTrue:[
  1227         aStream nextPutAll:(name , ' initialize').
  1336 	aStream nextPutAll:(name , ' initialize').
  1228         aStream nextPut:sep.
  1337 	aStream nextPut:sep.
  1229         aStream cr
  1338 	aStream cr
  1230     ]
  1339     ]
  1231 !
  1340 !
  1232 
  1341 
  1233 fileOutCategory:aCategory
  1342 fileOutCategory:aCategory
  1234     "create a file 'class-category.st' consisting of all methods in aCategory.
  1343     "create a file 'class-category.st' consisting of all methods in aCategory.
  1242 
  1351 
  1243     "
  1352     "
  1244      this test allows a smalltalk to be built without Projects/ChangeSets
  1353      this test allows a smalltalk to be built without Projects/ChangeSets
  1245     "
  1354     "
  1246     Project notNil ifTrue:[
  1355     Project notNil ifTrue:[
  1247         fileName := Project currentProjectDirectory , fileName.
  1356 	fileName := Project currentProjectDirectory , fileName.
       
  1357     ].
       
  1358 
       
  1359     "
       
  1360      if file exists, save original in a .sav file
       
  1361     "
       
  1362     fileName asFilename exists ifTrue:[
       
  1363 	fileName asFilename copyTo:(fileName , '.sav')
  1248     ].
  1364     ].
  1249     aStream := FileStream newFileNamed:fileName.
  1365     aStream := FileStream newFileNamed:fileName.
       
  1366     aStream isNil ifTrue:[
       
  1367 	^ FileOutErrorSignal raiseRequestWith:fileName
       
  1368 				  errorString:('cannot create file:', fileName)
       
  1369     ].
  1250     self fileOutCategory:aCategory on:aStream.
  1370     self fileOutCategory:aCategory on:aStream.
  1251     aStream close
  1371     aStream close
  1252 !
  1372 !
  1253 
  1373 
  1254 fileOutMethod:aMethod
  1374 fileOutMethod:aMethod
  1258 
  1378 
  1259     |aStream fileName selector|
  1379     |aStream fileName selector|
  1260 
  1380 
  1261     selector := self selectorForMethod:aMethod.
  1381     selector := self selectorForMethod:aMethod.
  1262     selector notNil ifTrue:[
  1382     selector notNil ifTrue:[
  1263         fileName := name , '-' , selector, '.st'.
  1383 	fileName := name , '-' , selector, '.st'.
  1264         fileName replaceAll:$: by:$_.
  1384 	fileName replaceAll:$: by:$_.
  1265         "
  1385 	"
  1266          this test allows a smalltalk to be built without Projects/ChangeSets
  1386 	 this test allows a smalltalk to be built without Projects/ChangeSets
  1267         "
  1387 	"
  1268         Project notNil ifTrue:[
  1388 	Project notNil ifTrue:[
  1269             fileName := Project currentProjectDirectory , fileName.
  1389 	    fileName := Project currentProjectDirectory , fileName.
  1270         ].
  1390 	].
  1271         aStream := FileStream newFileNamed:fileName.
  1391 
  1272         self fileOutMethod:aMethod on:aStream.
  1392 	"
  1273         aStream close
  1393 	 if file exists, save original in a .sav file
       
  1394 	"
       
  1395 	fileName asFilename exists ifTrue:[
       
  1396 	    fileName asFilename copyTo:(fileName , '.sav')
       
  1397 	].
       
  1398 	aStream := FileStream newFileNamed:fileName.
       
  1399 	aStream isNil ifTrue:[
       
  1400 	    ^ FileOutErrorSignal raiseRequestWith:fileName
       
  1401 				      errorString:('cannot create file:', fileName)
       
  1402 	].
       
  1403 	self fileOutMethod:aMethod on:aStream.
       
  1404 	aStream close
  1274     ]
  1405     ]
  1275 !
  1406 !
  1276 
  1407 
  1277 fileOut
  1408 fileOut
  1278     "create a file 'class.st' consisting of all methods in myself.
  1409     "create a file 'class.st' consisting of all methods in myself.
  1279      If the current project is not nil, create the file in the projects
  1410      If the current project is not nil, create the file in the projects
  1280      directory."
  1411      directory. Care is taken, to not clobber any existing file in
  1281 
  1412      case of errors (for example: disk full). Also, since the classes
  1282     |aStream fileName|
  1413      methods need a valid sourcefile, the current sourceFile cannot be rewritten,
  1283 
  1414      but must be kept around until the fileOut is finished."
  1284     fileName := (Smalltalk fileNameForClass:self name) , '.st'.
  1415 
       
  1416     |aStream baseName dirName fileName newFileName needRename|
       
  1417 
       
  1418     baseName := (Smalltalk fileNameForClass:self name).
       
  1419     fileName := baseName , '.st'.
  1285     "
  1420     "
  1286      this test allows a smalltalk to be built without Projects/ChangeSets
  1421      this test allows a smalltalk to be built without Projects/ChangeSets
  1287     "
  1422     "
  1288     Project notNil ifTrue:[
  1423     Project notNil ifTrue:[
  1289         fileName := Project currentProjectDirectory , fileName.
  1424 	dirName := Project currentProjectDirectory
  1290     ].
  1425     ] ifFalse:[
  1291     aStream := FileStream newFileNamed:fileName.
  1426 	dirName := ''
       
  1427     ].
       
  1428     fileName := dirName , fileName.
       
  1429     "
       
  1430      if file exists, copy the existing to a .sav-file,
       
  1431      create new file in a .new-file,
       
  1432      and, if that worked rename afterwards ...
       
  1433     "
       
  1434     fileName asFilename exists ifTrue:[
       
  1435 	fileName asFilename copyTo:('/tmp/' , baseName , '.sav').
       
  1436 	newFileName := dirName , baseName , '.new'.
       
  1437 	needRename := true
       
  1438     ] ifFalse:[
       
  1439 	newFileName := fileName.
       
  1440 	needRename := false
       
  1441     ].
       
  1442 
       
  1443     aStream := FileStream newFileNamed:newFileName.
  1292     aStream isNil ifTrue:[
  1444     aStream isNil ifTrue:[
  1293         ^ self error:('cannot create source file:', fileName)
  1445 	^ FileOutErrorSignal raiseRequestWith:newFileName
       
  1446 				  errorString:('cannot create file:', newFileName)
  1294     ].
  1447     ].
  1295     self fileOutOn:aStream.
  1448     self fileOutOn:aStream.
  1296     aStream close
  1449     aStream close.
       
  1450 
       
  1451     "
       
  1452      finally, replace the old-file
       
  1453      be careful, if the old one is a symbolic link; in this case,
       
  1454      we have to do a copy ...
       
  1455     "
       
  1456     needRename ifTrue:[
       
  1457 	newFileName asFilename copyTo:fileName.
       
  1458 	newFileName asFilename delete
       
  1459     ].
  1297 !
  1460 !
  1298 
  1461 
  1299 fileOutIn:aFileDirectory
  1462 fileOutIn:aFileDirectory
  1300     "create a file 'class.st' consisting of all methods in self in
  1463     "create a file 'class.st' consisting of all methods in self in
  1301      directory aFileDirectory (ignoring any directory setting in
  1464      directory aFileDirectory (ignoring any directory setting in
  1304     |aStream fileName|
  1467     |aStream fileName|
  1305 
  1468 
  1306     fileName := (Smalltalk fileNameForClass:self name) , '.st'.
  1469     fileName := (Smalltalk fileNameForClass:self name) , '.st'.
  1307     aStream := FileStream newFileNamed:fileName in:aFileDirectory.
  1470     aStream := FileStream newFileNamed:fileName in:aFileDirectory.
  1308     aStream isNil ifTrue:[
  1471     aStream isNil ifTrue:[
  1309         ^ self error:('cannot create source file:', fileName)
  1472 	^ self error:('cannot create source file:', fileName)
  1310     ].
  1473     ].
  1311     self fileOutOn:aStream.
  1474     self fileOutOn:aStream.
  1312     aStream close
  1475     aStream close
  1313 ! !
  1476 ! !
  1314 
  1477 
  1315 !Class methodsFor:'obsolete binary fileOut'!
       
  1316 
       
  1317 XXbinaryFileOutMethodsOn:aStream
       
  1318     "binary file out all methods onto aStream"
       
  1319 
       
  1320     |temporaryMethod index|
       
  1321 
       
  1322     methodArray notNil ifTrue:[
       
  1323         aStream nextPut:$!!.
       
  1324         self printClassNameOn:aStream.
       
  1325         aStream nextPutAll:' binaryMethods'.
       
  1326         aStream nextPut:$!!.
       
  1327         aStream cr.
       
  1328         index := 1.
       
  1329         methodArray do:[:aMethod |
       
  1330             (selectorArray at:index) storeOn:aStream.
       
  1331             aStream nextPut:$!!.
       
  1332 
       
  1333             aMethod byteCode isNil ifTrue:[
       
  1334                 temporaryMethod := self compiler compile:(aMethod source)
       
  1335                                                 forClass:self
       
  1336                                               inCategory:(aMethod category)
       
  1337                                                notifying:nil
       
  1338                                                  install:false.
       
  1339                 temporaryMethod binaryFileOutOn:aStream
       
  1340             ] ifFalse:[
       
  1341                 aMethod binaryFileOutOn:aStream
       
  1342             ].
       
  1343             aStream cr.
       
  1344             index := index + 1
       
  1345         ].
       
  1346         aStream nextPut:$!!.
       
  1347         aStream cr
       
  1348     ]
       
  1349 !
       
  1350 
       
  1351 XXbinaryFileOutOn:aStream
       
  1352     "file out all methods onto aStream"
       
  1353 
       
  1354     aStream nextPut:$'.
       
  1355     aStream nextPutAll:('From Smalltalk/X, Version:'
       
  1356                         , (Smalltalk versionString)
       
  1357                         , ' on ').
       
  1358     aStream nextPutAll:(Date today printString , ' at ' , Time now printString).
       
  1359     aStream nextPut:$'.
       
  1360     aStream nextPut:$!!.
       
  1361     aStream cr.
       
  1362     self fileOutDefinitionOn:aStream.
       
  1363     aStream nextPut:$!!. 
       
  1364     aStream cr.
       
  1365     comment notNil ifTrue:[
       
  1366         aStream nextPutAll:name.
       
  1367         aStream nextPutAll:' comment:'.
       
  1368         aStream nextPutAll:(comment storeString).
       
  1369         aStream nextPut:$!!.
       
  1370         aStream cr
       
  1371     ].
       
  1372     self class binaryFileOutMethodsOn:aStream.
       
  1373     self binaryFileOutMethodsOn:aStream.
       
  1374     (self class implements:#initialize) ifTrue:[
       
  1375         aStream nextPutAll:(name , ' initialize').
       
  1376         aStream nextPut:$!!. 
       
  1377         aStream cr
       
  1378     ]
       
  1379 !
       
  1380 
       
  1381 XXbinaryFileOut
       
  1382     "create a file 'class.sb' consisting of all methods in myself.
       
  1383      If the current project is not nil, create the file in the projects
       
  1384      directory."
       
  1385 
       
  1386     |aStream fileName|
       
  1387 
       
  1388     fileName := (Smalltalk fileNameForClass:self name) , '.sb'.
       
  1389     Project notNil ifTrue:[
       
  1390         fileName := Project currentProjectDirectory , fileName.
       
  1391     ].
       
  1392     aStream := FileStream newFileNamed:fileName.
       
  1393     aStream isNil ifTrue:[
       
  1394         ^ self error:('cannot create class file:', fileName)
       
  1395     ].
       
  1396     self binaryFileOutOn:aStream.
       
  1397     aStream close
       
  1398 ! !
       
  1399 
       
  1400 !Class methodsFor:'printOut'!
  1478 !Class methodsFor:'printOut'!
  1401 
  1479 
  1402 printClassNameOn:aStream
  1480 printClassNameOn:aStream
  1403     "helper for fileOut - print my name if I am not a Metaclass;
  1481     "helper for fileOut - print my name if I am not a Metaclass;
  1404      otherwise my name without -class followed by space-class"
  1482      otherwise my name without -class followed by space-class"
  1405 
  1483 
  1406     self isMeta ifTrue:[
  1484     self isMeta ifTrue:[
  1407         aStream nextPutAll:(name copyTo:(name size - 5)).
  1485 	aStream nextPutAll:(name copyTo:(name size - 5)).
  1408         aStream nextPutAll:' class'
  1486 	aStream nextPutAll:' class'
  1409     ] ifFalse:[
  1487     ] ifFalse:[
  1410         name printOn:aStream
  1488 	name printOn:aStream
  1411     ]
  1489     ]
  1412 !
  1490 !
  1413 
  1491 
  1414 printNameArray:anArray on:aStream indent:indent
  1492 printNameArray:anArray on:aStream indent:indent
  1415     "print an array of strings separated by spaces; when the stream
  1493     "print an array of strings separated by spaces; when the stream
  1418 
  1496 
  1419     |thisName nextName arraySize lenMax pos mustBreak line spaces|
  1497     |thisName nextName arraySize lenMax pos mustBreak line spaces|
  1420 
  1498 
  1421     arraySize := anArray size.
  1499     arraySize := anArray size.
  1422     arraySize ~~ 0 ifTrue:[
  1500     arraySize ~~ 0 ifTrue:[
  1423         pos := indent.
  1501 	pos := indent.
  1424         lenMax := aStream lineLength.
  1502 	lenMax := aStream lineLength.
  1425         thisName := anArray at:1.
  1503 	thisName := anArray at:1.
  1426         line := ''.
  1504 	line := ''.
  1427         1 to:arraySize do:[:index |
  1505 	1 to:arraySize do:[:index |
  1428             line := line , thisName.
  1506 	    line := line , thisName.
  1429             pos := pos + thisName size.
  1507 	    pos := pos + thisName size.
  1430             (index == arraySize) ifFalse:[
  1508 	    (index == arraySize) ifFalse:[
  1431                 nextName := anArray at:(index + 1).
  1509 		nextName := anArray at:(index + 1).
  1432                 mustBreak := false.
  1510 		mustBreak := false.
  1433                 (lenMax > 0) ifTrue:[
  1511 		(lenMax > 0) ifTrue:[
  1434                     ((pos + nextName size) > lenMax) ifTrue:[
  1512 		    ((pos + nextName size) > lenMax) ifTrue:[
  1435                         mustBreak := true
  1513 			mustBreak := true
  1436                     ]
  1514 		    ]
  1437                 ].
  1515 		].
  1438                 mustBreak ifTrue:[
  1516 		mustBreak ifTrue:[
  1439                     aStream nextPutAll:line.
  1517 		    aStream nextPutAll:line.
  1440                     aStream cr.
  1518 		    aStream cr.
  1441                     spaces isNil ifTrue:[
  1519 		    spaces isNil ifTrue:[
  1442                         spaces := String new:indent
  1520 			spaces := String new:indent
  1443                     ].
  1521 		    ].
  1444                     line := spaces.
  1522 		    line := spaces.
  1445                     pos := indent
  1523 		    pos := indent
  1446                 ] ifFalse:[
  1524 		] ifFalse:[
  1447                     line := line , ' '.
  1525 		    line := line , ' '.
  1448                     pos := pos + 1
  1526 		    pos := pos + 1
  1449                 ].
  1527 		].
  1450                 thisName := nextName
  1528 		thisName := nextName
  1451             ]
  1529 	    ]
  1452         ].
  1530 	].
  1453         aStream nextPutAll:line
  1531 	aStream nextPutAll:line
  1454     ]
  1532     ]
  1455 !
  1533 !
  1456 
  1534 
  1457 printClassVarNamesOn:aStream indent:indent
  1535 printClassVarNamesOn:aStream indent:indent
  1458     "print the class variable names indented and breaking at line end"
  1536     "print the class variable names indented and breaking at line end"
  1479 
  1557 
  1480     |indent|
  1558     |indent|
  1481 
  1559 
  1482     indent := 0.
  1560     indent := 0.
  1483     (superclass notNil) ifTrue:[
  1561     (superclass notNil) ifTrue:[
  1484         indent := (superclass printHierarchyAnswerIndentOn:aStream) + 2
  1562 	indent := (superclass printHierarchyAnswerIndentOn:aStream) + 2
  1485     ].
  1563     ].
  1486     aStream spaces:indent.
  1564     aStream spaces:indent.
  1487     aStream nextPutAll:name.
  1565     aStream nextPutAll:name.
  1488     aStream nextPutAll:' ('.
  1566     aStream nextPutAll:' ('.
  1489     self printInstVarNamesOn:aStream indent:(indent + name size + 2).
  1567     self printInstVarNamesOn:aStream indent:(indent + name size + 2).
  1505     self printInstVarNamesOn:aStream indent:(indent + name size + 2).
  1583     self printInstVarNamesOn:aStream indent:(indent + name size + 2).
  1506     aStream nextPutAll:')'.
  1584     aStream nextPutAll:')'.
  1507     aStream cr.
  1585     aStream cr.
  1508 
  1586 
  1509     (self subclasses sort:[:a :b | a name < b name]) do:[:aSubclass |
  1587     (self subclasses sort:[:a :b | a name < b name]) do:[:aSubclass |
  1510         aSubclass printFullHierarchyOn:aStream indent:(indent + 2)
  1588 	aSubclass printFullHierarchyOn:aStream indent:(indent + 2)
  1511     ]
  1589     ]
  1512 
  1590 
  1513     "|printStream|
  1591     "|printStream|
  1514      printStream := Printer new.
  1592      printStream := Printer new.
  1515      Object printFullHierarchyOn:printStream indent:0.
  1593      Object printFullHierarchyOn:printStream indent:0.
  1525     aPrintStream normal.
  1603     aPrintStream normal.
  1526     aPrintStream cr. 
  1604     aPrintStream cr. 
  1527 
  1605 
  1528     aPrintStream nextPutAll:'superclass           '.
  1606     aPrintStream nextPutAll:'superclass           '.
  1529     superclass isNil ifTrue:[
  1607     superclass isNil ifTrue:[
  1530         aPrintStream nextPutAll:'Object'
  1608 	aPrintStream nextPutAll:'Object'
  1531     ] ifFalse:[
  1609     ] ifFalse:[
  1532         aPrintStream nextPutAll:(superclass name)
  1610 	aPrintStream nextPutAll:(superclass name)
  1533     ].
  1611     ].
  1534     aPrintStream cr. 
  1612     aPrintStream cr. 
  1535 
  1613 
  1536     aPrintStream nextPutAll:'instance Variables   '.
  1614     aPrintStream nextPutAll:'instance Variables   '.
  1537     self printInstVarNamesOn:aPrintStream indent:21.
  1615     self printInstVarNamesOn:aPrintStream indent:21.
  1540     aPrintStream nextPutAll:'class Variables      '.
  1618     aPrintStream nextPutAll:'class Variables      '.
  1541     self printClassVarNamesOn:aPrintStream indent:21.
  1619     self printClassVarNamesOn:aPrintStream indent:21.
  1542     aPrintStream cr.
  1620     aPrintStream cr.
  1543 
  1621 
  1544     category notNil ifTrue:[
  1622     category notNil ifTrue:[
  1545         aPrintStream nextPutAll:'category             '.
  1623 	aPrintStream nextPutAll:'category             '.
  1546         aPrintStream nextPutAll:(category printString).
  1624 	aPrintStream nextPutAll:(category printString).
  1547         aPrintStream cr
  1625 	aPrintStream cr
  1548     ].
  1626     ].
  1549 
  1627 
  1550     comment notNil ifTrue:[
  1628     comment notNil ifTrue:[
  1551         aPrintStream cr.
  1629 	aPrintStream cr.
  1552         aPrintStream nextPutAll:'comment:'.
  1630 	aPrintStream nextPutAll:'comment:'.
  1553         aPrintStream cr.
  1631 	aPrintStream cr.
  1554         aPrintStream italic.
  1632 	aPrintStream italic.
  1555         aPrintStream nextPutAll:comment.
  1633 	aPrintStream nextPutAll:comment.
  1556         aPrintStream normal.
  1634 	aPrintStream normal.
  1557         aPrintStream cr
  1635 	aPrintStream cr
  1558     ]
  1636     ]
  1559 !
  1637 !
  1560 
  1638 
  1561 printOutSourceProtocol:aString on:aPrintStream
  1639 printOutSourceProtocol:aString on:aPrintStream
  1562     "given the source in aString, print the methods message specification
  1640     "given the source in aString, print the methods message specification
  1569     (text size < 1) ifTrue:[^self].
  1647     (text size < 1) ifTrue:[^self].
  1570     aPrintStream bold.
  1648     aPrintStream bold.
  1571     aPrintStream nextPutAll:(text at:1).
  1649     aPrintStream nextPutAll:(text at:1).
  1572     aPrintStream cr.
  1650     aPrintStream cr.
  1573     (text size >= 2) ifTrue:[
  1651     (text size >= 2) ifTrue:[
  1574         aPrintStream italic.
  1652 	aPrintStream italic.
  1575         line := (text at:2).
  1653 	line := (text at:2).
  1576         nQuote := line occurrencesOf:(Character doubleQuote).
  1654 	nQuote := line occurrencesOf:(Character doubleQuote).
  1577         (nQuote == 2) ifTrue:[
  1655 	(nQuote == 2) ifTrue:[
  1578             aPrintStream nextPutAll:line.
  1656 	    aPrintStream nextPutAll:line.
  1579             aPrintStream cr
  1657 	    aPrintStream cr
  1580         ] ifFalse:[
  1658 	] ifFalse:[
  1581             (nQuote == 1) ifTrue:[
  1659 	    (nQuote == 1) ifTrue:[
  1582                 aPrintStream nextPutAll:line.
  1660 		aPrintStream nextPutAll:line.
  1583                 aPrintStream cr.
  1661 		aPrintStream cr.
  1584                 index := 3.
  1662 		index := 3.
  1585                 line := text at:index.
  1663 		line := text at:index.
  1586                 nQuote := line occurrencesOf:(Character doubleQuote).
  1664 		nQuote := line occurrencesOf:(Character doubleQuote).
  1587                 [nQuote ~~ 1] whileTrue:[
  1665 		[nQuote ~~ 1] whileTrue:[
  1588                     aPrintStream nextPutAll:line.
  1666 		    aPrintStream nextPutAll:line.
  1589                     aPrintStream cr.
  1667 		    aPrintStream cr.
  1590                     index := index + 1.
  1668 		    index := index + 1.
  1591                     line := text at:index.
  1669 		    line := text at:index.
  1592                     nQuote := line occurrencesOf:(Character doubleQuote)
  1670 		    nQuote := line occurrencesOf:(Character doubleQuote)
  1593                 ].
  1671 		].
  1594                 aPrintStream nextPutAll:(text at:index).
  1672 		aPrintStream nextPutAll:(text at:index).
  1595                 aPrintStream cr
  1673 		aPrintStream cr
  1596              ]
  1674 	     ]
  1597          ]
  1675 	 ]
  1598     ].
  1676     ].
  1599     aPrintStream normal
  1677     aPrintStream normal
  1600 !
  1678 !
  1601 
  1679 
  1602 printOutSource:aString on:aPrintStream
  1680 printOutSource:aString on:aPrintStream
  1611     aPrintStream cr.
  1689     aPrintStream cr.
  1612     inComment := false.
  1690     inComment := false.
  1613     textSize := text size.
  1691     textSize := text size.
  1614     textIndex := 2.
  1692     textIndex := 2.
  1615     [textIndex <= textSize] whileTrue:[
  1693     [textIndex <= textSize] whileTrue:[
  1616         line := text at:textIndex.
  1694 	line := text at:textIndex.
  1617         ((line occurrencesOf:Character doubleQuote) == 0) ifTrue:[
  1695 	((line occurrencesOf:Character doubleQuote) == 0) ifTrue:[
  1618             aPrintStream nextPutAll:line
  1696 	    aPrintStream nextPutAll:line
  1619         ] ifFalse:[
  1697 	] ifFalse:[
  1620             lineSize := line size.
  1698 	    lineSize := line size.
  1621             lineIndex := 1.
  1699 	    lineIndex := 1.
  1622             [lineIndex <= lineSize] whileTrue:[
  1700 	    [lineIndex <= lineSize] whileTrue:[
  1623                 aCharacter := line at:lineIndex.
  1701 		aCharacter := line at:lineIndex.
  1624                 (aCharacter == Character doubleQuote) ifTrue:[
  1702 		(aCharacter == Character doubleQuote) ifTrue:[
  1625                     inComment ifTrue:[
  1703 		    inComment ifTrue:[
  1626                         aPrintStream normal.
  1704 			aPrintStream normal.
  1627                         aPrintStream nextPut:aCharacter.
  1705 			aPrintStream nextPut:aCharacter.
  1628                         inComment := false
  1706 			inComment := false
  1629                     ] ifFalse:[
  1707 		    ] ifFalse:[
  1630                         aPrintStream nextPut:aCharacter.
  1708 			aPrintStream nextPut:aCharacter.
  1631                         aPrintStream italic.
  1709 			aPrintStream italic.
  1632                         inComment := true
  1710 			inComment := true
  1633                     ]
  1711 		    ]
  1634                 ] ifFalse:[
  1712 		] ifFalse:[
  1635                     aPrintStream nextPut:aCharacter
  1713 		    aPrintStream nextPut:aCharacter
  1636                 ].
  1714 		].
  1637                 lineIndex := lineIndex + 1
  1715 		lineIndex := lineIndex + 1
  1638             ]
  1716 	    ]
  1639         ].
  1717 	].
  1640         aPrintStream cr.
  1718 	aPrintStream cr.
  1641         textIndex := textIndex + 1
  1719 	textIndex := textIndex + 1
  1642     ]
  1720     ]
  1643 !
  1721 !
  1644     
  1722     
  1645 printOutCategory:aCategory on:aPrintStream
  1723 printOutCategory:aCategory on:aPrintStream
  1646     "print out all methods in aCategory on aPrintStream should be a PrintStream"
  1724     "print out all methods in aCategory on aPrintStream should be a PrintStream"
  1647 
  1725 
  1648     |any|
  1726     |any|
  1649     methodArray notNil ifTrue:[
  1727     methodArray notNil ifTrue:[
  1650         any := false.
  1728 	any := false.
  1651         methodArray do:[:aMethod |
  1729 	methodArray do:[:aMethod |
  1652             (aCategory = aMethod category) ifTrue:[
  1730 	    (aCategory = aMethod category) ifTrue:[
  1653                 any := true
  1731 		any := true
  1654             ]
  1732 	    ]
  1655         ].
  1733 	].
  1656         any ifTrue:[
  1734 	any ifTrue:[
  1657              aPrintStream italic.
  1735 	     aPrintStream italic.
  1658              aPrintStream nextPutAll:aCategory.
  1736 	     aPrintStream nextPutAll:aCategory.
  1659              aPrintStream normal.
  1737 	     aPrintStream normal.
  1660              aPrintStream cr.
  1738 	     aPrintStream cr.
  1661              aPrintStream cr.
  1739 	     aPrintStream cr.
  1662              methodArray do:[:aMethod |
  1740 	     methodArray do:[:aMethod |
  1663                  (aCategory = aMethod category) ifTrue:[
  1741 		 (aCategory = aMethod category) ifTrue:[
  1664                      self printOutSource:(aMethod source) on:aPrintStream.
  1742 		     self printOutSource:(aMethod source) on:aPrintStream.
  1665                      aPrintStream cr.
  1743 		     aPrintStream cr.
  1666                      aPrintStream cr
  1744 		     aPrintStream cr
  1667                  ]
  1745 		 ]
  1668              ].
  1746 	     ].
  1669              aPrintStream cr
  1747 	     aPrintStream cr
  1670          ]
  1748 	 ]
  1671     ]
  1749     ]
  1672 !
  1750 !
  1673 
  1751 
  1674 printOutOn:aPrintStream
  1752 printOutOn:aPrintStream
  1675     "print out all methods on aPrintStream which should be a printStream"
  1753     "print out all methods on aPrintStream which should be a printStream"
  1677     |collectionOfCategories|
  1755     |collectionOfCategories|
  1678     self printOutDefinitionOn:aPrintStream.
  1756     self printOutDefinitionOn:aPrintStream.
  1679     aPrintStream cr.
  1757     aPrintStream cr.
  1680     collectionOfCategories := self class categories.
  1758     collectionOfCategories := self class categories.
  1681     collectionOfCategories notNil ifTrue:[
  1759     collectionOfCategories notNil ifTrue:[
  1682         aPrintStream nextPutAll:'class protocol'.
  1760 	aPrintStream nextPutAll:'class protocol'.
  1683         aPrintStream cr. aPrintStream cr.
  1761 	aPrintStream cr. aPrintStream cr.
  1684         collectionOfCategories do:[:aCategory |
  1762 	collectionOfCategories do:[:aCategory |
  1685             self class printOutCategory:aCategory on:aPrintStream
  1763 	    self class printOutCategory:aCategory on:aPrintStream
  1686         ]
  1764 	]
  1687     ].
  1765     ].
  1688     collectionOfCategories := self categories.
  1766     collectionOfCategories := self categories.
  1689     collectionOfCategories notNil ifTrue:[
  1767     collectionOfCategories notNil ifTrue:[
  1690         aPrintStream nextPutAll:'instance protocol'.
  1768 	aPrintStream nextPutAll:'instance protocol'.
  1691         aPrintStream cr. aPrintStream cr.
  1769 	aPrintStream cr. aPrintStream cr.
  1692         collectionOfCategories do:[:aCategory |
  1770 	collectionOfCategories do:[:aCategory |
  1693             self printOutCategory:aCategory on:aPrintStream
  1771 	    self printOutCategory:aCategory on:aPrintStream
  1694         ]
  1772 	]
  1695     ]
  1773     ]
  1696 !
  1774 !
  1697 
  1775 
  1698 printOutCategoryProtocol:aCategory on:aPrintStream
  1776 printOutCategoryProtocol:aCategory on:aPrintStream
  1699     |any|
  1777     |any|
  1700 
  1778 
  1701     methodArray notNil ifTrue:[
  1779     methodArray notNil ifTrue:[
  1702         any := false.
  1780 	any := false.
  1703         methodArray do:[:aMethod |
  1781 	methodArray do:[:aMethod |
  1704             (aCategory = aMethod category) ifTrue:[
  1782 	    (aCategory = aMethod category) ifTrue:[
  1705                 any := true
  1783 		any := true
  1706             ]
  1784 	    ]
  1707         ].
  1785 	].
  1708         any ifTrue:[
  1786 	any ifTrue:[
  1709             aPrintStream italic.
  1787 	    aPrintStream italic.
  1710             aPrintStream nextPutAll:aCategory.
  1788 	    aPrintStream nextPutAll:aCategory.
  1711             aPrintStream normal.
  1789 	    aPrintStream normal.
  1712             aPrintStream cr.
  1790 	    aPrintStream cr.
  1713             aPrintStream cr.
  1791 	    aPrintStream cr.
  1714             methodArray do:[:aMethod |
  1792 	    methodArray do:[:aMethod |
  1715                 (aCategory = aMethod category) ifTrue:[
  1793 		(aCategory = aMethod category) ifTrue:[
  1716                     self printOutSourceProtocol:(aMethod source) 
  1794 		    self printOutSourceProtocol:(aMethod source) 
  1717                                              on:aPrintStream.
  1795 					     on:aPrintStream.
  1718                     aPrintStream cr.
  1796 		    aPrintStream cr.
  1719                     aPrintStream cr
  1797 		    aPrintStream cr
  1720                 ]
  1798 		]
  1721             ].
  1799 	    ].
  1722             aPrintStream cr
  1800 	    aPrintStream cr
  1723         ]
  1801 	]
  1724     ]
  1802     ]
  1725 !
  1803 !
  1726 
  1804 
  1727 printOutProtocolOn:aPrintStream
  1805 printOutProtocolOn:aPrintStream
  1728     |collectionOfCategories|
  1806     |collectionOfCategories|
  1729     self printOutDefinitionOn:aPrintStream.
  1807     self printOutDefinitionOn:aPrintStream.
  1730     aPrintStream cr.
  1808     aPrintStream cr.
  1731     collectionOfCategories := self class categories.
  1809     collectionOfCategories := self class categories.
  1732     collectionOfCategories notNil ifTrue:[
  1810     collectionOfCategories notNil ifTrue:[
  1733         aPrintStream nextPutAll:'class protocol'.
  1811 	aPrintStream nextPutAll:'class protocol'.
  1734         aPrintStream cr. aPrintStream cr.
  1812 	aPrintStream cr. aPrintStream cr.
  1735         collectionOfCategories do:[:aCategory |
  1813 	collectionOfCategories do:[:aCategory |
  1736             self class printOutCategoryProtocol:aCategory on:aPrintStream
  1814 	    self class printOutCategoryProtocol:aCategory on:aPrintStream
  1737         ]
  1815 	]
  1738     ].
  1816     ].
  1739     collectionOfCategories := self categories.
  1817     collectionOfCategories := self categories.
  1740     collectionOfCategories notNil ifTrue:[
  1818     collectionOfCategories notNil ifTrue:[
  1741         aPrintStream nextPutAll:'instance protocol'.
  1819 	aPrintStream nextPutAll:'instance protocol'.
  1742         aPrintStream cr. aPrintStream cr.
  1820 	aPrintStream cr. aPrintStream cr.
  1743         collectionOfCategories do:[:aCategory |
  1821 	collectionOfCategories do:[:aCategory |
  1744             self printOutCategoryProtocol:aCategory on:aPrintStream
  1822 	    self printOutCategoryProtocol:aCategory on:aPrintStream
  1745         ]
  1823 	]
  1746     ]
  1824     ]
  1747 ! !
  1825 ! !
  1748 
  1826 
  1749 !Class methodsFor: 'binary storage'!
  1827 !Class methodsFor: 'binary storage'!
  1750 
  1828 
  1751 addGlobalsTo: globalDictionary manager: manager
  1829 addGlobalsTo: globalDictionary manager: manager
  1752 "
  1830 "
  1753     classPool == nil ifFalse: [
  1831     classPool == nil ifFalse: [
  1754         classPool associationsDo: [:assoc|
  1832 	classPool associationsDo: [:assoc|
  1755             globalDictionary at: assoc put: self
  1833 	    globalDictionary at: assoc put: self
  1756         ]
  1834 	]
  1757     ]
  1835     ]
  1758 "
  1836 "
  1759 !
  1837 !
  1760 
  1838 
  1761 storeBinaryDefinitionOf: anAssociation on: stream manager: manager
  1839 storeBinaryDefinitionOf: anAssociation on: stream manager: manager