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