1
|
1 |
JavaRef subclass:#JavaMethodref
|
29
|
2 |
instanceVariableNames:'method sel'
|
1
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
4
|
5 |
category:'Java-Reader-Support'
|
1
|
6 |
!
|
|
7 |
|
|
8 |
|
41
|
9 |
!JavaMethodref methodsFor:'accessing'!
|
|
10 |
|
|
11 |
name
|
|
12 |
^ nameandType name.
|
|
13 |
!
|
|
14 |
|
|
15 |
selector
|
90
|
16 |
self halt.
|
41
|
17 |
sel isNil ifTrue:[
|
|
18 |
sel := (nameandType name , nameandType signature) asSymbol.
|
|
19 |
].
|
|
20 |
^ sel
|
|
21 |
!
|
|
22 |
|
|
23 |
signature
|
|
24 |
^ nameandType signature.
|
|
25 |
! !
|
|
26 |
|
|
27 |
!JavaMethodref methodsFor:'printing & storing'!
|
|
28 |
|
|
29 |
displayString
|
|
30 |
^ 'JavaMethodRef (' , class displayString , ' '
|
|
31 |
, '''' , nameandType name , '''' , nameandType signature , ')'
|
|
32 |
! !
|
|
33 |
|
27
|
34 |
!JavaMethodref methodsFor:'resolving'!
|
|
35 |
|
|
36 |
method
|
87
|
37 |
|nm sig mthd cls|
|
27
|
38 |
|
|
39 |
method notNil ifTrue:[^ method].
|
|
40 |
|
90
|
41 |
cls := class javaClass.
|
|
42 |
cls ~~ class ifTrue:[
|
|
43 |
class := cls.
|
27
|
44 |
].
|
90
|
45 |
|
|
46 |
"/ (class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
47 |
"/ cls := class resolve.
|
|
48 |
"/ cls notNil ifTrue:[
|
|
49 |
"/ class := cls
|
|
50 |
"/ ]
|
|
51 |
"/ ].
|
|
52 |
"/ (class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
53 |
"/ self halt:'unresolved class'.
|
|
54 |
"/ ].
|
27
|
55 |
|
29
|
56 |
sel isNil ifTrue:[
|
|
57 |
nm := nameandType name asSymbol.
|
|
58 |
sig := nameandType signature.
|
|
59 |
sel := (nm , sig) asSymbol.
|
|
60 |
].
|
27
|
61 |
|
29
|
62 |
"/ 'search in: ' print. class fullName print. ' for ' print. nm print. ' sig: ' print. sig printNL.
|
41
|
63 |
|
63
|
64 |
mthd := class compiledMethodAt:sel.
|
|
65 |
mthd notNil ifTrue:[^ mthd].
|
|
66 |
self halt:'no such method found'.
|
29
|
67 |
!
|
|
68 |
|
|
69 |
methodFor:aClass
|
|
70 |
|nm sig mthd cls|
|
|
71 |
|
|
72 |
cls := aClass.
|
|
73 |
|
71
|
74 |
cls == Array ifTrue:[
|
|
75 |
cls := Java classNamed:'java.lang.Object'.
|
90
|
76 |
] ifFalse:[
|
100
|
77 |
cls == UndefinedObject ifTrue:[
|
|
78 |
cls := Java classNamed:'java.lang.Object'.
|
|
79 |
] ifFalse:[
|
|
80 |
cls isBehavior ifTrue:[
|
|
81 |
cls isMeta ifTrue:[
|
|
82 |
cls := cls soleInstance.
|
|
83 |
].
|
|
84 |
(cls isKindOf:JavaClass) ifFalse:[
|
|
85 |
self halt:'not a javaClass'.
|
|
86 |
self internalError:'not a javaClass'.
|
|
87 |
]
|
90
|
88 |
].
|
100
|
89 |
"/ cls := cls javaClass.
|
90
|
90 |
].
|
71
|
91 |
].
|
|
92 |
|
90
|
93 |
cls isUnresolved ifTrue:[
|
87
|
94 |
self halt:'unresolved class'.
|
29
|
95 |
].
|
|
96 |
|
|
97 |
sel isNil ifTrue:[
|
|
98 |
nm := nameandType name asSymbol.
|
|
99 |
sig := nameandType signature.
|
|
100 |
sel := (nm , sig) asSymbol.
|
|
101 |
].
|
|
102 |
|
|
103 |
[cls notNil] whileTrue:[
|
63
|
104 |
mthd := cls compiledMethodAt:sel.
|
|
105 |
mthd notNil ifTrue:[^ mthd].
|
41
|
106 |
|
29
|
107 |
cls := cls superclass
|
27
|
108 |
].
|
71
|
109 |
|
41
|
110 |
^ nil
|
27
|
111 |
! !
|
|
112 |
|
63
|
113 |
!JavaMethodref class methodsFor:'documentation'!
|
1
|
114 |
|
|
115 |
version
|
100
|
116 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethodref.st,v 1.13 1996/07/01 13:43:40 cg Exp $'
|
1
|
117 |
! !
|