# HG changeset patch # User Stefan Vogel # Date 1469109079 -7200 # Node ID 40f9f1f07a68eec2bf534bc814963bddb770d75f # Parent 529ce6e786175199cbf5c02e2813249238c13dbb #BUGFIX by stefan class: WeakIdentityDictionary changed:6 methods check for SmallInteger keys diff -r 529ce6e78617 -r 40f9f1f07a68 WeakIdentityDictionary.st --- a/WeakIdentityDictionary.st Thu Jul 21 15:50:52 2016 +0200 +++ b/WeakIdentityDictionary.st Thu Jul 21 15:51:19 2016 +0200 @@ -77,15 +77,20 @@ |val| + key class == SmallInteger ifTrue:[ + "SmallIntegers cannot be stored into a WeakArray" + ^ exceptionBlock value. + ]. + (OperatingSystem blockInterrupts) ifTrue:[ - "/ already blocked - ^ super at:key ifAbsent:exceptionBlock. + "/ already blocked + ^ super at:key ifAbsent:exceptionBlock. ]. [ - val := super at:key ifAbsent:exceptionBlock. + val := super at:key ifAbsent:exceptionBlock. ] ensure:[ - OperatingSystem unblockInterrupts. + OperatingSystem unblockInterrupts. ]. ^ val @@ -99,6 +104,11 @@ |val| + key class == SmallInteger ifTrue:[ + "SmallIntegers cannot be stored into a WeakArray" + self error:'WeakidentityDictionary: cannot store a SmallInteger'. + ]. + (OperatingSystem blockInterrupts) ifTrue:[ "/ already blocked ^ super at:key ifAbsentPut:replacementBlock. @@ -120,15 +130,20 @@ |val| + key class == SmallInteger ifTrue:[ + "SmallIntegers cannot be stored into a WeakArray" + self error:'WeakidentityDictionary: cannot store a SmallInteger'. + ]. + (OperatingSystem blockInterrupts) ifTrue:[ - "/ already blocked - ^ super at:key put:anObject. + "/ already blocked + ^ super at:key put:anObject. ]. [ - val := super at:key put:anObject. + val := super at:key put:anObject. ] ensure:[ - OperatingSystem unblockInterrupts. + OperatingSystem unblockInterrupts. ]. ^ val @@ -148,15 +163,20 @@ |ret| + aKey class == SmallInteger ifTrue:[ + "SmallIntegers cannot be stored into a WeakArray" + ^ aBlock value. + ]. + (OperatingSystem blockInterrupts) ifTrue:[ - "/ already blocked - ^ super removeKey:aKey ifAbsent:aBlock. + "/ already blocked + ^ super removeKey:aKey ifAbsent:aBlock. ]. [ - ret := super removeKey:aKey ifAbsent:aBlock + ret := super removeKey:aKey ifAbsent:aBlock ] ensure:[ - OperatingSystem unblockInterrupts + OperatingSystem unblockInterrupts ]. ^ ret @@ -170,15 +190,20 @@ |val| + key class == SmallInteger ifTrue:[ + "SmallIntegers cannot be stored into a WeakArray" + ^ nil. + ]. + (OperatingSystem blockInterrupts) ifTrue:[ - "/ already blocked - ^ super safeRemoveKey:key. + "/ already blocked + ^ super safeRemoveKey:key. ]. [ - val := super safeRemoveKey:key. + val := super safeRemoveKey:key. ] ensure:[ - OperatingSystem unblockInterrupts. + OperatingSystem unblockInterrupts. ]. ^ val @@ -406,15 +431,20 @@ |val| + key class == SmallInteger ifTrue:[ + "SmallIntegers cannot be stored into a WeakArray" + ^ false. + ]. + (OperatingSystem blockInterrupts) ifTrue:[ - "/ already blocked - ^ super includesKey:key. + "/ already blocked + ^ super includesKey:key. ]. [ - val := super includesKey:key. + val := super includesKey:key. ] ensure:[ - OperatingSystem unblockInterrupts. + OperatingSystem unblockInterrupts. ]. ^ val