src/JavaFieldRef2.st
branchjk_new_structure
changeset 806 7d1f2ba6d2df
parent 794 9635f32d1723
child 807 b9dde0678965
--- a/src/JavaFieldRef2.st	Thu May 19 11:10:09 2011 +0000
+++ b/src/JavaFieldRef2.st	Fri May 20 15:32:09 2011 +0000
@@ -46,11 +46,10 @@
                 resolveStaticFieldIndentifiedByRef: self.
     classCache := (constantPool at: classRefIndex) resolve.
     classCache ifNil: [ self breakPoint: #mh ].
-    classCache 
-        ifNotNil: [ offset := classCache class instVarOffsetOf: self name ].
+    self resolveStaticOffset.
     nameAndTypeCache := (constantPool at: nameAndTypeIndex) resolve.
     self resolveType.
-   nameAndTypeCache ifNil: [self breakPoint: #mh].
+    nameAndTypeCache ifNil: [ self breakPoint: #mh ].
 
     "Created: / 28-04-2011 / 22:05:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 18-05-2011 / 12:44:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
@@ -61,14 +60,40 @@
                 resolveFieldIndentifiedByRef: self.
     classCache := (constantPool at: classRefIndex) resolve.
     classCache ifNil: [ self breakPoint: #mh ].
-    classCache ifNotNil: [ offset := classCache instVarOffsetOf: self name ].
+    self resolveOffset.
     nameAndTypeCache := (constantPool at: nameAndTypeIndex) resolve.
     self resolveType.
-   nameAndTypeCache ifNil: [self breakPoint: #mh].
+    nameAndTypeCache ifNil: [ self breakPoint: #mh ].
 
     "Modified: / 18-05-2011 / 12:44:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
+resolveOffset
+    "fieldRef must be resolved before calling me"
+    
+    | currentClass |
+
+    currentClass := classCache.
+    
+    [ offset := currentClass class instVarOffsetOf: self name.
+    offset isNil and: [ currentClass superclass ~= JavaObject ]. ] whileTrue: [ currentClass := currentClass superclass. ].
+
+    "Modified: / 20-05-2011 / 17:32:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+resolveStaticOffset
+    "fieldRef must be resolved before calling me"
+
+    | currentClass |
+
+    currentClass := classCache.
+
+    [ offset := currentClass instVarOffsetOf: self name.
+    offset isNil and: [ currentClass superclass ~= JavaObject ]. ] whileTrue: [ currentClass := currentClass superclass. ].
+
+    "Modified: / 20-05-2011 / 17:32:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
 resolveType
     type := JavaMethod typeFromSignature:((constantPool at: nameAndTypeIndex) descriptor) in:nil.
     type == #long ifTrue:[