JavaUnresolvedStringConstant.st
changeset 90 918e2740098c
parent 37 34688ddacf17
child 135 098936234135
--- a/JavaUnresolvedStringConstant.st	Fri Jun 28 21:39:41 1996 +0000
+++ b/JavaUnresolvedStringConstant.st	Fri Jun 28 21:39:53 1996 +0000
@@ -1,79 +1,55 @@
 JavaUnresolvedConstant subclass:#JavaUnresolvedStringConstant
-	instanceVariableNames:''
-	classVariableNames:'PatchStack'
+	instanceVariableNames:'stringIndex'
+	classVariableNames:''
 	poolDictionaries:''
 	category:'Java-Reader-Support'
 !
 
 
-!JavaUnresolvedStringConstant class methodsFor:'instance creation'!
+!JavaUnresolvedStringConstant  class methodsFor:'instance creation'!
 
-stringIndex:index
-    ^ self index:index
+pool:aPool poolIndex:index stringIndex:stringIndex
+    ^ self new 
+        pool:aPool poolIndex:index stringIndex:stringIndex
+
+
 ! !
 
-!JavaUnresolvedStringConstant class methodsFor:'resolving'!
-
-patchupStringConstants
-    "sent after java/lang/String has been loaded.
-     patch all previously unresolved string constants
-     to become JavaStrings now ..."
-
-    |jString|
-
-    jString := Java classNamed:'java/lang/String'.
-    jString notNil ifTrue:[
-        PatchStack notNil ifTrue:[
-            PatchStack do:[:entry |
-                |table index string s|
+!JavaUnresolvedStringConstant methodsFor:'accessing'!
 
-                table := entry at:1.
-                index := entry at:2.
-                string := entry at:3.
-
-                s := jString basicNew.
-                s instVarNamed:'value'  put: string.
-                s instVarNamed:'offset' put: 0.
-                s instVarNamed:'count'  put: string size.
+pool:aPool poolIndex:i stringIndex:string_index
+    constantPool := aPool.
+    constantPoolIndex := i.
+    stringIndex := string_index.
 
-                table at:index put:s.
-            ]
-        ].
-        PatchStack := nil
-    ]
-
-    "
-     JavaUnresolvedStringConstant patchupStringConstants
-    "
 ! !
 
 !JavaUnresolvedStringConstant methodsFor:'resolving'!
 
-resolveFrom:aConstantTable
-    |string|
+preResolve
+    |jString chars|
+
+    Java javaString notNil ifTrue:[
+        chars := (constantPool at:stringIndex).
+        chars isString ifFalse:[
+            self halt:'should not happen'
+        ].
+        jString := JavaObject javaStringFrom:chars.
 
-    "/
-    "/ I would like to return a JAVA-String here
-    "/ however, we can only do this, after 'java/lang/String'
-    "/ is loaded ... (hen & egg problem)
-    "/
-    "/ therefore, remember things until the class is loaded, and
-    "/ patch string constants later
-    "/
-    string := self class resolve:(aConstantTable at:index) from:aConstantTable.
-    PatchStack isNil ifTrue:[
-        PatchStack := OrderedCollection new.
+"/constantPool owner == (Java at:'java/awt/Container') ifTrue:[
+"/self halt
+"/].
+
+        constantPool at:constantPoolIndex put:jString.
+        ^ jString.
     ].
-    PatchStack addLast:(Array with:aConstantTable with:index with:string).
 
-    ^ string
-
-    "Created: 15.4.1996 / 15:51:42 / cg"
-    "Modified: 15.4.1996 / 16:28:45 / cg"
+    self rememberForResolveWith:'java/lang/String'.
+    ^ self
 ! !
 
-!JavaUnresolvedStringConstant class methodsFor:'documentation'!
+!JavaUnresolvedStringConstant  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedStringConstant.st,v 1.2 1996/05/02 20:46:36 cg Exp $'
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedStringConstant.st,v 1.3 1996/06/28 21:36:50 cg Exp $'
 ! !