Behavior.st
changeset 13419 5023fe2f46ce
parent 13414 a366c72d27f2
child 13460 3197ced2f512
equal deleted inserted replaced
13418:99d8ad133755 13419:5023fe2f46ce
     1 "
     1 "
     2  COPYRIGHT (c) 1988 by Claus Gittinger
     2  COPYRIGHT (c) 1988 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 "{ Package: 'stx:libbasic' }"
    12 "{ Package: 'stx:libbasic' }"
    13 
    13 
    14 Object subclass:#Behavior
    14 Object subclass:#Behavior
    15         instanceVariableNames:'superclass flags methodDictionary lookupObject instSize'
    15 	instanceVariableNames:'superclass flags methodDictionary lookupObject instSize'
    16         classVariableNames:'SubclassInfo'
    16 	classVariableNames:'SubclassInfo'
    17         poolDictionaries:''
    17 	poolDictionaries:''
    18         category:'Kernel-Classes'
    18 	category:'Kernel-Classes'
    19 !
    19 !
    20 
    20 
    21 !Behavior class methodsFor:'documentation'!
    21 !Behavior class methodsFor:'documentation'!
    22 
    22 
    23 copyright
    23 copyright
    24 "
    24 "
    25  COPYRIGHT (c) 1988 by Claus Gittinger
    25  COPYRIGHT (c) 1988 by Claus Gittinger
    26               All Rights Reserved
    26 	      All Rights Reserved
    27 
    27 
    28  This software is furnished under a license and may be used
    28  This software is furnished under a license and may be used
    29  only in accordance with the terms of that license and with the
    29  only in accordance with the terms of that license and with the
    30  inclusion of the above copyright notice.   This software may not
    30  inclusion of the above copyright notice.   This software may not
    31  be provided or otherwise made available to, or used by, any
    31  be provided or otherwise made available to, or used by, any
    66     (lookup and search in these is seldom anyway, so the added benefit from using a
    66     (lookup and search in these is seldom anyway, so the added benefit from using a
    67      hashed dictionary is almost void).
    67      hashed dictionary is almost void).
    68 
    68 
    69     [Instance variables:]
    69     [Instance variables:]
    70 
    70 
    71         superclass        <Class>            the receivers superclass
    71 	superclass        <Class>            the receivers superclass
    72 
    72 
    73         methodDictionary  <MethodDictionary> inst-selectors and methods
    73 	methodDictionary  <MethodDictionary> inst-selectors and methods
    74 
    74 
    75         instSize          <SmallInteger>     the number of instance variables
    75 	instSize          <SmallInteger>     the number of instance variables
    76 
    76 
    77         flags             <SmallInteger>     special flag bits coded in a number
    77 	flags             <SmallInteger>     special flag bits coded in a number
    78                                              not for application use
    78 					     not for application use
    79 
    79 
    80     flag bits (see stc.h):
    80     flag bits (see stc.h):
    81 
    81 
    82     NOTICE: layout known by compiler and runtime system; be careful when changing
    82     NOTICE: layout known by compiler and runtime system; be careful when changing
    83 
    83 
    84     [author:]
    84     [author:]
    85         Claus Gittinger
    85 	Claus Gittinger
    86 
    86 
    87     [see also:]
    87     [see also:]
    88         Class ClassDescription Metaclass
    88 	Class ClassDescription Metaclass
    89         Method MethodDictionary
    89 	Method MethodDictionary
    90 "
    90 "
    91 !
    91 !
    92 
    92 
    93 virtualMachineRelationship
    93 virtualMachineRelationship
    94 "
    94 "
    95     Expert info follows:
    95     Expert info follows:
    96     --------------------
    96     --------------------
    97     NOTICE:
    97     NOTICE:
    98         the stuff described below may not be available on other
    98 	the stuff described below may not be available on other
    99         Smalltalk implementations; be aware that these error mechanisms
    99 	Smalltalk implementations; be aware that these error mechanisms
   100         are ST/X specials and applications using these (tricks) may
   100 	are ST/X specials and applications using these (tricks) may
   101         not be portable to other systems.
   101 	not be portable to other systems.
   102 
   102 
   103     WARNING:
   103     WARNING:
   104         do not try the examples below on (some) other smalltalk systems;
   104 	do not try the examples below on (some) other smalltalk systems;
   105         it has been reported, that some crash badly when doing this .... ;-)
   105 	it has been reported, that some crash badly when doing this .... ;-)
   106 
   106 
   107     Instances of Behavior and subclasses (i.e. in sloppy words: classes)
   107     Instances of Behavior and subclasses (i.e. in sloppy words: classes)
   108     play a special role w.r.t. the VM. Only objects whose class-slot is marked
   108     play a special role w.r.t. the VM. Only objects whose class-slot is marked
   109     as being behaviorLike (in the flag-instvar) are considered to be classLike
   109     as being behaviorLike (in the flag-instvar) are considered to be classLike
   110     and a message lookup will be done for it in the well known way.
   110     and a message lookup will be done for it in the well known way.
   130 
   130 
   131     Be aware, that the VM trusts the isBehaviorLike flag - IF it is set for some
   131     Be aware, that the VM trusts the isBehaviorLike flag - IF it is set for some
   132     object, the VM EXPECTS the object selector and methodDictionaries to be found
   132     object, the VM EXPECTS the object selector and methodDictionaries to be found
   133     at the instance positions as defined here.
   133     at the instance positions as defined here.
   134     (i.e. instanceVariables with contents and semantic corresponding to
   134     (i.e. instanceVariables with contents and semantic corresponding to
   135         superclass
   135 	superclass
   136         flags
   136 	flags
   137         methodDictionary
   137 	methodDictionary
   138      must be present and have the same instVar-index as here).
   138      must be present and have the same instVar-index as here).
   139 
   139 
   140     The VM (and the system) may crash badly, if this is not the case.
   140     The VM (and the system) may crash badly, if this is not the case.
   141 
   141 
   142     Since every class in the system derives from Behavior, the flag setting
   142     Since every class in the system derives from Behavior, the flag setting
   166     ST-programmer, though (and even most of those will never use these features).
   166     ST-programmer, though (and even most of those will never use these features).
   167 
   167 
   168 
   168 
   169     Examples (only of theoretical interest):
   169     Examples (only of theoretical interest):
   170     ----------------------------------------
   170     ----------------------------------------
   171         take away the behaviorLike-flag from a class.
   171 	take away the behaviorLike-flag from a class.
   172         -> The instances will not understand any messages, since the VM will
   172 	-> The instances will not understand any messages, since the VM will
   173            not recognize its class as being a class ...
   173 	   not recognize its class as being a class ...
   174 
   174 
   175         |newMeta notRecognizedAsClass someInstance|
   175 	|newMeta notRecognizedAsClass someInstance|
   176 
   176 
   177         newMeta := Metaclass new.
   177 	newMeta := Metaclass new.
   178         newMeta flags:0.
   178 	newMeta flags:0.
   179 
   179 
   180         notRecognizedAsClass := newMeta new.
   180 	notRecognizedAsClass := newMeta new.
   181 
   181 
   182         someInstance := notRecognizedAsClass new.
   182 	someInstance := notRecognizedAsClass new.
   183         someInstance perform:#isNil
   183 	someInstance perform:#isNil
   184 
   184 
   185 
   185 
   186     Of course, this is an exception which can be handled ...:
   186     Of course, this is an exception which can be handled ...:
   187     Example:
   187     Example:
   188 
   188 
   189         |newMeta notRecognizedAsClass someInstance|
   189 	|newMeta notRecognizedAsClass someInstance|
   190 
   190 
   191         newMeta := Metaclass new.
   191 	newMeta := Metaclass new.
   192         newMeta flags:0.
   192 	newMeta flags:0.
   193 
   193 
   194         notRecognizedAsClass := newMeta new.
   194 	notRecognizedAsClass := newMeta new.
   195 
   195 
   196         someInstance := notRecognizedAsClass new.
   196 	someInstance := notRecognizedAsClass new.
   197         Object errorSignal handle:[:ex |
   197 	Object errorSignal handle:[:ex |
   198             ex return
   198 	    ex return
   199         ] do:[
   199 	] do:[
   200             someInstance perform:#isNil
   200 	    someInstance perform:#isNil
   201         ]
   201 	]
   202 
   202 
   203 
   203 
   204     likewise, a doesNotUnderstand-notUnderstood can be handled:
   204     likewise, a doesNotUnderstand-notUnderstood can be handled:
   205     Example:
   205     Example:
   206 
   206 
   207         |newMeta funnyClass someInstance|
   207 	|newMeta funnyClass someInstance|
   208 
   208 
   209         newMeta := Metaclass new.
   209 	newMeta := Metaclass new.
   210 
   210 
   211         funnyClass := newMeta new.
   211 	funnyClass := newMeta new.
   212         funnyClass setSuperclass:nil.
   212 	funnyClass setSuperclass:nil.
   213 
   213 
   214         someInstance := funnyClass new.
   214 	someInstance := funnyClass new.
   215         Object errorSignal handle:[:ex |
   215 	Object errorSignal handle:[:ex |
   216              ex return
   216 	     ex return
   217         ] do:[
   217 	] do:[
   218             someInstance perform:#isNil
   218 	    someInstance perform:#isNil
   219         ]
   219 	]
   220 
   220 
   221 
   221 
   222     more examples, which try to trick the VM ;-):
   222     more examples, which try to trick the VM ;-):
   223         badly playing around with a classes internals ...
   223 	badly playing around with a classes internals ...
   224 
   224 
   225         |newClass someInstance|
   225 	|newClass someInstance|
   226 
   226 
   227         newClass := Class new.
   227 	newClass := Class new.
   228         newClass setSuperclass:nil.
   228 	newClass setSuperclass:nil.
   229         someInstance := newClass new.
   229 	someInstance := newClass new.
   230         someInstance inspect
   230 	someInstance inspect
   231 
   231 
   232 
   232 
   233         |newClass someInstance|
   233 	|newClass someInstance|
   234 
   234 
   235         newClass := Class new.
   235 	newClass := Class new.
   236         newClass setSuperclass:newClass.
   236 	newClass setSuperclass:newClass.
   237         someInstance := newClass new.
   237 	someInstance := newClass new.
   238         someInstance inspect
   238 	someInstance inspect
   239 
   239 
   240 
   240 
   241         |newClass someInstance|
   241 	|newClass someInstance|
   242 
   242 
   243         newClass := Class new.
   243 	newClass := Class new.
   244         newClass setSuperclass:1.
   244 	newClass setSuperclass:1.
   245         someInstance := newClass new.
   245 	someInstance := newClass new.
   246         someInstance inspect
   246 	someInstance inspect
   247 
   247 
   248 
   248 
   249     Example:
   249     Example:
   250         creating totally anonymous classes:
   250 	creating totally anonymous classes:
   251 
   251 
   252         |newClass someInstance|
   252 	|newClass someInstance|
   253 
   253 
   254         newClass := Class new.
   254 	newClass := Class new.
   255         someInstance := newClass new.
   255 	someInstance := newClass new.
   256         someInstance inspect
   256 	someInstance inspect
   257 
   257 
   258 
   258 
   259     Example:
   259     Example:
   260         creating totally anonymous metaclasses:
   260 	creating totally anonymous metaclasses:
   261 
   261 
   262         |newMeta newClass someInstance|
   262 	|newMeta newClass someInstance|
   263 
   263 
   264         newMeta := Metaclass new.
   264 	newMeta := Metaclass new.
   265         newClass := newMeta new.
   265 	newClass := newMeta new.
   266         someInstance := newClass new.
   266 	someInstance := newClass new.
   267         someInstance inspect
   267 	someInstance inspect
   268 
   268 
   269 
   269 
   270     PS: if you experiment with new behaviorLike objects, you may want
   270     PS: if you experiment with new behaviorLike objects, you may want
   271         to turn off the VM's debugPrintouts
   271 	to turn off the VM's debugPrintouts
   272         with:
   272 	with:
   273                 'Smalltalk debugPrinting:false'
   273 		'Smalltalk debugPrinting:false'
   274         and:
   274 	and:
   275                 'Smalltalk infoPrinting:false'
   275 		'Smalltalk infoPrinting:false'
   276 
   276 
   277     Meta-Object-Protocol support:
   277     Meta-Object-Protocol support:
   278     -----------------------------
   278     -----------------------------
   279     the above tricks do not affect the inline caches, and are therefore somewhat slow.
   279     the above tricks do not affect the inline caches, and are therefore somewhat slow.
   280     Another hook is the lookupObject which, if non-nil, is consulted to do the lookup
   280     Another hook is the lookupObject which, if non-nil, is consulted to do the lookup
   281     instead of the hardwired VM lookup algorithm, and provide a method as return value.
   281     instead of the hardwired VM lookup algorithm, and provide a method as return value.
   282     This method (if non-nil) will be put into the inline-and polymorph caches for speedy
   282     This method (if non-nil) will be put into the inline-and polymorph caches for speedy
   283     call the next time. If non-nil, the lookup object is sent the:
   283     call the next time. If non-nil, the lookup object is sent the:
   284             lookupMethodForSelector:aSelector 
   284 	    lookupMethodForSelector:aSelector
   285             directedTo:searchClass 
   285 	    directedTo:searchClass
   286             for:aReceiver 
   286 	    for:aReceiver
   287             withArguments:argArrayOrNil 
   287 	    withArguments:argArrayOrNil
   288             from:sendingContext
   288 	    from:sendingContext
   289     message.
   289     message.
   290     'searchClass' is the object class or any of its superclasses (for directed/super sends).
   290     'searchClass' is the object class or any of its superclasses (for directed/super sends).
   291     You can return any arbitrary method there - for example to implement multiple inheritance,
   291     You can return any arbitrary method there - for example to implement multiple inheritance,
   292     selector namespace tricks or multi-dispatch on argument types (double dispatch for a method).
   292     selector namespace tricks or multi-dispatch on argument types (double dispatch for a method).
   293     Be aware, that the returned method is cached, and the lookup is not consulted again for the
   293     Be aware, that the returned method is cached, and the lookup is not consulted again for the
   310 
   310 
   311     |newClass|
   311     |newClass|
   312 
   312 
   313     newClass := self basicNew.
   313     newClass := self basicNew.
   314     newClass
   314     newClass
   315         setSuperclass:Object
   315 	setSuperclass:Object
   316         methodDictionary:(MethodDictionary new)
   316 	methodDictionary:(MethodDictionary new)
   317         instSize:0
   317 	instSize:0
   318         flags:(self flagBehavior).
   318 	flags:(self flagBehavior).
   319     ^ newClass
   319     ^ newClass
   320 
   320 
   321     "
   321     "
   322      Behavior new               <- a new behavior
   322      Behavior new               <- a new behavior
   323      Behavior new new           <- an instance of it
   323      Behavior new new           <- an instance of it
   355      |bit|
   355      |bit|
   356      bit := Class flagBehavior.
   356      bit := Class flagBehavior.
   357 
   357 
   358      ObjectMemory allObjectsDo:[:o|
   358      ObjectMemory allObjectsDo:[:o|
   359        o isBehavior ifTrue:[
   359        o isBehavior ifTrue:[
   360          (o class flags bitTest:bit) ifFalse:[
   360 	 (o class flags bitTest:bit) ifFalse:[
   361              self halt
   361 	     self halt
   362          ].
   362 	 ].
   363        ] ifFalse:[
   363        ] ifFalse:[
   364          (o class flags bitTest:bit) ifTrue:[
   364 	 (o class flags bitTest:bit) ifTrue:[
   365              self halt
   365 	     self halt
   366          ].
   366 	 ].
   367        ].
   367        ].
   368        o class isBehavior ifFalse:[
   368        o class isBehavior ifFalse:[
   369          self halt
   369 	 self halt
   370        ] ifTrue:[
   370        ] ifTrue:[
   371          (o class class flags bitTest:bit) ifFalse:[
   371 	 (o class class flags bitTest:bit) ifFalse:[
   372              self halt
   372 	     self halt
   373          ]
   373 	 ]
   374        ]
   374        ]
   375      ]
   375      ]
   376     "
   376     "
   377 !
   377 !
   378 
   378 
   504 !
   504 !
   505 
   505 
   506 flagForSymbolic:aSymbol
   506 flagForSymbolic:aSymbol
   507     "return the flag code for indexed instances with aSymbolic type.
   507     "return the flag code for indexed instances with aSymbolic type.
   508      The argument may be one of
   508      The argument may be one of
   509         #float, #double,
   509 	#float, #double,
   510         #word, #signedWord,
   510 	#word, #signedWord,
   511         #long, #signedLong
   511 	#long, #signedLong
   512         #longLong, #signedLongLong,
   512 	#longLong, #signedLongLong,
   513         #byte
   513 	#byte
   514         #weakObjects
   514 	#weakObjects
   515      For VW compatibility, also accept:
   515      For VW compatibility, also accept:
   516         #objects, #bytes, #weak.
   516 	#objects, #bytes, #weak.
   517     "
   517     "
   518 
   518 
   519 %{   /* NOCONTEXT */
   519 %{   /* NOCONTEXT */
   520     if (aSymbol == @symbol(float)) {
   520     if (aSymbol == @symbol(float)) {
   521         RETURN ( __mkSmallInteger(FLOATARRAY) );
   521 	RETURN ( __mkSmallInteger(FLOATARRAY) );
   522     }
   522     }
   523     if (aSymbol == @symbol(double)) {
   523     if (aSymbol == @symbol(double)) {
   524         RETURN ( __mkSmallInteger(DOUBLEARRAY) );
   524 	RETURN ( __mkSmallInteger(DOUBLEARRAY) );
   525     }
   525     }
   526     if (aSymbol == @symbol(long)) {
   526     if (aSymbol == @symbol(long)) {
   527         RETURN ( __mkSmallInteger(LONGARRAY) );
   527 	RETURN ( __mkSmallInteger(LONGARRAY) );
   528     }
   528     }
   529     if (aSymbol == @symbol(longLong)) {
   529     if (aSymbol == @symbol(longLong)) {
   530         RETURN ( __mkSmallInteger(LONGLONGARRAY) );
   530 	RETURN ( __mkSmallInteger(LONGLONGARRAY) );
   531     }
   531     }
   532     if (aSymbol == @symbol(word)) {
   532     if (aSymbol == @symbol(word)) {
   533         RETURN ( __mkSmallInteger(WORDARRAY) );
   533 	RETURN ( __mkSmallInteger(WORDARRAY) );
   534     }
   534     }
   535     if (aSymbol == @symbol(signedWord)) {
   535     if (aSymbol == @symbol(signedWord)) {
   536         RETURN ( __mkSmallInteger(SWORDARRAY) );
   536 	RETURN ( __mkSmallInteger(SWORDARRAY) );
   537     }
   537     }
   538     if (aSymbol == @symbol(signedLong)) {
   538     if (aSymbol == @symbol(signedLong)) {
   539         RETURN ( __mkSmallInteger(SLONGARRAY) );
   539 	RETURN ( __mkSmallInteger(SLONGARRAY) );
   540     }
   540     }
   541     if (aSymbol == @symbol(signedLongLong)) {
   541     if (aSymbol == @symbol(signedLongLong)) {
   542         RETURN ( __mkSmallInteger(SLONGLONGARRAY) );
   542 	RETURN ( __mkSmallInteger(SLONGLONGARRAY) );
   543     }
   543     }
   544     if ((aSymbol == @symbol(byte)) || (aSymbol == @symbol(bytes))) {
   544     if ((aSymbol == @symbol(byte)) || (aSymbol == @symbol(bytes))) {
   545         RETURN ( __mkSmallInteger(BYTEARRAY) );
   545 	RETURN ( __mkSmallInteger(BYTEARRAY) );
   546     }
   546     }
   547     if (aSymbol == @symbol(objects)) {
   547     if (aSymbol == @symbol(objects)) {
   548         RETURN ( __mkSmallInteger(POINTERARRAY) );
   548 	RETURN ( __mkSmallInteger(POINTERARRAY) );
   549     }
   549     }
   550     if ((aSymbol == @symbol(weakObjects)) || (aSymbol == @symbol(weak))) {
   550     if ((aSymbol == @symbol(weakObjects)) || (aSymbol == @symbol(weak))) {
   551         RETURN ( __mkSmallInteger(WKPOINTERARRAY) );
   551 	RETURN ( __mkSmallInteger(WKPOINTERARRAY) );
   552     }
   552     }
   553 %}.
   553 %}.
   554     ^ 0         "/ not indexed
   554     ^ 0         "/ not indexed
   555 
   555 
   556     "Modified: / 07-06-2007 / 11:57:44 / cg"
   556     "Modified: / 07-06-2007 / 11:57:44 / cg"
   805 
   805 
   806     |remaining classesInLoadOrder|
   806     |remaining classesInLoadOrder|
   807 
   807 
   808     "private classes are not loaded directly, so ignore them"
   808     "private classes are not loaded directly, so ignore them"
   809     remaining := someClasses asIdentitySet reject:[:eachClass| eachClass isPrivate].
   809     remaining := someClasses asIdentitySet reject:[:eachClass| eachClass isPrivate].
   810     "JV-2011-05-05: Sort the classes by name to get more stable order. 
   810     "JV-2011-05-05: Sort the classes by name to get more stable order.
   811      This stabilizes order of classes in generated build files and
   811      This stabilizes order of classes in generated build files and
   812      makes text-based diffing/merging easier for both human beings
   812      makes text-based diffing/merging easier for both human beings
   813      and version control systems"
   813      and version control systems"
   814     remaining := remaining asOrderedCollection sort:[:a :b|a name < b name].
   814     remaining := remaining asOrderedCollection sort:[:a :b|a name < b name].
   815     classesInLoadOrder := OrderedCollection new:(remaining size).
   815     classesInLoadOrder := OrderedCollection new:(remaining size).
   816 
   816 
   817     [remaining notEmpty] whileTrue:[
   817     [remaining notEmpty] whileTrue:[
   818         |thoseWithOtherSuperclasses thoseWhichCanBeLoadedNow|
   818 	|thoseWithOtherSuperclasses thoseWhichCanBeLoadedNow|
   819 
   819 
   820         "find the next class(es) to be loaded.
   820 	"find the next class(es) to be loaded.
   821          Consider first:
   821 	 Consider first:
   822             all those, which do not have a superclass in the remaining set.
   822 	    all those, which do not have a superclass in the remaining set.
   823             and which do not use a shared pool defined in the remaining set"
   823 	    and which do not use a shared pool defined in the remaining set"
   824 
   824 
   825         thoseWithOtherSuperclasses :=
   825 	thoseWithOtherSuperclasses :=
   826             remaining
   826 	    remaining
   827                 reject:[:eachClass |
   827 		reject:[:eachClass |
   828                     (remaining includes:eachClass superclass)
   828 		    (remaining includes:eachClass superclass)
   829                     or:[eachClass sharedPoolNames contains:[:eachPoolSymbol|
   829 		    or:[eachClass sharedPoolNames contains:[:eachPoolSymbol|
   830                             remaining contains:[:eachRemainingClass| eachPoolSymbol = eachRemainingClass name]
   830 			    remaining contains:[:eachRemainingClass| eachPoolSymbol = eachRemainingClass name]
   831                         ]
   831 			]
   832                     ].
   832 		    ].
   833                 ].
   833 		].
   834 
   834 
   835         "second: the subset with all those having no private classes,
   835 	"second: the subset with all those having no private classes,
   836                  or having private classes, whose superclasses are NOT in the remaining set"
   836 		 or having private classes, whose superclasses are NOT in the remaining set"
   837 
   837 
   838         thoseWhichCanBeLoadedNow :=
   838 	thoseWhichCanBeLoadedNow :=
   839             thoseWithOtherSuperclasses
   839 	    thoseWithOtherSuperclasses
   840                 reject:[:eachClass |
   840 		reject:[:eachClass |
   841                     eachClass allPrivateClasses contains:[:eachPrivateClass| |superClassesOwner|
   841 		    eachClass allPrivateClasses contains:[:eachPrivateClass| |superClassesOwner|
   842                         superClassesOwner := eachPrivateClass superclass.
   842 			superClassesOwner := eachPrivateClass superclass.
   843                         "take care of classes inheriting from nil or ProtoObject"
   843 			"take care of classes inheriting from nil or ProtoObject"
   844                         superClassesOwner isBehavior ifTrue:[
   844 			superClassesOwner isBehavior ifTrue:[
   845                             superClassesOwner := superClassesOwner owningClassOrYourself.
   845 			    superClassesOwner := superClassesOwner owningClassOrYourself.
   846                         ].
   846 			].
   847                         superClassesOwner ~~ eachClass
   847 			superClassesOwner ~~ eachClass
   848                         and:[remaining includes:superClassesOwner]
   848 			and:[remaining includes:superClassesOwner]
   849                     ].
   849 		    ].
   850                 ].
   850 		].
   851 
   851 
   852         thoseWhichCanBeLoadedNow isEmpty ifTrue:[
   852 	thoseWhichCanBeLoadedNow isEmpty ifTrue:[
   853             thoseWithOtherSuperclasses isEmpty ifTrue:[
   853 	    thoseWithOtherSuperclasses isEmpty ifTrue:[
   854                 "this does not normally happen"
   854 		"this does not normally happen"
   855                 self error:'superclass order is cyclic'.
   855 		self error:'superclass order is cyclic'.
   856             ] ifFalse:[
   856 	    ] ifFalse:[
   857                 "no class found, that may be loaded - maybe there is a cyclic
   857 		"no class found, that may be loaded - maybe there is a cyclic
   858                  dependency involving private classes.
   858 		 dependency involving private classes.
   859                  If you proceed here, private class dependencies are ignored
   859 		 If you proceed here, private class dependencies are ignored
   860                  for this pass"
   860 		 for this pass"
   861                 self error:'load order is cyclic (care for private classes)' mayProceed:true.
   861 		self error:'load order is cyclic (care for private classes)' mayProceed:true.
   862                 thoseWhichCanBeLoadedNow := thoseWithOtherSuperclasses.
   862 		thoseWhichCanBeLoadedNow := thoseWithOtherSuperclasses.
   863             ].
   863 	    ].
   864         ].
   864 	].
   865         remaining removeAllFoundIn:thoseWhichCanBeLoadedNow.
   865 	remaining removeAllFoundIn:thoseWhichCanBeLoadedNow.
   866         classesInLoadOrder addAll:(thoseWhichCanBeLoadedNow asArray sort:[:a :b | a name < b name]).
   866 	classesInLoadOrder addAll:(thoseWhichCanBeLoadedNow asArray sort:[:a :b | a name < b name]).
   867     ].
   867     ].
   868     ^ classesInLoadOrder
   868     ^ classesInLoadOrder
   869 
   869 
   870     "
   870     "
   871      Class classesSortedByLoadOrder:(Smalltalk allClassesInPackage:'stx:libbasic')
   871      Class classesSortedByLoadOrder:(Smalltalk allClassesInPackage:'stx:libbasic')
   883      A helper for the browser, some dialogs and some refactorings"
   883      A helper for the browser, some dialogs and some refactorings"
   884 
   884 
   885     |common|
   885     |common|
   886 
   886 
   887     listOfClassesOrClassNames do:[:classOrClassName |
   887     listOfClassesOrClassNames do:[:classOrClassName |
   888         |class|
   888 	|class|
   889 
   889 
   890         class := classOrClassName isBehavior
   890 	class := classOrClassName isBehavior
   891                         ifTrue:[classOrClassName]
   891 			ifTrue:[classOrClassName]
   892                         ifFalse:[Smalltalk classNamed:classOrClassName].
   892 			ifFalse:[Smalltalk classNamed:classOrClassName].
   893 
   893 
   894         common isNil ifTrue:[
   894 	common isNil ifTrue:[
   895             common := class
   895 	    common := class
   896         ] ifFalse:[
   896 	] ifFalse:[
   897             (class isSubclassOf:common) ifTrue:[
   897 	    (class isSubclassOf:common) ifTrue:[
   898                 "keep common"
   898 		"keep common"
   899             ] ifFalse:[
   899 	    ] ifFalse:[
   900                 (common isSubclassOf:class) ifTrue:[
   900 		(common isSubclassOf:class) ifTrue:[
   901                     common := class
   901 		    common := class
   902                 ] ifFalse:[
   902 		] ifFalse:[
   903                     common := common commonSuperclass:class.
   903 		    common := common commonSuperclass:class.
   904 
   904 
   905 "/                    "walk up, checking"
   905 "/                    "walk up, checking"
   906 "/                    found := false.
   906 "/                    found := false.
   907 "/
   907 "/
   908 "/                    common allSuperclassesDo:[:sup |
   908 "/                    common allSuperclassesDo:[:sup |
   917 "/                                common := sup.
   917 "/                                common := sup.
   918 "/                                found := true.
   918 "/                                found := true.
   919 "/                            ]
   919 "/                            ]
   920 "/                        ].
   920 "/                        ].
   921 "/                    ].
   921 "/                    ].
   922                 ]
   922 		]
   923             ].
   923 	    ].
   924         ].
   924 	].
   925         (common isNil or:[common == Object]) ifTrue:[^ common].
   925 	(common isNil or:[common == Object]) ifTrue:[^ common].
   926     ].
   926     ].
   927     ^ common
   927     ^ common
   928 
   928 
   929     "
   929     "
   930      Class commonSuperclassOf:#(Array OrderedCollection Set)
   930      Class commonSuperclassOf:#(Array OrderedCollection Set)
   948 
   948 
   949 definitionSelectorFirstParts
   949 definitionSelectorFirstParts
   950     "return a collection of partial class-definition selectors"
   950     "return a collection of partial class-definition selectors"
   951 
   951 
   952     ^ #( #'subclass:'
   952     ^ #( #'subclass:'
   953          #'variableSubclass:'
   953 	 #'variableSubclass:'
   954          #'variableByteSubclass:'
   954 	 #'variableByteSubclass:'
   955          #'variableWordSubclass:'
   955 	 #'variableWordSubclass:'
   956          #'variableLongSubclass:'
   956 	 #'variableLongSubclass:'
   957          #'variableSignedWordSubclass:'
   957 	 #'variableSignedWordSubclass:'
   958          #'variableSignedLongSubclass:'
   958 	 #'variableSignedLongSubclass:'
   959          #'variableLongLongSubclass:'
   959 	 #'variableLongLongSubclass:'
   960          #'variableSignedLongLongSubclass:'
   960 	 #'variableSignedLongLongSubclass:'
   961          #'variableFloatSubclass:'
   961 	 #'variableFloatSubclass:'
   962          #'variableDoubleSubclass:'
   962 	 #'variableDoubleSubclass:'
   963       )
   963       )
   964 !
   964 !
   965 
   965 
   966 definitionSelectors
   966 definitionSelectors
   967     "return a collection class-definition selectors"
   967     "return a collection class-definition selectors"
   968 
   968 
   969     ^ #(
   969     ^ #(
   970          #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   970 	 #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   971          #'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   971 	 #'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   972          #'variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   972 	 #'variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   973          #'variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   973 	 #'variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   974          #'variableLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   974 	 #'variableLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   975          #'variableSignedWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   975 	 #'variableSignedWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   976          #'variableSignedLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   976 	 #'variableSignedLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   977          #'variableLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   977 	 #'variableLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   978          #'variableSignedLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   978 	 #'variableSignedLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   979          #'variableFloatSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   979 	 #'variableFloatSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   980          #'variableDoubleSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   980 	 #'variableDoubleSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:'
   981 
   981 
   982         "/ ST/X private subclasses
   982 	"/ ST/X private subclasses
   983 
   983 
   984          #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   984 	 #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   985          #'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   985 	 #'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   986          #'variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   986 	 #'variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   987          #'variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   987 	 #'variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   988          #'variableLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   988 	 #'variableLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   989          #'variableSignedWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   989 	 #'variableSignedWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   990          #'variableSignedLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   990 	 #'variableSignedLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   991          #'variableLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   991 	 #'variableLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   992          #'variableSignedLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   992 	 #'variableSignedLongLongSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   993          #'variableFloatSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   993 	 #'variableFloatSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   994          #'variableDoubleSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   994 	 #'variableDoubleSubclass:instanceVariableNames:classVariableNames:poolDictionaries:privateIn:'
   995 
   995 
   996         "/ ST/V subclass messages
   996 	"/ ST/V subclass messages
   997 
   997 
   998          #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:'
   998 	 #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:'
   999          #'variableByteSubclass:classVariableNames:poolDictionaries:'
   999 	 #'variableByteSubclass:classVariableNames:poolDictionaries:'
  1000          #'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:'
  1000 	 #'variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:'
  1001 
  1001 
  1002         "/ Dolphin
  1002 	"/ Dolphin
  1003          #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:classInstanceVariableNames:'
  1003 	 #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:classInstanceVariableNames:'
  1004       )
  1004       )
  1005 !
  1005 !
  1006 
  1006 
  1007 isBuiltInClass
  1007 isBuiltInClass
  1008     "return true if this class is known by the run-time-system.
  1008     "return true if this class is known by the run-time-system.
  1069 
  1069 
  1070 selectorsWithArgs:numberOfArgs
  1070 selectorsWithArgs:numberOfArgs
  1071     "Return all selectors defined in this class that take this number of arguments."
  1071     "Return all selectors defined in this class that take this number of arguments."
  1072 
  1072 
  1073     ^ self selectors
  1073     ^ self selectors
  1074         select:[:sel | sel numArgs == numberOfArgs]
  1074 	select:[:sel | sel numArgs == numberOfArgs]
  1075 
  1075 
  1076     "
  1076     "
  1077      SmallInteger selectorsWithArgs:0
  1077      SmallInteger selectorsWithArgs:0
  1078      SmallInteger selectorsWithArgs:2
  1078      SmallInteger selectorsWithArgs:2
  1079      SmallInteger selectorsWithArgs:3
  1079      SmallInteger selectorsWithArgs:3
  1150      1st argument to the methodDictionary. Flushes all caches."
  1150      1st argument to the methodDictionary. Flushes all caches."
  1151 
  1151 
  1152     |oldMethod ns selector |
  1152     |oldMethod ns selector |
  1153 
  1153 
  1154     (newSelector isMemberOf:Symbol) ifFalse:[
  1154     (newSelector isMemberOf:Symbol) ifFalse:[
  1155         self error:'invalid selector'.
  1155 	self error:'invalid selector'.
  1156     ].
  1156     ].
  1157     
  1157 
  1158     ns := newMethod nameSpace.
  1158     ns := newMethod nameSpace.
  1159     selector := (ns isNil or:[ns == self programmingLanguage])                   
  1159     selector := (ns isNil or:[ns == self programmingLanguage])
  1160                     ifTrue:[newSelector]
  1160 		    ifTrue:[newSelector]
  1161                                         ifFalse:[(':' , ns name , '::' , newSelector) asSymbol].
  1161 		    ifFalse:[(':' , ns name , '::' , newSelector) asSymbol].
  1162 
  1162 
  1163 
  1163 
  1164     oldMethod := self compiledMethodAt:selector.
  1164     oldMethod := self compiledMethodAt:selector.
  1165     oldMethod notNil ifTrue:[
  1165     oldMethod notNil ifTrue:[
  1166         newMethod restricted:(oldMethod isRestricted).
  1166 	newMethod restricted:(oldMethod isRestricted).
  1167         newMethod setPrivacy:(oldMethod privacy) flushCaches:false.
  1167 	newMethod setPrivacy:(oldMethod privacy) flushCaches:false.
  1168     ].
  1168     ].
  1169 
  1169 
  1170     (self primAddSelector:selector withMethod:newMethod) ifFalse:[^ false].
  1170     (self primAddSelector:selector withMethod:newMethod) ifFalse:[^ false].
  1171 
  1171 
  1172     selector isNameSpaceSelector ifTrue:
  1172     selector isNameSpaceSelector ifTrue:
  1177      data for myself ... (actually, in any case all that needs
  1177      data for myself ... (actually, in any case all that needs
  1178      to be flushed is info for myself and all of my subclasses)
  1178      to be flushed is info for myself and all of my subclasses)
  1179     "
  1179     "
  1180 "
  1180 "
  1181     problem: this is slower; since looking for all subclasses is (currently)
  1181     problem: this is slower; since looking for all subclasses is (currently)
  1182              a bit slow :-(
  1182 	     a bit slow :-(
  1183              We need the hasSubclasses-info bit in Behavior; now
  1183 	     We need the hasSubclasses-info bit in Behavior; now
  1184 
  1184 
  1185     self withAllSubclassesDo:[:aClass |
  1185     self withAllSubclassesDo:[:aClass |
  1186         ObjectMemory flushInlineCachesFor:aClass withArgs:nargs.
  1186 	ObjectMemory flushInlineCachesFor:aClass withArgs:nargs.
  1187         ObjectMemory flushMethodCacheFor:aClass
  1187 	ObjectMemory flushMethodCacheFor:aClass
  1188     ].
  1188     ].
  1189 "
  1189 "
  1190 
  1190 
  1191     "/
  1191     "/
  1192     "/ pass the selector AND the old method as changeArg
  1192     "/ pass the selector AND the old method as changeArg
  1231      from the methodDictionary"
  1231      from the methodDictionary"
  1232 
  1232 
  1233     |dict newDict|
  1233     |dict newDict|
  1234 
  1234 
  1235     (Smalltalk
  1235     (Smalltalk
  1236         changeRequest:#methodInClassRemoved
  1236 	changeRequest:#methodInClassRemoved
  1237         with:(Array with:self with:aSelector)) ifFalse:[
  1237 	with:(Array with:self with:aSelector)
  1238     ^ false
  1238     ) ifFalse:[
       
  1239 	^ false
  1239     ].
  1240     ].
  1240 
  1241 
  1241     dict := self methodDictionary.
  1242     dict := self methodDictionary.
  1242     newDict := dict removeKeyAndCompress:aSelector.
  1243     newDict := dict removeKeyAndCompress:aSelector.
  1243     newDict isNil ifTrue:[
  1244     newDict isNil ifTrue:[
  1275     "return the lookupObject (Jan's MetaObjectProtocol support) or nil.
  1276     "return the lookupObject (Jan's MetaObjectProtocol support) or nil.
  1276      If non-nil, no lookup is performed by the VM, instead the lookupObject
  1277      If non-nil, no lookup is performed by the VM, instead the lookupObject
  1277      has to provide a method object for message sends."
  1278      has to provide a method object for message sends."
  1278 
  1279 
  1279     | behavior lookup |
  1280     | behavior lookup |
       
  1281 
       
  1282     Lookup isNil ifTrue:[^ nil].
       
  1283 
  1280     behavior := self.
  1284     behavior := self.
  1281     [ behavior notNil ] whileTrue:
  1285     [ behavior notNil ] whileTrue:[
  1282         [lookup := behavior getLookupObject.
  1286 	lookup := behavior getLookupObject.
  1283         lookup ifNotNil: [^lookup].
  1287 	lookup notNil ifTrue: [^ lookup].
  1284         behavior := behavior superclass].
  1288 	behavior := behavior superclass
  1285 
  1289     ].
  1286     ^Lookup builtin.
  1290 
       
  1291     ^ Lookup builtin.
  1287 
  1292 
  1288     "Modified: / 26-04-2010 / 21:05:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1293     "Modified: / 26-04-2010 / 21:05:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1289 !
  1294 !
  1290 
  1295 
  1291 lookupObject: anObject
  1296 lookupObject: anObject
  1292     anObject isNil ifTrue:[^self setLookupObject: anObject].
  1297     anObject isNil ifTrue:[^self setLookupObject: anObject].
  1293 
  1298 
  1294     (anObject respondsTo: #lookupMethodForSelector:directedTo:for:withArguments:from:)
  1299     (anObject respondsTo: #lookupMethodForSelector:directedTo:for:withArguments:from:)
  1295         ifFalse:
  1300     ifFalse:[
  1296             [self error:'Lookup object does not respond to #lookupMethodForSelector:directedTo:for:withArguments:from:'].
  1301 	self error:'Lookup object does not respond to #lookupMethodForSelector:directedTo:for:withArguments:from:'
  1297     (anObject respondsTo:#superLookupObject:) 
  1302     ].
  1298         ifTrue:
  1303     (anObject respondsTo:#superLookupObject:)
  1299             [anObject superLookupObject: self lookupObject].
  1304     ifTrue:[
       
  1305 	anObject superLookupObject: self lookupObject
       
  1306     ].
  1300     self setLookupObject: anObject.
  1307     self setLookupObject: anObject.
  1301 
  1308 
  1302     "Created: / 26-04-2010 / 13:35:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1309     "Created: / 26-04-2010 / 13:35:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1303     "Modified: / 26-04-2010 / 21:05:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" 
  1310     "Modified: / 26-04-2010 / 21:05:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1304 !
  1311 !
  1305 
  1312 
  1306 methodDictionary
  1313 methodDictionary
  1307     "return the receivers method dictionary."
  1314     "return the receivers method dictionary."
  1308 
  1315 
  1314 
  1321 
  1315 methodDictionary:dict
  1322 methodDictionary:dict
  1316     "set the receivers method dictionary and flush inline caches."
  1323     "set the receivers method dictionary and flush inline caches."
  1317 
  1324 
  1318     dict isNil ifTrue:[
  1325     dict isNil ifTrue:[
  1319         self error:'attempt to set methodDictionary to nil.' mayProceed:true.
  1326 	self error:'attempt to set methodDictionary to nil.' mayProceed:true.
  1320         ^ self
  1327 	^ self
  1321     ].
  1328     ].
  1322     self setMethodDictionary:dict.
  1329     self setMethodDictionary:dict.
  1323     ObjectMemory flushCaches.
  1330     ObjectMemory flushCaches.
  1324 
  1331 
  1325     "Created: 5.6.1996 / 11:29:36 / stefan"
  1332     "Created: 5.6.1996 / 11:29:36 / stefan"
  1345      (should we return a Set ?)"
  1352      (should we return a Set ?)"
  1346 
  1353 
  1347     |md|
  1354     |md|
  1348 
  1355 
  1349     (md := self methodDictionary) isNil ifTrue:[
  1356     (md := self methodDictionary) isNil ifTrue:[
  1350         'oops - nil methodDictionary' errorPrintCR.
  1357 	'oops - nil methodDictionary' errorPrintCR.
  1351         ^ #()
  1358 	^ #()
  1352     ].
  1359     ].
  1353     ^ md keys
  1360     ^ md keys
  1354 
  1361 
  1355     "Modified: 7.6.1996 / 15:33:18 / stefan"
  1362     "Modified: 7.6.1996 / 15:33:18 / stefan"
  1356     "Modified: 12.11.1996 / 11:31:51 / cg"
  1363     "Modified: 12.11.1996 / 11:31:51 / cg"
  1406 
  1413 
  1407     ^ self class compilerClass.
  1414     ^ self class compilerClass.
  1408 !
  1415 !
  1409 
  1416 
  1410 dllPath
  1417 dllPath
  1411     "if a class contains ExternalFunctions, 
  1418     "if a class contains ExternalFunctions,
  1412      return a collection of pathNames where to find the DLLs
  1419      return a collection of pathNames where to find the DLLs
  1413      containing the external functions.
  1420      containing the external functions.
  1414 
  1421 
  1415      Do not code absolute path names here - keep them in the system settings.
  1422      Do not code absolute path names here - keep them in the system settings.
  1416      Use this if the DLL location is kept in some registry entry."
  1423      Use this if the DLL location is kept in some registry entry."
  1478     "compile code, aString for this class; on any error, notify
  1485     "compile code, aString for this class; on any error, notify
  1479      requestor, anObject with the error reason.
  1486      requestor, anObject with the error reason.
  1480      Returns the new method or nil (on failure)."
  1487      Returns the new method or nil (on failure)."
  1481 
  1488 
  1482     ^ self compilerClass
  1489     ^ self compilerClass
  1483         compile:code
  1490 	compile:code
  1484         forClass:self
  1491 	forClass:self
  1485         notifying:requestor
  1492 	notifying:requestor
  1486 
  1493 
  1487     "Modified: 13.12.1995 / 11:02:40 / cg"
  1494     "Modified: 13.12.1995 / 11:02:40 / cg"
  1488     "Created: 1.4.1997 / 23:43:43 / stefan"
  1495     "Created: 1.4.1997 / 23:43:43 / stefan"
  1489 ! !
  1496 ! !
  1490 
  1497 
  1509 
  1516 
  1510     |newInst indexed|
  1517     |newInst indexed|
  1511 
  1518 
  1512     indexed := false.
  1519     indexed := false.
  1513     aPrototype class isVariable ifTrue:[
  1520     aPrototype class isVariable ifTrue:[
  1514         self isVariable ifTrue:[
  1521 	self isVariable ifTrue:[
  1515             indexed := true.
  1522 	    indexed := true.
  1516         ].
  1523 	].
  1517         "otherwise, these are lost ..."
  1524 	"otherwise, these are lost ..."
  1518     ].
  1525     ].
  1519     indexed ifTrue:[
  1526     indexed ifTrue:[
  1520         newInst := self basicNew:aPrototype basicSize
  1527 	newInst := self basicNew:aPrototype basicSize
  1521     ] ifFalse:[
  1528     ] ifFalse:[
  1522         newInst := self basicNew
  1529 	newInst := self basicNew
  1523     ].
  1530     ].
  1524 
  1531 
  1525     newInst cloneInstanceVariablesFrom:aPrototype.
  1532     newInst cloneInstanceVariablesFrom:aPrototype.
  1526 
  1533 
  1527     ^ newInst
  1534     ^ newInst
  1528 
  1535 
  1529     "
  1536     "
  1530      Class withoutUpdatingChangesDo:[
  1537      Class withoutUpdatingChangesDo:[
  1531          Point subclass:#Point3D
  1538 	 Point subclass:#Point3D
  1532            instanceVariableNames:'z'
  1539 	   instanceVariableNames:'z'
  1533            classVariableNames:''
  1540 	   classVariableNames:''
  1534            poolDictionaries:''
  1541 	   poolDictionaries:''
  1535            category:'testing'.
  1542 	   category:'testing'.
  1536          (Point3D cloneFrom:1@2) inspect.
  1543 	 (Point3D cloneFrom:1@2) inspect.
  1537      ]
  1544      ]
  1538     "
  1545     "
  1539 
  1546 
  1540     "
  1547     "
  1541      Class withoutUpdatingChangesDo:[
  1548      Class withoutUpdatingChangesDo:[
  1542          Point variableSubclass:#Point3D
  1549 	 Point variableSubclass:#Point3D
  1543            instanceVariableNames:'z'
  1550 	   instanceVariableNames:'z'
  1544            classVariableNames:''
  1551 	   classVariableNames:''
  1545            poolDictionaries:''
  1552 	   poolDictionaries:''
  1546            category:'testing'.
  1553 	   category:'testing'.
  1547          (Point3D cloneFrom:#(1 2 3)) inspect.
  1554 	 (Point3D cloneFrom:#(1 2 3)) inspect.
  1548      ]
  1555      ]
  1549     "
  1556     "
  1550 
  1557 
  1551     "
  1558     "
  1552      |someObject|
  1559      |someObject|
  1553 
  1560 
  1554      Class withoutUpdatingChangesDo:[
  1561      Class withoutUpdatingChangesDo:[
  1555          Object subclass:#TestClass1
  1562 	 Object subclass:#TestClass1
  1556            instanceVariableNames:'foo bar'
  1563 	   instanceVariableNames:'foo bar'
  1557            classVariableNames:''
  1564 	   classVariableNames:''
  1558            poolDictionaries:''
  1565 	   poolDictionaries:''
  1559            category:'testing'.
  1566 	   category:'testing'.
  1560          someObject := TestClass1 new.
  1567 	 someObject := TestClass1 new.
  1561          someObject instVarAt:1 put:'foo'; instVarAt:2 put:'bar'.
  1568 	 someObject instVarAt:1 put:'foo'; instVarAt:2 put:'bar'.
  1562          Object subclass:#TestClass2
  1569 	 Object subclass:#TestClass2
  1563            instanceVariableNames:'bar foo'
  1570 	   instanceVariableNames:'bar foo'
  1564            classVariableNames:''
  1571 	   classVariableNames:''
  1565            poolDictionaries:''
  1572 	   poolDictionaries:''
  1566            category:'testing'.
  1573 	   category:'testing'.
  1567          (TestClass2 cloneFrom:someObject) inspect.
  1574 	 (TestClass2 cloneFrom:someObject) inspect.
  1568      ]
  1575      ]
  1569     "
  1576     "
  1570 !
  1577 !
  1571 
  1578 
  1572 deepCopyUsing:aDictionary postCopySelector:postCopySelector
  1579 deepCopyUsing:aDictionary postCopySelector:postCopySelector
  1629 
  1636 
  1630 allInstancesDo:aBlock
  1637 allInstancesDo:aBlock
  1631     "evaluate aBlock for all of my instances"
  1638     "evaluate aBlock for all of my instances"
  1632 
  1639 
  1633     ObjectMemory allInstancesOf:self do:[:anObject |
  1640     ObjectMemory allInstancesOf:self do:[:anObject |
  1634         aBlock value:anObject
  1641 	aBlock value:anObject
  1635     ]
  1642     ]
  1636 
  1643 
  1637     "
  1644     "
  1638      StandardSystemView allInstancesDo:[:v | Transcript showCR:(v name)]
  1645      StandardSystemView allInstancesDo:[:v | Transcript showCR:(v name)]
  1639     "
  1646     "
  1644 
  1651 
  1645     |owner|
  1652     |owner|
  1646 
  1653 
  1647     owner := self owningClass.
  1654     owner := self owningClass.
  1648     [owner notNil] whileTrue:[
  1655     [owner notNil] whileTrue:[
  1649         aBlock value:owner.
  1656 	aBlock value:owner.
  1650         owner := owner owningClass.
  1657 	owner := owner owningClass.
  1651     ].
  1658     ].
  1652 
  1659 
  1653     "
  1660     "
  1654      Method::MethodWhoInfo allOwningclassesDo:[:c | Transcript showCR:(c name)]
  1661      Method::MethodWhoInfo allOwningclassesDo:[:c | Transcript showCR:(c name)]
  1655     "
  1662     "
  1668 
  1675 
  1669 allSubInstancesDo:aBlock
  1676 allSubInstancesDo:aBlock
  1670     "evaluate aBlock for all of my instances and all instances of subclasses"
  1677     "evaluate aBlock for all of my instances and all instances of subclasses"
  1671 
  1678 
  1672     ObjectMemory allObjectsDo:[:anObject |
  1679     ObjectMemory allObjectsDo:[:anObject |
  1673         (anObject isKindOf:self) ifTrue:[
  1680 	(anObject isKindOf:self) ifTrue:[
  1674             aBlock value:anObject
  1681 	    aBlock value:anObject
  1675         ]
  1682 	]
  1676     ]
  1683     ]
  1677 
  1684 
  1678     "
  1685     "
  1679      StandardSystemView allSubInstancesDo:[:v | Transcript showCR:(v name)]
  1686      StandardSystemView allSubInstancesDo:[:v | Transcript showCR:(v name)]
  1680     "
  1687     "
  1682 
  1689 
  1683 allSubclassesDo:aBlock
  1690 allSubclassesDo:aBlock
  1684     "evaluate aBlock for all of my subclasses.
  1691     "evaluate aBlock for all of my subclasses.
  1685      There is no specific order, in which the entries are enumerated.
  1692      There is no specific order, in which the entries are enumerated.
  1686      Warning:
  1693      Warning:
  1687         This will only enumerate globally known classes - for anonymous
  1694 	This will only enumerate globally known classes - for anonymous
  1688         behaviors, you have to walk over all instances of Behavior."
  1695 	behaviors, you have to walk over all instances of Behavior."
  1689 
  1696 
  1690     self allSubclassesInOrderDo:aBlock
  1697     self allSubclassesInOrderDo:aBlock
  1691 
  1698 
  1692 "/    self isMeta ifTrue:[
  1699 "/    self isMeta ifTrue:[
  1693 "/        "/ metaclasses are not found via Smalltalk allClassesDo:
  1700 "/        "/ metaclasses are not found via Smalltalk allClassesDo:
  1713 
  1720 
  1714 allSubclassesInOrderDo:aBlock
  1721 allSubclassesInOrderDo:aBlock
  1715     "evaluate aBlock for all of my subclasses.
  1722     "evaluate aBlock for all of my subclasses.
  1716      There is no specific order, in which the entries are enumerated.
  1723      There is no specific order, in which the entries are enumerated.
  1717      Warning:
  1724      Warning:
  1718         This will only enumerate globally known classes - for anonymous
  1725 	This will only enumerate globally known classes - for anonymous
  1719         behaviors, you have to walk over all instances of Behavior."
  1726 	behaviors, you have to walk over all instances of Behavior."
  1720 
  1727 
  1721     |meta toDo cls|
  1728     |meta toDo cls|
  1722 
  1729 
  1723     meta := self isMeta.
  1730     meta := self isMeta.
  1724 
  1731 
  1725     toDo := OrderedCollection new.
  1732     toDo := OrderedCollection new.
  1726     toDo addAll:self theNonMetaclass subclasses.
  1733     toDo addAll:self theNonMetaclass subclasses.
  1727     [toDo notEmpty] whileTrue:[
  1734     [toDo notEmpty] whileTrue:[
  1728         cls := toDo removeFirst.
  1735 	cls := toDo removeFirst.
  1729         toDo addAll:cls subclasses.
  1736 	toDo addAll:cls subclasses.
  1730         meta ifTrue:[
  1737 	meta ifTrue:[
  1731             aBlock value:cls class.
  1738 	    aBlock value:cls class.
  1732         ] ifFalse:[
  1739 	] ifFalse:[
  1733             aBlock value:cls.
  1740 	    aBlock value:cls.
  1734         ]
  1741 	]
  1735     ].
  1742     ].
  1736 
  1743 
  1737 "/    self isMeta ifTrue:[
  1744 "/    self isMeta ifTrue:[
  1738 "/        "/ metaclasses are not found via Smalltalk allClassesDo:
  1745 "/        "/ metaclasses are not found via Smalltalk allClassesDo:
  1739 "/        "/ here, walk over classes and enumerate corresponding metas.
  1746 "/        "/ here, walk over classes and enumerate corresponding metas.
  1761 
  1768 
  1762     |theClass|
  1769     |theClass|
  1763 
  1770 
  1764     theClass := self superclass.
  1771     theClass := self superclass.
  1765     [theClass notNil] whileTrue:[
  1772     [theClass notNil] whileTrue:[
  1766         aBlock value:theClass.
  1773 	aBlock value:theClass.
  1767         theClass := theClass superclass
  1774 	theClass := theClass superclass
  1768     ]
  1775     ]
  1769 
  1776 
  1770     "
  1777     "
  1771      String allSuperclassesDo:[:c | Transcript showCR:(c name)]
  1778      String allSuperclassesDo:[:c | Transcript showCR:(c name)]
  1772     "
  1779     "
  1819      This will only enumerate globally known classes - for anonymous
  1826      This will only enumerate globally known classes - for anonymous
  1820      behaviors, you have to walk over all instances of Behavior."
  1827      behaviors, you have to walk over all instances of Behavior."
  1821 
  1828 
  1822     "Do it the hard way. Subclasses redefine this"
  1829     "Do it the hard way. Subclasses redefine this"
  1823     Smalltalk allClassesDo:[:aClass |
  1830     Smalltalk allClassesDo:[:aClass |
  1824         (aClass superclass == self) ifTrue:[
  1831 	(aClass superclass == self) ifTrue:[
  1825             aBlock value:aClass
  1832 	    aBlock value:aClass
  1826         ]
  1833 	]
  1827     ]
  1834     ]
  1828 !
  1835 !
  1829 
  1836 
  1830 whichClassSatisfies: aBlock
  1837 whichClassSatisfies: aBlock
  1831     "return the first class along the superclass-chain, which satisfies aBlock.
  1838     "return the first class along the superclass-chain, which satisfies aBlock.
  1833 
  1840 
  1834     |cls|
  1841     |cls|
  1835 
  1842 
  1836     cls := self.
  1843     cls := self.
  1837     [cls notNil] whileTrue:[
  1844     [cls notNil] whileTrue:[
  1838         (aBlock value: cls) ifTrue: [^ cls].
  1845 	(aBlock value: cls) ifTrue: [^ cls].
  1839         cls := cls superclass.
  1846 	cls := cls superclass.
  1840     ].
  1847     ].
  1841     ^ nil
  1848     ^ nil
  1842 
  1849 
  1843     "
  1850     "
  1844      SimpleView whichClassSatisfies:[:cls | cls instanceVariableNames includes:'gc']
  1851      SimpleView whichClassSatisfies:[:cls | cls instanceVariableNames includes:'gc']
  1847 
  1854 
  1848 withAllSubclassesDo:aBlock
  1855 withAllSubclassesDo:aBlock
  1849     "evaluate aBlock for mySelf and all of my subclasses.
  1856     "evaluate aBlock for mySelf and all of my subclasses.
  1850      There is no specific order, in which the entries are enumerated.
  1857      There is no specific order, in which the entries are enumerated.
  1851      Warning:
  1858      Warning:
  1852         This will only enumerate globally known classes - for anonymous
  1859 	This will only enumerate globally known classes - for anonymous
  1853         behaviors, you have to walk over all instances of Behavior."
  1860 	behaviors, you have to walk over all instances of Behavior."
  1854 
  1861 
  1855     aBlock value:self.
  1862     aBlock value:self.
  1856     self allSubclassesDo:aBlock
  1863     self allSubclassesDo:aBlock
  1857 
  1864 
  1858     "
  1865     "
  1867     |theSuperClass|
  1874     |theSuperClass|
  1868 
  1875 
  1869     aBlock value:self.
  1876     aBlock value:self.
  1870     theSuperClass := self superclass.
  1877     theSuperClass := self superclass.
  1871     [theSuperClass notNil] whileTrue:[
  1878     [theSuperClass notNil] whileTrue:[
  1872         aBlock value:theSuperClass.
  1879 	aBlock value:theSuperClass.
  1873         theSuperClass := theSuperClass superclass
  1880 	theSuperClass := theSuperClass superclass
  1874     ].
  1881     ].
  1875 
  1882 
  1876     "
  1883     "
  1877      String withAllSuperclassesDo:[:each| Transcript showCR:each]
  1884      String withAllSuperclassesDo:[:each| Transcript showCR:each]
  1878     "
  1885     "
  1905      This is sent to a class after it
  1912      This is sent to a class after it
  1906      has been loaded into the system.
  1913      has been loaded into the system.
  1907      Statically compiled classes are initialized by the VM"
  1914      Statically compiled classes are initialized by the VM"
  1908 
  1915 
  1909     (self class includesSelector:#initialize) ifTrue:[
  1916     (self class includesSelector:#initialize) ifTrue:[
  1910         self initialize.
  1917 	self initialize.
  1911     ].
  1918     ].
  1912     self privateClassesSorted do:[:aPrivateClass |
  1919     self privateClassesSorted do:[:aPrivateClass |
  1913         aPrivateClass initializeWithAllPrivateClasses.
  1920 	aPrivateClass initializeWithAllPrivateClasses.
  1914     ].
  1921     ].
  1915 
  1922 
  1916     "Created: / 13.5.1998 / 23:33:16 / cg"
  1923     "Created: / 13.5.1998 / 23:33:16 / cg"
  1917     "Modified: / 13.5.1998 / 23:34:06 / cg"
  1924     "Modified: / 13.5.1998 / 23:34:06 / cg"
  1918 !
  1925 !
  1970      * dont argue about the goto and the arrangement below - it saves
  1977      * dont argue about the goto and the arrangement below - it saves
  1971      * an extra nil-compare and branch in the common case ...
  1978      * an extra nil-compare and branch in the common case ...
  1972      * (i.e. if no GC is needed, we fall through without a branch)
  1979      * (i.e. if no GC is needed, we fall through without a branch)
  1973      */
  1980      */
  1974     if (nextPtr < __newEndPtr) {
  1981     if (nextPtr < __newEndPtr) {
  1975         _objPtr(newobj)->o_size = instsize;
  1982 	_objPtr(newobj)->o_size = instsize;
  1976         /* o_allFlags(newobj) = 0;              */
  1983 	/* o_allFlags(newobj) = 0;              */
  1977         /* _objPtr(newobj)->o_space = __newSpace; */
  1984 	/* _objPtr(newobj)->o_space = __newSpace; */
  1978         o_setAllFlags(newobj, __newSpace);
  1985 	o_setAllFlags(newobj, __newSpace);
  1979 #ifdef __HAS_ALIGN4__
  1986 #ifdef __HAS_ALIGN4__
  1980         /*
  1987 	/*
  1981          * if the alignment is 4, we are already sat,
  1988 	 * if the alignment is 4, we are already sat,
  1982          * since a non-indexed object always has a word-aligned size.
  1989 	 * since a non-indexed object always has a word-aligned size.
  1983          */
  1990 	 */
  1984         __newNextPtr = nextPtr;
  1991 	__newNextPtr = nextPtr;
  1985 #else
  1992 #else
  1986         if (instsize & (__ALIGN__-1)) {
  1993 	if (instsize & (__ALIGN__-1)) {
  1987             __newNextPtr = (char *)newobj + (instsize & ~(__ALIGN__-1)) + __ALIGN__;
  1994 	    __newNextPtr = (char *)newobj + (instsize & ~(__ALIGN__-1)) + __ALIGN__;
  1988         } else {
  1995 	} else {
  1989             __newNextPtr = nextPtr;
  1996 	    __newNextPtr = nextPtr;
  1990         }
  1997 	}
  1991 #endif
  1998 #endif
  1992 
  1999 
  1993 ok:
  2000 ok:
  1994         __InstPtr(newobj)->o_class = self;
  2001 	__InstPtr(newobj)->o_class = self;
  1995         __qSTORE(newobj, self);
  2002 	__qSTORE(newobj, self);
  1996 
  2003 
  1997         if (nInstVars) {
  2004 	if (nInstVars) {
  1998 #if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4)
  2005 #if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4)
  1999             memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars);
  2006 	    memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars);
  2000 #else
  2007 #else
  2001             REGISTER OBJ *op;
  2008 	    REGISTER OBJ *op;
  2002 
  2009 
  2003             op = __InstPtr(newobj)->i_instvars;
  2010 	    op = __InstPtr(newobj)->i_instvars;
  2004 
  2011 
  2005             /*
  2012 	    /*
  2006              * knowing that nil is 0
  2013 	     * knowing that nil is 0
  2007              */
  2014 	     */
  2008 # if defined(FAST_OBJECT_MEMSET_DOUBLES_UNROLLED)
  2015 # if defined(FAST_OBJECT_MEMSET_DOUBLES_UNROLLED)
  2009             if (nInstVars > 8) {
  2016 	    if (nInstVars > 8) {
  2010                 *op++ = nil;    /* for alignment */
  2017 		*op++ = nil;    /* for alignment */
  2011                 nInstVars--;
  2018 		nInstVars--;
  2012                 while (nInstVars >= 8) {
  2019 		while (nInstVars >= 8) {
  2013                     *(double *)op = 0.0;
  2020 		    *(double *)op = 0.0;
  2014                     ((double *)op)[1] = 0.0;
  2021 		    ((double *)op)[1] = 0.0;
  2015                     ((double *)op)[2] = 0.0;
  2022 		    ((double *)op)[2] = 0.0;
  2016                     ((double *)op)[3] = 0.0;
  2023 		    ((double *)op)[3] = 0.0;
  2017                     op += 8;
  2024 		    op += 8;
  2018                     nInstVars -= 8;
  2025 		    nInstVars -= 8;
  2019                 }
  2026 		}
  2020             }
  2027 	    }
  2021             while (nInstVars != 0) {
  2028 	    while (nInstVars != 0) {
  2022                 *op++ = 0;
  2029 		*op++ = 0;
  2023                 nInstVars--;
  2030 		nInstVars--;
  2024             }
  2031 	    }
  2025 # else
  2032 # else
  2026 #  if defined(FAST_OBJECT_MEMSET_LONGLONG_UNROLLED)
  2033 #  if defined(FAST_OBJECT_MEMSET_LONGLONG_UNROLLED)
  2027             if (nInstVars > 8) {
  2034 	    if (nInstVars > 8) {
  2028                 *op++ = nil;    /* for alignment */
  2035 		*op++ = nil;    /* for alignment */
  2029                 nInstVars--;
  2036 		nInstVars--;
  2030                 while (nInstVars >= 8) {
  2037 		while (nInstVars >= 8) {
  2031                     *(long long *)op = 0;
  2038 		    *(long long *)op = 0;
  2032                     ((long long *)op)[1] = 0;
  2039 		    ((long long *)op)[1] = 0;
  2033                     ((long long *)op)[2] = 0;
  2040 		    ((long long *)op)[2] = 0;
  2034                     ((long long *)op)[3] = 0;
  2041 		    ((long long *)op)[3] = 0;
  2035                     op += 8;
  2042 		    op += 8;
  2036                     nInstVars -= 8;
  2043 		    nInstVars -= 8;
  2037                 }
  2044 		}
  2038             }
  2045 	    }
  2039             while (nInstVars != 0) {
  2046 	    while (nInstVars != 0) {
  2040                 *op++ = 0;
  2047 		*op++ = 0;
  2041                 nInstVars--;
  2048 		nInstVars--;
  2042             }
  2049 	    }
  2043 
  2050 
  2044 #  else
  2051 #  else
  2045 #   if defined(FAST_OBJECT_MEMSET_WORDS_UNROLLED)
  2052 #   if defined(FAST_OBJECT_MEMSET_WORDS_UNROLLED)
  2046             while (nInstVars >= 8) {
  2053 	    while (nInstVars >= 8) {
  2047                 *op = nil;
  2054 		*op = nil;
  2048                 *(op+1) = nil;
  2055 		*(op+1) = nil;
  2049                 *(op+2) = nil;
  2056 		*(op+2) = nil;
  2050                 *(op+3) = nil;
  2057 		*(op+3) = nil;
  2051                 *(op+4) = nil;
  2058 		*(op+4) = nil;
  2052                 *(op+5) = nil;
  2059 		*(op+5) = nil;
  2053                 *(op+6) = nil;
  2060 		*(op+6) = nil;
  2054                 *(op+7) = nil;
  2061 		*(op+7) = nil;
  2055                 op += 8;
  2062 		op += 8;
  2056                 nInstVars -= 8;
  2063 		nInstVars -= 8;
  2057             }
  2064 	    }
  2058             while (nInstVars != 0) {
  2065 	    while (nInstVars != 0) {
  2059                 *op++ = nil;
  2066 		*op++ = nil;
  2060                 nInstVars--;
  2067 		nInstVars--;
  2061             }
  2068 	    }
  2062 #   else
  2069 #   else
  2063 #    if defined(FAST_MEMSET)
  2070 #    if defined(FAST_MEMSET)
  2064             memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE);
  2071 	    memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE);
  2065 #    else
  2072 #    else
  2066             do {
  2073 	    do {
  2067                 *op++ = nil;
  2074 		*op++ = nil;
  2068                 nInstVars--;
  2075 		nInstVars--;
  2069             } while (nInstVars != 0);
  2076 	    } while (nInstVars != 0);
  2070 #    endif
  2077 #    endif
  2071 #   endif
  2078 #   endif
  2072 #  endif
  2079 #  endif
  2073 # endif
  2080 # endif
  2074 #endif
  2081 #endif
  2075         }
  2082 	}
  2076         RETURN ( newobj );
  2083 	RETURN ( newobj );
  2077     }
  2084     }
  2078 
  2085 
  2079     /*
  2086     /*
  2080      * the slow case - a GC will occur
  2087      * the slow case - a GC will occur
  2081      */
  2088      */
  2116     REGISTER OBJ *op;
  2123     REGISTER OBJ *op;
  2117     float *fp;
  2124     float *fp;
  2118     double *dp;
  2125     double *dp;
  2119 
  2126 
  2120     if (__isSmallInteger(anInteger)) {
  2127     if (__isSmallInteger(anInteger)) {
  2121         nindexedinstvars = __intVal(anInteger);
  2128 	nindexedinstvars = __intVal(anInteger);
  2122         if (nindexedinstvars >= 0) {
  2129 	if (nindexedinstvars >= 0) {
  2123             nInstVars = __intVal(__INST(instSize));
  2130 	    nInstVars = __intVal(__INST(instSize));
  2124             flags = __intVal(__INST(flags)) & ARRAYMASK;
  2131 	    flags = __intVal(__INST(flags)) & ARRAYMASK;
  2125             switch (flags) {
  2132 	    switch (flags) {
  2126                 case BYTEARRAY:
  2133 		case BYTEARRAY:
  2127                     instsize = OHDR_SIZE + nindexedinstvars;
  2134 		    instsize = OHDR_SIZE + nindexedinstvars;
  2128                     if (nInstVars == 0) {
  2135 		    if (nInstVars == 0) {
  2129                         if (__CanDoQuickNew(instsize)) {        /* OBJECT ALLOCATION */
  2136 			if (__CanDoQuickNew(instsize)) {        /* OBJECT ALLOCATION */
  2130                             /*
  2137 			    /*
  2131                              * the most common case
  2138 			     * the most common case
  2132                              */
  2139 			     */
  2133                             __qCheckedNew(newobj, instsize);
  2140 			    __qCheckedNew(newobj, instsize);
  2134                             __InstPtr(newobj)->o_class = self;
  2141 			    __InstPtr(newobj)->o_class = self;
  2135                             __qSTORE(newobj, self);
  2142 			    __qSTORE(newobj, self);
  2136 
  2143 
  2137 #if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4)
  2144 #if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4)
  2138                             nInstVars = nindexedinstvars >> 2;
  2145 			    nInstVars = nindexedinstvars >> 2;
  2139                             if (nindexedinstvars & 3) nInstVars++;
  2146 			    if (nindexedinstvars & 3) nInstVars++;
  2140                             memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars);
  2147 			    memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars);
  2141 #else
  2148 #else
  2142 # if defined(FAST_ARRAY_MEMSET)
  2149 # if defined(FAST_ARRAY_MEMSET)
  2143                             memset(__InstPtr(newobj)->i_instvars, 0, nindexedinstvars);
  2150 			    memset(__InstPtr(newobj)->i_instvars, 0, nindexedinstvars);
  2144 # else
  2151 # else
  2145                             cp = (char *)__InstPtr(newobj)->i_instvars;
  2152 			    cp = (char *)__InstPtr(newobj)->i_instvars;
  2146                             while (nindexedinstvars >= sizeof(long)) {
  2153 			    while (nindexedinstvars >= sizeof(long)) {
  2147                                 *(long *)cp = 0;
  2154 				*(long *)cp = 0;
  2148                                 cp += sizeof(long);
  2155 				cp += sizeof(long);
  2149                                 nindexedinstvars -= sizeof(long);
  2156 				nindexedinstvars -= sizeof(long);
  2150                             }
  2157 			    }
  2151                             while (nindexedinstvars--)
  2158 			    while (nindexedinstvars--)
  2152                                 *cp++ = '\0';
  2159 				*cp++ = '\0';
  2153 # endif
  2160 # endif
  2154 #endif
  2161 #endif
  2155                             RETURN ( newobj );
  2162 			    RETURN ( newobj );
  2156                         }
  2163 			}
  2157                     } else {
  2164 		    } else {
  2158                         instsize += __OBJS2BYTES__(nInstVars);
  2165 			instsize += __OBJS2BYTES__(nInstVars);
  2159                     }
  2166 		    }
  2160                     __PROTECT_CONTEXT__
  2167 		    __PROTECT_CONTEXT__
  2161                     __qNew(newobj, instsize);   /* OBJECT ALLOCATION */
  2168 		    __qNew(newobj, instsize);   /* OBJECT ALLOCATION */
  2162                     __UNPROTECT_CONTEXT__
  2169 		    __UNPROTECT_CONTEXT__
  2163                     if (newobj == nil) {
  2170 		    if (newobj == nil) {
  2164                         break;
  2171 			break;
  2165                     }
  2172 		    }
  2166                     __InstPtr(newobj)->o_class = self;
  2173 		    __InstPtr(newobj)->o_class = self;
  2167                     __qSTORE(newobj, self);
  2174 		    __qSTORE(newobj, self);
  2168 
  2175 
  2169 #if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4)
  2176 #if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4)
  2170                     nInstVars = (instsize-OHDR_SIZE) >> 2;
  2177 		    nInstVars = (instsize-OHDR_SIZE) >> 2;
  2171                     if (instsize & 3) nInstVars++;
  2178 		    if (instsize & 3) nInstVars++;
  2172                     memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars);
  2179 		    memset4(__InstPtr(newobj)->i_instvars, 0, nInstVars);
  2173 #else
  2180 #else
  2174 # if defined(FAST_ARRAY_MEMSET)
  2181 # if defined(FAST_ARRAY_MEMSET)
  2175                     /*
  2182 		    /*
  2176                      * knowing that nil is 0
  2183 		     * knowing that nil is 0
  2177                      */
  2184 		     */
  2178                     memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE);
  2185 		    memset(__InstPtr(newobj)->i_instvars, 0, instsize-OHDR_SIZE);
  2179 # else
  2186 # else
  2180                     op = __InstPtr(newobj)->i_instvars;
  2187 		    op = __InstPtr(newobj)->i_instvars;
  2181                     while (nInstVars--)
  2188 		    while (nInstVars--)
  2182                         *op++ = nil;
  2189 			*op++ = nil;
  2183                     cp = (char *)op;
  2190 		    cp = (char *)op;
  2184                     while (nindexedinstvars >= sizeof(long)) {
  2191 		    while (nindexedinstvars >= sizeof(long)) {
  2185                         *(long *)cp = 0;
  2192 			*(long *)cp = 0;
  2186                         cp += sizeof(long);
  2193 			cp += sizeof(long);
  2187                         nindexedinstvars -= sizeof(long);
  2194 			nindexedinstvars -= sizeof(long);
  2188                     }
  2195 		    }
  2189                     while (nindexedinstvars--)
  2196 		    while (nindexedinstvars--)
  2190                         *cp++ = '\0';
  2197 			*cp++ = '\0';
  2191 # endif
  2198 # endif
  2192 #endif
  2199 #endif
  2193                     RETURN ( newobj );
  2200 		    RETURN ( newobj );
  2194                     break;
  2201 		    break;
  2195 
  2202 
  2196                 case WORDARRAY:
  2203 		case WORDARRAY:
  2197                 case SWORDARRAY:
  2204 		case SWORDARRAY:
  2198                     instsize = OHDR_SIZE +
  2205 		    instsize = OHDR_SIZE +
  2199                                __OBJS2BYTES__(nInstVars) +
  2206 			       __OBJS2BYTES__(nInstVars) +
  2200                                nindexedinstvars * 2;
  2207 			       nindexedinstvars * 2;
  2201                     __PROTECT_CONTEXT__
  2208 		    __PROTECT_CONTEXT__
  2202                     __qNew(newobj, instsize);   /* OBJECT ALLOCATION */
  2209 		    __qNew(newobj, instsize);   /* OBJECT ALLOCATION */
  2203                     __UNPROTECT_CONTEXT__
  2210 		    __UNPROTECT_CONTEXT__
  2204                     if (newobj == nil) {
  2211 		    if (newobj == nil) {
  2205                         break;
  2212 			break;
  2206                     }
  2213 		    }
  2207                     __InstPtr(newobj)->o_class = self;
  2214 		    __InstPtr(newobj)->o_class = self;
  2208                     __qSTORE(newobj, self);
  2215 		    __qSTORE(newobj, self);
  2209 
  2216 
  2210 #if defined(FAST_ARRAY_MEMSET)
  2217 #if defined(FAST_ARRAY_MEMSET)
  2211                     /*
  2218 		    /*
  2212                      * knowing that nil is 0
  2219 		     * knowing that nil is 0
  2213                      */
  2220 		     */
  2214                     memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2221 		    memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2215 #else
  2222 #else
  2216                     op = __InstPtr(newobj)->i_instvars;
  2223 		    op = __InstPtr(newobj)->i_instvars;
  2217                     while (nInstVars--)
  2224 		    while (nInstVars--)
  2218                         *op++ = nil;
  2225 			*op++ = nil;
  2219                     sp = (short *)op;
  2226 		    sp = (short *)op;
  2220                     while (nindexedinstvars--)
  2227 		    while (nindexedinstvars--)
  2221                         *sp++ = 0;
  2228 			*sp++ = 0;
  2222 #endif
  2229 #endif
  2223                     RETURN ( newobj );
  2230 		    RETURN ( newobj );
  2224                     break;
  2231 		    break;
  2225 
  2232 
  2226                case LONGARRAY:
  2233 	       case LONGARRAY:
  2227                case SLONGARRAY:
  2234 	       case SLONGARRAY:
  2228                     instsize = OHDR_SIZE +
  2235 		    instsize = OHDR_SIZE +
  2229                                __OBJS2BYTES__(nInstVars) +
  2236 			       __OBJS2BYTES__(nInstVars) +
  2230                                nindexedinstvars * 4;
  2237 			       nindexedinstvars * 4;
  2231                     __PROTECT_CONTEXT__
  2238 		    __PROTECT_CONTEXT__
  2232                     __qAlignedNew(newobj, instsize);    /* OBJECT ALLOCATION */
  2239 		    __qAlignedNew(newobj, instsize);    /* OBJECT ALLOCATION */
  2233                     __UNPROTECT_CONTEXT__
  2240 		    __UNPROTECT_CONTEXT__
  2234                     if (newobj == nil) {
  2241 		    if (newobj == nil) {
  2235                         break;
  2242 			break;
  2236                     }
  2243 		    }
  2237                     __InstPtr(newobj)->o_class = self;
  2244 		    __InstPtr(newobj)->o_class = self;
  2238                     __qSTORE(newobj, self);
  2245 		    __qSTORE(newobj, self);
  2239 
  2246 
  2240 #if defined(memset4)
  2247 #if defined(memset4)
  2241                     /*
  2248 		    /*
  2242                      * knowing that nil is 0
  2249 		     * knowing that nil is 0
  2243                      */
  2250 		     */
  2244                     {
  2251 		    {
  2245                         int n4 = nInstVars + nindexedinstvars;
  2252 			int n4 = nInstVars + nindexedinstvars;
  2246 
  2253 
  2247                         memset4(__InstPtr(newobj)->i_instvars, 0, n4);
  2254 			memset4(__InstPtr(newobj)->i_instvars, 0, n4);
  2248                     }
  2255 		    }
  2249 #else
  2256 #else
  2250 # if defined(FAST_ARRAY_MEMSET)
  2257 # if defined(FAST_ARRAY_MEMSET)
  2251                     /*
  2258 		    /*
  2252                      * knowing that nil is 0
  2259 		     * knowing that nil is 0
  2253                      */
  2260 		     */
  2254                     memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2261 		    memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2255 # else
  2262 # else
  2256                     op = __InstPtr(newobj)->i_instvars;
  2263 		    op = __InstPtr(newobj)->i_instvars;
  2257                     while (nInstVars--)
  2264 		    while (nInstVars--)
  2258                         *op++ = nil;
  2265 			*op++ = nil;
  2259                     lp = (long *)op;
  2266 		    lp = (long *)op;
  2260                     while (nindexedinstvars--)
  2267 		    while (nindexedinstvars--)
  2261                         *lp++ = 0;
  2268 			*lp++ = 0;
  2262 # endif
  2269 # endif
  2263 #endif
  2270 #endif
  2264                     RETURN ( newobj );
  2271 		    RETURN ( newobj );
  2265                     break;
  2272 		    break;
  2266 
  2273 
  2267                case LONGLONGARRAY:
  2274 	       case LONGLONGARRAY:
  2268                case SLONGLONGARRAY:
  2275 	       case SLONGLONGARRAY:
  2269                     instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
  2276 		    instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
  2270 
  2277 
  2271 #ifdef __NEED_LONGLONG_ALIGN
  2278 #ifdef __NEED_LONGLONG_ALIGN
  2272                     instsize = ((instsize-1) + __LONGLONG_ALIGN) & ~(__LONGLONG_ALIGN-1);
  2279 		    instsize = ((instsize-1) + __LONGLONG_ALIGN) & ~(__LONGLONG_ALIGN-1);
  2273 #endif
  2280 #endif
  2274                     instsize += nindexedinstvars * 8;
  2281 		    instsize += nindexedinstvars * 8;
  2275 
  2282 
  2276                     __PROTECT_CONTEXT__
  2283 		    __PROTECT_CONTEXT__
  2277                     __qAlignedNew(newobj, instsize);    /* OBJECT ALLOCATION */
  2284 		    __qAlignedNew(newobj, instsize);    /* OBJECT ALLOCATION */
  2278                     __UNPROTECT_CONTEXT__
  2285 		    __UNPROTECT_CONTEXT__
  2279                     if (newobj == nil) {
  2286 		    if (newobj == nil) {
  2280                         break;
  2287 			break;
  2281                     }
  2288 		    }
  2282                     __InstPtr(newobj)->o_class = self;
  2289 		    __InstPtr(newobj)->o_class = self;
  2283                     __qSTORE(newobj, self);
  2290 		    __qSTORE(newobj, self);
  2284 
  2291 
  2285 #if defined(memset4)
  2292 #if defined(memset4)
  2286                     {
  2293 		    {
  2287                         int n4 = (instsize-OHDR_SIZE) / 4;
  2294 			int n4 = (instsize-OHDR_SIZE) / 4;
  2288 
  2295 
  2289                         memset4(__InstPtr(newobj)->i_instvars, 0, n4);
  2296 			memset4(__InstPtr(newobj)->i_instvars, 0, n4);
  2290                     }
  2297 		    }
  2291 #else
  2298 #else
  2292                     memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2299 		    memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2293 #endif
  2300 #endif
  2294                     RETURN ( newobj );
  2301 		    RETURN ( newobj );
  2295                     break;
  2302 		    break;
  2296 
  2303 
  2297                case FLOATARRAY:
  2304 	       case FLOATARRAY:
  2298                     instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
  2305 		    instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
  2299                     instsize += nindexedinstvars * sizeof(float);
  2306 		    instsize += nindexedinstvars * sizeof(float);
  2300 
  2307 
  2301                     __PROTECT_CONTEXT__
  2308 		    __PROTECT_CONTEXT__
  2302                     __qNew(newobj, instsize);   /* OBJECT ALLOCATION */
  2309 		    __qNew(newobj, instsize);   /* OBJECT ALLOCATION */
  2303                     __UNPROTECT_CONTEXT__
  2310 		    __UNPROTECT_CONTEXT__
  2304                     if (newobj == nil) {
  2311 		    if (newobj == nil) {
  2305                         break;
  2312 			break;
  2306                     }
  2313 		    }
  2307                     __InstPtr(newobj)->o_class = self;
  2314 		    __InstPtr(newobj)->o_class = self;
  2308                     __qSTORE(newobj, self);
  2315 		    __qSTORE(newobj, self);
  2309 
  2316 
  2310                     op = __InstPtr(newobj)->i_instvars;
  2317 		    op = __InstPtr(newobj)->i_instvars;
  2311 #if defined(__FLOAT0_IS_INT0) /* knowin that float 0.0 is all-zeros */
  2318 #if defined(__FLOAT0_IS_INT0) /* knowin that float 0.0 is all-zeros */
  2312 # if defined(memset4)
  2319 # if defined(memset4)
  2313                     {
  2320 		    {
  2314                         int n4 = (instsize-OHDR_SIZE) / 4;
  2321 			int n4 = (instsize-OHDR_SIZE) / 4;
  2315 
  2322 
  2316                         memset4(__InstPtr(newobj)->i_instvars, 0, n4);
  2323 			memset4(__InstPtr(newobj)->i_instvars, 0, n4);
  2317                     }
  2324 		    }
  2318 # else
  2325 # else
  2319                     memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2326 		    memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2320 # endif
  2327 # endif
  2321 #else
  2328 #else
  2322                     while (nInstVars--)
  2329 		    while (nInstVars--)
  2323                         *op++ = nil;
  2330 			*op++ = nil;
  2324                     fp = (float *)op;
  2331 		    fp = (float *)op;
  2325                     while (nindexedinstvars--)
  2332 		    while (nindexedinstvars--)
  2326                         *fp++ = 0.0;
  2333 			*fp++ = 0.0;
  2327 #endif
  2334 #endif
  2328                     RETURN ( newobj );
  2335 		    RETURN ( newobj );
  2329                     break;
  2336 		    break;
  2330 
  2337 
  2331                case DOUBLEARRAY:
  2338 	       case DOUBLEARRAY:
  2332                     instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
  2339 		    instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
  2333 #ifdef __NEED_DOUBLE_ALIGN
  2340 #ifdef __NEED_DOUBLE_ALIGN
  2334                     instsize = ((instsize-1) + __DOUBLE_ALIGN) & ~(__DOUBLE_ALIGN-1);
  2341 		    instsize = ((instsize-1) + __DOUBLE_ALIGN) & ~(__DOUBLE_ALIGN-1);
  2335 #endif
  2342 #endif
  2336                     instsize += nindexedinstvars * sizeof(double);
  2343 		    instsize += nindexedinstvars * sizeof(double);
  2337 
  2344 
  2338                     __PROTECT_CONTEXT__
  2345 		    __PROTECT_CONTEXT__
  2339                     __qAlignedNew(newobj, instsize);    /* OBJECT ALLOCATION */
  2346 		    __qAlignedNew(newobj, instsize);    /* OBJECT ALLOCATION */
  2340                     __UNPROTECT_CONTEXT__
  2347 		    __UNPROTECT_CONTEXT__
  2341                     if (newobj == nil) {
  2348 		    if (newobj == nil) {
  2342                         break;
  2349 			break;
  2343                     }
  2350 		    }
  2344                     __InstPtr(newobj)->o_class = self;
  2351 		    __InstPtr(newobj)->o_class = self;
  2345                     __qSTORE(newobj, self);
  2352 		    __qSTORE(newobj, self);
  2346 
  2353 
  2347 #if defined(__DOUBLE0_IS_INT0) /* knowin that double 0.0 is all-zeros */
  2354 #if defined(__DOUBLE0_IS_INT0) /* knowin that double 0.0 is all-zeros */
  2348 # ifdef memset4
  2355 # ifdef memset4
  2349                     {
  2356 		    {
  2350                         int n4 = (instsize-OHDR_SIZE) / 4;
  2357 			int n4 = (instsize-OHDR_SIZE) / 4;
  2351 
  2358 
  2352                         memset4(__InstPtr(newobj)->i_instvars, 0, n4);
  2359 			memset4(__InstPtr(newobj)->i_instvars, 0, n4);
  2353                     }
  2360 		    }
  2354 # else
  2361 # else
  2355                     memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2362 		    memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2356 # endif
  2363 # endif
  2357 #else
  2364 #else
  2358                     op = __InstPtr(newobj)->i_instvars;
  2365 		    op = __InstPtr(newobj)->i_instvars;
  2359                     while (nInstVars--)
  2366 		    while (nInstVars--)
  2360                         *op++ = nil;
  2367 			*op++ = nil;
  2361 
  2368 
  2362 # ifdef __NEED_DOUBLE_ALIGN
  2369 # ifdef __NEED_DOUBLE_ALIGN
  2363                     /*
  2370 		    /*
  2364                      * care for double alignment
  2371 		     * care for double alignment
  2365                      * add filler.
  2372 		     * add filler.
  2366                      */
  2373 		     */
  2367                     if ((INT)op & (__DOUBLE_ALIGN-1)) {
  2374 		    if ((INT)op & (__DOUBLE_ALIGN-1)) {
  2368                         *op++ = nil;
  2375 			*op++ = nil;
  2369                     }
  2376 		    }
  2370 # endif
  2377 # endif
  2371                     dp = (double *)op;
  2378 		    dp = (double *)op;
  2372                     while (nindexedinstvars--)
  2379 		    while (nindexedinstvars--)
  2373                         *dp++ = 0.0;
  2380 			*dp++ = 0.0;
  2374 #endif
  2381 #endif
  2375                     RETURN ( newobj );
  2382 		    RETURN ( newobj );
  2376                     break;
  2383 		    break;
  2377 
  2384 
  2378                 case WKPOINTERARRAY:
  2385 		case WKPOINTERARRAY:
  2379                 case POINTERARRAY:
  2386 		case POINTERARRAY:
  2380                     nInstVars += nindexedinstvars;
  2387 		    nInstVars += nindexedinstvars;
  2381                     instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
  2388 		    instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
  2382                     __PROTECT_CONTEXT__
  2389 		    __PROTECT_CONTEXT__
  2383                     __qAlignedNew(newobj, instsize);    /* OBJECT ALLOCATION */
  2390 		    __qAlignedNew(newobj, instsize);    /* OBJECT ALLOCATION */
  2384                     __UNPROTECT_CONTEXT__
  2391 		    __UNPROTECT_CONTEXT__
  2385                     if (newobj == nil) {
  2392 		    if (newobj == nil) {
  2386                         break;
  2393 			break;
  2387                     }
  2394 		    }
  2388                     __InstPtr(newobj)->o_class = self;
  2395 		    __InstPtr(newobj)->o_class = self;
  2389                     __qSTORE(newobj, self);
  2396 		    __qSTORE(newobj, self);
  2390 
  2397 
  2391 #if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4)
  2398 #if defined(memset4) && defined(FAST_ARRAY_MEMSET4) || defined(FAST_MEMSET4)
  2392                     memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars);
  2399 		    memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars);
  2393 #else
  2400 #else
  2394                     /*
  2401 		    /*
  2395                      * knowing that nil is 0
  2402 		     * knowing that nil is 0
  2396                      */
  2403 		     */
  2397 # ifdef sparc
  2404 # ifdef sparc
  2398 #  define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED
  2405 #  define FAST_ARRAY_MEMSET_DOUBLES_UNROLLED
  2399 # endif
  2406 # endif
  2400 
  2407 
  2401 # if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED)
  2408 # if defined(FAST_ARRAY_MEMSET_DOUBLES_UNROLLED)
  2402                     op = __InstPtr(newobj)->i_instvars;
  2409 		    op = __InstPtr(newobj)->i_instvars;
  2403                     if (nInstVars > 8) {
  2410 		    if (nInstVars > 8) {
  2404                         *op++ = nil;    /* for alignment */
  2411 			*op++ = nil;    /* for alignment */
  2405                         nInstVars--;
  2412 			nInstVars--;
  2406                         while (nInstVars >= 8) {
  2413 			while (nInstVars >= 8) {
  2407                             *(double *)op = 0.0;
  2414 			    *(double *)op = 0.0;
  2408                             ((double *)op)[1] = 0.0;
  2415 			    ((double *)op)[1] = 0.0;
  2409                             ((double *)op)[2] = 0.0;
  2416 			    ((double *)op)[2] = 0.0;
  2410                             ((double *)op)[3] = 0.0;
  2417 			    ((double *)op)[3] = 0.0;
  2411                             op += 8;
  2418 			    op += 8;
  2412                             nInstVars -= 8;
  2419 			    nInstVars -= 8;
  2413                         }
  2420 			}
  2414                     }
  2421 		    }
  2415                     while (nInstVars) {
  2422 		    while (nInstVars) {
  2416                         *op++ = 0;
  2423 			*op++ = 0;
  2417                         nInstVars--;
  2424 			nInstVars--;
  2418                     }
  2425 		    }
  2419 # else
  2426 # else
  2420 #  if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED)
  2427 #  if defined(FAST_ARRAY_MEMSET_LONGLONG_UNROLLED)
  2421                     op = __InstPtr(newobj)->i_instvars;
  2428 		    op = __InstPtr(newobj)->i_instvars;
  2422                     if (nInstVars > 8) {
  2429 		    if (nInstVars > 8) {
  2423                         *op++ = nil;    /* for alignment */
  2430 			*op++ = nil;    /* for alignment */
  2424                         nInstVars--;
  2431 			nInstVars--;
  2425                         while (nInstVars >= 8) {
  2432 			while (nInstVars >= 8) {
  2426                             *(long long *)op = 0;
  2433 			    *(long long *)op = 0;
  2427                             ((long long *)op)[1] = 0;
  2434 			    ((long long *)op)[1] = 0;
  2428                             ((long long *)op)[2] = 0;
  2435 			    ((long long *)op)[2] = 0;
  2429                             ((long long *)op)[3] = 0;
  2436 			    ((long long *)op)[3] = 0;
  2430                             op += 8;
  2437 			    op += 8;
  2431                             nInstVars -= 8;
  2438 			    nInstVars -= 8;
  2432                         }
  2439 			}
  2433                     }
  2440 		    }
  2434                     while (nInstVars) {
  2441 		    while (nInstVars) {
  2435                         *op++ = 0;
  2442 			*op++ = 0;
  2436                         nInstVars--;
  2443 			nInstVars--;
  2437                     }
  2444 		    }
  2438 #  else
  2445 #  else
  2439 #   if defined(FAST_ARRAY_MEMSET)
  2446 #   if defined(FAST_ARRAY_MEMSET)
  2440                     memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2447 		    memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2441 #   else
  2448 #   else
  2442                     op = __InstPtr(newobj)->i_instvars;
  2449 		    op = __InstPtr(newobj)->i_instvars;
  2443                     while (nInstVars--)
  2450 		    while (nInstVars--)
  2444                         *op++ = nil;
  2451 			*op++ = nil;
  2445 #   endif
  2452 #   endif
  2446 #  endif
  2453 #  endif
  2447 # endif
  2454 # endif
  2448 #endif
  2455 #endif
  2449                     RETURN ( newobj );
  2456 		    RETURN ( newobj );
  2450                     break;
  2457 		    break;
  2451 
  2458 
  2452                 default:
  2459 		default:
  2453                     /*
  2460 		    /*
  2454                      * new:n for non-variable classes only allowed if
  2461 		     * new:n for non-variable classes only allowed if
  2455                      * n == 0
  2462 		     * n == 0
  2456                      */
  2463 		     */
  2457                     if (nindexedinstvars == 0) {
  2464 		    if (nindexedinstvars == 0) {
  2458                         instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
  2465 			instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
  2459                         __PROTECT_CONTEXT__
  2466 			__PROTECT_CONTEXT__
  2460                         __qAlignedNew(newobj, instsize);        /* OBJECT ALLOCATION */
  2467 			__qAlignedNew(newobj, instsize);        /* OBJECT ALLOCATION */
  2461                         __UNPROTECT_CONTEXT__
  2468 			__UNPROTECT_CONTEXT__
  2462                         if (newobj == nil) {
  2469 			if (newobj == nil) {
  2463                             break;
  2470 			    break;
  2464                         }
  2471 			}
  2465                         __InstPtr(newobj)->o_class = self;
  2472 			__InstPtr(newobj)->o_class = self;
  2466                         __qSTORE(newobj, self);
  2473 			__qSTORE(newobj, self);
  2467 
  2474 
  2468                         if (nInstVars) {
  2475 			if (nInstVars) {
  2469 #if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4)
  2476 #if defined(memset4) && defined(FAST_OBJECT_MEMSET4) || defined(FAST_MEMSET4)
  2470                             memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars);
  2477 			    memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars);
  2471 #else
  2478 #else
  2472 # if defined(FAST_MEMSET)
  2479 # if defined(FAST_MEMSET)
  2473                             /*
  2480 			    /*
  2474                              * knowing that nil is 0
  2481 			     * knowing that nil is 0
  2475                              */
  2482 			     */
  2476                             memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2483 			    memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE);
  2477 # else
  2484 # else
  2478                             op = __InstPtr(newobj)->i_instvars;
  2485 			    op = __InstPtr(newobj)->i_instvars;
  2479                             do {
  2486 			    do {
  2480                                 *op++ = nil;
  2487 				*op++ = nil;
  2481                             } while (--nInstVars);
  2488 			    } while (--nInstVars);
  2482 # endif
  2489 # endif
  2483 #endif
  2490 #endif
  2484                         }
  2491 			}
  2485                         RETURN ( newobj );
  2492 			RETURN ( newobj );
  2486                     }
  2493 		    }
  2487                     break;
  2494 		    break;
  2488             }
  2495 	    }
  2489         }
  2496 	}
  2490     }
  2497     }
  2491 %}.
  2498 %}.
  2492     "
  2499     "
  2493      arrive here if something went wrong ...
  2500      arrive here if something went wrong ...
  2494      figure out what it was
  2501      figure out what it was
  2495     "
  2502     "
  2496 
  2503 
  2497     (anInteger isMemberOf:SmallInteger) ifFalse:[
  2504     (anInteger isMemberOf:SmallInteger) ifFalse:[
  2498         "
  2505 	"
  2499          the argument is either not an integer,
  2506 	 the argument is either not an integer,
  2500          or a LargeInteger (which means that its definitely too big)
  2507 	 or a LargeInteger (which means that its definitely too big)
  2501         "
  2508 	"
  2502         self error:'argument to new: must be Integer' mayProceed:true.
  2509 	self error:'argument to new: must be Integer' mayProceed:true.
  2503         ^ nil
  2510 	^ nil
  2504     ].
  2511     ].
  2505     (anInteger < 0) ifTrue:[
  2512     (anInteger < 0) ifTrue:[
  2506         "
  2513 	"
  2507          the argument is negative,
  2514 	 the argument is negative,
  2508         "
  2515 	"
  2509         self error:'bad (negative) argument to new:'.
  2516 	self error:'bad (negative) argument to new:'.
  2510         ^ nil
  2517 	^ nil
  2511     ].
  2518     ].
  2512     self isVariable ifFalse:[
  2519     self isVariable ifFalse:[
  2513         "
  2520 	"
  2514          this class does not have any indexed instance variables
  2521 	 this class does not have any indexed instance variables
  2515         "
  2522 	"
  2516         self error:'class has no indexed instvars - cannot create with new:'.
  2523 	self error:'class has no indexed instvars - cannot create with new:'.
  2517         ^ nil
  2524 	^ nil
  2518     ].
  2525     ].
  2519     "
  2526     "
  2520      memory allocation failed.
  2527      memory allocation failed.
  2521      When we arrive here, there was no memory, even after
  2528      When we arrive here, there was no memory, even after
  2522      a garbage collect.
  2529      a garbage collect.
  2532 
  2539 
  2533     ^ self new fromLiteralArrayEncoding:anArray.
  2540     ^ self new fromLiteralArrayEncoding:anArray.
  2534 
  2541 
  2535     "
  2542     "
  2536      Rectangle
  2543      Rectangle
  2537         decodeFromLiteralArray:#(Rectangle 10 10 100 100)
  2544 	decodeFromLiteralArray:#(Rectangle 10 10 100 100)
  2538     "
  2545     "
  2539 
  2546 
  2540     "Modified: / 28.1.1998 / 17:40:30 / cg"
  2547     "Modified: / 28.1.1998 / 17:40:30 / cg"
  2541 !
  2548 !
  2542 
  2549 
  2569 
  2576 
  2570     |size|
  2577     |size|
  2571 
  2578 
  2572     size := self sizeOfInst:anInteger.
  2579     size := self sizeOfInst:anInteger.
  2573     (ObjectMemory checkForFastNew:size) ifFalse:[
  2580     (ObjectMemory checkForFastNew:size) ifFalse:[
  2574         "
  2581 	"
  2575          incrementally collect garbage
  2582 	 incrementally collect garbage
  2576         "
  2583 	"
  2577         ObjectMemory incrementalGC.
  2584 	ObjectMemory incrementalGC.
  2578     ].
  2585     ].
  2579     ^ self basicNew:anInteger
  2586     ^ self basicNew:anInteger
  2580 !
  2587 !
  2581 
  2588 
  2582 readFrom:aStream
  2589 readFrom:aStream
  2584      and return it.
  2591      and return it.
  2585      The read object must be a kind of myself if its not, an error is raised.
  2592      The read object must be a kind of myself if its not, an error is raised.
  2586      This is the reverse operation to 'storeOn:'.
  2593      This is the reverse operation to 'storeOn:'.
  2587 
  2594 
  2588      WARNING: storeOn: does not handle circular references and multiple
  2595      WARNING: storeOn: does not handle circular references and multiple
  2589               references to the same object.
  2596 	      references to the same object.
  2590               Use #storeBinary:/readBinaryFrom: for this."
  2597 	      Use #storeBinary:/readBinaryFrom: for this."
  2591 
  2598 
  2592     ^ self
  2599     ^ self
  2593         readFrom:aStream
  2600 	readFrom:aStream
  2594         onError:[ self conversionErrorSignal
  2601 	onError:[ self conversionErrorSignal
  2595                     raiseErrorString:'conversion error for: ' , self name ]
  2602 		    raiseErrorString:'conversion error for: ' , self name ]
  2596 
  2603 
  2597     "
  2604     "
  2598      |s|
  2605      |s|
  2599      s := WriteStream on:String new.
  2606      s := WriteStream on:String new.
  2600      #(1 2 3 4) storeOn:s.
  2607      #(1 2 3 4) storeOn:s.
  2611      To get any object, use 'Object readFrom:...',
  2618      To get any object, use 'Object readFrom:...',
  2612      To get any number, use 'Number readFrom:...' and so on.
  2619      To get any number, use 'Number readFrom:...' and so on.
  2613      This is the reverse operation to 'storeOn:'.
  2620      This is the reverse operation to 'storeOn:'.
  2614 
  2621 
  2615      WARNING: storeOn: does not handle circular references and multiple
  2622      WARNING: storeOn: does not handle circular references and multiple
  2616               references to the same object.
  2623 	      references to the same object.
  2617               Use #storeBinary:/readBinaryFrom: for this."
  2624 	      Use #storeBinary:/readBinaryFrom: for this."
  2618 
  2625 
  2619     ^ [
  2626     ^ [
  2620         |newObject|
  2627 	|newObject|
  2621         newObject := self evaluatorClass evaluate:aStream ifFail:exceptionBlock.
  2628 	newObject := self evaluatorClass evaluate:aStream ifFail:exceptionBlock.
  2622         (newObject isKindOf:self) ifTrue:[newObject] ifFalse:[exceptionBlock value].
  2629 	(newObject isKindOf:self) ifTrue:[newObject] ifFalse:[exceptionBlock value].
  2623     ] on:Error do:exceptionBlock.
  2630     ] on:Error do:exceptionBlock.
  2624 
  2631 
  2625     "
  2632     "
  2626      |s|
  2633      |s|
  2627      s := WriteStream on:String new.
  2634      s := WriteStream on:String new.
  2628      #(1 2 3 4) storeOn:s.
  2635      #(1 2 3 4) storeOn:s.
  2629      Transcript showCR:(
  2636      Transcript showCR:(
  2630         Array readFrom:(ReadStream on:s contents) onError:'not an Array'
  2637 	Array readFrom:(ReadStream on:s contents) onError:'not an Array'
  2631      )
  2638      )
  2632     "
  2639     "
  2633     "
  2640     "
  2634      |s|
  2641      |s|
  2635      s := WriteStream on:String new.
  2642      s := WriteStream on:String new.
  2636      #[1 2 3 4] storeOn:s.
  2643      #[1 2 3 4] storeOn:s.
  2637      Transcript showCR:(
  2644      Transcript showCR:(
  2638          Array readFrom:(ReadStream on:s contents) onError:'not an Array'
  2645 	 Array readFrom:(ReadStream on:s contents) onError:'not an Array'
  2639      )
  2646      )
  2640     "
  2647     "
  2641     "
  2648     "
  2642      Object readFrom:'illegal' onError:['bla']
  2649      Object readFrom:'illegal' onError:['bla']
  2643      String readFrom:'illegal' onError:'bla'
  2650      String readFrom:'illegal' onError:'bla'
  2651      readable string here.
  2658      readable string here.
  2652      See comments in Behavior>>readFromString:onError:,
  2659      See comments in Behavior>>readFromString:onError:,
  2653      Behavior>>readFrom: and Behavior>>readFrom:onError:"
  2660      Behavior>>readFrom: and Behavior>>readFrom:onError:"
  2654 
  2661 
  2655     ^ self
  2662     ^ self
  2656         readFromString:aString
  2663 	readFromString:aString
  2657         onError:[ self conversionErrorSignal
  2664 	onError:[ self conversionErrorSignal
  2658                     raiseErrorString:'expected: ' , self name ]
  2665 		    raiseErrorString:'expected: ' , self name ]
  2659 
  2666 
  2660     "
  2667     "
  2661      Integer readFromString:'12345678901234567890'
  2668      Integer readFromString:'12345678901234567890'
  2662      Point readFromString:'1@2'
  2669      Point readFromString:'1@2'
  2663      Point readFromString:'1'
  2670      Point readFromString:'1'
  2674     |str val|
  2681     |str val|
  2675 
  2682 
  2676     str := ReadStream on:aString.
  2683     str := ReadStream on:aString.
  2677     val := self readFrom:str onError:[^ exceptionBlock value].
  2684     val := self readFrom:str onError:[^ exceptionBlock value].
  2678     str atEnd ifFalse:[
  2685     str atEnd ifFalse:[
  2679         str skipSeparators.
  2686 	str skipSeparators.
  2680         str atEnd ifFalse:[
  2687 	str atEnd ifFalse:[
  2681             ^ exceptionBlock value
  2688 	    ^ exceptionBlock value
  2682         ]
  2689 	]
  2683     ].
  2690     ].
  2684     ^ val
  2691     ^ val
  2685 
  2692 
  2686     "
  2693     "
  2687      Integer readFromString:'12345678901234567890'
  2694      Integer readFromString:'12345678901234567890'
  2736 iconInBrowserSymbol
  2743 iconInBrowserSymbol
  2737     "can be redefined for a private icon in the browser (for me and my subclasses).
  2744     "can be redefined for a private icon in the browser (for me and my subclasses).
  2738      The returned symbol must be a selector of the ToolbarIconLibrary."
  2745      The returned symbol must be a selector of the ToolbarIconLibrary."
  2739 
  2746 
  2740     (self isBrowserStartable) ifTrue:[
  2747     (self isBrowserStartable) ifTrue:[
  2741         self isVisualStartable ifTrue:[
  2748 	self isVisualStartable ifTrue:[
  2742             ^ #visualStartableClassBrowserIcon
  2749 	    ^ #visualStartableClassBrowserIcon
  2743         ].
  2750 	].
  2744         ^ #startableClassBrowserIcon
  2751 	^ #startableClassBrowserIcon
  2745     ].
  2752     ].
  2746     self isLoaded ifFalse:[
  2753     self isLoaded ifFalse:[
  2747         ^ #autoloadedClassBrowserIcon
  2754 	^ #autoloadedClassBrowserIcon
  2748     ].
  2755     ].
  2749 
  2756 
  2750     "/ give ruby and other special metaclasses a chance ot provide their orn icon...
  2757     "/ give ruby and other special metaclasses a chance ot provide their orn icon...
  2751     ^ self class iconInBrowserSymbol
  2758     ^ self class iconInBrowserSymbol
  2752 
  2759 
  2816      be executed out of the caches."
  2823      be executed out of the caches."
  2817 
  2824 
  2818     |dict oldMethod|
  2825     |dict oldMethod|
  2819 
  2826 
  2820     newMethod isNil ifTrue:[
  2827     newMethod isNil ifTrue:[
  2821         self error:'invalid method'.
  2828 	self error:'invalid method'.
  2822     ].
  2829     ].
  2823     (Smalltalk
  2830     (Smalltalk
  2824             changeRequest:#methodInClass
  2831 	    changeRequest:#methodInClass
  2825             with:(Array with:self with:aSelector with:oldMethod)) ifFalse:[
  2832 	    with:(Array with:self with:aSelector with:oldMethod)) ifFalse:[
  2826         ^ false
  2833 	^ false
  2827     ].
  2834     ].
  2828     "/ oldMethod := self compiledMethodAt:aSelector.
  2835     "/ oldMethod := self compiledMethodAt:aSelector.
  2829 
  2836 
  2830     dict := self methodDictionary.
  2837     dict := self methodDictionary.
  2831     "/ oldMethod := dict at:aSelector ifAbsent:nil.
  2838     "/ oldMethod := dict at:aSelector ifAbsent:nil.
  2850     "/ proper methodDictionaries (it cannot do another message send, to
  2857     "/ proper methodDictionaries (it cannot do another message send, to
  2851     "/ find any methods ...), we convert it here if required.
  2858     "/ find any methods ...), we convert it here if required.
  2852     "/ No other classes instances are allowed.
  2859     "/ No other classes instances are allowed.
  2853 
  2860 
  2854     dict class ~~ MethodDictionary ifTrue:[
  2861     dict class ~~ MethodDictionary ifTrue:[
  2855         methodDictionary := MethodDictionary withAll:dict.
  2862 	methodDictionary := MethodDictionary withAll:dict.
  2856         methodDictionary isNil ifTrue:[
  2863 	methodDictionary isNil ifTrue:[
  2857 
  2864 
  2858             "/ refuse to do this
  2865 	    "/ refuse to do this
  2859             "/ (can only happen in case of memory allocation trouble,
  2866 	    "/ (can only happen in case of memory allocation trouble,
  2860             "/  where the allocation failed and some exception handler returned
  2867 	    "/  where the allocation failed and some exception handler returned
  2861             "/  nil ...)
  2868 	    "/  nil ...)
  2862 
  2869 
  2863             self error:'cannot set methodDictionary to nil' mayProceed:true.
  2870 	    self error:'cannot set methodDictionary to nil' mayProceed:true.
  2864             ^ self.
  2871 	    ^ self.
  2865         ]
  2872 	]
  2866     ] ifFalse:[
  2873     ] ifFalse:[
  2867         methodDictionary := dict.
  2874 	methodDictionary := dict.
  2868     ].
  2875     ].
  2869     ^ self.
  2876     ^ self.
  2870 
  2877 
  2871     "Created: 5.6.1996 / 11:29:36 / stefan"
  2878     "Created: 5.6.1996 / 11:29:36 / stefan"
  2872     "Modified: 12.6.1996 / 13:58:55 / stefan"
  2879     "Modified: 12.6.1996 / 13:58:55 / stefan"
  2923 
  2930 
  2924     |classvars superclass|
  2931     |classvars superclass|
  2925 
  2932 
  2926     superclass := self superclass.
  2933     superclass := self superclass.
  2927     (superclass notNil) ifTrue:[
  2934     (superclass notNil) ifTrue:[
  2928         superclass addAllClassVarNamesTo:aCollection
  2935 	superclass addAllClassVarNamesTo:aCollection
  2929     ].
  2936     ].
  2930     (classvars := self classVariableString) notNil ifTrue:[
  2937     (classvars := self classVariableString) notNil ifTrue:[
  2931         aCollection addAll:(classvars asCollectionOfWords).
  2938 	aCollection addAll:(classvars asCollectionOfWords).
  2932     ].
  2939     ].
  2933     ^ aCollection
  2940     ^ aCollection
  2934 
  2941 
  2935     "Created: 16.4.1996 / 18:00:38 / cg"
  2942     "Created: 16.4.1996 / 18:00:38 / cg"
  2936 !
  2943 !
  2942 
  2949 
  2943     |superclass|
  2950     |superclass|
  2944 
  2951 
  2945     superclass := self superclass.
  2952     superclass := self superclass.
  2946     (superclass notNil) ifTrue:[
  2953     (superclass notNil) ifTrue:[
  2947         superclass addAllInstVarNamesTo:aCollection
  2954 	superclass addAllInstVarNamesTo:aCollection
  2948     ].
  2955     ].
  2949     aCollection addAll:self instVarNames.
  2956     aCollection addAll:self instVarNames.
  2950     ^ aCollection
  2957     ^ aCollection
  2951 
  2958 
  2952     "
  2959     "
  2957 
  2964 
  2958 addAllPrivateClassesTo:aCollection
  2965 addAllPrivateClassesTo:aCollection
  2959     "add all of my private classes to aCollection"
  2966     "add all of my private classes to aCollection"
  2960 
  2967 
  2961     self privateClassesDo:[:aPrivateClass |
  2968     self privateClassesDo:[:aPrivateClass |
  2962         aCollection add:aPrivateClass.
  2969 	aCollection add:aPrivateClass.
  2963         aPrivateClass addAllPrivateClassesTo:aCollection
  2970 	aPrivateClass addAllPrivateClassesTo:aCollection
  2964     ].
  2971     ].
  2965 !
  2972 !
  2966 
  2973 
  2967 getLookupObject
  2974 getLookupObject
  2968     "return the lookupObject (Jan's MetaObjectProtocol support) or nil.
  2975     "return the lookupObject (Jan's MetaObjectProtocol support) or nil.
  2969      If non-nil, no lookup is performed by the VM, instead the lookupObject
  2976      If non-nil, no lookup is performed by the VM, instead the lookupObject
  2970      has to provide a method object for message sends."
  2977      has to provide a method object for message sends."
  2971 
  2978 
  2972     ^lookupObject
  2979     ^ lookupObject
  2973 
  2980 
  2974     "Created: / 26-04-2010 / 13:36:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2981     "Created: / 26-04-2010 / 13:36:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2975 !
  2982 !
  2976 
  2983 
  2977 setLookupObject:aMethodLookupObject
  2984 setLookupObject:aMethodLookupObject
  3047 
  3054 
  3048 firstDefinitionSelectorPart
  3055 firstDefinitionSelectorPart
  3049     "return the first part of the selector with which I was (can be) defined in my superclass"
  3056     "return the first part of the selector with which I was (can be) defined in my superclass"
  3050 
  3057 
  3051     self isVariable ifFalse:[
  3058     self isVariable ifFalse:[
  3052         ^ #'subclass:'
  3059 	^ #'subclass:'
  3053     ].
  3060     ].
  3054     self isBytes ifTrue:[
  3061     self isBytes ifTrue:[
  3055         ^ #'variableByteSubclass:'
  3062 	^ #'variableByteSubclass:'
  3056     ].
  3063     ].
  3057     self isLongs ifTrue:[
  3064     self isLongs ifTrue:[
  3058         ^ #'variableLongSubclass:'
  3065 	^ #'variableLongSubclass:'
  3059     ].
  3066     ].
  3060     self isFloats ifTrue:[
  3067     self isFloats ifTrue:[
  3061         ^ #'variableFloatSubclass:'
  3068 	^ #'variableFloatSubclass:'
  3062     ].
  3069     ].
  3063     self isDoubles ifTrue:[
  3070     self isDoubles ifTrue:[
  3064         ^ #'variableDoubleSubclass:'
  3071 	^ #'variableDoubleSubclass:'
  3065     ].
  3072     ].
  3066     self isWords ifTrue:[
  3073     self isWords ifTrue:[
  3067         ^ #'variableWordSubclass:'
  3074 	^ #'variableWordSubclass:'
  3068     ].
  3075     ].
  3069     self isSignedWords ifTrue:[
  3076     self isSignedWords ifTrue:[
  3070         ^ #'variableSignedWordSubclass:'
  3077 	^ #'variableSignedWordSubclass:'
  3071     ].
  3078     ].
  3072     self isSignedLongs ifTrue:[
  3079     self isSignedLongs ifTrue:[
  3073         ^ #'variableSignedLongSubclass:'
  3080 	^ #'variableSignedLongSubclass:'
  3074     ].
  3081     ].
  3075     self isSignedLongLongs ifTrue:[
  3082     self isSignedLongLongs ifTrue:[
  3076         ^ #'variableSignedLongLongSubclass:'
  3083 	^ #'variableSignedLongLongSubclass:'
  3077     ].
  3084     ].
  3078     self isLongLongs ifTrue:[
  3085     self isLongLongs ifTrue:[
  3079         ^ #'variableLongLongSubclass:'
  3086 	^ #'variableLongLongSubclass:'
  3080     ].
  3087     ].
  3081     ^ #'variableSubclass:'
  3088     ^ #'variableSubclass:'
  3082 !
  3089 !
  3083 
  3090 
  3084 fullName
  3091 fullName
  3296 
  3303 
  3297     |newColl|
  3304     |newColl|
  3298 
  3305 
  3299     newColl := OrderedCollection new.
  3306     newColl := OrderedCollection new.
  3300     self allSubclassesDo:[:aClass |
  3307     self allSubclassesDo:[:aClass |
  3301         (aClass isRealNameSpace) ifFalse:[
  3308 	(aClass isRealNameSpace) ifFalse:[
  3302             newColl add:aClass
  3309 	    newColl add:aClass
  3303         ]
  3310 	]
  3304     ].
  3311     ].
  3305     ^ newColl
  3312     ^ newColl
  3306 
  3313 
  3307     "
  3314     "
  3308      Collection allSubclasses
  3315      Collection allSubclasses
  3318 
  3325 
  3319     |newColl|
  3326     |newColl|
  3320 
  3327 
  3321     newColl := OrderedCollection new.
  3328     newColl := OrderedCollection new.
  3322     self allSubclassesInOrderDo:[:aClass |
  3329     self allSubclassesInOrderDo:[:aClass |
  3323         (aClass isRealNameSpace) ifFalse:[
  3330 	(aClass isRealNameSpace) ifFalse:[
  3324             newColl add:aClass
  3331 	    newColl add:aClass
  3325         ]
  3332 	]
  3326     ].
  3333     ].
  3327     ^ newColl
  3334     ^ newColl
  3328 
  3335 
  3329     "
  3336     "
  3330      Collection allSubclassesInOrder
  3337      Collection allSubclassesInOrder
  3338 
  3345 
  3339     |aCollection theSuperClass|
  3346     |aCollection theSuperClass|
  3340 
  3347 
  3341     theSuperClass := self superclass.
  3348     theSuperClass := self superclass.
  3342     theSuperClass isNil ifTrue:[
  3349     theSuperClass isNil ifTrue:[
  3343         ^ #()
  3350 	^ #()
  3344     ].
  3351     ].
  3345     aCollection := OrderedCollection new.
  3352     aCollection := OrderedCollection new.
  3346     [theSuperClass notNil] whileTrue:[
  3353     [theSuperClass notNil] whileTrue:[
  3347         aCollection add:theSuperClass.
  3354 	aCollection add:theSuperClass.
  3348         theSuperClass := theSuperClass superclass
  3355 	theSuperClass := theSuperClass superclass
  3349     ].
  3356     ].
  3350     ^ aCollection
  3357     ^ aCollection
  3351 
  3358 
  3352     "
  3359     "
  3353      String allSuperclasses
  3360      String allSuperclasses
  3430 
  3437 
  3431 %{  /* NOCONTEXT */
  3438 %{  /* NOCONTEXT */
  3432     OBJ __theClass = __INST(superclass);
  3439     OBJ __theClass = __INST(superclass);
  3433 
  3440 
  3434     while (__theClass != nil) {
  3441     while (__theClass != nil) {
  3435         if (__theClass == aClass) {
  3442 	if (__theClass == aClass) {
  3436             RETURN(true);
  3443 	    RETURN(true);
  3437         }
  3444 	}
  3438         if (__isBehaviorLike(__theClass)) {
  3445 	if (__isBehaviorLike(__theClass)) {
  3439             __theClass = __ClassInstPtr(__theClass)->c_superclass;
  3446 	    __theClass = __ClassInstPtr(__theClass)->c_superclass;
  3440         } else {
  3447 	} else {
  3441             __theClass = nil;
  3448 	    __theClass = nil;
  3442         }
  3449 	}
  3443     }
  3450     }
  3444     RETURN (false);
  3451     RETURN (false);
  3445 %}.
  3452 %}.
  3446 
  3453 
  3447 "/    |theClass|
  3454 "/    |theClass|
  3459 "/"/        theClass := theClass superclass.
  3466 "/"/        theClass := theClass superclass.
  3460 "/    ].
  3467 "/    ].
  3461 "/    ^ false
  3468 "/    ^ false
  3462 
  3469 
  3463     "
  3470     "
  3464      String isSubclassOf:Collection 
  3471      String isSubclassOf:Collection
  3465      LinkedList isSubclassOf:Array  
  3472      LinkedList isSubclassOf:Array
  3466      1 isSubclassOf:Number              <- will fail since 1 is no class
  3473      1 isSubclassOf:Number              <- will fail since 1 is no class
  3467      Number isSubclassOf:1              
  3474      Number isSubclassOf:1
  3468     "
  3475     "
  3469 !
  3476 !
  3470 
  3477 
  3471 subclasses
  3478 subclasses
  3472     "return a collection of the direct subclasses of the receiver"
  3479     "return a collection of the direct subclasses of the receiver"
  3473 
  3480 
  3474     |newColl|
  3481     |newColl|
  3475 
  3482 
  3476     newColl := OrderedCollection new.
  3483     newColl := OrderedCollection new.
  3477     self subclassesDo:[:aClass |
  3484     self subclassesDo:[:aClass |
  3478         newColl add:aClass
  3485 	newColl add:aClass
  3479     ].
  3486     ].
  3480     ^ newColl.
  3487     ^ newColl.
  3481 !
  3488 !
  3482 
  3489 
  3483 superclasses
  3490 superclasses
  3513 
  3520 
  3514     |aCollection|
  3521     |aCollection|
  3515 
  3522 
  3516     aCollection := OrderedCollection new.
  3523     aCollection := OrderedCollection new.
  3517     self withAllSuperclassesDo:[:cls |
  3524     self withAllSuperclassesDo:[:cls |
  3518         aCollection add:cls
  3525 	aCollection add:cls
  3519     ].
  3526     ].
  3520     ^ aCollection
  3527     ^ aCollection
  3521 
  3528 
  3522     "
  3529     "
  3523      String withAllSuperclasses
  3530      String withAllSuperclasses
  3548 
  3555 
  3549     |coll|
  3556     |coll|
  3550 
  3557 
  3551     coll := OrderedCollection new:100.
  3558     coll := OrderedCollection new:100.
  3552     self allInstancesDo:[:anObject |
  3559     self allInstancesDo:[:anObject |
  3553         coll add:anObject
  3560 	coll add:anObject
  3554     ].
  3561     ].
  3555     ^ coll
  3562     ^ coll
  3556 
  3563 
  3557     "
  3564     "
  3558      ScrollBar allInstances
  3565      ScrollBar allInstances
  3568 
  3575 
  3569     |coll|
  3576     |coll|
  3570 
  3577 
  3571     coll := self allInstances.
  3578     coll := self allInstances.
  3572     doWeakly ifTrue:[
  3579     doWeakly ifTrue:[
  3573         coll := WeakArray withAll:coll
  3580 	coll := WeakArray withAll:coll
  3574     ].
  3581     ].
  3575     ^ coll
  3582     ^ coll
  3576 
  3583 
  3577     "Created: / 19.6.1998 / 02:17:20 / cg"
  3584     "Created: / 19.6.1998 / 02:17:20 / cg"
  3578 !
  3585 !
  3583 
  3590 
  3584     |coll|
  3591     |coll|
  3585 
  3592 
  3586     coll := OrderedCollection new:100.
  3593     coll := OrderedCollection new:100.
  3587     self allSubInstancesDo:[:anObject |
  3594     self allSubInstancesDo:[:anObject |
  3588         (anObject isKindOf:self) ifTrue:[
  3595 	(anObject isKindOf:self) ifTrue:[
  3589             coll add:anObject
  3596 	    coll add:anObject
  3590         ]
  3597 	]
  3591     ].
  3598     ].
  3592     ^ coll
  3599     ^ coll
  3593 
  3600 
  3594     "
  3601     "
  3595      View allSubInstances
  3602      View allSubInstances
  3618 
  3625 
  3619     |count|
  3626     |count|
  3620 
  3627 
  3621     count := 0.
  3628     count := 0.
  3622     ObjectMemory allObjectsDo:[:anObject |
  3629     ObjectMemory allObjectsDo:[:anObject |
  3623         (anObject isKindOf:self) ifTrue:[
  3630 	(anObject isKindOf:self) ifTrue:[
  3624             count := count + 1
  3631 	    count := count + 1
  3625         ]
  3632 	]
  3626     ].
  3633     ].
  3627     ^ count
  3634     ^ count
  3628 
  3635 
  3629     "
  3636     "
  3630      View derivedInstanceCount
  3637      View derivedInstanceCount
  3638 
  3645 
  3639     "Read the documentation on why there seem to be no
  3646     "Read the documentation on why there seem to be no
  3640      instances of SmallInteger and UndefinedObject"
  3647      instances of SmallInteger and UndefinedObject"
  3641 
  3648 
  3642     ObjectMemory allObjectsDo:[:anObject |
  3649     ObjectMemory allObjectsDo:[:anObject |
  3643         (anObject isKindOf:self) ifTrue:[
  3650 	(anObject isKindOf:self) ifTrue:[
  3644             ^ true
  3651 	    ^ true
  3645         ]
  3652 	]
  3646     ].
  3653     ].
  3647     ^ false
  3654     ^ false
  3648 
  3655 
  3649     "
  3656     "
  3650      Object hasDerivedInstances         - certainly true
  3657      Object hasDerivedInstances         - certainly true
  3674 "/            ^ true
  3681 "/            ^ true
  3675 "/        ]
  3682 "/        ]
  3676 "/    ].
  3683 "/    ].
  3677 
  3684 
  3678     ObjectMemory allInstancesOf:self do:[:anObject |
  3685     ObjectMemory allInstancesOf:self do:[:anObject |
  3679         ^ true
  3686 	^ true
  3680     ].
  3687     ].
  3681     ^ false
  3688     ^ false
  3682 
  3689 
  3683     "
  3690     "
  3684      Object hasInstances
  3691      Object hasInstances
  3711 "/            count := count + 1
  3718 "/            count := count + 1
  3712 "/        ]
  3719 "/        ]
  3713 "/    ].
  3720 "/    ].
  3714 
  3721 
  3715     ObjectMemory allInstancesOf:self do:[:anObject |
  3722     ObjectMemory allInstancesOf:self do:[:anObject |
  3716         count := count + 1
  3723 	count := count + 1
  3717     ].
  3724     ].
  3718     ^ count
  3725     ^ count
  3719 
  3726 
  3720     "
  3727     "
  3721      View instanceCount
  3728      View instanceCount
  3731 elementByteSize
  3738 elementByteSize
  3732     "for bit-like containers, return the number of bytes stored per
  3739     "for bit-like containers, return the number of bytes stored per
  3733      element. For pointer indexed classes, 0 is returned"
  3740      element. For pointer indexed classes, 0 is returned"
  3734 
  3741 
  3735     self isBitsExtended ifTrue:[
  3742     self isBitsExtended ifTrue:[
  3736         self isBytes ifTrue:[^ 1].
  3743 	self isBytes ifTrue:[^ 1].
  3737         self isWords ifTrue:[^ 2].
  3744 	self isWords ifTrue:[^ 2].
  3738         self isSignedWords ifTrue:[^ 2].
  3745 	self isSignedWords ifTrue:[^ 2].
  3739         self isLongs ifTrue:[^ 4].
  3746 	self isLongs ifTrue:[^ 4].
  3740         self isSignedLongs ifTrue:[^ 4].
  3747 	self isSignedLongs ifTrue:[^ 4].
  3741         self isLongLongs ifTrue:[^ 8].
  3748 	self isLongLongs ifTrue:[^ 8].
  3742         self isSignedLongLongs ifTrue:[^ 8].
  3749 	self isSignedLongLongs ifTrue:[^ 8].
  3743     ].
  3750     ].
  3744     self isFloats ifTrue:[^ 4].
  3751     self isFloats ifTrue:[^ 4].
  3745     self isDoubles ifTrue:[^ 8].
  3752     self isDoubles ifTrue:[^ 8].
  3746 
  3753 
  3747     ^ 0
  3754     ^ 0
  3757 
  3764 
  3758     REGISTER int what;
  3765     REGISTER int what;
  3759 
  3766 
  3760     what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK);
  3767     what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK);
  3761     RETURN (( (what == __MASKSMALLINT(BYTEARRAY))
  3768     RETURN (( (what == __MASKSMALLINT(BYTEARRAY))
  3762              || (what == __MASKSMALLINT(WORDARRAY))) ? true : false );
  3769 	     || (what == __MASKSMALLINT(WORDARRAY))) ? true : false );
  3763 %}.
  3770 %}.
  3764     ^ self isBytes or:[self isWords]
  3771     ^ self isBytes or:[self isWords]
  3765 !
  3772 !
  3766 
  3773 
  3767 isBitsExtended
  3774 isBitsExtended
  3776 
  3783 
  3777     REGISTER int what;
  3784     REGISTER int what;
  3778 
  3785 
  3779     what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK);
  3786     what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK);
  3780     RETURN (( (what == __MASKSMALLINT(BYTEARRAY))
  3787     RETURN (( (what == __MASKSMALLINT(BYTEARRAY))
  3781              || (what == __MASKSMALLINT(WORDARRAY))
  3788 	     || (what == __MASKSMALLINT(WORDARRAY))
  3782              || (what == __MASKSMALLINT(SWORDARRAY))
  3789 	     || (what == __MASKSMALLINT(SWORDARRAY))
  3783              || (what == __MASKSMALLINT(LONGARRAY))
  3790 	     || (what == __MASKSMALLINT(LONGARRAY))
  3784              || (what == __MASKSMALLINT(SLONGARRAY))
  3791 	     || (what == __MASKSMALLINT(SLONGARRAY))
  3785              || (what == __MASKSMALLINT(LONGLONGARRAY))
  3792 	     || (what == __MASKSMALLINT(LONGLONGARRAY))
  3786              || (what == __MASKSMALLINT(SLONGLONGARRAY))) ? true : false );
  3793 	     || (what == __MASKSMALLINT(SLONGLONGARRAY))) ? true : false );
  3787 %}
  3794 %}
  3788 !
  3795 !
  3789 
  3796 
  3790 isBytes
  3797 isBytes
  3791     "return true, if instances have indexed byte instance variables"
  3798     "return true, if instances have indexed byte instance variables"
  3792 
  3799 
  3793     "this could also be defined as:
  3800     "this could also be defined as:
  3794         ^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagBytes
  3801 	^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagBytes
  3795     "
  3802     "
  3796 %{  /* NOCONTEXT */
  3803 %{  /* NOCONTEXT */
  3797 
  3804 
  3798     RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(BYTEARRAY)) ? true : false );
  3805     RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(BYTEARRAY)) ? true : false );
  3799 %}
  3806 %}
  3801 
  3808 
  3802 isDoubles
  3809 isDoubles
  3803     "return true, if instances have indexed double instance variables"
  3810     "return true, if instances have indexed double instance variables"
  3804 
  3811 
  3805     "this could also be defined as:
  3812     "this could also be defined as:
  3806         ^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagDoubles
  3813 	^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagDoubles
  3807     "
  3814     "
  3808 %{  /* NOCONTEXT */
  3815 %{  /* NOCONTEXT */
  3809 
  3816 
  3810     RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(DOUBLEARRAY)) ? true : false );
  3817     RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(DOUBLEARRAY)) ? true : false );
  3811 %}
  3818 %}
  3813 
  3820 
  3814 isFixed
  3821 isFixed
  3815     "return true, if instances do not have indexed instance variables"
  3822     "return true, if instances do not have indexed instance variables"
  3816 
  3823 
  3817     "this could also be defined as:
  3824     "this could also be defined as:
  3818         ^ self isVariable not
  3825 	^ self isVariable not
  3819     "
  3826     "
  3820 
  3827 
  3821 %{  /* NOCONTEXT */
  3828 %{  /* NOCONTEXT */
  3822 
  3829 
  3823     RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? false : true );
  3830     RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? false : true );
  3827 
  3834 
  3828 isFloats
  3835 isFloats
  3829     "return true, if instances have indexed float instance variables"
  3836     "return true, if instances have indexed float instance variables"
  3830 
  3837 
  3831     "this could also be defined as:
  3838     "this could also be defined as:
  3832         ^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagFloats
  3839 	^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagFloats
  3833     "
  3840     "
  3834 %{  /* NOCONTEXT */
  3841 %{  /* NOCONTEXT */
  3835 
  3842 
  3836     RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(FLOATARRAY)) ? true : false );
  3843     RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(FLOATARRAY)) ? true : false );
  3837 %}
  3844 %}
  3844 
  3851 
  3845     int what;
  3852     int what;
  3846 
  3853 
  3847     what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK);
  3854     what = (INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK);
  3848     RETURN (( (what == __MASKSMALLINT(FLOATARRAY))
  3855     RETURN (( (what == __MASKSMALLINT(FLOATARRAY))
  3849              || (what == __MASKSMALLINT(DOUBLEARRAY))) ? true : false );
  3856 	     || (what == __MASKSMALLINT(DOUBLEARRAY))) ? true : false );
  3850 %}.
  3857 %}.
  3851     ^ self isFloats or:[self isDoubles]
  3858     ^ self isFloats or:[self isDoubles]
  3852 
  3859 
  3853     "
  3860     "
  3854      (Object new) class isFloatsOrDoubles
  3861      (Object new) class isFloatsOrDoubles
  3888 
  3895 
  3889     REGISTER int flags;
  3896     REGISTER int flags;
  3890 
  3897 
  3891     flags = __intVal(__INST(flags)) & ARRAYMASK;
  3898     flags = __intVal(__INST(flags)) & ARRAYMASK;
  3892     switch (flags) {
  3899     switch (flags) {
  3893         default:
  3900 	default:
  3894             /* normal objects */
  3901 	    /* normal objects */
  3895             RETURN ( true );
  3902 	    RETURN ( true );
  3896 
  3903 
  3897         case BYTEARRAY:
  3904 	case BYTEARRAY:
  3898         case WORDARRAY:
  3905 	case WORDARRAY:
  3899         case LONGARRAY:
  3906 	case LONGARRAY:
  3900         case SWORDARRAY:
  3907 	case SWORDARRAY:
  3901         case SLONGARRAY:
  3908 	case SLONGARRAY:
  3902         case SLONGLONGARRAY:
  3909 	case SLONGLONGARRAY:
  3903         case LONGLONGARRAY:
  3910 	case LONGLONGARRAY:
  3904         case FLOATARRAY:
  3911 	case FLOATARRAY:
  3905         case DOUBLEARRAY:
  3912 	case DOUBLEARRAY:
  3906             RETURN (false );
  3913 	    RETURN (false );
  3907 
  3914 
  3908         case WKPOINTERARRAY:
  3915 	case WKPOINTERARRAY:
  3909             /* what about those ? */
  3916 	    /* what about those ? */
  3910             RETURN (true );
  3917 	    RETURN (true );
  3911     }
  3918     }
  3912 %}
  3919 %}
  3913 !
  3920 !
  3914 
  3921 
  3915 isSignedLongLongs
  3922 isSignedLongLongs
  3941 
  3948 
  3942 isVariable
  3949 isVariable
  3943     "return true, if instances have indexed instance variables"
  3950     "return true, if instances have indexed instance variables"
  3944 
  3951 
  3945     "this could also be defined as:
  3952     "this could also be defined as:
  3946         ^ (flags bitAnd:(Behavior maskIndexType)) ~~ 0
  3953 	^ (flags bitAnd:(Behavior maskIndexType)) ~~ 0
  3947      "
  3954      "
  3948 
  3955 
  3949 %{  /* NOCONTEXT */
  3956 %{  /* NOCONTEXT */
  3950 
  3957 
  3951     RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? true : false );
  3958     RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) ? true : false );
  3959 
  3966 
  3960     REGISTER int flags;
  3967     REGISTER int flags;
  3961 
  3968 
  3962     flags = __intVal(__INST(flags)) & ARRAYMASK;
  3969     flags = __intVal(__INST(flags)) & ARRAYMASK;
  3963     if (flags == WKPOINTERARRAY) {
  3970     if (flags == WKPOINTERARRAY) {
  3964         RETURN ( true );
  3971 	RETURN ( true );
  3965     }
  3972     }
  3966 %}.
  3973 %}.
  3967     ^ false
  3974     ^ false
  3968 !
  3975 !
  3969 
  3976 
  3970 isWords
  3977 isWords
  3971     "return true, if instances have indexed short instance variables"
  3978     "return true, if instances have indexed short instance variables"
  3972 
  3979 
  3973     "this could also be defined as:
  3980     "this could also be defined as:
  3974         ^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagWords
  3981 	^ (flags bitAnd:(Behavior maskIndexType)) == Behavior flagWords
  3975     "
  3982     "
  3976 %{  /* NOCONTEXT */
  3983 %{  /* NOCONTEXT */
  3977 
  3984 
  3978     RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(WORDARRAY)) ? true : false );
  3985     RETURN ( (((INT)(__INST(flags)) & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(WORDARRAY)) ? true : false );
  3979 %}
  3986 %}
  3991 %{
  3998 %{
  3992     INT nBytes;
  3999     INT nBytes;
  3993 
  4000 
  3994     nBytes = __intVal(nInstvars) * sizeof(OBJ) + OHDR_SIZE;
  4001     nBytes = __intVal(nInstvars) * sizeof(OBJ) + OHDR_SIZE;
  3995     if (__isSmallInteger(n)) {
  4002     if (__isSmallInteger(n)) {
  3996         int nIndex;
  4003 	int nIndex;
  3997 
  4004 
  3998         nIndex = __intVal(n);
  4005 	nIndex = __intVal(n);
  3999         switch (__intVal(__INST(flags)) & ARRAYMASK) {
  4006 	switch (__intVal(__INST(flags)) & ARRAYMASK) {
  4000             case BYTEARRAY:
  4007 	    case BYTEARRAY:
  4001                 nBytes += nIndex;
  4008 		nBytes += nIndex;
  4002                 if (nBytes & (__ALIGN__ - 1)) {
  4009 		if (nBytes & (__ALIGN__ - 1)) {
  4003                     nBytes = (nBytes & ~(__ALIGN__ - 1)) + __ALIGN__;
  4010 		    nBytes = (nBytes & ~(__ALIGN__ - 1)) + __ALIGN__;
  4004                 }
  4011 		}
  4005                 break;
  4012 		break;
  4006 
  4013 
  4007             case WORDARRAY:
  4014 	    case WORDARRAY:
  4008             case SWORDARRAY:
  4015 	    case SWORDARRAY:
  4009                 nBytes += nIndex * 2;
  4016 		nBytes += nIndex * 2;
  4010                 if (nBytes & (__ALIGN__ - 1)) {
  4017 		if (nBytes & (__ALIGN__ - 1)) {
  4011                     nBytes = (nBytes & ~(__ALIGN__ - 1)) + __ALIGN__;
  4018 		    nBytes = (nBytes & ~(__ALIGN__ - 1)) + __ALIGN__;
  4012                 }
  4019 		}
  4013                 break;
  4020 		break;
  4014 
  4021 
  4015             case LONGARRAY:
  4022 	    case LONGARRAY:
  4016             case SLONGARRAY:
  4023 	    case SLONGARRAY:
  4017                 nBytes += nIndex * 4;
  4024 		nBytes += nIndex * 4;
  4018                 break;
  4025 		break;
  4019 
  4026 
  4020             case LONGLONGARRAY:
  4027 	    case LONGLONGARRAY:
  4021             case SLONGLONGARRAY:
  4028 	    case SLONGLONGARRAY:
  4022                 nBytes += nIndex * 8;
  4029 		nBytes += nIndex * 8;
  4023                 break;
  4030 		break;
  4024 
  4031 
  4025             case FLOATARRAY:
  4032 	    case FLOATARRAY:
  4026                 nBytes += nIndex * sizeof(float);
  4033 		nBytes += nIndex * sizeof(float);
  4027                 break;
  4034 		break;
  4028 
  4035 
  4029             case DOUBLEARRAY:
  4036 	    case DOUBLEARRAY:
  4030                 nBytes += nIndex * sizeof(double);
  4037 		nBytes += nIndex * sizeof(double);
  4031                 break;
  4038 		break;
  4032 
  4039 
  4033             default:
  4040 	    default:
  4034                 nBytes += nIndex * sizeof(OBJ);
  4041 		nBytes += nIndex * sizeof(OBJ);
  4035                 break;
  4042 		break;
  4036         }
  4043 	}
  4037     }
  4044     }
  4038     RETURN (__mkSmallInteger(nBytes));
  4045     RETURN (__mkSmallInteger(nBytes));
  4039 %}
  4046 %}
  4040 ! !
  4047 ! !
  4041 
  4048 
  4048 
  4055 
  4049     |superclass|
  4056     |superclass|
  4050 
  4057 
  4051     superclass := self superclass.
  4058     superclass := self superclass.
  4052     superclass notNil ifTrue:[
  4059     superclass notNil ifTrue:[
  4053         ^ superclass allSelectors addAll:(self selectors); yourself.
  4060 	^ superclass allSelectors addAll:(self selectors); yourself.
  4054     ].
  4061     ].
  4055     ^ self selectors asIdentitySet
  4062     ^ self selectors asIdentitySet
  4056 
  4063 
  4057     "
  4064     "
  4058      Point allSelectors
  4065      Point allSelectors
  4085 
  4092 
  4086 canUnderstand:aSelector
  4093 canUnderstand:aSelector
  4087     "return true, if the receiver or one of its superclasses implements aSelector.
  4094     "return true, if the receiver or one of its superclasses implements aSelector.
  4088      (i.e. true if my instances understand aSelector)"
  4095      (i.e. true if my instances understand aSelector)"
  4089 
  4096 
  4090         "JV @ 2010-08-22: Rewritten to respect lookup object."
  4097     |l|
  4091         ^ (self lookupObject 
  4098 
  4092             lookupMethodForSelector:aSelector 
  4099     "JV @ 2010-08-22: Rewritten to respect lookup object."
  4093             directedTo:self 
  4100     (l := self lookupObject) notNil ifTrue:[
  4094             for: nil "Fake receiver"
  4101 	^ (l
  4095                 withArguments: nil "Fake arguments" 
  4102 	    lookupMethodForSelector:aSelector
  4096                 from: thisContext sender) notNil
  4103 	    directedTo:self
       
  4104 	    for: nil "Fake receiver"
       
  4105 		withArguments: nil "Fake arguments"
       
  4106 		from: thisContext sender) notNil
       
  4107     ].
  4097 
  4108 
  4098     "Original implementation"
  4109     "Original implementation"
  4099         "       
       
  4100     ^ (self lookupMethodFor:aSelector) notNil
  4110     ^ (self lookupMethodFor:aSelector) notNil
  4101         "
       
  4102 
  4111 
  4103     "
  4112     "
  4104      True canUnderstand:#ifTrue:
  4113      True canUnderstand:#ifTrue:
  4105      True canUnderstand:#==
  4114      True canUnderstand:#==
  4106      True canUnderstand:#do:
  4115      True canUnderstand:#do:
  4129 
  4138 
  4130     |dict|
  4139     |dict|
  4131 
  4140 
  4132     dict := self methodDictionary.
  4141     dict := self methodDictionary.
  4133     dict isNil ifTrue:[
  4142     dict isNil ifTrue:[
  4134         ('Behavior [warning]: nil methodDictionary in ' , self name printString) errorPrintCR.
  4143 	('Behavior [warning]: nil methodDictionary in ' , self name printString) errorPrintCR.
  4135         ^ exceptionValue value
  4144 	^ exceptionValue value
  4136     ].
  4145     ].
  4137 
  4146 
  4138     ^ dict at:aSelector ifAbsent:exceptionValue
  4147     ^ dict at:aSelector ifAbsent:exceptionValue
  4139 
  4148 
  4140     "
  4149     "
  4173    "Warning: this method is here to support multiple languages.
  4182    "Warning: this method is here to support multiple languages.
  4174      Do not use in code that works just with the smalltalk code.
  4183      Do not use in code that works just with the smalltalk code.
  4175      Use compiledMethodAt: selector instead"
  4184      Use compiledMethodAt: selector instead"
  4176 
  4185 
  4177     "Returns a method with given name of value of exceptionValue
  4186     "Returns a method with given name of value of exceptionValue
  4178     if not present. This differs from #compiledMethodAt:, since class 
  4187     if not present. This differs from #compiledMethodAt:, since class
  4179     may contain more methods with same name and different selectors.
  4188     may contain more methods with same name and different selectors.
  4180 
  4189 
  4181     Only methods in the receiver - not in the superclass chain are tested."
  4190     Only methods in the receiver - not in the superclass chain are tested."
  4182 
  4191 
  4183     |dict mth|
  4192     |dict mth|
  4184 
  4193 
  4185     dict := self methodDictionary.
  4194     dict := self methodDictionary.
  4186     dict isNil ifTrue:[
  4195     dict isNil ifTrue:[
  4187         ('Behavior [warning]: nil methodDictionary in ' , self name printString) errorPrintCR.
  4196 	('Behavior [warning]: nil methodDictionary in ' , self name printString) errorPrintCR.
  4188         ^ exceptionValue value
  4197 	^ exceptionValue value
  4189     ].
  4198     ].
  4190     "Quick check: look into method dictionary"        
  4199     "Quick check: look into method dictionary"
  4191     mth := dict at: name asSymbol ifAbsent:nil.
  4200     mth := dict at: name asSymbol ifAbsent:nil.
  4192     mth ifNotNil:[^mth].
  4201     mth ifNotNil:[^mth].
  4193 
  4202 
  4194     "Slow search..."
  4203     "Slow search..."
  4195     dict do:
  4204     dict do:
  4196         [:each|
  4205 	[:each|
  4197         (each isSynthetic not and:[each name = name])
  4206 	(each isSynthetic not and:[each name = name])
  4198             ifTrue:[^each]].
  4207 	    ifTrue:[^each]].
  4199     ^exceptionValue value
  4208     ^exceptionValue value
  4200     
  4209 
  4201 
  4210 
  4202     "
  4211     "
  4203      Object compiledMethodNamed:#==
  4212      Object compiledMethodNamed:#==
  4204      (Object compiledMethodNamed:#==) category
  4213      (Object compiledMethodNamed:#==) category
  4205     "
  4214     "
  4237     "return true, if the receiver implements aSelector.
  4246     "return true, if the receiver implements aSelector.
  4238      (i.e. implemented in THIS class - NOT in a superclass).
  4247      (i.e. implemented in THIS class - NOT in a superclass).
  4239     This is semantically equivalent to includesSelector: (which is ST/80/Squeak compatibility).
  4248     This is semantically equivalent to includesSelector: (which is ST/80/Squeak compatibility).
  4240 
  4249 
  4241      Caveat:
  4250      Caveat:
  4242         This simply checks for the selector being present in the classes
  4251 	This simply checks for the selector being present in the classes
  4243         selector table - therefore, it does not care for ignoredMethods.
  4252 	selector table - therefore, it does not care for ignoredMethods.
  4244         (but: you should not use this method for protocol-testing, anyway).
  4253 	(but: you should not use this method for protocol-testing, anyway).
  4245 
  4254 
  4246      Hint:
  4255      Hint:
  4247         Dont use this method to check if someone responds to a message -
  4256 	Dont use this method to check if someone responds to a message -
  4248         use #canUnderstand: on the class or #respondsTo: on the instance
  4257 	use #canUnderstand: on the class or #respondsTo: on the instance
  4249         to do this."
  4258 	to do this."
  4250 
  4259 
  4251     ^ self includesSelector:aSelector
  4260     ^ self includesSelector:aSelector
  4252 
  4261 
  4253     "
  4262     "
  4254      notice: this is class protocol
  4263      notice: this is class protocol
  4277     "return true, if the methodDictionary of THIS class includes a method for aSelector.
  4286     "return true, if the methodDictionary of THIS class includes a method for aSelector.
  4278      (i.e. if aSelector is implemented in THIS class - NOT in a superclass).
  4287      (i.e. if aSelector is implemented in THIS class - NOT in a superclass).
  4279      This is semantically equivalent to implements: (ST/80/Squeak compatibility).
  4288      This is semantically equivalent to implements: (ST/80/Squeak compatibility).
  4280 
  4289 
  4281      Hint:
  4290      Hint:
  4282         Dont use this method to check if someone responds to a message -
  4291 	Dont use this method to check if someone responds to a message -
  4283         use #canUnderstand: on the class or #respondsTo: on the instance
  4292 	use #canUnderstand: on the class or #respondsTo: on the instance
  4284         to do this.
  4293 	to do this.
  4285 
  4294 
  4286      Caveat:
  4295      Caveat:
  4287         This simply checks for the selector being present in the classes
  4296 	This simply checks for the selector being present in the classes
  4288         selector table - therefore, it does not care for ignoredMethods.
  4297 	selector table - therefore, it does not care for ignoredMethods.
  4289         (but: you should not use this method for protocol-testing, anyway)."
  4298 	(but: you should not use this method for protocol-testing, anyway)."
  4290 
  4299 
  4291     ^ self methodDictionary includesIdenticalKey:aSelector
  4300     ^ self methodDictionary includesIdenticalKey:aSelector
  4292 
  4301 
  4293     "
  4302     "
  4294      Object includesSelector:#==
  4303      Object includesSelector:#==
  4312      an instance of the receiver. I.e. the selector arrays of the receiver
  4321      an instance of the receiver. I.e. the selector arrays of the receiver
  4313      and all of its superclasses are searched for aSelector.
  4322      and all of its superclasses are searched for aSelector.
  4314      Return the method, or nil if instances do not understand aSelector.
  4323      Return the method, or nil if instances do not understand aSelector.
  4315      EXPERIMENTAL: take care of multiple superclasses."
  4324      EXPERIMENTAL: take care of multiple superclasses."
  4316 
  4325 
  4317         "JV @ 2010-08-22: Rewritten to respect lookup object."
  4326     |l m cls|
  4318         ^ (self lookupObject 
  4327 
  4319             lookupMethodForSelector:aSelector 
  4328     "JV @ 2010-08-22: Rewritten to respect lookup object."
  4320             directedTo:self 
  4329     (l := self lookupObject) notNil ifTrue:[
  4321             for: nil "Fake receiver"
  4330 	^ (l
  4322                 withArguments: nil "Fake arguments" 
  4331 	    lookupMethodForSelector:aSelector
  4323                 from: thisContext sender)
  4332 	    directedTo:self
  4324 
  4333 	    for: nil "Fake receiver"
  4325     "Original implementation"
  4334 		withArguments: nil "Fake arguments"
  4326         "
  4335 		from: thisContext sender)
  4327     |m cls|
  4336     ].
  4328 
  4337 
  4329     cls := self.
  4338     cls := self.
  4330     [cls notNil] whileTrue:[
  4339     [cls notNil] whileTrue:[
  4331         m := cls compiledMethodAt:aSelector.
  4340 	m := cls compiledMethodAt:aSelector.
  4332         m notNil ifTrue:[^ m].
  4341 	m notNil ifTrue:[^ m].
  4333         cls hasMultipleSuperclasses ifTrue:[
  4342 	cls hasMultipleSuperclasses ifTrue:[
  4334             cls superclasses do:[:aSuperClass |
  4343 	    cls superclasses do:[:aSuperClass |
  4335                 m := aSuperClass lookupMethodFor:aSelector.
  4344 		m := aSuperClass lookupMethodFor:aSelector.
  4336                 m notNil ifTrue:[^ m].
  4345 		m notNil ifTrue:[^ m].
  4337             ].
  4346 	    ].
  4338             ^ nil
  4347 	    ^ nil
  4339         ] ifFalse:[
  4348 	] ifFalse:[
  4340             cls := cls superclass
  4349 	    cls := cls superclass
  4341         ]
  4350 	]
  4342     ].
  4351     ].
  4343     ^ nil
  4352     ^ nil
  4344         "
       
  4345 !
  4353 !
  4346 
  4354 
  4347 responseTo:aSelector
  4355 responseTo:aSelector
  4348     "return the method (from here or the inheritance chain),
  4356     "return the method (from here or the inheritance chain),
  4349      which implements aSelector; return nil if none."
  4357      which implements aSelector; return nil if none."
  4350 
  4358 
  4351     |cls|
  4359     |cls|
  4352 
  4360 
  4353     cls := self whichClassIncludesSelector:aSelector.
  4361     cls := self whichClassIncludesSelector:aSelector.
  4354     cls notNil ifTrue:[
  4362     cls notNil ifTrue:[
  4355         ^ cls compiledMethodAt:aSelector
  4363 	^ cls compiledMethodAt:aSelector
  4356     ].
  4364     ].
  4357     ^ nil
  4365     ^ nil
  4358 
  4366 
  4359     "
  4367     "
  4360      String responseTo:#==
  4368      String responseTo:#==
  4388 
  4396 
  4389     |md|
  4397     |md|
  4390 
  4398 
  4391     md := self methodDictionary.
  4399     md := self methodDictionary.
  4392     md isNil ifTrue:[
  4400     md isNil ifTrue:[
  4393         'OOPS - nil methodDictionary' errorPrintCR.
  4401 	'OOPS - nil methodDictionary' errorPrintCR.
  4394         ^ nil
  4402 	^ nil
  4395     ].
  4403     ].
  4396     ^ md keyAtValue:aMethod ifAbsent:failBlock.
  4404     ^ md keyAtValue:aMethod ifAbsent:failBlock.
  4397 
  4405 
  4398     "
  4406     "
  4399      |m|
  4407      |m|
  4427 
  4435 
  4428     |cls|
  4436     |cls|
  4429 
  4437 
  4430     cls := self.
  4438     cls := self.
  4431     [cls notNil] whileTrue:[
  4439     [cls notNil] whileTrue:[
  4432         (cls includesSelector:aSelector) ifTrue:[^ cls].
  4440 	(cls includesSelector:aSelector) ifTrue:[^ cls].
  4433         cls hasMultipleSuperclasses ifTrue:[
  4441 	cls hasMultipleSuperclasses ifTrue:[
  4434             cls superclasses do:[:aSuperClass |
  4442 	    cls superclasses do:[:aSuperClass |
  4435                 |implementingClass|
  4443 		|implementingClass|
  4436 
  4444 
  4437                 implementingClass := aSuperClass whichClassIncludesSelector:aSelector.
  4445 		implementingClass := aSuperClass whichClassIncludesSelector:aSelector.
  4438                 implementingClass notNil ifTrue:[^ implementingClass].
  4446 		implementingClass notNil ifTrue:[^ implementingClass].
  4439             ].
  4447 	    ].
  4440             ^ nil
  4448 	    ^ nil
  4441         ] ifFalse:[
  4449 	] ifFalse:[
  4442             cls := cls superclass
  4450 	    cls := cls superclass
  4443         ]
  4451 	]
  4444     ].
  4452     ].
  4445     ^ nil
  4453     ^ nil
  4446 
  4454 
  4447     "
  4455     "
  4448      String whichClassIncludesSelector:#==
  4456      String whichClassIncludesSelector:#==
  4523 
  4531 
  4524     |superclass superInsts|
  4532     |superclass superInsts|
  4525 
  4533 
  4526     superclass := self superclass.
  4534     superclass := self superclass.
  4527     superclass isNil ifTrue:[
  4535     superclass isNil ifTrue:[
  4528         superInsts := 0
  4536 	superInsts := 0
  4529     ] ifFalse:[
  4537     ] ifFalse:[
  4530         superInsts := superclass instSize
  4538 	superInsts := superclass instSize
  4531     ].
  4539     ].
  4532     ^ (superInsts+1 to:self instSize)
  4540     ^ (superInsts+1 to:self instSize)
  4533        collect:[:index | self instVarNameForIndex:index]
  4541        collect:[:index | self instVarNameForIndex:index]
  4534 
  4542 
  4535     "Modified: / 17-07-2006 / 00:28:40 / cg"
  4543     "Modified: / 17-07-2006 / 00:28:40 / cg"
  4553     |superclass s superInsts first n "{Class: SmallInteger }"|
  4561     |superclass s superInsts first n "{Class: SmallInteger }"|
  4554 
  4562 
  4555     superclass := self superclass.
  4563     superclass := self superclass.
  4556     s := ''.
  4564     s := ''.
  4557     superclass isNil ifTrue:[
  4565     superclass isNil ifTrue:[
  4558         superInsts := 0
  4566 	superInsts := 0
  4559     ] ifFalse:[
  4567     ] ifFalse:[
  4560         superInsts := superclass instSize
  4568 	superInsts := superclass instSize
  4561     ].
  4569     ].
  4562     n := self instSize.
  4570     n := self instSize.
  4563     first := true.
  4571     first := true.
  4564     superInsts+1 to:n do:[:i |
  4572     superInsts+1 to:n do:[:i |
  4565         first ifFalse:[s := s , ' '] ifTrue:[first := false].
  4573 	first ifFalse:[s := s , ' '] ifTrue:[first := false].
  4566 
  4574 
  4567         s := s , 'instvar' , i printString
  4575 	s := s , 'instvar' , i printString
  4568     ].
  4576     ].
  4569     ^ s
  4577     ^ s
  4570 
  4578 
  4571     "
  4579     "
  4572      Behavior new instanceVariableString
  4580      Behavior new instanceVariableString
  4582 
  4590 
  4583     name := aStringOrText asString string.
  4591     name := aStringOrText asString string.
  4584     ^ self whichClassSatisfies:[:aClass | aClass classVarNames includes:name]
  4592     ^ self whichClassSatisfies:[:aClass | aClass classVarNames includes:name]
  4585 
  4593 
  4586     "
  4594     "
  4587      TextView whichClassDefinesClassVar:'CachedScales' 
  4595      TextView whichClassDefinesClassVar:'CachedScales'
  4588      TextView whichClassDefinesClassVar:'xxx' 
  4596      TextView whichClassDefinesClassVar:'xxx'
  4589     "
  4597     "
  4590 !
  4598 !
  4591 
  4599 
  4592 whichClassDefinesInstVar: aString
  4600 whichClassDefinesInstVar: aString
  4593     ^ self whichClassSatisfies: [:aClass | aClass instVarNames includes: aString]
  4601     ^ self whichClassSatisfies: [:aClass | aClass instVarNames includes: aString]
  4594 !
  4602 !
  4595 
  4603 
  4596 whichSelectorsAssign: instVarName
  4604 whichSelectorsAssign: instVarName
  4597         "Answer a set of selectors whose methods write the argument, instVarName,
  4605 	"Answer a set of selectors whose methods write the argument, instVarName,
  4598         as a named instance variable."
  4606 	as a named instance variable."
  4599 
  4607 
  4600         ^ self whichSelectorsWrite: instVarName
  4608 	^ self whichSelectorsWrite: instVarName
  4601 !
  4609 !
  4602 
  4610 
  4603 whichSelectorsRead: instVarName
  4611 whichSelectorsRead: instVarName
  4604         "Answer a set of selectors whose methods read the argument, instVarName,
  4612 	"Answer a set of selectors whose methods read the argument, instVarName,
  4605         as a named instance variable."
  4613 	as a named instance variable."
  4606 
  4614 
  4607         | instVarIndex methodDict|
  4615 	| instVarIndex methodDict|
  4608         instVarIndex := self allInstVarNames indexOf: instVarName ifAbsent: [^Set new].
  4616 	instVarIndex := self allInstVarNames indexOf: instVarName ifAbsent: [^Set new].
  4609         methodDict := self methodDictionary.
  4617 	methodDict := self methodDictionary.
  4610         ^methodDict keys select: [:sel | (methodDict at: sel)
  4618 	^methodDict keys select: [:sel | (methodDict at: sel)
  4611                         readsField: instVarIndex]
  4619 			readsField: instVarIndex]
  4612 !
  4620 !
  4613 
  4621 
  4614 whichSelectorsReferTo:someLiteralConstant
  4622 whichSelectorsReferTo:someLiteralConstant
  4615     "return a collection of selectors of methods which refer to the argument.
  4623     "return a collection of selectors of methods which refer to the argument.
  4616      Search the literal arrays of my methods to do this."
  4624      Search the literal arrays of my methods to do this."
  4617 
  4625 
  4618     |setOfSelectors|
  4626     |setOfSelectors|
  4619 
  4627 
  4620     setOfSelectors := IdentitySet new.
  4628     setOfSelectors := IdentitySet new.
  4621     self methodDictionary keysAndValuesDo:[:sel :mthd |
  4629     self methodDictionary keysAndValuesDo:[:sel :mthd |
  4622         (mthd referencesLiteral:someLiteralConstant) ifTrue:[
  4630 	(mthd referencesLiteral:someLiteralConstant) ifTrue:[
  4623             setOfSelectors add:sel
  4631 	    setOfSelectors add:sel
  4624         ].
  4632 	].
  4625     ].
  4633     ].
  4626 
  4634 
  4627     ^ setOfSelectors
  4635     ^ setOfSelectors
  4628 
  4636 
  4629     "
  4637     "
  4662 
  4670 
  4663     "Modified: / 4.2.2000 / 00:41:10 / cg"
  4671     "Modified: / 4.2.2000 / 00:41:10 / cg"
  4664 !
  4672 !
  4665 
  4673 
  4666 whichSelectorsWrite: instVarName
  4674 whichSelectorsWrite: instVarName
  4667         "Answer a set of selectors whose methods write the argument, instVarName,
  4675 	"Answer a set of selectors whose methods write the argument, instVarName,
  4668         as a named instance variable."
  4676 	as a named instance variable."
  4669 
  4677 
  4670         | instVarIndex methodDict |
  4678 	| instVarIndex methodDict |
  4671         instVarIndex := self allInstVarNames indexOf: instVarName ifAbsent: [^Set new].
  4679 	instVarIndex := self allInstVarNames indexOf: instVarName ifAbsent: [^Set new].
  4672         methodDict := self methodDictionary.
  4680 	methodDict := self methodDictionary.
  4673         ^methodDict keys select: [:sel | (methodDict at: sel)
  4681 	^methodDict keys select: [:sel | (methodDict at: sel)
  4674                         writesField: instVarIndex]
  4682 			writesField: instVarIndex]
  4675 ! !
  4683 ! !
  4676 
  4684 
  4677 !Behavior methodsFor:'snapshots'!
  4685 !Behavior methodsFor:'snapshots'!
  4678 
  4686 
  4679 postSnapshot
  4687 postSnapshot
  4711 
  4719 
  4712 !Behavior class methodsFor:'documentation'!
  4720 !Behavior class methodsFor:'documentation'!
  4713 
  4721 
  4714 
  4722 
  4715 version_CVS
  4723 version_CVS
  4716     ^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.311 2011-06-28 12:41:18 vrany Exp $'
  4724     ^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.312 2011-06-28 13:54:21 cg Exp $'
  4717 !
  4725 !
  4718 
  4726 
  4719 version_SVN
  4727 version_SVN
  4720     ^ ' Id: Behavior.st 10643 2011-06-08 21:53:07Z vranyj1  '
  4728     ^ ' Id: Behavior.st 10643 2011-06-08 21:53:07Z vranyj1  '
  4721 ! !
  4729 ! !