JavaConstantPool.st
changeset 243 d580e27e1b66
parent 206 2200b9091b9e
child 252 04b330744577
--- a/JavaConstantPool.st	Mon Aug 18 20:35:22 1997 +0000
+++ b/JavaConstantPool.st	Tue Aug 19 13:29:42 1997 +0000
@@ -6,6 +6,57 @@
 !
 
 
+!JavaConstantPool class methodsFor:'special'!
+
+compressPools
+    "unify all constants"
+
+    |strings nameandTypes jStrings|
+
+    strings := Set new.
+    nameandTypes := Set new.
+
+    self allInstancesDo:[:aPool |
+        aPool keysAndValuesDo:[:idx :aConst |
+            |existing nt|
+
+            aConst isString ifTrue:[
+                existing := strings elementAt:aConst ifAbsent:nil.
+                existing isNil ifTrue:[
+                    strings add:aConst
+                ] ifFalse:[
+                    aPool at:idx put:existing
+                ]
+            ] ifFalse:[
+                (aConst isMemberOf:JavaFieldref) ifTrue:[
+                    nt := aConst nameandType.
+                    existing := nameandTypes elementAt:nt ifAbsent:nil.
+                    existing isNil ifTrue:[
+                        nameandTypes add:nt
+                    ] ifFalse:[
+                        aConst nameandType:existing
+                    ]
+                ] ifFalse:[
+                    (aConst isMemberOf:JavaNameandType) ifTrue:[
+                        existing := nameandTypes elementAt:aConst ifAbsent:nil.
+                        existing isNil ifTrue:[
+                            nameandTypes add:aConst
+                        ] ifFalse:[
+                            aPool at:idx put:existing
+                        ]
+                    ]
+                ]
+            ]
+        ].
+    ]
+
+    "
+     self compressPools
+    "
+
+    "Modified: 19.8.1997 / 14:04:25 / cg"
+! !
+
 !JavaConstantPool methodsFor:'accessing'!
 
 owner
@@ -135,5 +186,5 @@
 !JavaConstantPool class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaConstantPool.st,v 1.5 1997/08/08 11:33:21 cg Exp $'
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaConstantPool.st,v 1.6 1997/08/19 13:29:23 cg Exp $'
 ! !