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