This file is indexed.

/usr/share/gnu-smalltalk/kernel/Class.st is in gnu-smalltalk-common 3.2.5-1build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
"======================================================================
|
|   Class Method Definitions
|
|
 ======================================================================"

"======================================================================
|
| Copyright 1988,92,94,95,99,2000,2001,2002,2003,2005,2006,2007,2008,2009
| Free Software Foundation, Inc.
| Written by Steve Byrne.
|
| This file is part of the GNU Smalltalk class library.
|
| The GNU Smalltalk class library is free software; you can redistribute it
| and/or modify it under the terms of the GNU Lesser General Public License
| as published by the Free Software Foundation; either version 2.1, or (at
| your option) any later version.
| 
| The GNU Smalltalk class library is distributed in the hope that it will be
| useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
| General Public License for more details.
| 
| You should have received a copy of the GNU Lesser General Public License
| along with the GNU Smalltalk class library; see the file COPYING.LIB.
| If not, write to the Free Software Foundation, 59 Temple Place - Suite
| 330, Boston, MA 02110-1301, USA.  
|
 ======================================================================"



ClassDescription subclass: Class [
    | name comment category environment classVariables sharedPools securityPolicy pragmaHandlers |
    
    <category: 'Language-Implementation'>
    <comment: 'I am THE class object.  My instances are the classes of the system.
I provide information commonly attributed to classes: namely, the
class name, class comment (you wouldn''t be reading this if it
weren''t for me), a list of the instance variables of the class, and
the class category.'>

    Class class >> allPoolDictionaries: list except: inWhite do: aBlock [
        "Invoke aBlock with each of the result of combining the list
	 of pools using a topological sort, preferring dependent to
	 prerequisite, and then left to right.  Any pool that is
	 already in inWhite will not be answered."
        <category: 'private'>
        | white grey order descend |
	list isEmpty ifTrue: [ ^self ].

	white := inWhite copy.
        grey := IdentitySet new: list size.
        order := OrderedCollection new: list size.
        descend := [:pool |
            (white includes: pool) ifFalse:
                [(grey includes: pool) ifTrue:
                     [^SystemExceptions.InvalidValue
                          signalOn: list
                          reason: 'includes circular dependency'].

                "#allSuperspaces is not available on all pools"
                grey add: pool.
                pool allSuperspaces reverseDo: descend.
                order addFirst: pool.
                white add: pool]].
        list reverseDo: descend.
        order do: aBlock
    ]

    Class class >> initialize [
	"Perform the special initialization of root classes."

	<category: 'initialize'>
	self subclassesDo: [:each | each instanceClass initializeAsRootClass]
    ]

    name [
	"Answer the class name"

	<category: 'accessing instances and variables'>
	^name
    ]

    comment [
	"Answer the class comment"

	<category: 'accessing instances and variables'>
	^comment
    ]

    comment: aString [
	"Change the class name"

	<category: 'accessing instances and variables'>
	comment := aString
    ]

    environment [
	<category: 'accessing instances and variables'>
	^environment
    ]

    environment: aNamespace [
	"Set the receiver's environment to aNamespace and recompile everything"

	<category: 'accessing instances and variables'>
	environment := aNamespace.
	(self asClass)
	    compileAll;
	    compileAllSubclasses.
	(self asMetaclass)
	    compileAll;
	    compileAllSubclasses
    ]

    category [
	"Answer the class category"

	<category: 'accessing instances and variables'>
	^category
    ]

    category: aString [
	"Change the class category to aString"

	<category: 'accessing instances and variables'>
	category := aString
    ]

    superclass: aClass [
	"Set the receiver's superclass."
	<category: 'accessing instances and variables'>
	(aClass isNil and: [self superclass notNil]) 
	    ifTrue: [self initializeAsRootClass].
	super superclass: aClass
    ]

    addClassVarName: aString [
	"Add a class variable with the given name to the class pool dictionary."

	<category: 'accessing instances and variables'>
	| sym |
	sym := aString asClassPoolKey.
	(self classPool includesKey: sym) 
	    ifFalse: [self classPool at: sym put: nil].
	^self classPool associationAt: sym
    ]

    addClassVarName: aString value: valueBlock [
	"Add a class variable with the given name to the class pool dictionary,
	 and evaluate valueBlock as its initializer."

	<category: 'accessing instances and variables'>
	^(self addClassVarName: aString)
	    value: valueBlock value;
	    yourself
    ]

    bindingFor: aString [
	"Answer the variable binding for the class variable with the
	 given name"

	<category: 'accessing instances and variables'>
	| sym |
	sym := aString asClassPoolKey.
	^self classPool associationAt: sym
    ]

    removeClassVarName: aString [
	"Removes the class variable from the class, error if not present, or
	 still in use."

	<category: 'accessing instances and variables'>
	| sym |
	sym := aString asClassPoolKey.
	(classVariables notNil and: [classVariables includesKey: sym]) 
	    ifFalse: [SystemExceptions.NotFound signalOn: aString what: 'class variable'].
	classVariables removeKey: sym.
	(self asClass)
	    compileAll;
	    compileAllSubclasses.
	(self asMetaclass)
	    compileAll;
	    compileAllSubclasses
    ]

    classPool [
	"Answer the class pool dictionary"

	<category: 'accessing instances and variables'>
	classVariables isNil 
	    ifTrue: [classVariables := BindingDictionary new environment: self].
	^classVariables
    ]

    classVarNames [
	"Answer the names of the variables in the class pool dictionary"

	<category: 'accessing instances and variables'>
	^classVariables notNil ifTrue: [classVariables keys] ifFalse: [Set new]
    ]

    allClassVarNames [
	"Answer the names of the variables in the receiver's class pool dictionary
	 and in each of the superclasses' class pool dictionaries"

	<category: 'accessing instances and variables'>
	| superVarNames |
	superVarNames := self classVarNames.
	self allSuperclasses 
	    do: [:each | superVarNames addAll: each classVarNames].
	^superVarNames
    ]

    addSharedPool: aDictionary [
	"Add the given shared pool to the list of the class' pool dictionaries"

	<category: 'accessing instances and variables'>
	sharedPools ifNil: [sharedPools := #()].
	(sharedPools includes: aDictionary) 
	    ifFalse: [sharedPools := sharedPools copyWith: aDictionary]
    ]

    removeSharedPool: aDictionary [
	"Remove the given dictionary to the list of the class' pool dictionaries"

	<category: 'accessing instances and variables'>
	sharedPools ifNil: [sharedPools := #()].
	sharedPools := sharedPools copyWithout: aDictionary
    ]

    sharedPools [
	"Return the names of the shared pools defined by the class"

	<category: 'accessing instances and variables'>
	| s |
	s := Set new.
	(sharedPools notNil and: [sharedPools notEmpty])
	    ifTrue: 
		[self environment associationsDo: 
			[:each | 
			(sharedPools identityIncludes: each value) ifTrue: [s add: each key]]].
	^s
    ]

    classPragmas [
	"Return the pragmas that are written in the file-out of this class."

	<category: 'accessing instances and variables'>
	^#(#category #comment)
    ]

    initializeAsRootClass [
	"Perform special initialization reserved to root classes."

	<category: 'accessing instances and variables'>
	self 
	    registerHandler: [:method :ann | method rewriteAsCCall: (ann arguments at: 1) for: self]
	    forPragma: #cCall:.
	self registerHandler: 
		[:method :ann | 
		method 
		    rewriteAsCCall: (ann arguments at: 1)
		    returning: (ann arguments at: 2)
		    args: (ann arguments at: 3)]
	    forPragma: #cCall:returning:args:.
	self registerHandler: 
		[:method :ann | 
		method rewriteAsAsyncCCall: (ann arguments at: 1)
		    args: (ann arguments at: 2)]
	    forPragma: #asyncCCall:args:
    ]

    initialize [
	"redefined in children (?)"

	<category: 'accessing instances and variables'>
	^self
    ]

    = aClass [
	"Returns true if the two class objects are to be considered equal."

	"^(aClass isKindOf: Class) and: [name = aClass name]"

	<category: 'testing'>
	^self == aClass
    ]

    categoriesFor: method are: categories [
	"Don't use this, it is only present to file in from IBM Smalltalk"

	<category: 'instance creation - alternative'>
	self >> method methodCategory: (categories at: 1)
    ]

    subclass: classNameString instanceVariableNames: stringInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames [
	"Don't use this, it is only present to file in from IBM Smalltalk"

	<category: 'instance creation - alternative'>
	^self 
	    subclass: classNameString
	    instanceVariableNames: stringInstVarNames
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: 'no category'
    ]

    subclass: classNameString classInstanceVariableNames: stringClassInstVarNames instanceVariableNames: stringInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames [
	"Don't use this, it is only present to file in from IBM Smalltalk"

	<category: 'instance creation - alternative'>
	^(self 
	    subclass: classNameString
	    instanceVariableNames: stringInstVarNames
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: 'no category')
	    classInstanceVariableNames: stringClassInstVarNames;
	    yourself
    ]

    variableSubclass: classNameString instanceVariableNames: stringInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames [
	"Don't use this, it is only present to file in from IBM Smalltalk"

	<category: 'instance creation - alternative'>
	^self 
	    variableSubclass: classNameString
	    instanceVariableNames: stringInstVarNames
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: 'no category'
    ]

    variableSubclass: classNameString classInstanceVariableNames: stringClassInstVarNames instanceVariableNames: stringInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames [
	"Don't use this, it is only present to file in from IBM Smalltalk"

	<category: 'instance creation - alternative'>
	^(self 
	    variableSubclass: classNameString
	    instanceVariableNames: stringInstVarNames
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: 'no category')
	    classInstanceVariableNames: stringClassInstVarNames;
	    yourself
    ]

    variableByteSubclass: classNameString classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames [
	"Don't use this, it is only present to file in from IBM Smalltalk"

	<category: 'instance creation - alternative'>
	^self 
	    variableByteSubclass: classNameString
	    instanceVariableNames: ''
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: 'no category'
    ]

    variableByteSubclass: classNameString classInstanceVariableNames: stringClassInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames [
	"Don't use this, it is only present to file in from IBM Smalltalk"

	<category: 'instance creation - alternative'>
	^(self 
	    variableByteSubclass: classNameString
	    instanceVariableNames: ''
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: 'no category')
	    classInstanceVariableNames: stringClassInstVarNames;
	    yourself
    ]

    variableLongSubclass: classNameString classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames [
	"Don't use this, it is only present to file in from IBM Smalltalk"

	<category: 'instance creation - alternative'>
	^self 
	    variable: #uint
	    subclass: classNameString
	    instanceVariableNames: ''
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: 'no category'
    ]

    variableLongSubclass: classNameString classInstanceVariableNames: stringClassInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames [
	"Don't use this, it is only present to file in from IBM Smalltalk"

	<category: 'instance creation - alternative'>
	^(self 
	    variable: #uint
	    subclass: classNameString
	    instanceVariableNames: ''
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: 'no category')
	    classInstanceVariableNames: stringClassInstVarNames;
	    yourself
    ]

    extend [
	"Redefine a version of the receiver in the current namespace.  Note:
	 this method can bite you in various ways when sent to system classes;
	 read the section on namespaces in the manual for some examples of the
	 problems you can encounter."

	<category: 'instance creation'>
	| method |
	method := self kindOfSubclass 
		    , 'instanceVariableNames:classVariableNames:poolDictionaries:category:'.
	^self perform: method asSymbol
	    withArguments: 
		{self name asSymbol.
		''.
		''.
		''.
		'Extensions'}
    ]

    inheritShape [
	"Answer whether subclasses will have by default the same shape as
	 this class.  The default is false."
	<category: 'instance creation'>
	^false
    ]

    subclass: classNameString [
	"Define a subclass of the receiver with the given name.  If the class
	 is already defined, don't modify its instance or class variables
	 but still, if necessary, recompile everything needed."

	<category: 'instance creation'>
	| meta |
	KernelInitialized ifFalse: [^Smalltalk at: classNameString].
	meta := self metaclassFor: classNameString.
	^meta 
	    name: classNameString
	    environment: Namespace current
	    subclassOf: self
    ]

    subclass: classNameString instanceVariableNames: stringInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames category: categoryNameString [
	"Define a fixed subclass of the receiver with the given name, instance
	 variables, class variables, pool dictionaries and category. If the
	 class is already defined, if necessary, recompile everything needed."

	<category: 'instance creation'>
	| meta |
	KernelInitialized 
	    ifFalse: [^(Smalltalk at: classNameString) category: categoryNameString].
	meta := self metaclassFor: classNameString.
	^meta 
	    name: classNameString
	    environment: Namespace current
	    subclassOf: self
	    instanceVariableNames: stringInstVarNames
	    shape: (self inheritShape ifTrue: [ #inherit ])
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: categoryNameString
    ]

    variableSubclass: classNameString instanceVariableNames: stringInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames category: categoryNameString [
	"Define a variable pointer subclass of the receiver with the given
	 name, instance variables, class variables, pool dictionaries and
	 category. If the class is already defined, if necessary, recompile
	 everything needed."

	<category: 'instance creation'>
	| meta |
	KernelInitialized 
	    ifFalse: [^(Smalltalk at: classNameString) category: categoryNameString].
	meta := self metaclassFor: classNameString.
	^meta 
	    name: classNameString
	    environment: Namespace current
	    subclassOf: self
	    instanceVariableNames: stringInstVarNames
	    shape: #pointer
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: categoryNameString
    ]

    variable: shape subclass: classNameString instanceVariableNames: stringInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames category: categoryNameString [
	"Define a variable subclass of the receiver with the given name,
	 shape, instance variables, class variables, pool dictionaries and
	 category. If the class is already defined, if necessary, recompile
	 everything needed.  The shape can be one of #byte #int8 #character
	 #short #ushort #int #uint #int64 #uint64 #utf32 #float #double or
	 #pointer."

	<category: 'instance creation'>
	| meta |
	KernelInitialized 
	    ifFalse: [^(Smalltalk at: classNameString) category: categoryNameString].
	meta := self metaclassFor: classNameString.
	^meta 
	    name: classNameString
	    environment: Namespace current
	    subclassOf: self
	    instanceVariableNames: stringInstVarNames
	    shape: shape
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: categoryNameString
    ]

    variableWordSubclass: classNameString instanceVariableNames: stringInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames category: categoryNameString [
	"Define a word variable subclass of the receiver with the given
	 name, instance variables (must be ''), class variables, pool
	 dictionaries and category. If the class is already defined, if
	 necessary, recompile everything needed."

	<category: 'instance creation'>
	| meta |
	KernelInitialized 
	    ifFalse: [^(Smalltalk at: classNameString) category: categoryNameString].
	meta := self metaclassFor: classNameString.
	^meta 
	    name: classNameString
	    environment: Namespace current
	    subclassOf: self
	    instanceVariableNames: stringInstVarNames
	    shape: #word
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: categoryNameString
    ]

    variableByteSubclass: classNameString instanceVariableNames: stringInstVarNames classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames category: categoryNameString [
	"Define a byte variable subclass of the receiver with the given
	 name, instance variables (must be ''), class variables, pool
	 dictionaries and category. If the class is already defined, if
	 necessary, recompile everything needed."

	<category: 'instance creation'>
	| meta |
	KernelInitialized 
	    ifFalse: [^(Smalltalk at: classNameString) category: categoryNameString].
	meta := self metaclassFor: classNameString.
	^meta 
	    name: classNameString
	    environment: Namespace current
	    subclassOf: self
	    instanceVariableNames: stringInstVarNames
	    shape: #byte
	    classVariableNames: stringOfClassVarNames
	    poolDictionaries: stringOfPoolNames
	    category: categoryNameString
    ]

    article [
	"Answer an article (`a' or `an') which is ok for the receiver's name"

	<category: 'printing'>
	| name |
	name := self name.
	^(name at: 1) isVowel ifTrue: ['an'] ifFalse: ['a']
    ]

    printOn: aStream [
	"Print a representation of the receiver on aStream"

	<category: 'printing'>
	aStream nextPutAll: (self nameIn: Smalltalk)
    ]

    storeOn: aStream [
	"Store Smalltalk code compiling to the receiver on aStream"

	<category: 'printing'>
	aStream nextPutAll: (self nameIn: Smalltalk)
    ]

    securityPolicy [
	<category: 'security'>
	^securityPolicy
    ]

    securityPolicy: aSecurityPolicy [
	<category: 'security'>
	securityPolicy := aSecurityPolicy withOwner: self
    ]

    check: aPermission [
	<category: 'security'>
	self securityPolicy isNil ifTrue: [^self isUntrusted not].
	^self securityPolicy check: aPermission
    ]

    registerHandler: aBlock forPragma: pragma [
	"While compiling methods, on every encounter of the pragma
	 with the given name, call aBlock with the CompiledMethod and
	 an array of pragma argument values."
	<category: 'pragmas'>
	pragmaHandlers isNil ifTrue: [pragmaHandlers := IdentityDictionary new].
	pragmaHandlers at: pragma put: aBlock
    ]

    pragmaHandlerFor: aSymbol [
	"Answer the (possibly inherited) registered handler for pragma
	 aSymbol, or nil if not found."
	<category: 'pragmas'>
	| handler |
	pragmaHandlers isNil 
	    ifFalse: 
		[handler := pragmaHandlers at: aSymbol ifAbsent: [nil].
		handler isNil ifFalse: [^handler]].
	self superclass isNil 
	    ifFalse: [^self superclass pragmaHandlerFor: aSymbol].
	^nil
    ]

    classInstanceVariableNames: stringClassInstVarNames [
	<category: 'private'>
	self class instanceVariableNames: stringClassInstVarNames
    ]

    setClassVariables: aDictionary [
	<category: 'private'>
	classVariables := aDictionary
    ]

    setName: aString [
	<category: 'private'>
	name := aString
    ]

    setEnvironment: aNamespace [
	<category: 'private'>
	environment := aNamespace
    ]

    setSharedPools: anArray [
	"Private - Set the receiver's shared pools to be those in anArray"

	<category: 'private'>
	sharedPools := anArray ifNil: [#()]
    ]

    sharedPoolDictionaries [
	"Return the shared pools (not the names!) defined by the class"

	<category: 'private'>
	^sharedPools ifNil: [#()]
    ]

    allSharedPoolDictionariesDo: aBlock [
        "Answer the shared pools visible from methods in the metaclass,
         in the correct search order."

        | superclassSpaces |
        self withAllSuperclassesDo: [:behavior || classSpaces |
	    aBlock value: behavior classPool.

	    "Extract the spaces of this class from superclassSpaces into
	     classSpaces..."
            superclassSpaces isNil
		ifTrue: [classSpaces := IdentitySet new.
			 behavior environment withAllSuperspacesDo: [ :each |
			     classSpaces add: each]]
		ifFalse: [classSpaces := superclassSpaces].

	    "... and visit them."
            behavior
                allLocalSharedPoolDictionariesExcept: classSpaces
                do: aBlock.

	    "Collect those spaces that have to be skipped in the search."
	    superclassSpaces := IdentitySet new.
	    behavior superclass ifNotNil: [:superclass |
		superclass environment withAllSuperspacesDo: [ :each |
		    superclassSpaces add: each ]].

	    "Now proceed with the `natural' (non-imported spaces)."
            behavior environment withAllSuperspacesDo: [:each |
                (superclassSpaces includes: each) ifFalse:
		    [aBlock value: each.
		     "also visit the namespace shared pools"
		     Class allPoolDictionaries: each sharedPoolDictionaries
			   except: classSpaces
			   do: aBlock]]]
    ]

    allLocalSharedPoolDictionariesExcept: inWhite do: aBlock [
        "Answer the result of combining the list of pools imported
	 into the receiver using a topological sort, preferring dependent
	 to prerequisite, and then left to right.  Any pool that is
	 already in inWhite will not be answered."
        <category: 'private'>
	Class allPoolDictionaries: self sharedPoolDictionaries
	      except: inWhite do: aBlock
    ]

    metaclassFor: classNameString [
	"Create a Metaclass object for the given class name. The metaclass
	 is a subclass of the receiver's metaclass"

	<category: 'private'>
	| className class |
	className := classNameString asGlobalKey.
	class := Namespace current hereAt: className ifAbsent: [nil].
        class isNamespace ifTrue: [ self error: 'Class name %1 conflicts with the name of its namespace' % {classNameString asString} ].
	^(class isNil or: [class isClass not]) 
	    ifTrue: [Metaclass subclassOf: self class]
	    ifFalse: [class class]
    ]

    asClass [
	<category: 'testing functionality'>
	^self
    ]

    isClass [
	<category: 'testing functionality'>
	^true
    ]

    fileOutDeclarationOn: aFileStream [
	"File out class definition to aFileStream.  Requires package Parser."

	<category: 'filing'>
	self notYetImplemented
    ]

    fileOutOn: aFileStream [
	"File out complete class description:  class definition, class and
	 instance methods.  Requires package Parser."

	<category: 'filing'>
	self notYetImplemented
    ]

    binaryRepresentationVersion [
	"Answer a number >= 0 which represents the current version of the
	 object's representation.  The default implementation answers
	 zero."

	<category: 'saving and loading'>
	^0
    ]

    nonVersionedInstSize [
	"Answer the number of instance variables that the class used to have
	 when objects were stored without using a VersionableObjectProxy.
	 The default implementation answers the current instSize."

	<category: 'saving and loading'>
	^self instSize
    ]

    convertFromVersion: version withFixedVariables: fixed indexedVariables: indexed for: anObjectDumper [
	"This method is called if a VersionableObjectProxy is attached to
	 a class.  It receives the version number that was stored for the
	 object (or nil if the object did not use a VersionableObjectProxy),
	 the fixed instance variables, the indexed instance variables,
	 and the ObjectDumper that has read the object.
	 The default implementation ignores the version and simply fills
	 in an instance of the receiver with the given fixed and indexed
	 instance variables (nil if the class instances are of fixed size).
	 If instance variables were removed from the class, extras are
	 ignored; if the class is now fixed and used to be indexed,
	 indexed is not used."

	<category: 'saving and loading'>
	| object |
	object := self isFixed 
		    ifTrue: [self basicNew]
		    ifFalse: [self basicNew: indexed size].
	fixed 
	    from: 1
	    to: (fixed size min: self instSize)
	    keysAndValuesDo: [:i :obj | object instVarAt: i put: obj].
	(self isFixed or: [indexed isNil]) ifTrue: [^object].
	indexed keysAndValuesDo: [:i :obj | object basicAt: i put: obj].
	^object
    ]
]