Dictionary allInstances size
Window allInstances first close
anObject pointersTo
returns all objects that store a reference to anObject
anObject become: anotherObject
anObject
point now to anotherObject
| pt1 pt2 pt3 |
pt1 := 0@0.
pt2 := pt1.
pt3 := 100@100.
pt1 become: pt3.
self assert: pt2 = (100@100).
self assert: pt3 = (0@0).
self assert: pt1 = (100@100)
Swap all the pointers from one object to the other (asymmetric)
anObject becomeForward: anotherObject
| pt1 pt2 pt3 |
pt1 := 0@0.
pt2 := pt1.
pt3 := 100@100.
pt1 becomeForward: pt3.
self assert: pt1 = (100@100).
self assert: pt1 == pt2.
self assert: pt2 == pt3.
Class >> adoptInstance: anInstance
"Change the class of anInstance to me. Returns the class rather than the modified instance"
Behavior >> initialize
super initialize.
self superclass: Object.
self methodDict: self emptyMethodDictionary.
self setFormat: Object format.
| behavior model newClass |
behavior := Behavior new.
behavior superclass: Model.
behavior setFormat: Model format.
model := Model new.
model primitiveChangeClassTo: behavior new.
self assert: model class = behavior.
self assert: model class superclass = Model.
behavior compile: 'foo ^ 2'.
self assert: model foo = 2.
self should: [Model new foo] raise: MessageNotUnderstood
| logClass set |
logClass := Behavior new.
logClass superclass: Set;
setFormat: Set format.
logClass compile: 'add: anObject
Transcript show: ''adding '', anObject printString; cr.
^ super add: anObject'.
set := Set new.
set add: 1.
set class.
set primitiveChangeClassTo: logClass basicNew.
set add: 2.
/