Subclass of:
View inheritance diagram or package diagram


ProtoObject establishes minimal behavior required of any object in Squeak, even objects that should balk at normal object behavior. Generally these are proxy objects designed to read themselves in from the disk, or to perform some wrapper behavior, before responding to a message. Current examples are ObjectOut and ImageSegmentRootStub, and one could argue that ObjectTracer should also inherit from this class.

ProtoObject has no instance variables, nor should any be added.

Instance Method Summary

Instance Method Details

ProtoObject >> ==

Primitive. Answer whether the receiver and the argument are the same object (have the same object pointer). Do not redefine the message == in any other class! Essential. No Lookup. Do not override in any subclass. See Object documentation whatIsAPrimitive.

== anObject 

ProtoObject >> basicIdentityHash

Answer a SmallInteger whose value is related to the receiver's identity. This method must not be overridden, except by SmallInteger. Primitive. Fails if the receiver is a SmallInteger. Essential. See Object documentation whatIsAPrimitive.

Do not override. Use #identityHash unless you really know what you're doing.'


ProtoObject >> become:

Primitive. Swap the object pointers of the receiver and the argument. All variables in the entire system that used to point to the receiver now point to the argument, and vice-versa. Fails if either object is a SmallInteger

become: otherObject 

ProtoObject >> cannotInterpret:

Handle the fact that there was an attempt to send the given message to the receiver but a null methodDictionary was encountered while looking up the message selector. Hopefully this is the result of encountering a stub for a swapped out class which induces this exception on purpose. If this is the result of encountering a swap-out stub, then simulating the lookup in Smalltalk should suffice to install the class properly, and the message may be resent.

cannotInterpret: aMessage 
(self class lookupSelector: aMessage selector) == nil 
^aMessage sentTo: self

"Could not recover by simulated lookup -- it's an error"
Error signal: 'MethodDictionary fault'.

"Try again in case an error handler fixed things"
^aMessage sentTo: self

ProtoObject >> doOnlyOnce:

If the 'one-shot' mechanism is armed, evaluate aBlock once and disarm the one-shot mechanism. To rearm the mechanism, evaluate 'self rearmOneShot' manually.

doOnlyOnce: aBlock 

ProtoObject >> doesNotUnderstand:

doesNotUnderstand: aMessage 

ProtoObject >> flag:

Send this message, with a relevant symbol as argument, to flag a message for subsequent retrieval. For example, you might put the following line in a number of messages: self flag: #returnHereUrgently Then, to retrieve all such messages, browse all senders of #returnHereUrgently.

flag: aSymbol 

ProtoObject >> identityHash

Answer a SmallInteger whose value is related to the receiver's identity. This method must not be overridden, except by SmallInteger.

Do not override.


ProtoObject >> ifNil:

Return self, or evaluate the block if I'm == nil (q.v.)

ifNil: nilBlock 

ProtoObject >> ifNil:ifNotNil:

Evaluate the block, unless I'm == nil (q.v.)

ifNil: nilBlock ifNotNil: ifNotNilBlock 
^ifNotNilBlock cull: self

ProtoObject >> ifNotNil:

Evaluate the block, unless I'm == nil (q.v.)

ifNotNil: ifNotNilBlock 
^ifNotNilBlock cull: self

ProtoObject >> ifNotNil:ifNil:

If I got here, I am not nil, so evaluate the block ifNotNilBlock

ifNotNil: ifNotNilBlock ifNil: nilBlock 
^ifNotNilBlock cull: self

ProtoObject >> initialize

Subclasses should redefine this method to perform initializations on instance creation


ProtoObject >> instVarsInclude:

Answers true if anObject is among my named or indexed instance variables, and false otherwise

instVarsInclude: anObject 
<primitive: 132>
1 to: self class instSize do: :i |
(self instVarAt: i) == anObject 
ifTrue: ^true ]

1 to: self basicSize do: :i |
(self basicAt: i) == anObject 
ifTrue: ^true ]


ProtoObject >> isNil

Coerces nil to true and everything else to false.


ProtoObject >> nextInstance

Primitive. Answer the next instance after the receiver in the enumeration of all instances of this class. Fails if all instances have been enumerated. Essential. See Object documentation whatIsAPrimitive.


ProtoObject >> nextObject

Primitive. Answer the next object after the receiver in the enumeration of all objects. Return 0 when all objects have been enumerated.


ProtoObject >> pointersTo

^self pointersToExcept: #()

ProtoObject >> pointersToExcept:

Find all objects in the system that hold a pointer to me, excluding those listed

pointersToExcept: objectsToExclude 
| c pointers object objectsToAlwaysExclude |
Smalltalk garbageCollect
pointers := OrderedCollection new.
"SystemNavigation >> #allObjectsDo: is inlined here with a slight modification: the marker object is pointers. This gives better results, because the value of pointers, it's inner objects and transient method contexts will not be iterated over."
object := self someObject.
object == pointers ] whileFalse: 
(object pointsTo: self) 
ifTrue: pointers add: object ].

object := object nextObject

objectsToAlwaysExclude := {
(thisContext sender).
(thisContext sender sender).

c := thisContext.
^(pointers removeAllSuchThat: :ea |
ea == thisContext sender or: 
(objectsToAlwaysExclude identityIncludes: ea) or: objectsToExclude identityIncludes: ea ]

ProtoObject >> pointsTo:

Answers true if I hold a reference to anObject, or false otherwise

pointsTo: anObject 
^(self instVarsInclude: anObject) or: ^self class == anObject and: self class isCompact not ] ]

ProtoObject >> rearmOneShot

Call this manually to arm the one-shot mechanism; use the mechanism in code by calling self doOnlyOnce: <a block>

Smalltalk globals at: #'OneShotArmed' put: true
"self rearmOneShot"

ProtoObject >> rehash

Do nothing. Here so sending this to a Set does not have to do a time consuming respondsTo:


ProtoObject >> tryPrimitive:withArgs:

This method is a template that the Smalltalk simulator uses to execute primitives. See Object documentation whatIsAPrimitive.

tryPrimitive: primIndex withArgs: argumentArray 

ProtoObject >> withArgs:executeMethod:

Execute compiledMethod against the receiver and args in argArray

withArgs: argArray executeMethod: compiledMethod 

ProtoObject >> ~~

Answer whether the receiver and the argument are not the same object (do not have the same object pointer).

~~ anObject 
self == anObject 
ifTrue: ^false ] 
ifFalse: ^true ]