1
|
1 |
JavaRef subclass:#JavaMethodref
|
120
|
2 |
instanceVariableNames:'method sel lastClass lastMethod'
|
1
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
4
|
5 |
category:'Java-Reader-Support'
|
1
|
6 |
!
|
|
7 |
|
|
8 |
|
152
|
9 |
!JavaMethodref class methodsFor:'flushing'!
|
|
10 |
|
|
11 |
flushCaches
|
|
12 |
self allInstancesDo:[:ref |
|
|
13 |
ref flush
|
|
14 |
].
|
|
15 |
|
|
16 |
"
|
|
17 |
JavaMethodref flushCaches
|
|
18 |
"
|
|
19 |
|
|
20 |
"Modified: 20.3.1997 / 00:10:24 / cg"
|
|
21 |
! !
|
|
22 |
|
41
|
23 |
!JavaMethodref methodsFor:'accessing'!
|
|
24 |
|
163
|
25 |
argSignature
|
|
26 |
^ JavaMethod argSigArrayFromSignature:(self signature)
|
|
27 |
|
|
28 |
"Created: 24.3.1997 / 12:22:50 / cg"
|
|
29 |
!
|
|
30 |
|
122
|
31 |
lastClass
|
|
32 |
"return lastClass"
|
|
33 |
|
|
34 |
^ lastClass!
|
|
35 |
|
|
36 |
lastClass:something
|
|
37 |
"set lastClass"
|
|
38 |
|
|
39 |
lastClass := something.!
|
|
40 |
|
|
41 |
lastMethod
|
|
42 |
"return lastMethod"
|
|
43 |
|
|
44 |
^ lastMethod!
|
|
45 |
|
|
46 |
lastMethod:something
|
|
47 |
"set lastMethod"
|
|
48 |
|
|
49 |
lastMethod := something.!
|
|
50 |
|
41
|
51 |
name
|
|
52 |
^ nameandType name.
|
|
53 |
!
|
|
54 |
|
163
|
55 |
returnType
|
|
56 |
^ JavaMethod returnTypeFromSignature:(self signature).
|
|
57 |
|
|
58 |
"Modified: 24.3.1997 / 12:25:11 / cg"
|
|
59 |
!
|
|
60 |
|
41
|
61 |
selector
|
|
62 |
sel isNil ifTrue:[
|
|
63 |
sel := (nameandType name , nameandType signature) asSymbol.
|
|
64 |
].
|
|
65 |
^ sel
|
|
66 |
!
|
|
67 |
|
|
68 |
signature
|
|
69 |
^ nameandType signature.
|
|
70 |
! !
|
|
71 |
|
|
72 |
!JavaMethodref methodsFor:'printing & storing'!
|
|
73 |
|
|
74 |
displayString
|
|
75 |
^ 'JavaMethodRef (' , class displayString , ' '
|
|
76 |
, '''' , nameandType name , '''' , nameandType signature , ')'
|
|
77 |
! !
|
|
78 |
|
27
|
79 |
!JavaMethodref methodsFor:'resolving'!
|
|
80 |
|
152
|
81 |
flush
|
|
82 |
method := nil.
|
|
83 |
lastClass := nil.
|
|
84 |
lastMethod := nil
|
|
85 |
|
|
86 |
"Created: 20.3.1997 / 00:10:01 / cg"
|
|
87 |
!
|
|
88 |
|
27
|
89 |
method
|
87
|
90 |
|nm sig mthd cls|
|
27
|
91 |
|
|
92 |
method notNil ifTrue:[^ method].
|
|
93 |
|
90
|
94 |
cls := class javaClass.
|
|
95 |
cls ~~ class ifTrue:[
|
|
96 |
class := cls.
|
27
|
97 |
].
|
90
|
98 |
|
|
99 |
"/ (class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
100 |
"/ cls := class resolve.
|
|
101 |
"/ cls notNil ifTrue:[
|
|
102 |
"/ class := cls
|
|
103 |
"/ ]
|
|
104 |
"/ ].
|
|
105 |
"/ (class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
|
|
106 |
"/ self halt:'unresolved class'.
|
|
107 |
"/ ].
|
27
|
108 |
|
29
|
109 |
sel isNil ifTrue:[
|
|
110 |
nm := nameandType name asSymbol.
|
|
111 |
sig := nameandType signature.
|
|
112 |
sel := (nm , sig) asSymbol.
|
|
113 |
].
|
27
|
114 |
|
29
|
115 |
"/ 'search in: ' print. class fullName print. ' for ' print. nm print. ' sig: ' print. sig printNL.
|
41
|
116 |
|
63
|
117 |
mthd := class compiledMethodAt:sel.
|
148
|
118 |
mthd isNil ifTrue:[
|
163
|
119 |
"/ self halt:'no method found for: ' , self displayString.
|
|
120 |
^ self.
|
148
|
121 |
].
|
|
122 |
mthd checkForNOOPMethod.
|
|
123 |
^ mthd
|
|
124 |
|
163
|
125 |
"Modified: 24.3.1997 / 12:21:52 / cg"
|
29
|
126 |
!
|
|
127 |
|
|
128 |
methodFor:aClass
|
|
129 |
|nm sig mthd cls|
|
|
130 |
|
|
131 |
cls := aClass.
|
|
132 |
|
71
|
133 |
cls == Array ifTrue:[
|
|
134 |
cls := Java classNamed:'java.lang.Object'.
|
90
|
135 |
] ifFalse:[
|
100
|
136 |
cls == UndefinedObject ifTrue:[
|
|
137 |
cls := Java classNamed:'java.lang.Object'.
|
|
138 |
] ifFalse:[
|
|
139 |
cls isBehavior ifTrue:[
|
|
140 |
cls isMeta ifTrue:[
|
|
141 |
cls := cls soleInstance.
|
|
142 |
].
|
|
143 |
(cls isKindOf:JavaClass) ifFalse:[
|
167
|
144 |
"/ self halt:'not a javaClass'.
|
125
|
145 |
^ nil
|
100
|
146 |
]
|
90
|
147 |
].
|
100
|
148 |
"/ cls := cls javaClass.
|
90
|
149 |
].
|
71
|
150 |
].
|
|
151 |
|
90
|
152 |
cls isUnresolved ifTrue:[
|
87
|
153 |
self halt:'unresolved class'.
|
29
|
154 |
].
|
|
155 |
|
|
156 |
sel isNil ifTrue:[
|
|
157 |
nm := nameandType name asSymbol.
|
|
158 |
sig := nameandType signature.
|
|
159 |
sel := (nm , sig) asSymbol.
|
|
160 |
].
|
|
161 |
|
|
162 |
[cls notNil] whileTrue:[
|
63
|
163 |
mthd := cls compiledMethodAt:sel.
|
122
|
164 |
mthd notNil ifTrue:[
|
|
165 |
lastClass := aClass.
|
|
166 |
lastMethod := mthd.
|
|
167 |
^ mthd
|
|
168 |
].
|
41
|
169 |
|
29
|
170 |
cls := cls superclass
|
27
|
171 |
].
|
71
|
172 |
|
41
|
173 |
^ nil
|
150
|
174 |
|
167
|
175 |
"Modified: 26.3.1997 / 13:32:39 / cg"
|
27
|
176 |
! !
|
|
177 |
|
135
|
178 |
!JavaMethodref class methodsFor:'documentation'!
|
1
|
179 |
|
|
180 |
version
|
167
|
181 |
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethodref.st,v 1.24 1997/03/26 17:24:04 cg Exp $'
|
1
|
182 |
! !
|