JavaMethodRef2.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 24 May 2013 17:55:42 +0100
branchbuiltin-class-support
changeset 2629 cedb88626902
parent 2429 ebece4dcaab9
child 2711 a00302fe5083
permissions -rw-r--r--
Closing branch.

"
 COPYRIGHT (c) 1996-2011 by Claus Gittinger

 New code and modifications done at SWING Research Group [1]:

 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 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.

 [1] Code written at SWING Research Group contains a signature
     of one of the above copright owners. For exact set of such code,
     see the differences between this version and version stx:libjava
     as of 1.9.2010
"
"{ Package: 'stx:libjava' }"

JavaClassContentRef2 subclass:#JavaMethodRef2
	instanceVariableNames:'selectorCache numArgSlotsCache returnTypeCache'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Java-Reader-Support-new'
!

!JavaMethodRef2 class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1996-2011 by Claus Gittinger

 New code and modifications done at SWING Research Group [1]:

 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 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.

 [1] Code written at SWING Research Group contains a signature
     of one of the above copright owners. For exact set of such code,
     see the differences between this version and version stx:libjava
     as of 1.9.2010

"
! !


!JavaMethodRef2 methodsFor:'printing & storing'!

printOn:aStream
    "append a printed representation if the receiver to the argument, aStream"

    super printOn:aStream.
! !


!JavaMethodRef2 methodsFor:'private - resolving'!

findResolvedStaticValue
    <resource: #obsolete>
"/    Logger 
"/        log: self printString 
"/                , ': findResolvedStaticValue is obsolete, call resolve its safe :)'
"/        severity: #info
"/        facility: #JVM.
    self findResolvedValue.

    "Created: / 28-04-2011 / 22:45:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
    "Modified: / 07-12-2011 / 15:10:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
    "Modified: / 07-12-2011 / 21:07:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

findResolvedValue: doClassInit
    "Resolve reference and set valueCache."
    
    valueCache := JavaResolver uniqueInstance 
                resolveMethodIndentifiedByRef: self.
    classCache := (constantPool at: classRefIndex) resolve: doClassInit.
    classCache isNil ifTrue: [ self breakPoint: #mh ].
    nameAndTypeCache := (constantPool at: nameAndTypeIndex) resolve.
    nameAndTypeCache isNil ifTrue: [ self breakPoint: #mh ].
    selectorCache isNil ifTrue: [
        selectorCache := (nameAndTypeCache name , nameAndTypeCache descriptor) asSymbol
    ].

    "Modified: / 18-05-2011 / 12:44:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
    "Created: / 09-02-2012 / 23:10:32 / mh <hlopik@gmail.com>"
    "Modified: / 22-08-2012 / 14:53:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !


!JavaMethodRef2 methodsFor:'queries'!

isJavaMethodRef
^ true.

    "Created: / 11-04-2011 / 19:56:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !


!JavaMethodRef2 methodsFor:'resolving'!

preResolve
    "Fill in selectorCache and numArgSlotsCache for these are used
     by the JIT-compiler"

    | returnTypeChar |

    nameAndTypeCache := (constantPool at: nameAndTypeIndex) resolve.
    nameAndTypeCache isNil ifTrue: [ self breakPoint: #mh ].
    selectorCache isNil ifTrue: [
        selectorCache := (nameAndTypeCache name , nameAndTypeCache descriptor) asSymbol
    ].
    numArgSlotsCache := JavaMethod numArgsFromSignature: nameAndTypeCache descriptor.
    returnTypeChar := nameAndTypeCache descriptor last.
    returnTypeChar == $V ifTrue:[
        returnTypeCache := JavaMethod r_void.    
    ] ifFalse:[
        returnTypeChar == $J ifTrue:[
            returnTypeCache := JavaMethod r_long.
        ] ifFalse:[
            returnTypeChar == $D ifTrue:[
                returnTypeCache := JavaMethod r_double.
            ] ifFalse:[
                returnTypeCache := 0.
            ]
        ]
    ]

    "Created: / 15-10-2012 / 23:13:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !


!JavaMethodRef2 class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libjava/JavaMethodRef2.st,v 1.5 2013-02-25 11:15:31 vrany Exp $'
!

version_HG

    ^ '$Changeset: <not expanded> $'
!

version_SVN
    ^ '§Id§'
! !