author | jv |
Thu, 23 Sep 2010 13:52:13 +0000 | |
changeset 748 | da0840b7798c |
parent 744 | 8cbe20f2a6f4 |
child 749 | e898eaeff091 |
permissions | -rw-r--r-- |
722 | 1 |
" |
2 |
COPYRIGHT (c) 2005 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 |
"{ Package: 'stx:libjava' }" |
|
13 |
||
14 |
Class subclass:#JavaBehavior |
|
15 |
instanceVariableNames:'constantPool interfaces accessFlags' |
|
16 |
classVariableNames:'InitialValuePerType A_OBSOLETE A_INTERFACE A_PUBLIC A_FINAL |
|
17 |
A_ABSTRACT A_INITIALIZED A_SMALLTALK A_ABSTRACT_OR_INTERFACE |
|
744 | 18 |
A_STATIC A_NATIVE A_SYNTHETIC A_ANNOTATION A_ENUM' |
722 | 19 |
poolDictionaries:'' |
20 |
category:'Languages-Java-Classes' |
|
21 |
! |
|
22 |
||
23 |
!JavaBehavior class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2005 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
Describes what is known and required by the VM. |
|
42 |
" |
|
43 |
! ! |
|
44 |
||
45 |
!JavaBehavior class methodsFor:'initialization'! |
|
46 |
||
47 |
initialize |
|
48 |
"/ those are defined in Java and read from the classFile |
|
49 |
A_PUBLIC := 16r000001. |
|
50 |
"/ A_PRIVATE := 16r000002. |
|
51 |
"/ A_PROTECTED := 16r000004. |
|
52 |
A_STATIC := 16r000008. |
|
53 |
A_FINAL := 16r000010. |
|
54 |
"/ A_SUPER := 16r000020. |
|
55 |
"/ A_SYNCHRONIZED := 16r000020. |
|
56 |
"/ A_VOLATILE := 16r000040. |
|
57 |
"/ A_TRANSIENT := 16r000080. |
|
58 |
A_NATIVE := 16r000100. |
|
59 |
||
60 |
A_INTERFACE := 16r000200. |
|
61 |
A_ABSTRACT := 16r000400. |
|
744 | 62 |
A_SYNTHETIC := 16r001000. "/ 1.1 |
63 |
A_ANNOTATION := 16r002000. "/ 1.1 |
|
64 |
A_ENUM := 16r004000. "/ 1.1 |
|
722 | 65 |
A_OBSOLETE := 16r008000. |
66 |
||
67 |
"/ those are local to the ST/X implementation |
|
68 |
A_INITIALIZED := 16r100000. |
|
69 |
A_SMALLTALK := 16r200000. |
|
70 |
||
71 |
A_ABSTRACT_OR_INTERFACE := A_ABSTRACT bitOr:A_INTERFACE. |
|
72 |
||
73 |
InitialValuePerType := IdentityDictionary new. |
|
74 |
InitialValuePerType at:$B put:0. |
|
75 |
InitialValuePerType at:$C put:0. |
|
76 |
InitialValuePerType at:$D put:0.0. |
|
77 |
InitialValuePerType at:$F put:(0.0 asShortFloat). |
|
78 |
InitialValuePerType at:$I put:0. |
|
79 |
InitialValuePerType at:$J put:0. |
|
80 |
InitialValuePerType at:$S put:0. |
|
81 |
InitialValuePerType at:$Z put:0. |
|
82 |
InitialValuePerType at:$L put:nil. |
|
83 |
InitialValuePerType at:$[ put:nil. |
|
84 |
||
85 |
" |
|
86 |
JavaBehavior initialize |
|
87 |
" |
|
88 |
||
89 |
"Modified: / 13.11.1998 / 14:09:52 / cg" |
|
90 |
! ! |
|
91 |
||
92 |
!JavaBehavior class methodsFor:'constants'! |
|
93 |
||
94 |
A_NATIVE |
|
95 |
^ A_NATIVE |
|
96 |
||
97 |
"Created: / 16.5.1998 / 01:18:43 / cg" |
|
98 |
! |
|
99 |
||
100 |
A_PUBLIC |
|
101 |
^ A_PUBLIC |
|
102 |
||
103 |
"Created: / 13.5.1998 / 13:03:18 / cg" |
|
104 |
! |
|
105 |
||
106 |
A_STATIC |
|
107 |
^ A_STATIC |
|
108 |
||
109 |
"Created: / 16.5.1998 / 00:02:07 / cg" |
|
110 |
! ! |
|
111 |
||
112 |
!JavaBehavior class methodsFor:'signature parsing'! |
|
113 |
||
114 |
initialValueFromSignature:aSignature |
|
115 |
"given a signature, return an initializer value" |
|
116 |
||
117 |
|s| |
|
118 |
||
119 |
s := aSignature readStream. |
|
120 |
^ self initialValueFromStream:s. |
|
121 |
||
122 |
" |
|
123 |
JavaBehavior initialValueFromSignature:'LObject;' |
|
124 |
JavaBehavior initialValueFromSignature:'B' |
|
125 |
JavaBehavior initialValueFromSignature:'I' |
|
126 |
" |
|
127 |
! |
|
128 |
||
129 |
initialValueFromStream:s |
|
130 |
"parse a fieldTypeSpec - see java doc" |
|
131 |
||
132 |
|typeChar| |
|
133 |
||
134 |
typeChar := s next. |
|
135 |
^ InitialValuePerType at:typeChar ifAbsent:nil. |
|
136 |
! ! |
|
137 |
||
138 |
!JavaBehavior methodsFor:'accessing'! |
|
139 |
||
140 |
constantPool |
|
141 |
^ constantPool |
|
142 |
! |
|
143 |
||
144 |
interfaces |
|
145 |
interfaces notNil ifTrue:[ |
|
146 |
interfaces := interfaces collect:[:clsRef | |
|
147 |
clsRef isUnresolved ifTrue:[ |
|
148 |
clsRef preResolve |
|
149 |
] ifFalse:[ |
|
150 |
clsRef |
|
151 |
] |
|
152 |
]. |
|
153 |
]. |
|
154 |
^ interfaces |
|
155 |
! ! |
|
156 |
||
157 |
!JavaBehavior methodsFor:'private accessing'! |
|
158 |
||
159 |
makeObsolete |
|
160 |
accessFlags := accessFlags bitOr:A_OBSOLETE |
|
161 |
||
162 |
"Created: 7.8.1997 / 19:04:48 / cg" |
|
163 |
! |
|
164 |
||
165 |
markUninitialized |
|
166 |
(accessFlags bitAnd:A_INITIALIZED) ~~ 0 ifTrue:[ |
|
167 |
accessFlags := accessFlags bitXor:A_INITIALIZED |
|
168 |
]. |
|
169 |
! |
|
170 |
||
171 |
setAccessFlags:flags |
|
172 |
accessFlags := flags. |
|
173 |
||
174 |
"Created: 15.4.1996 / 16:42:52 / cg" |
|
175 |
! |
|
176 |
||
177 |
setConstantPool:anArray |
|
178 |
constantPool := anArray. |
|
179 |
||
180 |
"Created: 15.4.1996 / 16:42:52 / cg" |
|
181 |
! |
|
182 |
||
183 |
setInterfaces:i |
|
184 |
i size > 0 ifTrue:[ |
|
185 |
interfaces := i |
|
186 |
] ifFalse:[ |
|
187 |
interfaces := nil |
|
188 |
] |
|
189 |
||
190 |
"Modified: 7.4.1997 / 15:44:53 / cg" |
|
739 | 191 |
! ! |
722 | 192 |
|
193 |
!JavaBehavior methodsFor:'queries'! |
|
194 |
||
195 |
hasInterface:aJavaInterface |
|
196 |
"return true, if I respond to all methods as |
|
197 |
required by the argument, an aJavaInterface" |
|
198 |
||
199 |
interfaces size > 0 ifTrue:[ |
|
200 |
self interfaces do:[:if | |
|
201 |
aJavaInterface == if ifTrue:[ |
|
202 |
^ true |
|
203 |
]. |
|
204 |
] |
|
205 |
]. |
|
206 |
superclass isJavaClass ifTrue:[ |
|
207 |
^ superclass hasInterface:aJavaInterface |
|
208 |
]. |
|
209 |
^ false. |
|
210 |
||
211 |
"/ aJavaInterface methodDictionary keysAndValuesDo:[:sel :mthd | |
|
212 |
"/ (self canUnderstand:sel) ifFalse:[ |
|
213 |
"/ ^ false. |
|
214 |
"/ ] |
|
215 |
"/ ]. |
|
216 |
^ true |
|
217 |
||
218 |
"Modified: / 28.1.1998 / 01:46:16 / cg" |
|
219 |
||
220 |
! |
|
221 |
||
222 |
isAbstract |
|
223 |
"return true, if the receiver is abstract |
|
224 |
(i.e. may not have instances)" |
|
225 |
||
226 |
^ (accessFlags bitAnd:A_ABSTRACT) ~~ 0 |
|
227 |
||
228 |
"Modified: / 7.5.1998 / 12:24:42 / cg" |
|
229 |
! |
|
230 |
||
231 |
isFinal |
|
232 |
"return true, if the receiver is final |
|
233 |
(i.e. may not be subclassed)" |
|
234 |
||
235 |
^ (accessFlags bitAnd:A_FINAL) ~~ 0 |
|
236 |
||
237 |
"Modified: / 7.5.1998 / 12:24:21 / cg" |
|
238 |
! |
|
239 |
||
240 |
isInitialized |
|
241 |
"return true, if the receiver is initialized" |
|
242 |
||
243 |
^ (accessFlags bitAnd:A_INITIALIZED) ~~ 0 |
|
244 |
||
245 |
"Modified: / 7.5.1998 / 12:23:54 / cg" |
|
246 |
! |
|
247 |
||
248 |
isInterface |
|
249 |
"return true, if the receiver is an interface" |
|
250 |
||
251 |
^ (accessFlags bitAnd:A_INTERFACE) ~~ 0 |
|
252 |
||
253 |
"Modified: / 7.5.1998 / 12:23:39 / cg" |
|
254 |
! |
|
255 |
||
256 |
isObsolete |
|
257 |
"return true, if the receiver is obsolete |
|
258 |
Java classes are never." |
|
259 |
||
260 |
^ (accessFlags bitAnd:A_OBSOLETE) ~~ 0. |
|
261 |
||
262 |
"Modified: 7.8.1997 / 19:04:28 / cg" |
|
263 |
! |
|
264 |
||
265 |
isPublic |
|
266 |
"return true, if the receiver is public" |
|
267 |
||
268 |
^ (accessFlags bitAnd:A_PUBLIC) ~~ 0 |
|
269 |
||
270 |
"Modified: / 7.5.1998 / 12:22:44 / cg" |
|
271 |
! ! |
|
272 |
||
273 |
!JavaBehavior class methodsFor:'documentation'! |
|
274 |
||
275 |
version |
|
748
da0840b7798c
Manufactured by SVN::ImportFromCVSTask to fix repository layout
jv
parents:
744
diff
changeset
|
276 |
^ '$Id$' |
744 | 277 |
! |
278 |
||
279 |
version_CVS |
|
748
da0840b7798c
Manufactured by SVN::ImportFromCVSTask to fix repository layout
jv
parents:
744
diff
changeset
|
280 |
^ '§Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaBehavior.st,v 1.3 2009/10/09 14:04:26 cg Exp §' |
722 | 281 |
! ! |
282 |
||
283 |
JavaBehavior initialize! |