--- a/compiler/PPCContextMemento.st Thu Apr 30 23:43:14 2015 +0200
+++ b/compiler/PPCContextMemento.st Sun May 10 06:28:36 2015 +0100
@@ -12,99 +12,99 @@
!PPCContextMemento methodsFor:'accessing'!
position
- ^ position
+ ^ position
!
position: anInteger
- position := anInteger
+ position := anInteger
! !
!PPCContextMemento methodsFor:'accessing - properties'!
hasProperty: aKey
- "Test if the property aKey is present."
-
- ^ properties notNil and: [ properties includesKey: aKey ]
+ "Test if the property aKey is present."
+
+ ^ properties notNil and: [ properties includesKey: aKey ]
!
keysAndValuesDo: aBlock
- properties ifNil: [ ^ self ].
- properties keysAndValuesDo: [ :key :value | aBlock value: key value: value copy ]
+ properties ifNil: [ ^ self ].
+ properties keysAndValuesDo: [ :key :value | aBlock value: key value: value copy ]
!
propertiesSize
- properties ifNil: [ ^ 0 ].
- ^ properties size.
+ properties ifNil: [ ^ 0 ].
+ ^ properties size.
!
propertyAt: aKey
- "Answer the property value associated with aKey."
-
- ^ self propertyAt: aKey ifAbsent: [ self error: 'Property not found' ]
+ "Answer the property value associated with aKey."
+
+ ^ self propertyAt: aKey ifAbsent: [ self error: 'Property not found' ]
!
propertyAt: aKey ifAbsent: aBlock
- "Answer the property value associated with aKey or, if aKey isn't found, answer the result of evaluating aBlock."
+ "Answer the property value associated with aKey or, if aKey isn't found, answer the result of evaluating aBlock."
- properties isNil ifFalse: [
- (properties includesKey: aKey) ifTrue: [
- ^ (properties at: aKey) copy
- ].
- ].
- ^ aBlock value
+ properties isNil ifFalse: [
+ (properties includesKey: aKey) ifTrue: [
+ ^ (properties at: aKey) copy
+ ].
+ ].
+ ^ aBlock value
"Modified: / 15-04-2015 / 11:19:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
propertyAt: aKey ifAbsentPut: aBlock
- "Answer the property associated with aKey or, if aKey isn't found store the result of evaluating aBlock as new value."
-
- ^ self propertyAt: aKey ifAbsent: [ self propertyAt: aKey put: aBlock value ]
+ "Answer the property associated with aKey or, if aKey isn't found store the result of evaluating aBlock as new value."
+
+ ^ self propertyAt: aKey ifAbsent: [ self propertyAt: aKey put: aBlock value ]
!
propertyAt: aKey put: anObject
- "Set the property at aKey to be anObject. If aKey is not found, create a new entry for aKey and set is value to anObject. Answer anObject."
+ "Set the property at aKey to be anObject. If aKey is not found, create a new entry for aKey and set is value to anObject. Answer anObject."
- ^ (properties ifNil: [ properties := Dictionary new: 1 ])
- at: aKey put: (anObject copy)
+ ^ (properties ifNil: [ properties := Dictionary new: 1 ])
+ at: aKey put: (anObject copy)
!
removeProperty: aKey
- "Remove the property with aKey. Answer the property or raise an error if aKey isn't found."
-
- ^ self removeProperty: aKey ifAbsent: [ self error: 'Property not found' ]
+ "Remove the property with aKey. Answer the property or raise an error if aKey isn't found."
+
+ ^ self removeProperty: aKey ifAbsent: [ self error: 'Property not found' ]
!
removeProperty: aKey ifAbsent: aBlock
- "Remove the property with aKey. Answer the value or, if aKey isn't found, answer the result of evaluating aBlock."
-
- | answer |
- properties isNil ifTrue: [ ^ aBlock value ].
- answer := properties removeKey: aKey ifAbsent: aBlock.
- properties isEmpty ifTrue: [ properties := nil ].
- ^ answer
+ "Remove the property with aKey. Answer the value or, if aKey isn't found, answer the result of evaluating aBlock."
+
+ | answer |
+ properties isNil ifTrue: [ ^ aBlock value ].
+ answer := properties removeKey: aKey ifAbsent: aBlock.
+ properties isEmpty ifTrue: [ properties := nil ].
+ ^ answer
! !
!PPCContextMemento methodsFor:'comparing'!
= anObject
-
- (self == anObject) ifTrue: [ ^ true ].
- (anObject class = PPCContextMemento) ifFalse: [ ^ false ].
-
- (anObject position = position) ifFalse: [ ^ false ].
+
+ (self == anObject) ifTrue: [ ^ true ].
+ (anObject class = PPCContextMemento) ifFalse: [ ^ false ].
+
+ (anObject position = position) ifFalse: [ ^ false ].
- (self propertiesSize = anObject propertiesSize) ifFalse: [ ^ false ].
+ (self propertiesSize = anObject propertiesSize) ifFalse: [ ^ false ].
- self keysAndValuesDo: [ :key :value |
- (anObject hasProperty: key) ifFalse: [ ^ false ].
- ((anObject propertyAt: key) = value) ifFalse: [ ^ false ].
+ self keysAndValuesDo: [ :key :value |
+ (anObject hasProperty: key) ifFalse: [ ^ false ].
+ ((anObject propertyAt: key) = value) ifFalse: [ ^ false ].
].
-
- ^ true.
+
+ ^ true.
!
hash
- ^ position hash bitXor: properties hash.
+ ^ position hash bitXor: properties hash.
! !