dont share -0.0 with +0.0
authorClaus Gittinger <cg@exept.de>
Tue, 26 Nov 2002 10:08:11 +0100
changeset 1343 133e6e5ba5a7
parent 1342 65f8f4d0ce09
child 1344 e181501d8aa0
dont share -0.0 with +0.0
ByteCodeCompiler.st
--- 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!