--- a/ByteCodeCompiler.st Wed Nov 20 10:20:02 2002 +0100
+++ b/ByteCodeCompiler.st Tue Nov 26 10:08:11 2002 +0100
@@ -1474,28 +1474,41 @@
"add a literal to the literalArray - watch for and eliminate
duplicates. return the index of the literal in the Array"
- |index "{ Class: SmallInteger }" class|
+ |index "{ Class: SmallInteger }" oldLit class|
litArray isNil ifTrue:[
- litArray := Array with:anObject.
- ^ 1
+ litArray := Array with:anObject.
+ ^ 1
].
index := litArray identityIndexOf:anObject.
(index == 0) ifTrue:[
- "
- reuse constants if same value and same class
- "
- class := anObject class.
- ((class == Float)
- or:[class == Fraction
- or:[class == LargeInteger
- "or:[class == String] --only if literalString option has been added---" ]]) ifTrue:[
- index := litArray indexOf:anObject.
- ].
- ((index == 0) or:[(litArray at:index) class ~~ class]) ifTrue:[
- litArray := litArray copyWith:anObject.
- ^ litArray size
- ].
+ "
+ reuse constants if same value and same class
+ "
+ class := anObject class.
+ ((class == Float)
+ or:[class == Fraction
+ or:[class == LargeInteger
+ "or:[class == String] --only if literalString option has been added---" ]]) ifTrue:[
+ index := litArray indexOf:anObject.
+ index ~~ 0 ifTrue:[
+ oldLit := litArray at:index.
+ oldLit class == class ifFalse:[
+ index := 0.
+ ] ifTrue:[
+ "/ dont mess up negative with positive zeros
+ anObject = 0.0 ifTrue:[
+ anObject isNegativeZero ~~ oldLit isNegativeZero ifTrue:[
+ index := 0
+ ]
+ ]
+ ].
+ ].
+ ].
+ (index == 0) ifTrue:[
+ litArray := litArray copyWith:anObject.
+ ^ litArray size
+ ].
].
^ index
@@ -3788,7 +3801,7 @@
!ByteCodeCompiler class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.204 2002-10-31 13:50:20 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.205 2002-11-26 09:08:11 cg Exp $'
! !
ByteCodeCompiler initialize!