JavaMethodref.st
author cg
Sat, 06 Jul 1996 18:16:52 +0000
changeset 120 6493fa59d355
parent 114 3f796855d7d4
child 122 e731a1c1d499
permissions -rw-r--r--
added slots for an inline cache

JavaRef subclass:#JavaMethodref
	instanceVariableNames:'method sel lastClass lastMethod'
	classVariableNames:''
	poolDictionaries:''
	category:'Java-Reader-Support'
!


!JavaMethodref methodsFor:'accessing'!

name
    ^ nameandType name.
!

selector
    sel isNil ifTrue:[
        sel := (nameandType name , nameandType signature) asSymbol.
    ].
    ^ sel
!

signature
    ^ nameandType signature.
! !

!JavaMethodref methodsFor:'printing & storing'!

displayString
    ^ 'JavaMethodRef (' , class displayString , ' ' 
                        , '''' , nameandType name , '''' , nameandType signature , ')'
! !

!JavaMethodref methodsFor:'resolving'!

method
    |nm sig mthd cls|

    method notNil ifTrue:[^ method].

    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.
        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 notNil ifTrue:[^ mthd].
    self halt:'no such method found'.
!

methodFor:aClass
    |nm sig mthd cls|

    cls := aClass.

    cls == Array ifTrue:[
        cls := Java classNamed:'java.lang.Object'.
    ] ifFalse:[
        cls == UndefinedObject ifTrue:[
            cls := Java classNamed:'java.lang.Object'.
        ] ifFalse:[
            cls isBehavior ifTrue:[
                cls isMeta ifTrue:[
                    cls := cls soleInstance.
                ].
                (cls isKindOf:JavaClass) ifFalse:[
                    self halt:'not a javaClass'.
                ]
            ].
    "/        cls := cls javaClass.
        ].
    ].

    cls isUnresolved ifTrue:[
        self halt:'unresolved class'.
    ].

    sel isNil ifTrue:[
        nm := nameandType name asSymbol.
        sig := nameandType signature.
        sel := (nm , sig) asSymbol.
    ].

    [cls notNil] whileTrue:[
        mthd := cls compiledMethodAt:sel.
        mthd notNil ifTrue:[^ mthd].

        cls := cls superclass
    ].

    ^ nil
! !

!JavaMethodref  class methodsFor:'documentation'!

version
    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethodref.st,v 1.15 1996/07/06 18:16:52 cg Exp $'
! !