454
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
|
|
14 |
|
1
|
15 |
JavaRef subclass:#JavaMethodref
|
120
|
16 |
instanceVariableNames:'method sel lastClass lastMethod'
|
1
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
4
|
19 |
category:'Java-Reader-Support'
|
1
|
20 |
!
|
|
21 |
|
454
|
22 |
!JavaMethodref class methodsFor:'documentation'!
|
|
23 |
|
|
24 |
copyright
|
|
25 |
"
|
|
26 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
27 |
All Rights Reserved
|
|
28 |
|
|
29 |
This software is furnished under a license and may be used
|
|
30 |
only in accordance with the terms of that license and with the
|
|
31 |
inclusion of the above copyright notice. This software may not
|
|
32 |
be provided or otherwise made available to, or used by, any
|
|
33 |
other person. No title to or ownership of the software is
|
|
34 |
hereby transferred.
|
|
35 |
"
|
|
36 |
|
|
37 |
|
|
38 |
! !
|
1
|
39 |
|
152
|
40 |
!JavaMethodref class methodsFor:'flushing'!
|
|
41 |
|
|
42 |
flushCaches
|
|
43 |
self allInstancesDo:[:ref |
|
|
44 |
ref flush
|
|
45 |
].
|
|
46 |
|
|
47 |
"
|
|
48 |
JavaMethodref flushCaches
|
|
49 |
"
|
|
50 |
|
|
51 |
"Modified: 20.3.1997 / 00:10:24 / cg"
|
|
52 |
! !
|
|
53 |
|
41
|
54 |
!JavaMethodref methodsFor:'accessing'!
|
|
55 |
|
163
|
56 |
argSignature
|
|
57 |
^ JavaMethod argSigArrayFromSignature:(self signature)
|
|
58 |
|
|
59 |
"Created: 24.3.1997 / 12:22:50 / cg"
|
|
60 |
!
|
|
61 |
|
122
|
62 |
lastClass
|
|
63 |
"return lastClass"
|
|
64 |
|
|
65 |
^ lastClass!
|
|
66 |
|
|
67 |
lastClass:something
|
|
68 |
"set lastClass"
|
|
69 |
|
|
70 |
lastClass := something.!
|
|
71 |
|
|
72 |
lastMethod
|
|
73 |
"return lastMethod"
|
|
74 |
|
|
75 |
^ lastMethod!
|
|
76 |
|
|
77 |
lastMethod:something
|
|
78 |
"set lastMethod"
|
|
79 |
|
|
80 |
lastMethod := something.!
|
|
81 |
|
198
|
82 |
lastMethod:someMethod lastClass:someClass
|
|
83 |
"set lastMethod & lastClass"
|
|
84 |
|
|
85 |
lastMethod := someMethod.
|
|
86 |
lastClass := someClass.
|
|
87 |
|
|
88 |
"Created: 4.8.1997 / 18:21:11 / cg"
|
|
89 |
!
|
|
90 |
|
41
|
91 |
name
|
|
92 |
^ nameandType name.
|
|
93 |
!
|
|
94 |
|
163
|
95 |
returnType
|
255
|
96 |
^ JavaMethod returnTypeFromSignature:(self signature) in:nil.
|
163
|
97 |
|
255
|
98 |
"Modified: / 8.1.1998 / 19:07:41 / cg"
|
163
|
99 |
!
|
|
100 |
|
41
|
101 |
selector
|
|
102 |
sel isNil ifTrue:[
|
|
103 |
sel := (nameandType name , nameandType signature) asSymbol.
|
|
104 |
].
|
|
105 |
^ sel
|
|
106 |
!
|
|
107 |
|
|
108 |
signature
|
|
109 |
^ nameandType signature.
|
|
110 |
! !
|
|
111 |
|
|
112 |
!JavaMethodref methodsFor:'printing & storing'!
|
|
113 |
|
|
114 |
displayString
|
|
115 |
^ 'JavaMethodRef (' , class displayString , ' '
|
|
116 |
, '''' , nameandType name , '''' , nameandType signature , ')'
|
|
117 |
! !
|
|
118 |
|
619
|
119 |
!JavaMethodref methodsFor:'queries'!
|
|
120 |
|
|
121 |
isJavaMethodRef
|
|
122 |
^ true
|
|
123 |
|
|
124 |
"Created: / 9.11.1999 / 15:39:49 / cg"
|
|
125 |
! !
|
|
126 |
|
27
|
127 |
!JavaMethodref methodsFor:'resolving'!
|
|
128 |
|
152
|
129 |
flush
|
|
130 |
method := nil.
|
|
131 |
lastClass := nil.
|
|
132 |
lastMethod := nil
|
|
133 |
|
|
134 |
"Created: 20.3.1997 / 00:10:01 / cg"
|
|
135 |
!
|
|
136 |
|
27
|
137 |
method
|
425
|
138 |
^ self resolveMethod
|
252
|
139 |
|
425
|
140 |
"Modified: / 9.11.1998 / 23:42:33 / cg"
|
29
|
141 |
!
|
|
142 |
|
|
143 |
methodFor:aClass
|
|
144 |
|nm sig mthd cls|
|
|
145 |
|
|
146 |
cls := aClass.
|
|
147 |
|
71
|
148 |
cls == Array ifTrue:[
|
|
149 |
cls := Java classNamed:'java.lang.Object'.
|
90
|
150 |
] ifFalse:[
|
100
|
151 |
cls == UndefinedObject ifTrue:[
|
|
152 |
cls := Java classNamed:'java.lang.Object'.
|
|
153 |
] ifFalse:[
|
|
154 |
cls isBehavior ifTrue:[
|
|
155 |
cls isMeta ifTrue:[
|
|
156 |
cls := cls soleInstance.
|
|
157 |
].
|
|
158 |
(cls isKindOf:JavaClass) ifFalse:[
|
167
|
159 |
"/ self halt:'not a javaClass'.
|
125
|
160 |
^ nil
|
100
|
161 |
]
|
90
|
162 |
].
|
100
|
163 |
"/ cls := cls javaClass.
|
90
|
164 |
].
|
71
|
165 |
].
|
|
166 |
|
90
|
167 |
cls isUnresolved ifTrue:[
|
87
|
168 |
self halt:'unresolved class'.
|
29
|
169 |
].
|
|
170 |
|
|
171 |
sel isNil ifTrue:[
|
|
172 |
nm := nameandType name asSymbol.
|
|
173 |
sig := nameandType signature.
|
|
174 |
sel := (nm , sig) asSymbol.
|
|
175 |
].
|
|
176 |
|
|
177 |
[cls notNil] whileTrue:[
|
63
|
178 |
mthd := cls compiledMethodAt:sel.
|
122
|
179 |
mthd notNil ifTrue:[
|
|
180 |
lastClass := aClass.
|
|
181 |
lastMethod := mthd.
|
|
182 |
^ mthd
|
|
183 |
].
|
41
|
184 |
|
29
|
185 |
cls := cls superclass
|
27
|
186 |
].
|
71
|
187 |
|
41
|
188 |
^ nil
|
150
|
189 |
|
167
|
190 |
"Modified: 26.3.1997 / 13:32:39 / cg"
|
425
|
191 |
!
|
|
192 |
|
|
193 |
resolveMethod
|
|
194 |
|nm sig mthd cls|
|
|
195 |
|
|
196 |
method notNil ifTrue:[^ method].
|
|
197 |
|
|
198 |
cls := class javaClass.
|
|
199 |
cls ~~ class ifTrue:[
|
|
200 |
class := cls.
|
|
201 |
].
|
|
202 |
|
|
203 |
"/ (class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
204 |
"/ cls := class resolve.
|
|
205 |
"/ cls notNil ifTrue:[
|
|
206 |
"/ class := cls
|
|
207 |
"/ ]
|
|
208 |
"/ ].
|
|
209 |
"/ (class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
210 |
"/ self halt:'unresolved class'.
|
|
211 |
"/ ].
|
|
212 |
|
|
213 |
sel isNil ifTrue:[
|
|
214 |
nm := nameandType name asSymbol.
|
|
215 |
sig := nameandType signature.
|
|
216 |
sel := (nm , sig) asSymbol.
|
|
217 |
].
|
|
218 |
|
|
219 |
"/ 'search in: ' print. class fullName print. ' for ' print. nm print. ' sig: ' print. sig printNL.
|
|
220 |
|
|
221 |
mthd := class compiledMethodAt:sel.
|
|
222 |
mthd isNil ifTrue:[
|
|
223 |
"/ self halt:'no method found for: ' , self displayString.
|
|
224 |
^ nil.
|
|
225 |
"/ old: ^ self.
|
|
226 |
].
|
|
227 |
"/ mthd checkForNOOPMethod.
|
|
228 |
^ mthd
|
|
229 |
|
|
230 |
"Modified: / 16.10.1998 / 00:22:59 / cg"
|
|
231 |
"Created: / 9.11.1998 / 23:42:20 / cg"
|
27
|
232 |
! !
|
|
233 |
|
203
|
234 |
!JavaMethodref methodsFor:'special'!
|
|
235 |
|
|
236 |
updateClassRefsFrom:oldClass to:newClass
|
|
237 |
lastClass := nil.
|
|
238 |
lastMethod := nil.
|
|
239 |
super updateClassRefsFrom:oldClass to:newClass
|
|
240 |
|
|
241 |
"Created: 7.8.1997 / 15:00:46 / cg"
|
|
242 |
! !
|
|
243 |
|
135
|
244 |
!JavaMethodref class methodsFor:'documentation'!
|
1
|
245 |
|
|
246 |
version
|
619
|
247 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethodref.st,v 1.35 1999/11/09 14:56:20 cg Exp $'
|
1
|
248 |
! !
|