JavaFieldref.st
author Claus Gittinger <cg@exept.de>
Thu, 22 Dec 2005 18:00:03 +0100
changeset 2125 cfa7b540ebf1
parent 2108 ca8c4e7db2e8
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1997 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"



"{ Package: 'stx:libjava' }"

JavaRef subclass:#JavaFieldref
	instanceVariableNames:'offset type'
	classVariableNames:'T_LONG T_DOUBLE'
	poolDictionaries:''
	category:'Languages-Java-Reader-Support'
!

!JavaFieldref class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1997 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"


! !

!JavaFieldref class methodsFor:'initialization'!

initialize
    T_LONG := 1.
    T_DOUBLE := 2.

    "
     self initialize
    "

    "Created: / 10.1.1998 / 11:45:00 / cg"
! !

!JavaFieldref methodsFor:'accessing'!

nameandType
    ^ nameandType

    "Created: 19.8.1997 / 13:54:35 / cg"
!

nameandType:aJavaNameandType
    nameandType := aJavaNameandType.
    self resolveType.

    "Created: / 19.8.1997 / 14:01:27 / cg"
    "Modified: / 5.11.1998 / 17:11:51 / cg"
! !

!JavaFieldref methodsFor:'printing & storing'!

displayString
    class isNil ifTrue:[
        ^ 'JavaFieldRef ( ** unknown class ** ''' , nameandType displayString , ''')'
    ].
    ^ 'JavaFieldRef (' , class displayString "fullName" , ' ' 
                       , '''' , nameandType name , '''' , nameandType signature 
                       , ' offs=' , offset printString
                       , ')'

    "Modified: / 10.11.1998 / 12:23:54 / cg"
! !

!JavaFieldref methodsFor:'resolving'!

isDouble
    type isNil ifTrue:[
        self resolveType
    ].
    ^ type == T_DOUBLE

    "Modified: / 10.1.1998 / 11:51:52 / cg"
!

isLong
    type isNil ifTrue:[
        self resolveType
    ].
    ^ type == T_LONG

    "Modified: / 10.1.1998 / 11:51:36 / cg"
!

name
    ^ nameandType name
!

offset
    offset isNil ifTrue:[
        self resolve.
    ].
    ^ offset.

    "Modified: / 10.1.1998 / 11:48:19 / cg"
!

resolve
    |nm cls|

    class isUnresolved ifTrue:[
        self halt:'unresolved class'.
        ^ nil.
    ].

    self resolveType.
    nm := nameandType name asSymbol.
    offset := class instVarOffsetOf:nm.
    ^ offset

    "Modified: / 9.11.1998 / 23:00:48 / cg"
!

resolveStatic
    |nm cls|

    cls := class javaClass.
    cls ~~ class ifTrue:[
        class := cls.
    ].
    class isNil ifTrue:[^ nil].

    self resolveType.
    nm := nameandType name asSymbol.
    offset := class class instVarOffsetOf:nm.
    ^ offset

    "Created: / 2.1.1998 / 17:16:55 / cg"
    "Modified: / 9.11.1998 / 23:01:10 / cg"
!

resolveType
    type := JavaMethod typeFromSignature:(nameandType signature) in:nil.
    type == #long ifTrue:[
        type := T_LONG.
    ] ifFalse:[
        type == #double ifTrue:[
            type := T_DOUBLE
        ]
    ].

    "Created: / 10.1.1998 / 11:49:36 / cg"
!

staticOffset
    offset isNil ifTrue:[
        self resolveStatic.
    ].
    ^ offset.

    "Modified: / 10.1.1998 / 11:47:59 / cg"
!

type
    type isNil ifTrue:[
        self resolveType.
    ].
    type == T_LONG ifTrue:[
        ^ #long.
    ].
    type == T_DOUBLE ifTrue:[
        ^ #double
    ].

    ^ type.

    "Modified: / 10.1.1998 / 11:50:54 / cg"
! !

!JavaFieldref class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libjava/Attic/JavaFieldref.st,v 1.23 2002-11-22 20:11:56 cg Exp $'
! !

JavaFieldref initialize!