author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 16 Jan 2013 22:06:41 +0000 | |
branch | refactoring-vmdata |
changeset 1977 | 526315e0a801 |
parent 1864 | 60a8dc26c8c6 |
child 2069 | 75d40b7b986f |
permissions | -rw-r--r-- |
877 | 1 |
" |
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 3 |
|
1155 | 4 |
New code and modifications done at SWING Research Group [1]: |
1152 | 5 |
|
877 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
7 |
SWING Research Group, Czech Technical University in Prague |
|
8 |
||
9 |
This software is furnished under a license and may be used |
|
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
15 |
||
1155 | 16 |
[1] Code written at SWING Research Group contains a signature |
17 |
of one of the above copright owners. For exact set of such code, |
|
18 |
see the differences between this version and version stx:libjava |
|
1152 | 19 |
as of 1.9.2010 |
877 | 20 |
" |
752 | 21 |
"{ Package: 'stx:libjava' }" |
22 |
||
23 |
JavaDescriptor subclass:#JavaMethodDescriptor |
|
1227 | 24 |
instanceVariableNames:'return name parameters' |
752 | 25 |
classVariableNames:'' |
26 |
poolDictionaries:'' |
|
27 |
category:'Languages-Java-Support' |
|
28 |
! |
|
29 |
||
877 | 30 |
!JavaMethodDescriptor class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 35 |
|
1155 | 36 |
New code and modifications done at SWING Research Group [1]: |
1152 | 37 |
|
877 | 38 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
39 |
SWING Research Group, Czech Technical University in Prague |
|
40 |
||
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
||
1155 | 48 |
[1] Code written at SWING Research Group contains a signature |
49 |
of one of the above copright owners. For exact set of such code, |
|
50 |
see the differences between this version and version stx:libjava |
|
1152 | 51 |
as of 1.9.2010 |
877 | 52 |
|
53 |
" |
|
54 |
! ! |
|
752 | 55 |
|
56 |
!JavaMethodDescriptor class methodsFor:'instance creation'! |
|
57 |
||
1227 | 58 |
name: name parameters: parameterDescriptors |
59 |
||
60 |
^self new |
|
61 |
name: name; |
|
62 |
parameters: parameterDescriptors; |
|
63 |
yourself |
|
64 |
||
65 |
"Created: / 06-12-2011 / 21:58:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
66 |
! |
|
67 |
||
68 |
name: name parameters: parameterDescriptors return: returnDescriptor |
|
69 |
||
70 |
^self new |
|
71 |
name: name; |
|
72 |
parameters: parameterDescriptors; |
|
73 |
return: returnDescriptor; |
|
74 |
yourself |
|
75 |
||
76 |
"Created: / 06-12-2011 / 21:58:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
77 |
! |
|
78 |
||
752 | 79 |
parameters: parameterDescriptors return: returnDescriptor |
80 |
||
81 |
^self new |
|
82 |
parameters: parameterDescriptors; |
|
83 |
return: returnDescriptor; |
|
84 |
yourself |
|
85 |
||
86 |
"Created: / 25-11-2010 / 18:45:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
87 |
! ! |
|
88 |
||
89 |
!JavaMethodDescriptor methodsFor:'accessing'! |
|
90 |
||
1227 | 91 |
name |
92 |
^ name |
|
93 |
! |
|
94 |
||
752 | 95 |
parameterClassObjects |
1033 | 96 |
^ (JavaVM classForName: 'java.lang.Class') javaArrayClass |
97 |
withAll: (parameters collect: [:p | p javaClassObject ]) |
|
851 | 98 |
"Created: / 25-11-2010 / 19:53:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" "Modified: / 19-12-2010 / 17:03:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 99 |
! |
100 |
||
101 |
parameterClasses |
|
102 |
||
103 |
^parameters collect:[:p|p javaClass] |
|
104 |
||
105 |
"Created: / 25-11-2010 / 19:53:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
106 |
! |
|
107 |
||
1609
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
108 |
parameterClassesUsingClassLoader: classLoaderOrNil |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
109 |
|
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
110 |
^parameters collect:[:p|p javaClassUsingClassLoader: classLoaderOrNil] |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
111 |
|
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
112 |
"Created: / 16-08-2012 / 12:47:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
113 |
! |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
114 |
|
752 | 115 |
parameters |
116 |
^ parameters |
|
117 |
! |
|
118 |
||
119 |
return |
|
120 |
^ return |
|
121 |
! |
|
122 |
||
123 |
returnClass |
|
915 | 124 |
|
125 |
^return notNil ifTrue:[ |
|
126 |
return javaClass |
|
127 |
] ifFalse:[ |
|
128 |
nil |
|
129 |
] |
|
752 | 130 |
|
131 |
"Created: / 25-11-2010 / 19:54:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
132 |
! |
|
133 |
||
134 |
returnClassObject |
|
135 |
^ return |
|
136 |
ifNil:[JavaVM javaClassObjectForClass: UndefinedObject] |
|
137 |
ifNotNil:[JavaVM javaClassObjectForClass: self returnClass]. |
|
138 |
||
139 |
"Created: / 25-11-2010 / 19:54:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
140 |
"Modified: / 06-02-2011 / 16:16:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1609
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
141 |
! |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
142 |
|
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
143 |
returnClassUsingClassLoader: classLoaderOrNil |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
144 |
|
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
145 |
^return notNil ifTrue:[ |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
146 |
return javaClassUsingClassLoader: classLoaderOrNil |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
147 |
] ifFalse:[ |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
148 |
nil |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
149 |
] |
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
150 |
|
7a2627788ad7
- JavaMirror: fixed method/constructor reflection for classes loaded by other than system/primordial classloader.
vranyj1
parents:
1288
diff
changeset
|
151 |
"Created: / 16-08-2012 / 12:54:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 152 |
! ! |
153 |
||
1227 | 154 |
!JavaMethodDescriptor methodsFor:'comparing'! |
155 |
||
156 |
= another |
|
157 |
||
158 |
^ self class == another class |
|
159 |
and:[ return = another return |
|
160 |
and:[ name = another name |
|
161 |
and:[ parameters := another parameters ]]] |
|
162 |
||
163 |
"Created: / 06-12-2011 / 22:45:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
164 |
! |
|
165 |
||
166 |
hash |
|
167 |
||
168 |
return hash bitXor: (name hash bitXor: parameters hash) |
|
169 |
||
170 |
"Created: / 06-12-2011 / 22:43:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
171 |
! |
|
172 |
||
173 |
match: another |
|
174 |
||
175 |
"This is somewhat relaxed method of =. It does not compare return type |
|
176 |
and also do a subclass matching of arguments" |
|
177 |
||
178 |
name = another name ifFalse:[ ^ false ]. |
|
179 |
(parameters size) == (another parameters size) ifFalse:[ ^ false ]. |
|
180 |
||
181 |
1 to: parameters size do:[:i| |
|
182 |
((parameters at: i) match: (another parameters at: i)) ifFalse: [ ^ false ]. |
|
183 |
]. |
|
184 |
^true |
|
185 |
||
186 |
"Created: / 06-12-2011 / 22:55:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
187 |
! ! |
|
188 |
||
752 | 189 |
!JavaMethodDescriptor methodsFor:'initialization'! |
190 |
||
1227 | 191 |
name: aString |
192 |
"Sets the method name" |
|
193 |
||
194 |
name := aString |
|
195 |
||
196 |
"Created: / 06-12-2011 / 21:51:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
197 |
! |
|
198 |
||
752 | 199 |
parameters:aCollection |
200 |
parameters := aCollection asArray. |
|
201 |
||
202 |
"Modified: / 26-11-2010 / 10:19:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
203 |
! |
|
204 |
||
205 |
return:something |
|
206 |
return := something. |
|
207 |
! ! |
|
208 |
||
1281 | 209 |
!JavaMethodDescriptor methodsFor:'queries'! |
210 |
||
211 |
numArgs |
|
212 |
||
213 |
^ parameters size |
|
214 |
||
215 |
"Created: / 14-12-2011 / 21:20:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1288 | 216 |
! |
217 |
||
218 |
numPhysicalArgs |
|
219 |
"Return number of physical slots that this method requires. |
|
220 |
Note, that in java, longs an doubles occopy two slots whereas |
|
221 |
other types occupy just one." |
|
222 |
||
223 |
parameters isNil ifTrue: [ ^ 0 ]. |
|
224 |
^parameters inject: 0 into:[:slots :fdesc|slots + fdesc slots]. |
|
225 |
||
226 |
"Created: / 16-12-2011 / 00:24:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1281 | 227 |
! ! |
228 |
||
752 | 229 |
!JavaMethodDescriptor class methodsFor:'documentation'! |
230 |
||
1864 | 231 |
version_HG |
232 |
||
233 |
^ '$Changeset: <not expanded> $' |
|
234 |
! |
|
235 |
||
752 | 236 |
version_SVN |
1864 | 237 |
^ '§Id§' |
752 | 238 |
! ! |