Cache methods and resolve special methods.
authorstefan
Fri, 29 Aug 1997 16:01:35 +0000
changeset 250 ea3955e7f791
parent 249 94833284dec6
child 251 4898461c0cca
Cache methods and resolve special methods.
JavaMethodref.st
--- a/JavaMethodref.st	Fri Aug 29 15:59:52 1997 +0000
+++ b/JavaMethodref.st	Fri Aug 29 16:01:35 1997 +0000
@@ -96,43 +96,40 @@
 !
 
 method
+    "resolve the methodRef in its class.
+     Used for invokenonvirtual and to get a method prototype
+     for virtual invokes."
+
     |nm sig mthd cls|
 
     method notNil ifTrue:[^ method].
 
+    "/ resolve the possibly unresolved class
     cls := class javaClass.
     cls ~~ class ifTrue:[
         class := cls.
     ].
 
-"/    (class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
-"/        cls := class resolve.
-"/        cls notNil ifTrue:[
-"/            class := cls
-"/        ]
-"/    ].
-"/    (class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
-"/        self halt:'unresolved class'.
-"/    ].
-
     sel isNil ifTrue:[
-        nm := nameandType name asSymbol.
+        nm := nameandType name.
         sig := nameandType signature.
         sel := (nm , sig) asSymbol.
     ].
 
 "/ 'search in: ' print. class fullName print. ' for ' print. nm print. ' sig: ' print. sig printNL.
 
-    mthd := class compiledMethodAt:sel.
+    mthd := cls compiledMethodAt:sel.
     mthd isNil ifTrue:[
 "/        self halt:'no method found for: ' , self displayString.
+"/ old:   ^ self.
         ^ nil.
-"/ old:        ^ self.
     ].
     mthd checkForNOOPMethod.
+    method := mthd.
     ^ mthd
 
     "Modified: 31.7.1997 / 22:16:24 / cg"
+    "Modified: 28.8.1997 / 12:15:50 / stefan"
 !
 
 methodFor:aClass
@@ -183,6 +180,33 @@
     ^ nil
 
     "Modified: 26.3.1997 / 13:32:39 / cg"
+!
+
+specialMethod:classOfCurrentMethod
+    "resolve a method for invokespecial"
+
+    |mthd|
+
+    mthd := self method.
+    mthd isNil ifTrue:[
+        ^ nil.
+    ].
+    (((mthd isPrivate not 
+     and:[class useSpecialSuper]) 
+     and:[mthd name ~~ #'<init>'])
+     and:[classOfCurrentMethod isSubclassOf:class]) ifTrue:[
+        |cls superMethod|
+        cls := class.
+        [superMethod isNil and:[(cls := cls superclass) notNil]] whileTrue:[
+            superMethod := cls compiledMethodAt:sel.
+        ].
+        (superMethod notNil and:[superMethod isAbstract not]) ifTrue:[
+            mthd := superMethod.
+        ].
+    ].
+    ^ mthd
+
+    "Modified: 28.8.1997 / 14:30:30 / stefan"
 ! !
 
 !JavaMethodref methodsFor:'special'!
@@ -198,5 +222,5 @@
 !JavaMethodref class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethodref.st,v 1.27 1997/08/07 13:19:04 cg Exp $'
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethodref.st,v 1.28 1997/08/29 16:01:35 stefan Exp $'
 ! !