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