1 x@(Root traits) immutablySettingSlots: slotArray to: valueArray
2 "TODO: optimize this somehow to avoid the wasteful clone?"
5 ifTrue: [x cloneSettingSlots: slotArray to: valueArray]
6 ifFalse: [x immutably cloneSettingSlots: slotArray to: valueArray]
9 x@(Root traits) isFrozen
10 "Whether the object and all its slot values recursively are immutable."
13 [x allSlotsDo: [| :obj | obj isImmutable ifFalse: [^ False]. True]]
16 "TODO: figure out a more systematic way to handle has-no-slots-and-never-will."
17 x@(Oddball traits) immutably [x].
18 x@(Oddball traits) freeze [x].
19 x@(SmallInteger traits) isImmutable [True].
20 x@(SmallInteger traits) isFrozen [True].
22 x@(Root traits) freeze &seen
23 "Make a frozen variant of the existing object, meaning an immutable version of
24 the object with frozen variants of its slot values (and so it must recurse)."
26 seen `defaultsTo: IdentityDictionary new.
27 x isFrozen \/ [x restrictsDelegation]
29 ifFalse: [seen at: x ifAbsentPut:
30 [x immutablySettingSlots: x slotNames to:
31 (x slotValues collect: [| :obj | obj freeze &seen: seen])]]