JavaUnresolvedClassConstant.st
author cg
Mon, 06 May 1996 18:58:11 +0000
changeset 54 f37bcefb7091
parent 52 1dc41619b6f8
child 67 a72c949d86dd
permissions -rw-r--r--
avoid loading classes twice

JavaUnresolvedConstant subclass:#JavaUnresolvedClassConstant
	instanceVariableNames:'fullName pool poolIndex'
	classVariableNames:''
	poolDictionaries:''
	category:'Java-Reader-Support'
!


!JavaUnresolvedClassConstant class methodsFor:'instance creation'!

fullName:nm
    ^ self new fullName:nm
!

nameIndex:index pool:aConstantPool slotIndex:slotIndex
    ^ self new index:index pool:aConstantPool slotIndex:slotIndex
! !

!JavaUnresolvedClassConstant methodsFor:'accessing'!

fullName
    ^ fullName

!

fullName:nm
    fullName := nm

!

index:index pool:aConstantPool slotIndex:slotIndex
    super index:index.
    pool := aConstantPool.
    poolIndex := slotIndex.

! !

!JavaUnresolvedClassConstant methodsFor:'printing & storing'!

displayString
    fullName isNil ifTrue:[
        ^ 'Unresolved(** nil **)'
    ].
    ^ 'Unresolved(' , (fullName copy replaceAll:$/ by:$.) , ')'
! !

!JavaUnresolvedClassConstant methodsFor:'resolving'!

resolve
    |cls|

    cls := Java classNamed:fullName.
    cls notNil ifTrue:[
        pool notNil ifTrue:[
            pool at:poolIndex put:cls
        ].
    ] ifFalse:[
        Java rememberUnresolved:self.
    ].
    ^ cls

    "Created: 15.4.1996 / 15:51:42 / cg"
    "Modified: 15.4.1996 / 16:26:05 / cg"
!

resolveFrom:aConstantTable
    |cls nm s|

    fullName := self class resolve:(aConstantTable at:index) from:aConstantTable.
    cls := Java classNamed:fullName.
    cls notNil ifTrue:[
        ^ cls
    ].

    (fullName startsWith:'[') ifTrue:[
        "/ a ref for newarray or new
        s := fullName readStream.
        s next.
        fullName := JavaMethod retvalSpecFromStream:s.
        cls := Java classNamed:fullName.
        cls notNil ifTrue:[
            ^ cls
        ].
    ].

    Java rememberUnresolved:self.
    ^ self
"/    ^ JavaClass fullName:fullName

    "Created: 15.4.1996 / 15:51:42 / cg"
    "Modified: 15.4.1996 / 16:26:05 / cg"
! !

!JavaUnresolvedClassConstant class methodsFor:'documentation'!

version
    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedClassConstant.st,v 1.10 1996/05/06 18:57:25 cg Exp $'
! !