author | Claus Gittinger <cg@exept.de> |
Mon, 08 Sep 2008 12:12:22 +0200 | |
changeset 11161 | 3888d6f4e6f9 |
parent 11142 | 4be78ca76701 |
child 11221 | 1e88faaa1249 |
permissions | -rw-r--r-- |
5755 | 1 |
" |
2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
10460 | 3 |
All Rights Reserved |
5755 | 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:libbasic' }" |
|
13 |
||
14 |
nil subclass:#Object |
|
6697 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'ErrorSignal HaltSignal MessageNotUnderstoodSignal |
|
17 |
UserInterruptSignal RecursionInterruptSignal |
|
18 |
ExceptionInterruptSignal SubscriptOutOfBoundsSignal |
|
19 |
IndexNotFoundSignal NonIntegerIndexSignal NotFoundSignal |
|
20 |
KeyNotFoundSignal ElementOutOfBoundsSignal UserNotificationSignal |
|
21 |
InformationSignal WarningSignal PrimitiveFailureSignal |
|
22 |
DeepCopyErrorSignal AbortSignal ErrorRecursion Dependencies |
|
23 |
InfoPrinting ActivityNotificationSignal InternalErrorSignal |
|
24 |
NonWeakDependencies SynchronizationSemaphores ObjectAttributes |
|
25 |
OSSignalInterruptSignal FinalizationLobby |
|
11025 | 26 |
RecursiveStoreStringSignal AbortAllSignal EnabledBreakPoints' |
6697 | 27 |
poolDictionaries:'' |
28 |
category:'Kernel-Objects' |
|
5755 | 29 |
! |
30 |
||
31 |
!Object class methodsFor:'documentation'! |
|
3023
674376809496
general listView support (#displayOn / widthOn / heightOn)
ca
parents:
3010
diff
changeset
|
32 |
|
5754 | 33 |
copyright |
5755 | 34 |
" |
35 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
10460 | 36 |
All Rights Reserved |
5755 | 37 |
|
38 |
This software is furnished under a license and may be used |
|
39 |
only in accordance with the terms of that license and with the |
|
40 |
inclusion of the above copyright notice. This software may not |
|
41 |
be provided or otherwise made available to, or used by, any |
|
42 |
other person. No title to or ownership of the software is |
|
43 |
hereby transferred. |
|
44 |
" |
|
45 |
! |
|
46 |
||
47 |
dependencies |
|
48 |
" |
|
10460 | 49 |
ST/X dependencies are slightly modified from ST-80's |
5755 | 50 |
(we think they are better ;-). |
51 |
||
52 |
One problem occuring very often in ST-80 is that some object |
|
53 |
cannot be garbage collected because some dependency is present, |
|
54 |
having the object as a dependent of some other object. |
|
55 |
In ST-80, this association remains alive (because a Dictionary |
|
56 |
is used to hold dependents) - even if no other references exist to |
|
57 |
to dependent or the dependee. |
|
58 |
||
59 |
This means, that in ST-80, a #release is mandatory in order to |
|
60 |
prevent memory leaks. |
|
61 |
We think, that this is a bad solution, since after all, exactly that |
|
62 |
kind of work should be performed by a garbage collector - you should not |
|
63 |
need to care about dependencies. |
|
10460 | 64 |
From a philosophical point of view, why should some object depend on |
5755 | 65 |
something that the programmer considers a dead object ? |
66 |
(well - worse than that: it seems that some ST-80 code even depends on |
|
67 |
that behavior) |
|
68 |
||
69 |
In order to limit the trouble, ST-80 reimplemented the way dependents |
|
70 |
are stored in the model class - this one keeps the dependents locally, |
|
71 |
so these dependents go away, once the model is reclaimed. |
|
72 |
That may make things even more confusing: with models, no #release is |
|
73 |
needed, with general objects it is mandatory. |
|
74 |
||
75 |
||
76 |
In ST/X, dependencies are implemented using a WeakDictionary; this means, |
|
77 |
that once the dependee dies, the dependency association is removed automatically, |
|
78 |
and the dependent can be reclaimed by the garbage collector, if no other |
|
79 |
references exist to the dependent. |
|
80 |
In order to (at least) provide a mechanism for the old behavior |
|
81 |
(in case your application heavily depends on the ST-80 mechanism), complementary |
|
10460 | 82 |
protocol to add nonWeak dependencies is provided |
5755 | 83 |
(see #addNonWeakDependent / #removeNonWeakDependent). |
84 |
||
85 |
||
86 |
Caveat: |
|
87 |
since interests are implemented using InterestConverter (which are simply |
|
88 |
forwarding messages), these must use the nonWeak mechanism (as done in ST-80 |
|
89 |
automatically). |
|
90 |
The reason is that there are usually no direct references to the converters, |
|
91 |
and those would be reclaimed if stored in a weakDictionary. |
|
92 |
This means, that those interests MUST be removed with #retractInterest |
|
10460 | 93 |
(which is bug-compatible to ST-80). |
5755 | 94 |
We rewrite things to provide a more convenient mechanism in the future ... |
95 |
||
96 |
||
97 |
I like to hear comments on the above - do you think its better ? |
|
98 |
" |
|
99 |
! |
|
100 |
||
101 |
documentation |
|
102 |
" |
|
10460 | 103 |
Object is the superclass of most other classes. |
5755 | 104 |
(except for nil-subclasses, which inherit nothing, |
105 |
to catch any message into their #doesNotUnderstand: method) |
|
106 |
||
107 |
Protocol which is common to every object is defined here. |
|
108 |
Also some utility stuff (like notify) and error handling is implemented here. |
|
109 |
||
110 |
Object has no instance variables (and may not get any added). One reason is, that |
|
10460 | 111 |
UndefinedObject and SmallInteger are also inheriting from Object - these two cannot |
112 |
have instance variables (due to their implementation). |
|
113 |
The other reason is that the runtime system (VM) knows about the layout of some built-in |
|
114 |
classes (think of Class, Method, Block and also Integer or Float). |
|
115 |
If you were allowed to add instance variables to Object, the VM had to be recompiled |
|
5755 | 116 |
(and also rewritten in some places). |
117 |
||
118 |
[Class variables:] |
|
119 |
||
10460 | 120 |
ErrorSignal <Signal> Signal raised for error/error: messages |
121 |
also, parent of all other signals. |
|
122 |
||
123 |
HaltSignal <Signal> Signal raised for halt/halt: messages |
|
124 |
||
125 |
MessageNotUnderstoodSignal Signals raised for various error conditions |
|
126 |
UserInterruptSignal |
|
127 |
RecursionInterruptSignal |
|
128 |
ExceptionInterruptSignal |
|
129 |
SubscriptOutOfBoundsSignal |
|
130 |
NonIntegerIndexSignal |
|
131 |
NotFoundSignal |
|
132 |
KeyNotFoundSignal |
|
133 |
ElementOutOfBoundsSignal |
|
134 |
InformationSignal |
|
135 |
WarningSignal |
|
136 |
DeepCopyErrorSignal |
|
137 |
InternalErrorSignal |
|
138 |
||
139 |
AbortSignal <Signal> Signal raised by debugger, to abort a computation |
|
140 |
BUT, the debugger will only raise it if it is handled. |
|
141 |
By handling the abortSignal, you can control where the |
|
142 |
debuggers abort-function resumes execution in case of |
|
143 |
an error. |
|
144 |
||
145 |
ErrorRecursion <Boolean> controls behavior when recursive errors occur (i.e. |
|
146 |
an error while handling an error). |
|
147 |
||
148 |
Dependencies <WeakDependencyDictionary> |
|
149 |
keeps track of object dependencies. |
|
150 |
||
151 |
InfoPrinting <Boolean> controls weather informational messages |
|
152 |
are printed. |
|
153 |
||
154 |
ActivityNotificationSignal <QuerySignal> |
|
155 |
raised on #activityNotification: |
|
156 |
||
157 |
NonWeakDependencies <Dictionary> keeps track of object dependencies. |
|
158 |
Dependents stay alive. |
|
159 |
||
160 |
SynchronizationSemaphores <WeakIdentityDictionary> |
|
161 |
Semaphores for per-object-monitor. |
|
162 |
||
5755 | 163 |
|
164 |
[author:] |
|
10460 | 165 |
Claus Gittinger |
5755 | 166 |
|
167 |
" |
|
168 |
! ! |
|
169 |
||
170 |
!Object class methodsFor:'initialization'! |
|
171 |
||
5971 | 172 |
initSignals |
173 |
"called only once - initialize signals" |
|
174 |
||
175 |
ErrorSignal := Error. |
|
176 |
||
177 |
ControlInterrupt notifierString:'control interrupted'. |
|
178 |
||
179 |
HaltSignal := HaltInterrupt. |
|
180 |
HaltSignal notifierString:'halt encountered'. |
|
181 |
||
5977 | 182 |
MessageNotUnderstoodSignal := MessageNotUnderstood. |
5971 | 183 |
MessageNotUnderstoodSignal notifierString:'message not understood'. |
184 |
||
6000 | 185 |
PrimitiveFailureSignal := PrimitiveFailure. |
5971 | 186 |
PrimitiveFailureSignal notifierString:'primitive failed'. |
187 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
188 |
InternalErrorSignal := VMInternalError. |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
189 |
|
5971 | 190 |
UserInterruptSignal := UserInterrupt. |
191 |
UserInterruptSignal notifierString:'user Interrupt'. |
|
192 |
||
6146 | 193 |
RecursionInterruptSignal := RecursionError. |
5971 | 194 |
RecursionInterruptSignal notifierString:'recursion limit reached'. |
195 |
||
5977 | 196 |
NotFoundSignal := NotFoundError. |
5971 | 197 |
NotFoundSignal notifierString:'no such element'. |
198 |
||
5977 | 199 |
IndexNotFoundSignal := IndexNotFoundError. |
5971 | 200 |
IndexNotFoundSignal notifierString:'bad index: '. |
201 |
||
5977 | 202 |
SubscriptOutOfBoundsSignal := SubscriptOutOfBoundsError. |
5971 | 203 |
SubscriptOutOfBoundsSignal notifierString:'subscript out of bounds: '. |
204 |
||
5977 | 205 |
NonIntegerIndexSignal := NonIntegerIndexError. |
206 |
NonIntegerIndexSignal notifierString:'index must be integer'. |
|
207 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
208 |
KeyNotFoundSignal := KeyNotFoundError. |
5977 | 209 |
KeyNotFoundSignal notifierString:'no such key: '. |
210 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
211 |
ElementOutOfBoundsSignal := ElementBoundsError. |
5971 | 212 |
|
7033
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
213 |
UserNotificationSignal := UserNotification. |
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
214 |
WarningSignal := Warning. |
7035
1d049fb7ae5a
Make UserInformation a class based exception
Stefan Vogel <sv@exept.de>
parents:
7033
diff
changeset
|
215 |
InformationSignal := UserInformation. |
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
216 |
ActivityNotificationSignal := ActivityNotification. |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
217 |
|
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
218 |
DeepCopyErrorSignal := DeepCopyError. |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
219 |
|
6203
d39d75849383
class based exceptions - abortSignal
Claus Gittinger <cg@exept.de>
parents:
6199
diff
changeset
|
220 |
AbortSignal := AbortOperationRequest. |
6877
ab4e7d42f9f8
AbortAllOperation - now class based
Claus Gittinger <cg@exept.de>
parents:
6874
diff
changeset
|
221 |
AbortAllSignal := AbortAllOperationRequest. |
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
222 |
|
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
223 |
OSSignalInterruptSignal := OSSignalInterrupt. |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
224 |
RecursiveStoreStringSignal := RecursiveStoreError. |
5971 | 225 |
|
5980 | 226 |
" |
227 |
Object initSignals |
|
228 |
" |
|
5971 | 229 |
|
230 |
"Modified: / 22.1.1998 / 21:23:40 / av" |
|
231 |
"Modified: / 4.8.1999 / 08:54:06 / stefan" |
|
6203
d39d75849383
class based exceptions - abortSignal
Claus Gittinger <cg@exept.de>
parents:
6199
diff
changeset
|
232 |
"Modified: / 16.11.2001 / 16:30:08 / cg" |
5971 | 233 |
! |
234 |
||
5755 | 235 |
initialize |
236 |
"called only once - initialize signals" |
|
237 |
||
238 |
ErrorSignal isNil ifTrue:[ |
|
10460 | 239 |
self initSignals |
5971 | 240 |
]. |
241 |
||
242 |
ObjectAttributes isNil ifTrue:[ |
|
10460 | 243 |
ObjectAttributes := WeakIdentityDictionary new. |
5971 | 244 |
]. |
245 |
Dependencies isNil ifTrue:[ |
|
10460 | 246 |
Dependencies := WeakDependencyDictionary new. |
5971 | 247 |
]. |
248 |
NonWeakDependencies isNil ifTrue:[ |
|
10460 | 249 |
NonWeakDependencies := IdentityDictionary new. |
5971 | 250 |
]. |
251 |
SynchronizationSemaphores isNil ifTrue:[ |
|
10460 | 252 |
SynchronizationSemaphores := WeakIdentityDictionary new. |
5971 | 253 |
]. |
5755 | 254 |
FinalizationLobby isNil ifTrue:[ |
10460 | 255 |
FinalizationLobby := Registry new. |
5755 | 256 |
]. |
257 |
||
258 |
"/ initialize InfoPrinting to the VM's infoPrint setting |
|
259 |
"/ (which can be turned off via a command line argument) |
|
260 |
InfoPrinting := ObjectMemory infoPrinting. |
|
261 |
||
262 |
"Object initialize" |
|
263 |
||
264 |
"Modified: / 22.1.1998 / 21:23:40 / av" |
|
265 |
"Modified: / 3.2.1998 / 18:55:09 / cg" |
|
266 |
"Modified: / 4.8.1999 / 08:54:06 / stefan" |
|
267 |
! ! |
|
268 |
||
7303 | 269 |
!Object class methodsFor:'Compatibility-ST80'! |
5755 | 270 |
|
271 |
rootError |
|
272 |
"return the signal used for error/error: - handling. |
|
273 |
Same as errorSignal for ST80 compatibility." |
|
274 |
||
7094
617eeaf2f8ba
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7081
diff
changeset
|
275 |
^ Error |
5755 | 276 |
|
277 |
"Created: / 15.1.1998 / 23:47:05 / stefan" |
|
278 |
! ! |
|
279 |
||
280 |
!Object class methodsFor:'Signal constants'! |
|
281 |
||
10460 | 282 |
abortAllSignal |
5755 | 283 |
"return the signal used to abort user actions (much like AbortSignal). |
284 |
This signal is supposed to abort multiple operation actions, and get out of |
|
285 |
the loop (such as when confirming multiple class deletions etc.)" |
|
286 |
||
287 |
^ AbortAllSignal |
|
288 |
! |
|
289 |
||
10460 | 290 |
abortSignal |
5755 | 291 |
"return the signal used to abort user actions. This signal is only |
292 |
raised if caught (by the debugger), and will lead way out of the |
|
293 |
currently active doIt/printIt or inspectIt. (also some others use |
|
294 |
this for a save abort)" |
|
295 |
||
8521 | 296 |
^ AbortOperationRequest |
5755 | 297 |
! |
298 |
||
299 |
activityNotificationSignal |
|
300 |
"return the signal used for activity notifications. |
|
301 |
A handler for this signal gets all #activityNotification: sends" |
|
302 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
303 |
^ ActivityNotification |
5755 | 304 |
! |
305 |
||
11132
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
306 |
conversionErrorSignal |
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
307 |
"return the signal used for conversion error handling" |
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
308 |
|
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
309 |
^ ConversionError |
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
310 |
! |
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
311 |
|
10460 | 312 |
deepCopyErrorSignal |
5755 | 313 |
"return the signal raised when a deepcopy is asked for |
314 |
an object which cannot do this (for example, BlockClosures |
|
315 |
or Contexts)." |
|
316 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
317 |
^ DeepCopyError |
5755 | 318 |
! |
319 |
||
320 |
elementOutOfBoundsSignal |
|
321 |
"return the signal used for element error reporting |
|
322 |
(this signal is used for example when a value not in 0..255 is to |
|
323 |
be put into a bytearray)" |
|
324 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
325 |
^ ElementBoundsError |
5755 | 326 |
! |
327 |
||
328 |
errorSignal |
|
329 |
"return the signal used for error/error: - handling" |
|
330 |
||
7094
617eeaf2f8ba
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
7081
diff
changeset
|
331 |
^ Error |
5755 | 332 |
! |
333 |
||
334 |
haltSignal |
|
335 |
"return the signal used for halt/halt: - handling" |
|
336 |
||
337 |
^ HaltSignal |
|
338 |
! |
|
339 |
||
340 |
indexNotFoundSignal |
|
341 |
"return the signal used for bad index error reporting. |
|
342 |
This is also the parentSignal of the nonIntegerIndex- and |
|
343 |
subscriptOutOfBoundsSignal" |
|
344 |
||
345 |
^ IndexNotFoundSignal |
|
346 |
||
347 |
"Created: / 8.11.1997 / 19:15:48 / cg" |
|
348 |
! |
|
349 |
||
10460 | 350 |
informationSignal |
351 |
"return the signal used for informations. |
|
5755 | 352 |
A handler for this signal gets all #information: sends" |
353 |
||
354 |
^ InformationSignal |
|
355 |
! |
|
356 |
||
357 |
internalErrorSignal |
|
358 |
"return the signal used to report internal (VM-) errors." |
|
359 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
360 |
^ VMInternalError |
5755 | 361 |
! |
362 |
||
10460 | 363 |
keyNotFoundSignal |
5755 | 364 |
"return the signal used for no such key error reporting" |
365 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
366 |
^ KeyNotFoundError |
5755 | 367 |
! |
368 |
||
369 |
messageNotUnderstoodSignal |
|
370 |
"return the signal used for doesNotUnderstand: - error handling" |
|
371 |
||
372 |
^ MessageNotUnderstoodSignal |
|
373 |
! |
|
374 |
||
10460 | 375 |
nonIntegerIndexSignal |
5755 | 376 |
"return the signal used for bad subscript error reporting" |
377 |
||
378 |
^ NonIntegerIndexSignal |
|
379 |
! |
|
380 |
||
10460 | 381 |
notFoundSignal |
5755 | 382 |
"return the signal used for no element found error reporting" |
383 |
||
384 |
^ NotFoundSignal |
|
385 |
! |
|
386 |
||
7644
211762a9a39f
added notifySignal for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
7621
diff
changeset
|
387 |
notifySignal |
211762a9a39f
added notifySignal for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
7621
diff
changeset
|
388 |
"return the parent of all notification signals." |
211762a9a39f
added notifySignal for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
7621
diff
changeset
|
389 |
|
211762a9a39f
added notifySignal for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
7621
diff
changeset
|
390 |
^ Notification |
211762a9a39f
added notifySignal for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
7621
diff
changeset
|
391 |
! |
211762a9a39f
added notifySignal for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
7621
diff
changeset
|
392 |
|
10460 | 393 |
osSignalInterruptSignal |
5755 | 394 |
"return the signal used for OS-signal error reporting; |
395 |
This is only raised if handled - otherwise, a debugger is entered." |
|
396 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
397 |
^ OSSignalInterrupt |
5755 | 398 |
|
399 |
"Modified: / 12.6.1998 / 16:27:26 / cg" |
|
400 |
! |
|
401 |
||
402 |
primitiveFailureSignal |
|
403 |
"return the signal used for primitiveFailed - error handling" |
|
404 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
405 |
^ PrimitiveFailure |
5755 | 406 |
! |
407 |
||
408 |
privateMethodSignal |
|
409 |
"return the signal used for privateMethod - error handling" |
|
410 |
||
411 |
^ MessageNotUnderstoodSignal |
|
412 |
! |
|
413 |
||
10460 | 414 |
recursionInterruptSignal |
5755 | 415 |
"return the signal used for recursion overflow error handling" |
416 |
||
417 |
^ RecursionInterruptSignal |
|
418 |
! |
|
419 |
||
420 |
recursiveStoreStringSignal |
|
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
421 |
"return the notification used to report storeString generation of recursive objects" |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
422 |
|
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
423 |
^ RecursiveStoreError |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
424 |
|
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
425 |
" |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
426 |
RecursiveStoreError handle:[:ex | |
10460 | 427 |
self halt |
5755 | 428 |
] do:[ |
10460 | 429 |
|a| |
430 |
||
431 |
a := Array new:1. |
|
432 |
a at:1 put:a. |
|
433 |
a storeOn:Transcript |
|
5755 | 434 |
] |
435 |
" |
|
436 |
||
437 |
" |
|
438 |
|a| |
|
439 |
||
440 |
a := Array new:1. |
|
441 |
a at:1 put:a. |
|
442 |
a storeOn:Transcript |
|
443 |
" |
|
444 |
! |
|
445 |
||
5980 | 446 |
subclassResponsibilitySignal |
447 |
"return the signal used for subclassResponsibility error reporting. |
|
6652
4cfba8cb0652
typo and undo renaming of #/#cons:
Stefan Vogel <sv@exept.de>
parents:
6647
diff
changeset
|
448 |
(this signal is used to signal incomplete subclasses - i.e. a programmers error)" |
5980 | 449 |
|
450 |
^ SubclassResponsibilityError |
|
451 |
! |
|
452 |
||
5755 | 453 |
subscriptOutOfBoundsSignal |
454 |
"return the signal used for subscript error reporting. |
|
455 |
(this signal is used for example when an array is accessed with an |
|
456 |
index less than 1 or greater than the array size)" |
|
457 |
||
458 |
^ SubscriptOutOfBoundsSignal |
|
459 |
! |
|
460 |
||
461 |
userInterruptSignal |
|
462 |
"return the signal used for ^C interrupts handling" |
|
463 |
||
464 |
^ UserInterruptSignal |
|
465 |
! |
|
466 |
||
467 |
userNotificationSignal |
|
468 |
"the parent signal used with information and warnings. |
|
469 |
Handling this allows handling of both information- and warning notifications." |
|
470 |
||
471 |
^ UserNotificationSignal |
|
472 |
! |
|
473 |
||
10460 | 474 |
warningSignal |
5755 | 475 |
"return the signal used for warnings. |
476 |
A handler for this signal gets all #warn: sends" |
|
477 |
||
478 |
^ WarningSignal |
|
479 |
! ! |
|
480 |
||
481 |
!Object class methodsFor:'info messages'! |
|
482 |
||
483 |
infoPrinting |
|
484 |
"return the flag which controls information messages." |
|
485 |
||
486 |
^ InfoPrinting |
|
487 |
! |
|
488 |
||
489 |
infoPrinting:aBoolean |
|
490 |
"{ Pragma: +optSpace }" |
|
491 |
||
492 |
"turn on/off printing of information messages. |
|
493 |
If the argument, aBoolean is false, infoPrint will not output |
|
494 |
messages. The default is true." |
|
495 |
||
496 |
InfoPrinting := aBoolean |
|
497 |
! ! |
|
498 |
||
499 |
!Object class methodsFor:'queries'! |
|
500 |
||
8892 | 501 |
isAbstract |
502 |
^ self == Object |
|
503 |
! |
|
504 |
||
5755 | 505 |
isBuiltInClass |
506 |
"return true, if this class is known by the run-time-system, |
|
507 |
i.e. you cannot add/remove instance variables without recompiling |
|
508 |
the VM. |
|
509 |
Here, true is returned for myself, false for subclasses." |
|
510 |
||
511 |
^ self == Object |
|
512 |
||
513 |
"Modified: 23.4.1996 / 16:00:07 / cg" |
|
514 |
! ! |
|
515 |
||
11161 | 516 |
|
517 |
||
8441
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
518 |
!Object methodsFor:'Compatibility-Dolphin'! |
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
519 |
|
11161 | 520 |
stbFixup: anSTBInFiler at: newObjectIndex |
521 |
"Answer the true object that must be used to represent the receiver when read from anSTBInFiler. |
|
522 |
Typically this is overridden by subclasses of STBProxy to answer the proxied object. Other classes |
|
523 |
may also override this method to effectively 'one way become' the receiver to some other object" |
|
524 |
||
525 |
^ self |
|
526 |
! |
|
527 |
||
10460 | 528 |
trigger:anAspect |
8441
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
529 |
self changed:anAspect |
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
530 |
! |
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
531 |
|
10460 | 532 |
trigger:anAspect with:anArgument |
8441
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
533 |
self changed:anAspect with:anArgument |
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
534 |
! |
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
535 |
|
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
536 |
when:anAspect sendTo:anObject |
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
537 |
self expressInterestIn:anAspect for:anObject sendBack:anAspect |
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
538 |
! ! |
728c887f2532
Dolphin compatibility: #trigger...
Stefan Vogel <sv@exept.de>
parents:
8426
diff
changeset
|
539 |
|
9375 | 540 |
!Object methodsFor:'Compatibility-ST/V'! |
541 |
||
542 |
triggerEvent:aSymbol |
|
543 |
self changed:aSymbol |
|
544 |
! ! |
|
545 |
||
7261 | 546 |
!Object methodsFor:'Compatibility-ST80'! |
5755 | 547 |
|
548 |
isMetaclass |
|
549 |
^ self isMeta |
|
550 |
! ! |
|
551 |
||
7261 | 552 |
!Object methodsFor:'Compatibility-Squeak'! |
5755 | 553 |
|
554 |
asString |
|
555 |
^ self printString |
|
556 |
! |
|
557 |
||
9071 | 558 |
becomeForward:anotherObject |
559 |
self becomeSameAs:anotherObject |
|
560 |
! |
|
561 |
||
562 |
becomeForward:anotherObject copyHash:copyHash |
|
563 |
copyHash ifTrue:[ self error:'unsupported operation' ]. |
|
564 |
self becomeSameAs:anotherObject |
|
565 |
! |
|
566 |
||
5755 | 567 |
clone |
568 |
^ self shallowCopy |
|
569 |
! |
|
570 |
||
6146 | 571 |
copyTwoLevel |
572 |
"one more level than a shallowCopy" |
|
573 |
||
574 |
^ self copyToLevel:2 |
|
575 |
||
576 |
" |
|
577 |
|original copy elL1 elL2 elL3 copyOfElL1| |
|
578 |
||
579 |
original := Array new:3. |
|
580 |
original at:1 put:1234. |
|
581 |
original at:2 put:'hello'. |
|
582 |
original at:3 put:(elL1 := Array new:3). |
|
583 |
||
584 |
elL1 at:1 put:1234. |
|
585 |
elL1 at:2 put:'hello'. |
|
586 |
elL1 at:3 put:(elL2 := Array new:3). |
|
587 |
||
588 |
elL2 at:1 put:1234. |
|
589 |
elL2 at:2 put:'hello'. |
|
590 |
elL2 at:3 put:(elL3 := Array new:3). |
|
591 |
||
592 |
elL3 at:1 put:1234. |
|
593 |
elL3 at:2 put:'hello'. |
|
594 |
elL3 at:3 put:(Array new:3). |
|
595 |
||
596 |
copy := original copyTwoLevel. |
|
597 |
(original at:2) ~~ (copy at:2) ifFalse:[self halt]. |
|
598 |
(original at:3) ~~ (copy at:3) ifFalse:[self halt]. |
|
599 |
||
600 |
copyOfElL1 := copy at:3. |
|
601 |
(elL1 at:2) == (copyOfElL1 at:2) ifFalse:[self halt]. |
|
602 |
(elL1 at:3) == (copyOfElL1 at:3) ifFalse:[self halt]. |
|
603 |
" |
|
604 |
! |
|
605 |
||
7320 | 606 |
explore |
607 |
(self confirm:'The Squeak explorer has not yet been ported to ST/X\\Inspect instead ?' withCRs) |
|
608 |
ifTrue:[ |
|
10460 | 609 |
self inspect |
7320 | 610 |
] |
611 |
! |
|
612 |
||
9335 | 613 |
isInMemory |
614 |
"All normal objects are." |
|
615 |
||
616 |
^ true |
|
617 |
! |
|
618 |
||
5755 | 619 |
stringForReadout |
10460 | 620 |
^ self stringRepresentation |
5755 | 621 |
! |
622 |
||
623 |
stringRepresentation |
|
10460 | 624 |
"Answer a string that represents the receiver. For most objects this is simply its printString, but for strings themselves, it's themselves. 6/12/96 sw" |
625 |
||
626 |
^ self printString |
|
5755 | 627 |
! |
628 |
||
9146
56176a7bf685
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9105
diff
changeset
|
629 |
valueWithPossibleArguments:argArray |
56176a7bf685
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9105
diff
changeset
|
630 |
^ self |
56176a7bf685
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9105
diff
changeset
|
631 |
! |
56176a7bf685
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9105
diff
changeset
|
632 |
|
5755 | 633 |
veryDeepCopy |
8383 | 634 |
^ self deepCopyUsing:(IdentityDictionary new) |
5755 | 635 |
! ! |
636 |
||
7567 | 637 |
!Object methodsFor:'Compatibility-VW'! |
638 |
||
8637 | 639 |
isCharacters |
640 |
"added for visual works compatibility" |
|
641 |
^ false |
|
642 |
! |
|
643 |
||
7567 | 644 |
keyNotFoundError:aKey |
645 |
"VW compatibility" |
|
646 |
||
647 |
self errorKeyNotFound:aKey. |
|
648 |
! |
|
649 |
||
650 |
oneWayBecome:anotherObject |
|
651 |
^ self becomeSameAs:anotherObject |
|
652 |
||
653 |
" |
|
654 |
|arr o1 o2| |
|
655 |
||
656 |
arr := Array new:2. |
|
657 |
arr at:1 put:(o1 := Object new). |
|
658 |
arr at:2 put:(o2 := Point new). |
|
659 |
o1 oneWayBecome:o2. |
|
660 |
(arr at:1) ~~ o2 ifTrue:[self halt]. |
|
661 |
" |
|
662 |
" |
|
663 |
|arr o1 o2| |
|
664 |
||
665 |
arr := Array new:2. |
|
666 |
arr at:1 put:(o1 := Object new). |
|
667 |
arr at:2 put:(o2 := Point new). |
|
668 |
o1 becomeSameAs:o2. |
|
669 |
(arr at:1) ~~ o2 ifTrue:[self halt]. |
|
670 |
" |
|
671 |
! ! |
|
672 |
||
5755 | 673 |
!Object methodsFor:'accessing'! |
674 |
||
675 |
at:index |
|
676 |
"return the indexed instance variable with index, anInteger; |
|
677 |
this method can be redefined in subclasses." |
|
678 |
||
679 |
^ self basicAt:index |
|
680 |
! |
|
681 |
||
682 |
at:index put:anObject |
|
683 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
|
684 |
this method can be redefined in subclasses. Returns anObject (sigh)" |
|
685 |
||
686 |
^ self basicAt:index put:anObject |
|
687 |
||
688 |
"Modified: 19.4.1996 / 11:13:29 / cg" |
|
689 |
! |
|
690 |
||
691 |
basicAt:index |
|
692 |
"return the indexed instance variable with index, anInteger. |
|
693 |
Trigger an error if the receiver has no indexed instance variables. |
|
694 |
This method should NOT be redefined in any subclass (except with great care, for tuning)" |
|
695 |
||
696 |
%{ /* NOCONTEXT */ |
|
697 |
||
698 |
REGISTER int nbytes, indx; |
|
699 |
OBJ myClass; |
|
700 |
REGISTER char *pFirst; |
|
701 |
REGISTER int n; |
|
702 |
||
703 |
/* |
|
704 |
* notice the missing test for self being a nonNilObject - |
|
705 |
* this can be done since basicAt: is defined both in UndefinedObject |
|
706 |
* and SmallInteger |
|
707 |
*/ |
|
708 |
if (__isSmallInteger(index)) { |
|
10460 | 709 |
myClass = __qClass(self); |
710 |
indx = __intVal(index) - 1; |
|
711 |
n /* nInstVars */ = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
|
712 |
n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* nInstVars */); |
|
713 |
nbytes = __qSize(self) - n /* nInstBytes */; |
|
714 |
pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */; |
|
715 |
||
716 |
switch ((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) { |
|
717 |
case __MASKSMALLINT(POINTERARRAY): |
|
718 |
case __MASKSMALLINT(WKPOINTERARRAY): |
|
719 |
/* |
|
720 |
* pointers |
|
721 |
*/ |
|
722 |
if ((unsigned)indx < (__BYTES2OBJS__(nbytes))) { |
|
723 |
OBJ *op; |
|
724 |
||
725 |
op = (OBJ *)pFirst + indx; |
|
726 |
RETURN ( *op ); |
|
727 |
} |
|
728 |
break; |
|
729 |
||
730 |
case __MASKSMALLINT(BYTEARRAY): |
|
731 |
/* |
|
732 |
* (unsigned) bytes |
|
733 |
*/ |
|
734 |
if ((unsigned)indx < nbytes) { |
|
735 |
unsigned char *cp; |
|
736 |
||
737 |
cp = (unsigned char *)pFirst + indx; |
|
738 |
RETURN ( __mkSmallInteger( (*cp & 0xFF)) ); |
|
739 |
} |
|
740 |
break; |
|
741 |
||
742 |
case __MASKSMALLINT(FLOATARRAY): |
|
743 |
/* |
|
744 |
* native floats |
|
745 |
*/ |
|
746 |
if ((unsigned)indx < (nbytes / sizeof(float))) { |
|
747 |
float *fp; |
|
748 |
float f; |
|
749 |
OBJ v; |
|
750 |
||
751 |
fp = (float *)pFirst + indx; |
|
752 |
f = *fp; |
|
753 |
if (f == 0.0) { |
|
754 |
v = __float0; |
|
755 |
} else { |
|
756 |
__qMKSFLOAT(v, f); |
|
757 |
} |
|
758 |
RETURN (v); |
|
759 |
} |
|
760 |
break; |
|
761 |
||
762 |
case __MASKSMALLINT(DOUBLEARRAY): |
|
763 |
/* |
|
764 |
* native doubles |
|
765 |
*/ |
|
5755 | 766 |
#ifdef __NEED_DOUBLE_ALIGN |
10460 | 767 |
if ((INT)pFirst & (__DOUBLE_ALIGN-1)) { |
768 |
int delta = __DOUBLE_ALIGN - ((INT)pFirst & (__DOUBLE_ALIGN-1)); |
|
769 |
||
770 |
pFirst += delta; |
|
771 |
nbytes -= delta; |
|
772 |
} |
|
5755 | 773 |
#endif |
10460 | 774 |
if ((unsigned)indx < (nbytes / sizeof(double))) { |
775 |
double *dp; |
|
776 |
double d; |
|
777 |
OBJ v; |
|
778 |
||
779 |
dp = (double *)pFirst + indx; |
|
780 |
d = *dp; |
|
781 |
if (d == 0.0) { |
|
782 |
v = __float0; |
|
783 |
} else { |
|
784 |
__qMKFLOAT(v, d); |
|
785 |
} |
|
786 |
RETURN (v); |
|
787 |
} |
|
788 |
break; |
|
789 |
||
790 |
case __MASKSMALLINT(WORDARRAY): |
|
791 |
/* |
|
792 |
* unsigned 16bit ints |
|
793 |
*/ |
|
794 |
/* Notice: the hard coded shifts are by purpose; |
|
795 |
* it makes us independent of the short-size of the machine |
|
796 |
*/ |
|
797 |
if ((unsigned)indx < (nbytes>>1)) { |
|
798 |
unsigned short *sp; |
|
799 |
||
800 |
sp = (unsigned short *)(pFirst + (indx<<1)); |
|
801 |
RETURN ( __mkSmallInteger( (*sp & 0xFFFF)) ); |
|
802 |
} |
|
803 |
break; |
|
804 |
||
805 |
case __MASKSMALLINT(SWORDARRAY): |
|
806 |
/* |
|
807 |
* signed 16bit ints |
|
808 |
*/ |
|
809 |
/* Notice: the hard coded shifts are by purpose; |
|
810 |
* it makes us independent of the short-size of the machine |
|
811 |
*/ |
|
812 |
if ((unsigned)indx < (nbytes>>1)) { |
|
813 |
short *ssp; |
|
814 |
||
815 |
ssp = (short *)(pFirst + (indx<<1)); |
|
816 |
RETURN ( __mkSmallInteger( (*ssp) )); |
|
817 |
} |
|
818 |
break; |
|
819 |
||
820 |
case __MASKSMALLINT(LONGARRAY): |
|
821 |
/* |
|
822 |
* unsigned 32bit ints |
|
823 |
*/ |
|
824 |
/* Notice: the hard coded shifts are by purpose; |
|
825 |
* it makes us independent of the int-size of the machine |
|
826 |
*/ |
|
827 |
if ((unsigned)indx < (nbytes>>2)) { |
|
828 |
unsigned int32 ul; |
|
829 |
unsigned int32 *lp; |
|
830 |
||
831 |
lp = (unsigned int32 *)(pFirst + (indx<<2)); |
|
832 |
ul = *lp; |
|
8901
824a89d0b5c7
alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents:
8892
diff
changeset
|
833 |
#if __POINTER_SIZE__ == 8 |
10460 | 834 |
{ |
835 |
unsigned INT ull = (unsigned INT)ul; |
|
836 |
RETURN ( __mkSmallInteger(ull) ); |
|
837 |
} |
|
5755 | 838 |
#else |
10460 | 839 |
if (ul <= _MAX_INT) { |
840 |
RETURN ( __mkSmallInteger(ul) ); |
|
841 |
} |
|
842 |
RETURN ( __MKULARGEINT(ul) ); |
|
5755 | 843 |
#endif |
10460 | 844 |
} |
845 |
break; |
|
846 |
||
847 |
case __MASKSMALLINT(SLONGARRAY): |
|
848 |
/* |
|
849 |
* signed 32bit ints |
|
850 |
*/ |
|
851 |
/* Notice: the hard coded shifts are by purpose; |
|
852 |
* it makes us independent of the int-size of the machine |
|
853 |
*/ |
|
854 |
if ((unsigned)indx < (nbytes>>2)) { |
|
855 |
int32 *slp; |
|
856 |
int32 l; |
|
857 |
||
858 |
slp = (int32 *)(pFirst + (indx<<2)); |
|
859 |
l = *slp; |
|
8901
824a89d0b5c7
alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents:
8892
diff
changeset
|
860 |
#if __POINTER_SIZE__ == 8 |
10460 | 861 |
{ |
862 |
INT ll = (INT)l; |
|
863 |
RETURN ( __mkSmallInteger(ll) ); |
|
864 |
} |
|
5755 | 865 |
#else |
10460 | 866 |
if (__ISVALIDINTEGER(l)) { |
867 |
RETURN ( __mkSmallInteger(l) ); |
|
868 |
} |
|
869 |
RETURN ( __MKLARGEINT(l) ); |
|
5755 | 870 |
#endif |
10460 | 871 |
} |
872 |
break; |
|
873 |
||
874 |
case __MASKSMALLINT(SLONGLONGARRAY): |
|
875 |
/* |
|
876 |
* signed 64bit longlongs |
|
877 |
*/ |
|
5755 | 878 |
#ifdef __NEED_LONGLONG_ALIGN |
10460 | 879 |
if ((INT)pFirst & (__LONGLONG_ALIGN-1)) { |
880 |
int delta = __LONGLONG_ALIGN - ((INT)pFirst & (__LONGLONG_ALIGN-1)); |
|
881 |
||
882 |
pFirst += delta; |
|
883 |
nbytes -= delta; |
|
884 |
} |
|
5755 | 885 |
#endif |
10460 | 886 |
/* Notice: the hard coded shifts are by purpose; |
887 |
* it makes us independent of the long/longlong-size of the machine |
|
888 |
*/ |
|
889 |
if ((unsigned)indx < (nbytes>>3)) { |
|
8901
824a89d0b5c7
alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents:
8892
diff
changeset
|
890 |
#if __POINTER_SIZE__ == 8 |
10460 | 891 |
INT *slp, ll; |
892 |
||
893 |
slp = (INT *)(pFirst + (indx<<3)); |
|
894 |
ll = *slp; |
|
895 |
if (__ISVALIDINTEGER(ll)) { |
|
896 |
RETURN ( __mkSmallInteger(ll) ); |
|
897 |
} |
|
898 |
RETURN ( __MKLARGEINT(ll) ); |
|
5755 | 899 |
#else |
10460 | 900 |
__int64__ *llp; |
901 |
||
902 |
llp = (__int64__ *)(pFirst + (indx<<3)); |
|
903 |
RETURN (__MKINT64(llp)); |
|
5755 | 904 |
#endif |
10460 | 905 |
} |
906 |
break; |
|
907 |
||
908 |
case __MASKSMALLINT(LONGLONGARRAY): |
|
909 |
/* |
|
910 |
* unsigned 64bit longlongs |
|
911 |
*/ |
|
5755 | 912 |
#ifdef __NEED_LONGLONG_ALIGN |
10460 | 913 |
if ((INT)pFirst & (__LONGLONG_ALIGN-1)) { |
914 |
int delta = __LONGLONG_ALIGN - ((INT)pFirst & (__LONGLONG_ALIGN-1)); |
|
915 |
||
916 |
pFirst += delta; |
|
917 |
nbytes -= delta; |
|
918 |
} |
|
5755 | 919 |
#endif |
10460 | 920 |
/* Notice: the hard coded shifts are by purpose; |
921 |
* it makes us independent of the long/longlong-size of the machine |
|
922 |
*/ |
|
923 |
if ((unsigned)indx < (nbytes>>3)) { |
|
8901
824a89d0b5c7
alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents:
8892
diff
changeset
|
924 |
#if __POINTER_SIZE__ == 8 |
10460 | 925 |
unsigned INT *ulp, ul; |
926 |
||
927 |
ulp = (unsigned INT *)(pFirst + (indx<<3)); |
|
928 |
ul = *ulp; |
|
929 |
if (ul <= _MAX_INT) { |
|
930 |
RETURN ( __mkSmallInteger(ul) ); |
|
931 |
} |
|
932 |
RETURN ( __MKULARGEINT(ul) ); |
|
5755 | 933 |
#else |
10460 | 934 |
__uint64__ *llp; |
935 |
||
936 |
llp = (__uint64__ *)(pFirst + (indx<<3)); |
|
937 |
RETURN (__MKUINT64(llp)); |
|
5755 | 938 |
#endif |
10460 | 939 |
} |
940 |
break; |
|
941 |
} |
|
5755 | 942 |
} |
943 |
%}. |
|
7216 | 944 |
^ self indexNotIntegerOrOutOfBounds:index |
5755 | 945 |
! |
946 |
||
947 |
basicAt:index put:anObject |
|
948 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
|
949 |
Returns anObject (sigh). |
|
950 |
Trigger an error if the receiver has no indexed instance variables. |
|
951 |
||
952 |
This method should NOT be redefined in any subclass (except with great care, for tuning)" |
|
953 |
||
954 |
%{ /* NOCONTEXT */ |
|
955 |
||
956 |
register int nbytes, indx; |
|
957 |
OBJ myClass; |
|
958 |
register char *pFirst; |
|
959 |
/* int nInstBytes, ninstvars, flags; */ |
|
960 |
REGISTER int n; |
|
961 |
unsigned int u; |
|
962 |
int val; |
|
963 |
||
964 |
/* notice the missing test for self being a nonNilObject - |
|
965 |
this can be done since basicAt: is defined both in UndefinedObject |
|
966 |
and SmallInteger */ |
|
967 |
||
968 |
if (__isSmallInteger(index)) { |
|
10460 | 969 |
indx = __intVal(index) - 1; |
970 |
myClass = __qClass(self); |
|
971 |
n /* ninstvars */ = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
|
972 |
n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* ninstvars */); |
|
973 |
nbytes = __qSize(self) - n /* nInstBytes */; |
|
974 |
pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */; |
|
975 |
||
976 |
switch ((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) { |
|
977 |
case __MASKSMALLINT(POINTERARRAY): |
|
978 |
case __MASKSMALLINT(WKPOINTERARRAY): |
|
979 |
if ((unsigned)indx < (__BYTES2OBJS__(nbytes))) { |
|
980 |
OBJ *op; |
|
981 |
||
982 |
op = (OBJ *)pFirst + indx; |
|
983 |
*op = anObject; |
|
984 |
__STORE(self, anObject); |
|
985 |
RETURN ( anObject ); |
|
986 |
} |
|
987 |
break; |
|
988 |
||
989 |
case __MASKSMALLINT(BYTEARRAY): |
|
990 |
if (__isSmallInteger(anObject)) { |
|
991 |
val = __intVal(anObject); |
|
992 |
if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) { |
|
993 |
if ((unsigned)indx < nbytes) { |
|
994 |
char *cp; |
|
995 |
||
996 |
cp = pFirst + indx; |
|
997 |
*cp = val; |
|
998 |
RETURN ( anObject ); |
|
999 |
} |
|
1000 |
} |
|
1001 |
} |
|
1002 |
break; |
|
1003 |
||
1004 |
case __MASKSMALLINT(FLOATARRAY): |
|
1005 |
if ((unsigned)indx < (nbytes / sizeof(float))) { |
|
1006 |
float *fp; |
|
1007 |
||
1008 |
fp = (float *)pFirst + indx; |
|
1009 |
if (anObject != nil) { |
|
1010 |
if (! __isSmallInteger(anObject)) { |
|
1011 |
if (__qIsFloatLike(anObject)) { |
|
1012 |
*fp = (float)(__floatVal(anObject)); |
|
1013 |
RETURN ( anObject ); |
|
1014 |
} |
|
1015 |
if (__qIsShortFloat(anObject)) { |
|
1016 |
*fp = __shortFloatVal(anObject); |
|
1017 |
RETURN ( anObject ); |
|
1018 |
} |
|
1019 |
} else { |
|
1020 |
*fp = (float) __intVal(anObject); |
|
1021 |
RETURN ( anObject ); |
|
1022 |
} |
|
1023 |
} |
|
1024 |
} |
|
1025 |
break; |
|
1026 |
||
1027 |
case __MASKSMALLINT(DOUBLEARRAY): |
|
5755 | 1028 |
#ifdef __NEED_DOUBLE_ALIGN |
10460 | 1029 |
if ((INT)pFirst & (__DOUBLE_ALIGN-1)) { |
1030 |
int delta = __DOUBLE_ALIGN - ((INT)pFirst & (__DOUBLE_ALIGN-1)); |
|
1031 |
||
1032 |
pFirst += delta; |
|
1033 |
nbytes -= delta; |
|
1034 |
} |
|
5755 | 1035 |
#endif |
10460 | 1036 |
if ((unsigned)indx < (nbytes / sizeof(double))) { |
1037 |
double *dp; |
|
1038 |
||
1039 |
dp = (double *)pFirst + indx; |
|
1040 |
if (anObject != nil) { |
|
1041 |
if (! __isSmallInteger(anObject)) { |
|
1042 |
if (__qIsFloatLike(anObject)) { |
|
1043 |
*dp = __floatVal(anObject); |
|
1044 |
RETURN ( anObject ); |
|
1045 |
} |
|
1046 |
if (__qIsShortFloat(anObject)) { |
|
1047 |
*dp = (double)__shortFloatVal(anObject); |
|
1048 |
RETURN ( anObject ); |
|
1049 |
} |
|
1050 |
} else { |
|
1051 |
*dp = (double) __intVal(anObject); |
|
1052 |
RETURN ( anObject ); |
|
1053 |
} |
|
1054 |
} |
|
1055 |
} |
|
1056 |
break; |
|
1057 |
||
1058 |
case __MASKSMALLINT(WORDARRAY): |
|
1059 |
if (__isSmallInteger(anObject)) { |
|
1060 |
val = __intVal(anObject); |
|
1061 |
if ((unsigned)val <= 0xFFFF) { |
|
1062 |
if ((unsigned)indx < (nbytes>>1)) { |
|
1063 |
unsigned short *sp; |
|
1064 |
||
1065 |
sp = (unsigned short *)(pFirst + (indx<<1)); |
|
1066 |
*sp = val; |
|
1067 |
RETURN ( anObject ); |
|
1068 |
} |
|
1069 |
} |
|
1070 |
} |
|
1071 |
break; |
|
1072 |
||
1073 |
case __MASKSMALLINT(SWORDARRAY): |
|
1074 |
if (__isSmallInteger(anObject)) { |
|
1075 |
val = __intVal(anObject); |
|
1076 |
if ((val >= -32768) && (val < 32768)) { |
|
1077 |
if ((unsigned)indx < (nbytes>>1)) { |
|
1078 |
short *ssp; |
|
1079 |
||
1080 |
ssp = (short *)(pFirst + (indx<<1)); |
|
1081 |
*ssp = val; |
|
1082 |
RETURN ( anObject ); |
|
1083 |
} |
|
1084 |
} |
|
1085 |
} |
|
1086 |
break; |
|
1087 |
||
1088 |
case __MASKSMALLINT(SLONGARRAY): |
|
1089 |
if ((unsigned)indx < (nbytes>>2)) { |
|
1090 |
int32 *slp; |
|
1091 |
||
1092 |
slp = (int32 *)(pFirst + (indx<<2)); |
|
1093 |
if (__isSmallInteger(anObject)) { |
|
1094 |
*slp = __intVal(anObject); |
|
1095 |
RETURN ( anObject ); |
|
1096 |
} |
|
1097 |
n = __signedLongIntVal(anObject); |
|
1098 |
/* |
|
1099 |
* zero means failure for an int larger than 4 bytes |
|
1100 |
* (would be a smallInteger) |
|
1101 |
*/ |
|
1102 |
if (n) { |
|
1103 |
*slp = n; |
|
1104 |
RETURN ( anObject ); |
|
1105 |
} |
|
1106 |
} |
|
1107 |
break; |
|
1108 |
||
1109 |
case __MASKSMALLINT(LONGARRAY): |
|
1110 |
if ((unsigned)indx < (nbytes>>2)) { |
|
1111 |
unsigned int32 *lp; |
|
1112 |
||
1113 |
lp = (unsigned int32 *)(pFirst + (indx<<2)); |
|
1114 |
if (anObject == __mkSmallInteger(0)) { |
|
1115 |
*lp = 0; |
|
1116 |
RETURN ( anObject ); |
|
1117 |
} |
|
1118 |
u = __longIntVal(anObject); |
|
1119 |
/* |
|
1120 |
* zero means failure for an int larger than 4 bytes |
|
1121 |
* (would be a smallInteger) |
|
1122 |
*/ |
|
1123 |
if (u) { |
|
1124 |
*lp = u; |
|
1125 |
RETURN ( anObject ); |
|
1126 |
} |
|
1127 |
} |
|
1128 |
break; |
|
1129 |
||
1130 |
case __MASKSMALLINT(SLONGLONGARRAY): |
|
5755 | 1131 |
#ifdef __NEED_LONGLONG_ALIGN |
10460 | 1132 |
if ((INT)pFirst & (__LONGLONG_ALIGN-1)) { |
1133 |
int delta = __LONGLONG_ALIGN - ((INT)pFirst & (__LONGLONG_ALIGN-1)); |
|
1134 |
||
1135 |
pFirst += delta; |
|
1136 |
nbytes -= delta; |
|
1137 |
} |
|
5755 | 1138 |
#endif |
10460 | 1139 |
if ((unsigned)indx < (nbytes>>3)) { |
1140 |
__int64__ ll; |
|
1141 |
__int64__ *sllp; |
|
1142 |
||
1143 |
sllp = (__int64__ *)(pFirst + (indx<<3)); |
|
1144 |
||
1145 |
if (anObject == __mkSmallInteger(0)) { |
|
1146 |
ll.lo = ll.hi = 0; |
|
1147 |
*sllp = ll; |
|
1148 |
RETURN ( anObject ); |
|
1149 |
} |
|
1150 |
if (__signedLong64IntVal(anObject, &ll)) { |
|
1151 |
*sllp = ll; |
|
1152 |
RETURN ( anObject ); |
|
1153 |
} |
|
1154 |
} |
|
1155 |
break; |
|
1156 |
||
1157 |
case __MASKSMALLINT(LONGLONGARRAY): |
|
5755 | 1158 |
#ifdef __NEED_LONGLONG_ALIGN |
10460 | 1159 |
if ((INT)pFirst & (__LONGLONG_ALIGN-1)) { |
1160 |
int delta = __LONGLONG_ALIGN - ((INT)pFirst & (__LONGLONG_ALIGN-1)); |
|
1161 |
||
1162 |
pFirst += delta; |
|
1163 |
nbytes -= delta; |
|
1164 |
} |
|
5755 | 1165 |
#endif |
10460 | 1166 |
if ((unsigned)indx < (nbytes>>3)) { |
1167 |
__uint64__ ll; |
|
1168 |
__uint64__ *llp; |
|
1169 |
||
1170 |
llp = (__uint64__ *)(pFirst + (indx<<3)); |
|
1171 |
if (anObject == __mkSmallInteger(0)) { |
|
1172 |
ll.lo = ll.hi = 0; |
|
1173 |
*llp = ll; |
|
1174 |
RETURN ( anObject ); |
|
1175 |
} |
|
1176 |
if (__unsignedLong64IntVal(anObject, &ll)) { |
|
1177 |
*llp = ll; |
|
1178 |
RETURN ( anObject ); |
|
1179 |
} |
|
1180 |
} |
|
1181 |
break; |
|
1182 |
} |
|
5755 | 1183 |
} |
1184 |
%}. |
|
1185 |
index isInteger ifFalse:[ |
|
10460 | 1186 |
" |
1187 |
the index should be an integer number |
|
1188 |
" |
|
1189 |
^ self indexNotInteger:index |
|
5755 | 1190 |
]. |
1191 |
(index between:1 and:self size) ifFalse:[ |
|
10460 | 1192 |
" |
1193 |
the index is less than 1 or greater than the size of the |
|
1194 |
receiver collection |
|
1195 |
" |
|
1196 |
^ self subscriptBoundsError:index |
|
5755 | 1197 |
]. |
1198 |
(self class isFloatsOrDoubles) ifTrue:[ |
|
10460 | 1199 |
anObject isNumber ifTrue:[ |
1200 |
^ self basicAt:index put:(anObject asFloat) |
|
1201 |
] |
|
5755 | 1202 |
]. |
1203 |
anObject isInteger ifFalse:[ |
|
10460 | 1204 |
" |
1205 |
the object to put into the receiver collection |
|
1206 |
should be an integer number |
|
1207 |
" |
|
1208 |
^ self elementNotInteger |
|
5755 | 1209 |
]. |
1210 |
" |
|
1211 |
the object to put into the receiver collection |
|
1212 |
is not an instance of the expected element class, |
|
1213 |
or the value is not within the elements valid range. |
|
1214 |
" |
|
7215
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
1215 |
^ self elementBoundsError:anObject |
5755 | 1216 |
|
1217 |
"Modified: 19.4.1996 / 11:14:10 / cg" |
|
1218 |
! |
|
1219 |
||
1220 |
byteAt:index |
|
10460 | 1221 |
"return the byte at index. |
5755 | 1222 |
This is only allowed for non-pointer indexed objects |
1223 |
(i.e. byteArrays, wordArrays, floatArrays etc.). |
|
1224 |
The receivers indexed instvars are treated as an uninterpreted |
|
1225 |
collection of bytes. |
|
1226 |
Only useful with binary storage." |
|
1227 |
||
1228 |
%{ /* NOCONTEXT */ |
|
1229 |
||
1230 |
REGISTER int indx; |
|
1231 |
int nIndex; |
|
1232 |
REGISTER OBJ slf; |
|
1233 |
REGISTER OBJ cls; |
|
1234 |
||
1235 |
if (__isSmallInteger(index)) { |
|
10460 | 1236 |
slf = self; |
1237 |
if (__isNonNilObject(slf)) { |
|
1238 |
unsigned char *pFirst; |
|
1239 |
int nIndex; |
|
1240 |
||
1241 |
cls = __qClass(slf); |
|
1242 |
||
1243 |
pFirst = __byteArrayVal(slf); |
|
1244 |
pFirst += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
1245 |
nIndex = __byteArraySize(slf); |
|
1246 |
indx = __intVal(index) - 1; |
|
1247 |
||
1248 |
switch ((INT)(__ClassInstPtr(cls)->c_flags) & __MASKSMALLINT(ARRAYMASK)) { |
|
1249 |
case __MASKSMALLINT(DOUBLEARRAY): |
|
5755 | 1250 |
#ifdef __NEED_DOUBLE_ALIGN |
10460 | 1251 |
if ((INT)pFirst & (__DOUBLE_ALIGN-1)) { |
1252 |
int delta = __DOUBLE_ALIGN - ((INT)pFirst & (__DOUBLE_ALIGN-1)); |
|
1253 |
||
1254 |
pFirst += delta; |
|
1255 |
nIndex -= delta; |
|
1256 |
} |
|
5755 | 1257 |
#endif |
10460 | 1258 |
/* fall into */ |
1259 |
case __MASKSMALLINT(BYTEARRAY): |
|
1260 |
case __MASKSMALLINT(WORDARRAY): |
|
1261 |
case __MASKSMALLINT(LONGARRAY): |
|
1262 |
case __MASKSMALLINT(SWORDARRAY): |
|
1263 |
case __MASKSMALLINT(SLONGARRAY): |
|
1264 |
case __MASKSMALLINT(FLOATARRAY): |
|
1265 |
if ((unsigned)indx < (unsigned)nIndex) { |
|
1266 |
RETURN ( __mkSmallInteger( (INT)(pFirst[indx])) ); |
|
1267 |
} |
|
1268 |
break; |
|
1269 |
||
1270 |
case __MASKSMALLINT(LONGLONGARRAY): |
|
1271 |
case __MASKSMALLINT(SLONGLONGARRAY): |
|
5755 | 1272 |
#ifdef __NEED_LONGLONG_ALIGN |
10460 | 1273 |
if ((INT)pFirst & (__LONGLONG_ALIGN-1)) { |
1274 |
int delta = __LONGLONG_ALIGN - ((INT)pFirst & (__LONGLONG_ALIGN-1)); |
|
1275 |
||
1276 |
pFirst += delta; |
|
1277 |
nIndex -= delta; |
|
1278 |
} |
|
5755 | 1279 |
#endif |
10460 | 1280 |
if ((unsigned)indx < (unsigned)nIndex) { |
1281 |
RETURN ( __mkSmallInteger( (INT)(pFirst[indx])) ); |
|
1282 |
} |
|
1283 |
break; |
|
1284 |
} |
|
1285 |
} |
|
5755 | 1286 |
} |
1287 |
%}. |
|
1288 |
"/ index not integer or index out of range |
|
1289 |
"/ or non-byte indexable receiver |
|
1290 |
||
1291 |
^ self primitiveFailed |
|
1292 |
||
1293 |
" |
|
1294 |
Point new byteAt:1 |
|
1295 |
(ByteArray with:1 with:2) byteAt:2 |
|
10460 | 1296 |
(WordArray with:1) byteAt:1 |
1297 |
(FloatArray with:1.0) byteAt:2 |
|
1298 |
'hello' byteAt:1 |
|
5755 | 1299 |
" |
1300 |
! |
|
1301 |
||
1302 |
byteAt:index put:byteValue |
|
10460 | 1303 |
"set the byte at index. |
5755 | 1304 |
This is only allowed for non-pointer indexed objects |
1305 |
(i.e. byteArrays, wordArrays, floatArrays etc.). |
|
1306 |
The receivers indexed instvars are treated as an uninterpreted |
|
1307 |
collection of bytes. |
|
1308 |
Only useful with binary storage." |
|
1309 |
||
1310 |
%{ /* NOCONTEXT */ |
|
1311 |
||
1312 |
REGISTER int indx; |
|
1313 |
int val, nIndex; |
|
1314 |
REGISTER OBJ slf; |
|
1315 |
REGISTER OBJ cls; |
|
1316 |
||
1317 |
if (__bothSmallInteger(index, byteValue)) { |
|
10460 | 1318 |
val = __intVal(byteValue); |
1319 |
if ((unsigned)(val) <= 0xFF /* i.e. (val >= 0) && (val <= 255) */) { |
|
1320 |
slf = self; |
|
1321 |
if (__isNonNilObject(slf)) { |
|
1322 |
cls = __qClass(slf); |
|
1323 |
||
1324 |
indx = __intVal(index) - 1; |
|
1325 |
switch ((INT)(__ClassInstPtr(cls)->c_flags) & __MASKSMALLINT(ARRAYMASK)) { |
|
1326 |
case __MASKSMALLINT(BYTEARRAY): |
|
1327 |
case __MASKSMALLINT(WORDARRAY): |
|
1328 |
case __MASKSMALLINT(LONGARRAY): |
|
1329 |
case __MASKSMALLINT(SWORDARRAY): |
|
1330 |
case __MASKSMALLINT(SLONGARRAY): |
|
1331 |
case __MASKSMALLINT(LONGLONGARRAY): |
|
1332 |
case __MASKSMALLINT(SLONGLONGARRAY): |
|
1333 |
case __MASKSMALLINT(FLOATARRAY): |
|
1334 |
case __MASKSMALLINT(DOUBLEARRAY): |
|
1335 |
indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
1336 |
nIndex = __byteArraySize(slf); |
|
1337 |
if ((unsigned)indx < (unsigned)nIndex) { |
|
1338 |
__ByteArrayInstPtr(slf)->ba_element[indx] = val; |
|
1339 |
RETURN ( byteValue ); |
|
1340 |
} |
|
1341 |
break; |
|
1342 |
} |
|
1343 |
} |
|
1344 |
} |
|
5755 | 1345 |
} |
1346 |
%}. |
|
1347 |
"/ index not integer or index out of range |
|
1348 |
"/ or non-byte indexable receiver |
|
1349 |
||
1350 |
^ self primitiveFailed |
|
1351 |
||
1352 |
" |
|
1353 |
(ByteArray with:1 with:2) byteAt:2 put:3; yourself |
|
10460 | 1354 |
'hello' copy byteAt:1 put:105; yourself |
5755 | 1355 |
" |
1356 |
! |
|
1357 |
||
1358 |
instVarAt:index |
|
1359 |
"return a non-indexed instance variable; |
|
10460 | 1360 |
peeking into an object this way is not very object oriented |
5755 | 1361 |
- use with care (needed for copy, inspector etc.)" |
1362 |
||
1363 |
%{ /* NOCONTEXT */ |
|
1364 |
||
1365 |
OBJ myClass; |
|
1366 |
int idx, ninstvars; |
|
1367 |
||
1368 |
if (__isSmallInteger(index)) { |
|
10460 | 1369 |
myClass = __Class(self); |
1370 |
idx = __intVal(index) - 1; |
|
1371 |
/* |
|
1372 |
* do not allow returning of non-object fields. |
|
1373 |
* if subclass did not make privisions for that, |
|
1374 |
* we wont do so here ... |
|
1375 |
*/ |
|
1376 |
if (((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(NONOBJECT_INSTS))) { |
|
1377 |
if (idx == 0) { |
|
1378 |
RETURN ( nil ) |
|
1379 |
} |
|
1380 |
} |
|
1381 |
ninstvars = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
|
1382 |
if ((idx >= 0) && (idx < ninstvars)) { |
|
1383 |
RETURN ( __InstPtr(self)->i_instvars[idx] ); |
|
1384 |
} |
|
5755 | 1385 |
} |
7216 | 1386 |
%}. |
1387 |
^ self indexNotIntegerOrOutOfBounds:index |
|
5755 | 1388 |
! |
1389 |
||
1390 |
instVarAt:index put:value |
|
1391 |
"change a non-indexed instance variable; |
|
10460 | 1392 |
peeking into an object this way is not very object oriented |
5755 | 1393 |
- use with care (needed for copy, inspector etc.)" |
1394 |
||
1395 |
%{ /* NOCONTEXT */ |
|
1396 |
||
1397 |
OBJ myClass; |
|
1398 |
int idx, ninstvars; |
|
1399 |
||
1400 |
if (__isSmallInteger(index)) { |
|
10460 | 1401 |
myClass = __Class(self); |
1402 |
idx = __intVal(index) - 1; |
|
1403 |
ninstvars = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
|
1404 |
/* |
|
1405 |
* do not allow setting of non-object fields. |
|
1406 |
* if subclass did not make privisions for that, |
|
1407 |
* we wont do so here ... |
|
1408 |
*/ |
|
1409 |
if (((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(NONOBJECT_INSTS))) { |
|
1410 |
if (idx == 0) { |
|
1411 |
RETURN ( nil ) |
|
1412 |
} |
|
1413 |
} |
|
1414 |
if ((idx >= 0) && (idx < ninstvars)) { |
|
1415 |
__InstPtr(self)->i_instvars[idx] = value; |
|
1416 |
__STORE(self, value); |
|
1417 |
RETURN ( value ); |
|
1418 |
} |
|
5755 | 1419 |
} |
7216 | 1420 |
%}. |
1421 |
^ self indexNotIntegerOrOutOfBounds:index |
|
5755 | 1422 |
! |
1423 |
||
10460 | 1424 |
instVarNamed:name |
5755 | 1425 |
"return a non-indexed instance variables value by name; |
10460 | 1426 |
peeking into an object this way is not very object oriented |
5755 | 1427 |
- use with care if at all (provided for inspectors and memory usage monitor). |
1428 |
Notice, this access is very slow (because the classes instVar-description has to be |
|
1429 |
parsed ad runtime)" |
|
1430 |
||
10918
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1431 |
|idx| |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1432 |
|
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1433 |
idx := self class instVarOffsetOf:name. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1434 |
idx isNil ifTrue:[ |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1435 |
^ self errorKeyNotFound:name. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1436 |
]. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1437 |
^ self instVarAt:idx. |
5755 | 1438 |
|
1439 |
||
1440 |
" |
|
1441 |
|p| |
|
1442 |
||
1443 |
p := Point x:10 y:20. |
|
10918
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1444 |
p instVarNamed:'cx' |
5755 | 1445 |
" |
1446 |
||
1447 |
"Modified: 19.4.1996 / 11:12:39 / cg" |
|
1448 |
! |
|
1449 |
||
1450 |
instVarNamed:name ifAbsent:exceptionBlock |
|
1451 |
"return a non-indexed instance variables value by name, |
|
1452 |
or the value of exceptionBlock, if there is no such instance variable. |
|
10460 | 1453 |
peeking into an object this way is not very object oriented |
5755 | 1454 |
- use with care if at all (provided for inspectors and memory usage monitor). |
1455 |
Notice, this access is very slow (because the classes instVar-description has to be |
|
1456 |
parsed ad runtime)" |
|
1457 |
||
1458 |
|idx| |
|
1459 |
||
1460 |
idx := self class instVarOffsetOf:name. |
|
1461 |
idx isNil ifTrue:[^ exceptionBlock value]. |
|
1462 |
^ self instVarAt:idx |
|
1463 |
||
1464 |
||
1465 |
" |
|
1466 |
|p| |
|
1467 |
||
1468 |
p := Point x:10 y:20. |
|
10460 | 1469 |
p instVarNamed:'x' |
5755 | 1470 |
" |
1471 |
||
1472 |
"Created: 6.7.1996 / 23:02:49 / cg" |
|
1473 |
"Modified: 6.7.1996 / 23:03:41 / cg" |
|
1474 |
! |
|
1475 |
||
1476 |
instVarNamed:name put:value |
|
1477 |
"set a non-indexed instance variable by name; |
|
10460 | 1478 |
peeking into an object this way is not very object oriented |
5755 | 1479 |
- if at all, use with care (provided for protocol completeness). |
1480 |
Notice, this access is very slow (because the classes instVar-description has to be |
|
1481 |
parsed ad runtime)" |
|
1482 |
||
10918
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1483 |
|idx| |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1484 |
|
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1485 |
idx := self class instVarOffsetOf:name. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1486 |
idx isNil ifTrue:[ |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1487 |
^ self errorKeyNotFound:name. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1488 |
]. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1489 |
^ self instVarAt:idx put:value. |
5755 | 1490 |
|
1491 |
" |
|
1492 |
|p| |
|
1493 |
||
1494 |
p := Point x:10 y:20. |
|
1495 |
p instVarNamed:'x' put:30. |
|
10460 | 1496 |
p |
5755 | 1497 |
" |
1498 |
||
1499 |
"Modified: 19.4.1996 / 11:12:49 / cg" |
|
10918
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1500 |
! |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1501 |
|
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1502 |
instVarNamed:name put:anObject ifAbsent:exceptionBlock |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1503 |
"return a non-indexed instance variables value by name, |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1504 |
or the value of exceptionBlock, if there is no such instance variable. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1505 |
peeking into an object this way is not very object oriented |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1506 |
- use with care if at all (provided for inspectors and memory usage monitor). |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1507 |
Notice, this access is very slow (because the classes instVar-description has to be |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1508 |
parsed ad runtime)" |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1509 |
|
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1510 |
|idx| |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1511 |
|
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1512 |
idx := self class instVarOffsetOf:name. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1513 |
idx isNil ifTrue:[^ exceptionBlock value]. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1514 |
^ self instVarAt:idx put:anObject. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1515 |
|
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1516 |
|
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1517 |
" |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1518 |
|p| |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1519 |
|
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1520 |
p := Point x:10 y:20. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1521 |
p instVarNamed:'x' put:4711 ifAbsent:[self halt:'no such instvar']. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1522 |
p instVarNamed:'bla' put:4712 ifAbsent:[self halt:'no such instvar']. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1523 |
p inspect. |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1524 |
" |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1525 |
|
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1526 |
"Created: 6.7.1996 / 23:02:49 / cg" |
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
1527 |
"Modified: 6.7.1996 / 23:03:41 / cg" |
5755 | 1528 |
! ! |
1529 |
||
1530 |
!Object methodsFor:'attributes access'! |
|
1531 |
||
10460 | 1532 |
objectAttributeAt:attributeKey |
5755 | 1533 |
"return the attribute for a given key or nil if not found" |
1534 |
||
1535 |
| attrs | |
|
1536 |
||
1537 |
attrs := self objectAttributes. |
|
1538 |
(attrs notNil and:[attrs size > 0]) ifTrue:[ |
|
10460 | 1539 |
^ attrs at:attributeKey ifAbsent:[] |
5755 | 1540 |
]. |
1541 |
^ nil |
|
1542 |
||
1543 |
"Created: / 22.1.1998 / 21:29:17 / av" |
|
1544 |
"Modified: / 3.2.1998 / 18:55:55 / cg" |
|
1545 |
! |
|
1546 |
||
6323 | 1547 |
objectAttributeAt:attributeKey put:anObject |
5755 | 1548 |
"store the attribute anObject referenced by key into the receiver" |
1549 |
||
1550 |
"/ must do this save from interrupts, since the attributes collection |
|
1551 |
"/ is possibly accessed from multiple threads ... |
|
1552 |
[ |
|
10460 | 1553 |
| attrs | |
1554 |
||
1555 |
attrs := self objectAttributes. |
|
1556 |
(attrs isNil or:[attrs size == 0]) ifTrue:[ |
|
1557 |
attrs := WeakIdentityDictionary new. |
|
1558 |
attrs at:attributeKey put:anObject. |
|
1559 |
self objectAttributes:attrs. |
|
1560 |
] ifFalse:[ |
|
1561 |
attrs at:attributeKey put:anObject. |
|
1562 |
]. |
|
6323 | 1563 |
] valueUninterruptably |
5755 | 1564 |
|
1565 |
"Attaching additional attributes (slots) to an arbitrary object: |
|
1566 |
||
1567 |
|p| |
|
1568 |
||
1569 |
p := Point new. |
|
1570 |
p objectAttributeAt:#color put:#green. |
|
1571 |
||
1572 |
p objectAttributeAt:#color |
|
1573 |
" |
|
1574 |
||
1575 |
"Created: / 22.1.1998 / 21:29:25 / av" |
|
1576 |
"Modified: / 3.2.1998 / 18:57:58 / cg" |
|
1577 |
! |
|
1578 |
||
1579 |
objectAttributes |
|
1580 |
"return a Collection of attributes - nil if there is none. |
|
1581 |
The default implementation here uses a global WeakDictionary to store |
|
1582 |
attributes |
|
1583 |
This may be too slow for high frequency slot access, |
|
1584 |
therefore, some classes may redefine this for better performance. |
|
1585 |
Notice the mentioning of a WeakDictionary - read the classes documentation." |
|
1586 |
||
1587 |
^ ObjectAttributes at:self ifAbsent:[nil] |
|
1588 |
||
1589 |
"Created: / 22.1.1998 / 21:29:30 / av" |
|
1590 |
"Modified: / 18.2.2000 / 11:34:16 / cg" |
|
1591 |
! |
|
1592 |
||
1593 |
objectAttributes:aCollection |
|
1594 |
"set the collection of attributes. |
|
1595 |
The default implementation here uses a global Dictionary to store |
|
1596 |
attributes which may be too slow for high frequency change&update. |
|
1597 |
Therefore, some classes may redefine this for better performance." |
|
1598 |
||
1599 |
"/ must do this save from interrupts, since the attributes collection |
|
1600 |
"/ is possibly accessed from multiple threads. |
|
1601 |
||
1602 |
(OperatingSystem blockInterrupts) ifTrue:[ |
|
10460 | 1603 |
"/ the common case - already blocked |
1604 |
||
1605 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[ |
|
1606 |
ObjectAttributes removeKey:self ifAbsent:nil |
|
1607 |
] ifFalse:[ |
|
1608 |
ObjectAttributes at:self put:aCollection |
|
1609 |
]. |
|
1610 |
^ self |
|
5755 | 1611 |
]. |
1612 |
||
1613 |
[ |
|
10460 | 1614 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[ |
1615 |
ObjectAttributes removeKey:self ifAbsent:nil |
|
1616 |
] ifFalse:[ |
|
1617 |
ObjectAttributes at:self put:aCollection |
|
1618 |
]. |
|
6421
58dca33cf0fc
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
6418
diff
changeset
|
1619 |
] ensure:[ |
10460 | 1620 |
OperatingSystem unblockInterrupts |
5755 | 1621 |
] |
1622 |
||
1623 |
"Created: / 22.1.1998 / 21:29:35 / av" |
|
1624 |
"Modified: / 3.2.1998 / 18:58:10 / cg" |
|
1625 |
! |
|
1626 |
||
6323 | 1627 |
removeObjectAttribute:attributeKey |
5755 | 1628 |
"make the argument, anObject be no attribute of the receiver" |
1629 |
||
1630 |
"/ must do this save from interrupts, since the attributes collection |
|
1631 |
"/ is possibly accessed from multiple threads. |
|
1632 |
[ |
|
10460 | 1633 |
|attrs n a| |
1634 |
||
1635 |
attrs := self objectAttributes. |
|
1636 |
attrs size == 0 ifTrue:[ |
|
1637 |
self objectAttributes:nil |
|
1638 |
] ifFalse:[ |
|
1639 |
attrs removeKey:attributeKey ifAbsent:nil. |
|
1640 |
attrs size == 0 ifTrue:[ |
|
1641 |
self objectAttributes:nil |
|
1642 |
] |
|
1643 |
] |
|
6323 | 1644 |
] valueUninterruptably |
5755 | 1645 |
|
1646 |
"Created: / 22.1.1998 / 21:29:39 / av" |
|
1647 |
"Modified: / 18.2.2000 / 11:32:19 / cg" |
|
1648 |
! ! |
|
1649 |
||
1650 |
!Object methodsFor:'change & update'! |
|
1651 |
||
1652 |
broadcast:aSelectorSymbol |
|
1653 |
"send a message with selector aSelectorSymbol to all my dependents" |
|
1654 |
||
10460 | 1655 |
self dependentsDo:[:dependent | |
1656 |
dependent perform:aSelectorSymbol |
|
5755 | 1657 |
] |
1658 |
! |
|
1659 |
||
1660 |
broadcast:aSelectorSymbol with:anArgument |
|
1661 |
"send a message with selector aSelectorSymbol with an additional |
|
1662 |
argument anArgument to all my dependents." |
|
1663 |
||
10460 | 1664 |
self dependentsDo:[:dependent | |
1665 |
dependent perform:aSelectorSymbol with:anArgument |
|
5755 | 1666 |
] |
1667 |
! |
|
1668 |
||
1669 |
changeRequest |
|
1670 |
"the receiver wants to change - check if all dependents |
|
1671 |
grant the request, and return true if so" |
|
1672 |
||
10460 | 1673 |
self dependentsDo:[:dependent | |
1674 |
dependent updateRequest ifFalse:[^ false]. |
|
5755 | 1675 |
]. |
1676 |
^ true |
|
1677 |
! |
|
1678 |
||
1679 |
changeRequest:aParameter |
|
1680 |
"the receiver wants to change - check if all dependents |
|
1681 |
grant the request, and return true if so" |
|
1682 |
||
10460 | 1683 |
self dependentsDo:[:dependent | |
1684 |
(dependent updateRequest:aParameter) ifFalse:[^ false]. |
|
5755 | 1685 |
]. |
1686 |
^ true |
|
1687 |
! |
|
1688 |
||
1689 |
changeRequest:aParameter from:anObject |
|
1690 |
"the receiver wants to change - check if all dependents |
|
1691 |
except anObject grant the request, and return true if so. |
|
1692 |
The argument anObject is typically going to be the one who is |
|
1693 |
about to send the change request." |
|
1694 |
||
10460 | 1695 |
self dependentsDo:[:dependent | |
1696 |
dependent == anObject ifFalse:[ |
|
1697 |
(dependent updateRequest:aParameter) ifFalse:[^ false]. |
|
1698 |
] |
|
5755 | 1699 |
]. |
1700 |
^ true |
|
1701 |
! |
|
1702 |
||
1703 |
changeRequestFrom:anObject |
|
1704 |
"the receiver wants to change - check if all dependents |
|
1705 |
except anObject grant the request, and return true if so. |
|
1706 |
The argument anObject is typically going to be the one who is |
|
1707 |
about to send the change request." |
|
1708 |
||
10460 | 1709 |
self dependentsDo:[:dependent | |
1710 |
dependent == anObject ifFalse:[ |
|
1711 |
(dependent updateRequest) ifFalse:[^ false]. |
|
1712 |
] |
|
5755 | 1713 |
]. |
1714 |
^ true |
|
1715 |
! |
|
1716 |
||
1717 |
changed |
|
1718 |
"notify all dependents that the receiver has changed. |
|
1719 |
Each dependent gets a '#update:'-message with the original |
|
1720 |
receiver as argument." |
|
1721 |
||
1722 |
self changed:nil |
|
1723 |
! |
|
1724 |
||
1725 |
changed:aParameter |
|
1726 |
"notify all dependents that the receiver has changed somehow. |
|
1727 |
Each dependent gets a '#update:'-message with aParameter |
|
1728 |
as argument." |
|
1729 |
||
1730 |
self changed:aParameter with:nil |
|
1731 |
! |
|
1732 |
||
1733 |
changed:aParameter with:anArgument |
|
1734 |
"notify all dependents that the receiver has changed somehow. |
|
1735 |
Each dependent gets a '#update:with:from:'-message, with aParameter |
|
1736 |
and anArgument as arguments." |
|
1737 |
||
10460 | 1738 |
self dependentsDo:[:dependent | |
1739 |
dependent update:aParameter with:anArgument from:self |
|
5755 | 1740 |
] |
1741 |
! |
|
1742 |
||
1743 |
update:aParameter |
|
1744 |
"the message is sent to a dependent, when one of the objects |
|
1745 |
on whom the receiver depends, has changed. The argument aParameter |
|
1746 |
is either the changed object or the argument to the #changed: message. |
|
1747 |
||
1748 |
Default behavior here is to do nothing" |
|
1749 |
||
1750 |
^ self |
|
1751 |
! |
|
1752 |
||
1753 |
update:aParameter with:anArgument |
|
1754 |
"dependent is notified of some change - |
|
1755 |
Default is to try update:" |
|
1756 |
||
1757 |
^ self update:aParameter |
|
1758 |
! |
|
1759 |
||
1760 |
update:aParameter with:anArgument from:sender |
|
1761 |
"dependent is notified of some change - |
|
1762 |
Default is to try update:with:" |
|
1763 |
||
1764 |
^ self update:aParameter with:anArgument |
|
1765 |
! |
|
1766 |
||
1767 |
updateRequest |
|
1768 |
"return true, if an update request is granted. |
|
1769 |
Default here is to grant updates - may be used |
|
1770 |
to lock updates if someone is making other changes |
|
1771 |
from within an update. Or if someone has locked its |
|
1772 |
state and does not want others to change things. |
|
1773 |
However, these dependents must all honor the |
|
1774 |
changeRequest - ifTrue - change protocol. I.e. they |
|
1775 |
must first ask all others via changeRequest, and only do the change |
|
1776 |
it returns true. The others must decide in updateRequest and |
|
1777 |
return true if they think a change is ok." |
|
1778 |
||
1779 |
^ true |
|
1780 |
! |
|
1781 |
||
1782 |
updateRequest:aSymbol |
|
1783 |
"return true, if an update request is granted. |
|
1784 |
Default here a simple updateRequest" |
|
1785 |
||
1786 |
^ self updateRequest |
|
7177 | 1787 |
! |
1788 |
||
1789 |
withoutUpdating:someone do:aBlock |
|
1790 |
"evaluate a block but remove someone from my dependents temporarily" |
|
1791 |
||
1792 |
(self dependents includesIdentical:someone) |
|
1793 |
ifFalse:[ |
|
10460 | 1794 |
^ aBlock value. |
7177 | 1795 |
]. |
1796 |
self removeDependent:someone. |
|
1797 |
^ aBlock ensure:[ self addDependent:someone ] |
|
5755 | 1798 |
! ! |
1799 |
||
1800 |
!Object methodsFor:'cleanup'! |
|
1801 |
||
1802 |
lowSpaceCleanup |
|
1803 |
"ignored here - redefined in some classes to |
|
1804 |
cleanup in low-memory situations" |
|
1805 |
||
1806 |
^ self |
|
1807 |
! ! |
|
1808 |
||
1809 |
!Object methodsFor:'comparing'! |
|
1810 |
||
1811 |
= anObject |
|
1812 |
"return true, if the receiver and the arg have the same structure. |
|
1813 |
Notice: |
|
10460 | 1814 |
This method is partially open coded (inlined) by the compiler(s) |
1815 |
identical objects are always considered equal. |
|
1816 |
redefining it may not work as expected." |
|
5755 | 1817 |
|
1818 |
^ self == anObject |
|
1819 |
! |
|
1820 |
||
1821 |
== anObject |
|
1822 |
"return true, if the receiver and the arg are the same object. |
|
1823 |
Never redefine this in any class. |
|
1824 |
Notice: |
|
10460 | 1825 |
This method is open coded (inlined) by the compiler(s) |
1826 |
- redefining it may not work as expected." |
|
5755 | 1827 |
|
1828 |
%{ /* NOCONTEXT */ |
|
1829 |
||
1830 |
RETURN ( (self == anObject) ? true : false ); |
|
1831 |
%} |
|
1832 |
! |
|
1833 |
||
5814 | 1834 |
deepSameContentsAs:anObject |
1835 |
"return true, if the receiver and the arg have the same contents |
|
1836 |
in both the named instance vars and any indexed instVars. |
|
1837 |
This method descends into referenced objects, where #sameContentsAs: does not descend" |
|
1838 |
||
5821 | 1839 |
|myClass val |
5814 | 1840 |
sz "{ Class: SmallInteger }" | |
1841 |
||
1842 |
myClass := self class. |
|
1843 |
myClass isVariable ifTrue:[ |
|
10460 | 1844 |
sz := self basicSize. |
1845 |
||
1846 |
"compare the indexed variables" |
|
1847 |
1 to:sz do:[:i | |
|
1848 |
val := self basicAt:i. |
|
1849 |
val isLiteral ifTrue:[ |
|
1850 |
val = (anObject basicAt:i) ifFalse:[^ false]. |
|
1851 |
] ifFalse:[ |
|
1852 |
(val deepSameContentsAs:(anObject basicAt:i)) ifFalse:[^ false]. |
|
1853 |
] |
|
1854 |
] |
|
5814 | 1855 |
]. |
1856 |
||
1857 |
"compare the instance variables" |
|
1858 |
sz := myClass instSize. |
|
10460 | 1859 |
1 to:sz do:[:i | |
1860 |
val := self instVarAt:i. |
|
1861 |
val isLiteral ifTrue:[ |
|
1862 |
val = (anObject instVarAt:i) ifFalse:[^ false]. |
|
1863 |
] ifFalse:[ |
|
1864 |
(val deepSameContentsAs:(anObject instVarAt:i)) ifFalse:[^ false]. |
|
1865 |
] |
|
5814 | 1866 |
]. |
1867 |
||
1868 |
^ true |
|
1869 |
||
1870 |
" |
|
10460 | 1871 |
#(1 2 3 4) deepSameContentsAs:#[1 2 3 4] asArray |
5814 | 1872 |
(1@2) deepSameContentsAs:(1->2) |
1873 |
" |
|
1874 |
! |
|
1875 |
||
5755 | 1876 |
hash |
1877 |
"return an Integer useful as a hash key for the receiver. |
|
1878 |
This hash should return same values for objects with same |
|
1879 |
contents (i.e. use this to hash on structure)" |
|
1880 |
||
1881 |
^ self identityHash |
|
1882 |
! |
|
1883 |
||
1884 |
identityHash |
|
1885 |
"return an Integer useful as a hash key for the receiver. |
|
1886 |
This hash should return same values for the same object (i.e. use |
|
1887 |
this to hash on identity of objects). |
|
1888 |
||
1889 |
We cannot use the Objects address (as other smalltalks do) since |
|
1890 |
no object-table exists and the hashval must not change when objects |
|
1891 |
are moved by the collector. Therefore we assign each object a unique |
|
1892 |
Id in the object header itself as its hashed upon. |
|
1893 |
(luckily we have 11 bits spare to do this - unluckily its only 11 bits). |
|
1894 |
Time will show, if 11 bits are enough; if not, another entry in the |
|
1895 |
object header will be needed, adding 4 bytes to every object. Alternatively, |
|
1896 |
hashed-upon objects could add an instvar containing the hash value." |
|
1897 |
||
1898 |
%{ /* NOCONTEXT */ |
|
1899 |
||
5806
a7361ebe686a
avoid warnings on alpha (int-size)
Claus Gittinger <cg@exept.de>
parents:
5769
diff
changeset
|
1900 |
REGISTER unsigned INT hash; |
5755 | 1901 |
static unsigned nextHash = 0; |
1902 |
||
1903 |
if (__isNonNilObject(self)) { |
|
10460 | 1904 |
hash = __GET_HASH(self); |
1905 |
if (hash == 0) { |
|
1906 |
/* has no hash yet */ |
|
1907 |
||
1908 |
if (++nextHash > __MAX_HASH__) { |
|
1909 |
nextHash = 1; |
|
1910 |
} |
|
1911 |
hash = nextHash; |
|
1912 |
__SET_HASH(self, hash); |
|
1913 |
} |
|
1914 |
||
1915 |
/* |
|
1916 |
* now, we got 11 bits for hashing; |
|
1917 |
* make it as large as possible; since most hashers use the returned |
|
1918 |
* key and take it modulo some prime number, this will allow for |
|
1919 |
* better distribution (i.e. bigger empty spaces) in hashed collection. |
|
1920 |
*/ |
|
1921 |
hash = __MAKE_HASH__(hash); |
|
1922 |
RETURN ( __mkSmallInteger(hash) ); |
|
5755 | 1923 |
} |
1924 |
%}. |
|
1925 |
^ 0 "never reached, since redefined in UndefinedObject and SmallInteger" |
|
1926 |
! |
|
1927 |
||
1928 |
identityHashForBinaryStore |
|
1929 |
"hash which is usable if the object does not change its class |
|
1930 |
and does not #become something else, while the hash is used. |
|
1931 |
This is only used by the binary storage mechanism, during the |
|
1932 |
object writing phase." |
|
1933 |
||
1934 |
%{ /* NOCONTEXT */ |
|
1935 |
||
5806
a7361ebe686a
avoid warnings on alpha (int-size)
Claus Gittinger <cg@exept.de>
parents:
5769
diff
changeset
|
1936 |
REGISTER unsigned INT hash, hash1, hash2, sz; |
5755 | 1937 |
OBJ o; |
5806
a7361ebe686a
avoid warnings on alpha (int-size)
Claus Gittinger <cg@exept.de>
parents:
5769
diff
changeset
|
1938 |
static unsigned INT nextHash = 0; |
a7361ebe686a
avoid warnings on alpha (int-size)
Claus Gittinger <cg@exept.de>
parents:
5769
diff
changeset
|
1939 |
static unsigned INT nextClassHash = 0; |
5755 | 1940 |
|
1941 |
if (__isNonNilObject(self)) { |
|
10460 | 1942 |
/* |
1943 |
* my own identityHash |
|
1944 |
*/ |
|
1945 |
hash1 = __GET_HASH(self); |
|
1946 |
if (hash1 == 0) { |
|
1947 |
/* has no hash yet */ |
|
1948 |
||
1949 |
if (++nextHash > __MAX_HASH__) { |
|
1950 |
nextHash = 1; |
|
1951 |
} |
|
1952 |
hash1 = nextHash; |
|
1953 |
__SET_HASH(self, hash1); |
|
1954 |
} |
|
1955 |
/* |
|
1956 |
* my classes identityHash |
|
1957 |
*/ |
|
1958 |
o = __qClass(self); |
|
1959 |
hash2 = __GET_HASH(o); |
|
1960 |
if (hash2 == 0) { |
|
1961 |
/* has no hash yet */ |
|
1962 |
||
1963 |
if (++nextClassHash > __MAX_HASH__) { |
|
1964 |
nextClassHash = 1; |
|
1965 |
} |
|
1966 |
hash2 = nextClassHash; |
|
1967 |
__SET_HASH(o, hash2); |
|
1968 |
} |
|
1969 |
||
1970 |
/* |
|
1971 |
* some bits of my size |
|
1972 |
*/ |
|
1973 |
sz = __qSize(self); |
|
1974 |
||
1975 |
/* |
|
1976 |
* now, we got 11 + 11 + 8 bits for hashing; |
|
1977 |
* make it as large as possible; since most hashers use the returned |
|
1978 |
* key and take it modulo some prime number, this will allow for |
|
1979 |
* better distribution (i.e. bigger empty spaces) in hashed collection. |
|
1980 |
*/ |
|
1981 |
hash = (hash1 << 11) | hash2; /* 22 bits */ |
|
1982 |
hash = (hash << 8) | (sz & 0xFC); /* 30 bits */ |
|
1983 |
||
1984 |
while ((hash & 0x20000000) == 0) { |
|
1985 |
hash <<= 1; |
|
1986 |
} |
|
1987 |
||
1988 |
RETURN ( __mkSmallInteger(hash) ); |
|
5755 | 1989 |
} |
1990 |
%}. |
|
1991 |
"never reached, since UndefinedObject and SmallInteger are not hashed upon in binary storage" |
|
1992 |
^ self identityHash |
|
1993 |
! |
|
1994 |
||
1995 |
sameContentsAs:anObject |
|
1996 |
"return true, if the receiver and the arg have the same contents |
|
7121 | 1997 |
in both the named instance vars and any indexed instVars. |
1998 |
The code here only checks if values present in the receiver are also |
|
1999 |
present in the arg, not vice versa. |
|
2000 |
I.e. the argument may be bigger and/or have more instance variables." |
|
5755 | 2001 |
|
5821 | 2002 |
|myClass |
5755 | 2003 |
sz "{ Class: SmallInteger }" | |
2004 |
||
2005 |
myClass := self class. |
|
2006 |
myClass isVariable ifTrue:[ |
|
10460 | 2007 |
sz := self basicSize. |
2008 |
anObject basicSize >= sz ifFalse:[^ false]. |
|
2009 |
||
2010 |
"compare the indexed variables" |
|
2011 |
1 to:sz do:[:i | |
|
2012 |
(self basicAt:i) == (anObject basicAt:i) ifFalse:[^ false]. |
|
2013 |
] |
|
5755 | 2014 |
]. |
2015 |
||
2016 |
"compare the instance variables" |
|
2017 |
sz := myClass instSize. |
|
7121 | 2018 |
anObject instSize >= sz ifFalse:[^ false]. |
2019 |
||
10460 | 2020 |
1 to:sz do:[:i | |
2021 |
(self instVarAt:i) == (anObject instVarAt:i) ifFalse:[^ false]. |
|
5755 | 2022 |
]. |
2023 |
||
2024 |
^ true |
|
2025 |
||
2026 |
" |
|
10460 | 2027 |
#(1 2 3 4) sameContentsAs:#[1 2 3 4] asArray |
5814 | 2028 |
(1@2) sameContentsAs:(1->2) |
5755 | 2029 |
" |
2030 |
||
2031 |
"Created: / 21.4.1998 / 15:56:40 / cg" |
|
2032 |
"Modified: / 21.4.1998 / 15:58:15 / cg" |
|
2033 |
! |
|
2034 |
||
2035 |
~= anObject |
|
2036 |
"return true, if the receiver and the arg do not have the same structure. |
|
2037 |
Notice: |
|
10460 | 2038 |
This method is partially open coded (inlined) by the compiler(s) |
2039 |
identical objects are never considered unequal. |
|
2040 |
redefining it may not work as expected." |
|
5755 | 2041 |
|
2042 |
^ (self = anObject) not |
|
2043 |
! |
|
2044 |
||
2045 |
~~ anObject |
|
2046 |
"return true, if the receiver and the arg are not the same object. |
|
2047 |
Never redefine this in any class. |
|
2048 |
Notice: |
|
10460 | 2049 |
This method is open coded (inlined) by the compiler(s) |
2050 |
- redefining it may not work as expected." |
|
5755 | 2051 |
|
2052 |
%{ /* NOCONTEXT */ |
|
2053 |
RETURN ( (self == anObject) ? false : true ); |
|
2054 |
%} |
|
2055 |
! ! |
|
2056 |
||
2057 |
!Object methodsFor:'converting'! |
|
2058 |
||
2059 |
-> anObject |
|
2060 |
"return an association with the receiver as key and |
|
2061 |
the argument as value" |
|
2062 |
||
2063 |
^ Association key:self value:anObject |
|
2064 |
! |
|
2065 |
||
10062 | 2066 |
as:aSimilarClass |
2067 |
"If the receivers class is not aSimilarClass, |
|
10460 | 2068 |
create and return an object of class aSimilarClass that has the same contents |
10062 | 2069 |
as the receiver. |
2070 |
Otherwise, return the receiver." |
|
2071 |
||
2072 |
self class == aSimilarClass ifTrue:[^ self]. |
|
2073 |
^ aSimilarClass newFrom:self |
|
2074 |
||
2075 |
" |
|
2076 |
#[1 2 3 4] as:ByteArray |
|
2077 |
#[1 2 3 4] as:Array |
|
10539 | 2078 |
#[81 82 83 84] as:String |
2079 |
#[81 82 83 84] as:Symbol |
|
10062 | 2080 |
" |
2081 |
! |
|
2082 |
||
5755 | 2083 |
asCollection |
2084 |
"return myself as a Collection. |
|
2085 |
Redefined in collection to return themself." |
|
2086 |
||
2087 |
^ Array with:self |
|
2088 |
! |
|
2089 |
||
2090 |
asSequenceableCollection |
|
2091 |
"return myself as a SequenceableCollection. |
|
2092 |
Redefined in SequenceableCollection" |
|
2093 |
||
2094 |
^ Array with:self |
|
2095 |
! |
|
2096 |
||
2097 |
asValue |
|
2098 |
"return a valueHolder for for the receiver" |
|
2099 |
||
2100 |
^ ValueHolder with:self |
|
6146 | 2101 |
! |
2102 |
||
2103 |
collect |
|
2104 |
"return mySelf" |
|
2105 |
||
2106 |
^ self |
|
2107 |
! |
|
2108 |
||
2109 |
deepCollect |
|
2110 |
"return mySelf" |
|
2111 |
||
2112 |
^ self |
|
2113 |
! |
|
2114 |
||
2115 |
deepSelect |
|
2116 |
"return mySelf" |
|
2117 |
||
2118 |
^ self |
|
2119 |
! |
|
2120 |
||
2121 |
select |
|
2122 |
"return mySelf" |
|
2123 |
||
2124 |
^ self |
|
5755 | 2125 |
! ! |
2126 |
||
2127 |
!Object methodsFor:'copying'! |
|
2128 |
||
10460 | 2129 |
cloneFrom:anObject |
5755 | 2130 |
"Helper for copy: |
2131 |
copy all instance variables from anObject into the receiver, |
|
2132 |
which should be of the same class as the argument." |
|
2133 |
||
2134 |
self cloneFrom:anObject performing:#yourself |
|
2135 |
||
2136 |
" |
|
2137 |
|x| |
|
2138 |
||
2139 |
x := Array new:3. |
|
2140 |
x cloneFrom:#(1 2 3). |
|
2141 |
" |
|
2142 |
! |
|
2143 |
||
2144 |
cloneFrom:anObject performing:aSymbol |
|
2145 |
"Helper for copy: |
|
8383 | 2146 |
for each instance variable from anObject, send it aSymbol |
5755 | 2147 |
and store the result into the receiver, |
2148 |
which should be of the same class as the argument." |
|
2149 |
||
2150 |
|myClass sz "{ Class: SmallInteger }" t | |
|
2151 |
||
2152 |
myClass := self class. |
|
2153 |
myClass isVariable ifTrue:[ |
|
10460 | 2154 |
sz := self basicSize. |
2155 |
||
2156 |
"process the indexed instance variables" |
|
2157 |
1 to:sz do:[:i | |
|
2158 |
t := anObject basicAt:i. |
|
2159 |
aSymbol ~~ #yourself ifTrue:[ |
|
2160 |
t := t perform:aSymbol. |
|
2161 |
]. |
|
2162 |
self basicAt:i put:t. |
|
2163 |
] |
|
5755 | 2164 |
]. |
2165 |
||
8383 | 2166 |
"process the named instance variables" |
5755 | 2167 |
sz := myClass instSize. |
10460 | 2168 |
1 to:sz do:[:i | |
2169 |
t := anObject instVarAt:i. |
|
2170 |
aSymbol ~~ #yourself ifTrue:[ |
|
2171 |
t := t perform:aSymbol |
|
2172 |
]. |
|
2173 |
self instVarAt:i put:t |
|
5755 | 2174 |
]. |
2175 |
||
2176 |
^ self |
|
2177 |
! |
|
2178 |
||
2179 |
cloneInstanceVariablesFrom:aPrototype |
|
2180 |
"Shallow copy variables from a prototype into myself. |
|
2181 |
This copies instVars by name - i.e. same-named variables are |
|
2182 |
copied, others are not. |
|
10460 | 2183 |
The variable slots are copied as available |
5755 | 2184 |
(i.e. the min of both indexed sizes is used)." |
10460 | 2185 |
|
5755 | 2186 |
|myInfo otherInfo| |
2187 |
||
2188 |
myInfo := self class instanceVariableOffsets. |
|
2189 |
otherInfo := aPrototype class instanceVariableOffsets. |
|
2190 |
myInfo keysAndValuesDo:[:name :index | |varIndexAssoc| |
|
10460 | 2191 |
varIndexAssoc := otherInfo at:name ifAbsent:[]. |
2192 |
varIndexAssoc notNil ifTrue:[ |
|
2193 |
self instVarAt:index put:(aPrototype instVarAt:(varIndexAssoc value)) |
|
2194 |
] |
|
5755 | 2195 |
]. |
2196 |
self isVariable ifTrue:[ |
|
10460 | 2197 |
1 to:(self basicSize min:aPrototype basicSize) do:[:index | |
2198 |
self basicAt:index put:(aPrototype basicAt:index) |
|
2199 |
]. |
|
5755 | 2200 |
]. |
2201 |
||
2202 |
" |
|
2203 |
Class withoutUpdatingChangesDo:[ |
|
10460 | 2204 |
Point subclass:#Point3D |
2205 |
instanceVariableNames:'z' |
|
2206 |
classVariableNames:'' |
|
2207 |
poolDictionaries:'' |
|
2208 |
category:'testing'. |
|
2209 |
(Point3D new cloneInstanceVariablesFrom:1@2) inspect. |
|
5755 | 2210 |
] |
2211 |
" |
|
2212 |
||
2213 |
" |
|
2214 |
Class withoutUpdatingChangesDo:[ |
|
10460 | 2215 |
Point variableSubclass:#Point3D |
2216 |
instanceVariableNames:'z' |
|
2217 |
classVariableNames:'' |
|
2218 |
poolDictionaries:'' |
|
2219 |
category:'testing'. |
|
2220 |
((Point3D new:2) cloneInstanceVariablesFrom:#(1 2 3)) inspect. |
|
5755 | 2221 |
] |
2222 |
" |
|
2223 |
||
2224 |
" |
|
2225 |
|someObject| |
|
2226 |
||
2227 |
Class withoutUpdatingChangesDo:[ |
|
10460 | 2228 |
Object subclass:#TestClass1 |
2229 |
instanceVariableNames:'foo bar' |
|
2230 |
classVariableNames:'' |
|
2231 |
poolDictionaries:'' |
|
2232 |
category:'testing'. |
|
2233 |
someObject := TestClass1 new. |
|
2234 |
someObject instVarAt:1 put:'foo'; instVarAt:2 put:'bar'. |
|
2235 |
Object subclass:#TestClass2 |
|
2236 |
instanceVariableNames:'bar foo' |
|
2237 |
classVariableNames:'' |
|
2238 |
poolDictionaries:'' |
|
2239 |
category:'testing'. |
|
2240 |
(TestClass2 new cloneInstanceVariablesFrom:someObject) inspect. |
|
5755 | 2241 |
] |
2242 |
" |
|
2243 |
||
2244 |
" |
|
2245 |
|top b b1| |
|
2246 |
||
2247 |
top := StandardSystemView new. |
|
2248 |
top extent:100@100. |
|
2249 |
||
2250 |
b := Button in:top. |
|
2251 |
b label:'hello'. |
|
2252 |
||
2253 |
b1 := ArrowButton new cloneInstanceVariablesFrom:b. |
|
2254 |
||
2255 |
top open. |
|
2256 |
b1 inspect |
|
2257 |
" |
|
2258 |
! |
|
2259 |
||
2260 |
copy |
|
2261 |
"return a copy of the receiver - defaults to shallowcopy here. |
|
2262 |
Notice, that copy does not copy dependents." |
|
2263 |
||
2264 |
^ self shallowCopy postCopy |
|
2265 |
! |
|
2266 |
||
6146 | 2267 |
copyToLevel:level |
6962
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2268 |
"a controlled deepCopy, where the number of levels can be specified. |
10460 | 2269 |
Notice: |
2270 |
This method DOES NOT handle cycles/self-refs and does NOT preserve object identity; |
|
2271 |
i.e. identical references in the source are copied multiple times into the copy." |
|
6962
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2272 |
|
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2273 |
|newObject class index| |
6146 | 2274 |
|
2275 |
level == 1 ifTrue:[^ self shallowCopy]. |
|
2276 |
||
6962
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2277 |
class := self class. |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2278 |
newObject := self clone. |
6146 | 2279 |
newObject == self ifTrue: [^ self]. |
10460 | 2280 |
class isVariable ifTrue:[ |
2281 |
index := self basicSize. |
|
2282 |
[index > 0] whileTrue:[ |
|
2283 |
newObject basicAt: index put: ((self basicAt: index) copyToLevel:(level-1)). |
|
2284 |
index := index - 1 |
|
2285 |
] |
|
6962
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2286 |
]. |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2287 |
index := class instSize. |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2288 |
[index > 0] whileTrue:[ |
10460 | 2289 |
newObject instVarAt: index put: ((self instVarAt: index) copyToLevel:(level-1)). |
2290 |
index := index - 1 |
|
6962
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2291 |
]. |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2292 |
^ newObject |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2293 |
|
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2294 |
" |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2295 |
|a b| |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2296 |
|
10460 | 2297 |
a := #( |
2298 |
'1.1' |
|
2299 |
'1.2' |
|
2300 |
'1.3' |
|
2301 |
( |
|
2302 |
'1.41' |
|
2303 |
'1.42' |
|
2304 |
'1.43' |
|
2305 |
( |
|
2306 |
'1.441' |
|
2307 |
'1.442' |
|
2308 |
'1.443' |
|
2309 |
( '1.4441' '1.4442' '1.4443' ) |
|
2310 |
'1.445' |
|
2311 |
) |
|
2312 |
'1.45' |
|
2313 |
) |
|
2314 |
'1.5' |
|
2315 |
). |
|
6962
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2316 |
|
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2317 |
b := a copyToLevel:1. |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2318 |
self assert: ( (a at:1) == (b at:1) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2319 |
self assert: ( (a at:4) == (b at:4) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2320 |
|
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2321 |
b := a copyToLevel:2. |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2322 |
self assert: ( (a at:1) ~~ (b at:1) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2323 |
self assert: ( (a at:4) ~~ (b at:4) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2324 |
self assert: ( ((a at:4) at:1) == ((b at:4) at:1) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2325 |
self assert: ( ((a at:4) at:4) == ((b at:4) at:4) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2326 |
|
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2327 |
b := a copyToLevel:3. |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2328 |
self assert: ( (a at:1) ~~ (b at:1) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2329 |
self assert: ( (a at:4) ~~ (b at:4) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2330 |
self assert: ( ((a at:4) at:1) ~~ ((b at:4) at:1) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2331 |
self assert: ( ((a at:4) at:4) ~~ ((b at:4) at:4) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2332 |
self assert: ( (((a at:4) at:4) at:1) == (((b at:4) at:4)at:1) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2333 |
self assert: ( (((a at:4) at:4) at:4) == (((b at:4) at:4)at:4) ). |
eab0d4c42375
copyToLevel: example and comment
Claus Gittinger <cg@exept.de>
parents:
6961
diff
changeset
|
2334 |
" |
6146 | 2335 |
! |
2336 |
||
5755 | 2337 |
deepCopy |
2338 |
"return a copy of the object with all subobjects also copied. |
|
10460 | 2339 |
This method DOES handle cycles/self-refs and preserves object identity; |
5755 | 2340 |
however the receivers class is not copied (to avoid the 'total' copy). |
2341 |
||
2342 |
This deepCopy is a bit slower than the old (unsecure) one, since it |
|
2343 |
keeps track of already copied objects. If you are sure, that your |
|
2344 |
copied object does not include duplicates (or you do not care) and |
|
10460 | 2345 |
no cycles are involved, you can use the old simpleDeepCopy, |
5755 | 2346 |
which avoids this overhead (but may run into trouble). |
2347 |
Notice, that deepCopy does not copy dependents." |
|
2348 |
||
8383 | 2349 |
^ self deepCopyUsing:(IdentityDictionary new) |
5755 | 2350 |
|
2351 |
"an example which is not handled by the old deepCopy: |
|
10460 | 2352 |
|
5755 | 2353 |
|a| |
2354 |
a := Array new:3. |
|
2355 |
a at:3 put:a. |
|
2356 |
a deepCopy inspect |
|
2357 |
" |
|
2358 |
||
2359 |
" |
|
2360 |
|a| |
|
2361 |
a := Color black onDevice:Screen current. |
|
2362 |
a deepCopy inspect |
|
2363 |
" |
|
2364 |
||
2365 |
"Modified: 27.3.1996 / 16:31:20 / stefan" |
|
2366 |
! |
|
2367 |
||
2368 |
deepCopyError |
|
2369 |
"{ Pragma: +optSpace }" |
|
2370 |
||
2371 |
"raise a signal, that deepCopy is not allowed for this object" |
|
2372 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
2373 |
^ DeepCopyError raise |
5755 | 2374 |
! |
2375 |
||
2376 |
deepCopyUsing:aDictionary |
|
10460 | 2377 |
"a helper for deepCopy; return a copy of the object with |
2378 |
all subobjects also copied. If the to-be-copied object is in the dictionary, |
|
5755 | 2379 |
use the value found there. The class of the receiver is not copied. |
2380 |
This method DOES handle cycles/self references." |
|
2381 |
||
10941 | 2382 |
^ self deepCopyUsing:aDictionary postCopySelector:#postDeepCopyFrom:. |
2383 |
||
5755 | 2384 |
|
2385 |
" |
|
2386 |
|a b c copyOfC| |
|
2387 |
||
2388 |
a := Array with:'hello' with:'world' with:nil. |
|
2389 |
b := 99 @ 999. |
|
2390 |
a at:3 put:b. |
|
2391 |
c := Array with:a with:b with:a. |
|
2392 |
||
2393 |
Transcript showCR: (c at:1) == (c at:3). |
|
2394 |
copyOfC := c deepCopy. |
|
2395 |
Transcript showCR: (copyOfC at:1) == (copyOfC at:3) |
|
2396 |
" |
|
2397 |
! |
|
2398 |
||
10954 | 2399 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
2400 |
"a helper for deepCopy; return a copy of the object with |
|
2401 |
all subobjects also copied. If the to-be-copied object is in the dictionary, |
|
2402 |
use the value found there. The class of the receiver is not copied. |
|
2403 |
This method DOES handle cycles/self references." |
|
2404 |
||
2405 |
|myClass aCopy |
|
2406 |
sz "{ Class: SmallInteger }" |
|
2407 |
iOrig iCopy| |
|
2408 |
||
2409 |
myClass := self class. |
|
2410 |
"/ (myClass whichClassImplements:#deepCopyUsing:) ~~ Object ifTrue:[ |
|
2411 |
"/ ^ self deepCopyUsing:aDictionary. |
|
2412 |
"/ ]. |
|
2413 |
||
2414 |
myClass isVariable ifTrue:[ |
|
2415 |
sz := self basicSize. |
|
2416 |
aCopy := myClass basicNew:sz. |
|
2417 |
] ifFalse:[ |
|
2418 |
sz := 0. |
|
2419 |
aCopy := myClass basicNew |
|
2420 |
]. |
|
2421 |
aCopy setHashFrom:self. |
|
2422 |
aDictionary at:self put:aCopy. |
|
2423 |
||
2424 |
" |
|
2425 |
copy indexed instvars - if any |
|
2426 |
" |
|
2427 |
sz ~~ 0 ifTrue:[ |
|
2428 |
myClass isBits ifTrue:[ |
|
2429 |
"block-copy indexed instvars" |
|
2430 |
aCopy replaceFrom:1 to:sz with:self startingAt:1 |
|
2431 |
] ifFalse:[ |
|
2432 |
"individual deep copy the indexed variables" |
|
2433 |
1 to:sz do:[:i | |
|
2434 |
iOrig := self basicAt:i. |
|
2435 |
iOrig notNil ifTrue:[ |
|
2436 |
"/ used to be dict-includesKey-ifTrue[dict-at:], |
|
2437 |
"/ changed to use dict-at:ifAbsent:, to avoid double lookup in dictionary |
|
2438 |
iCopy := aDictionary at:iOrig ifAbsent:nil. |
|
2439 |
iCopy isNil ifTrue:[ |
|
2440 |
iCopy := iOrig deepCopyUsing:aDictionary postCopySelector:postCopySelector |
|
2441 |
]. |
|
2442 |
aCopy basicAt:i put:iCopy |
|
2443 |
] |
|
2444 |
] |
|
2445 |
] |
|
2446 |
]. |
|
2447 |
||
2448 |
" |
|
2449 |
copy the instance variables |
|
2450 |
" |
|
2451 |
sz := myClass instSize. |
|
2452 |
1 to:sz do:[:i | |
|
2453 |
(self skipInstvarIndexInDeepCopy:i) ifFalse:[ |
|
2454 |
iOrig := self instVarAt:i. |
|
2455 |
iOrig notNil ifTrue:[ |
|
2456 |
iCopy := aDictionary at:iOrig ifAbsent:nil. |
|
2457 |
iCopy isNil ifTrue:[ |
|
2458 |
iCopy := iOrig deepCopyUsing:aDictionary postCopySelector:postCopySelector |
|
2459 |
]. |
|
2460 |
aCopy instVarAt:i put:iCopy |
|
2461 |
] |
|
2462 |
] |
|
2463 |
]. |
|
2464 |
aCopy perform:postCopySelector with:self "ifNotUnderstood:[]". |
|
2465 |
^ aCopy |
|
2466 |
! |
|
2467 |
||
5755 | 2468 |
postCopy |
2469 |
"this is for compatibility with ST-80 code, which uses postCopy for |
|
2470 |
cleanup after copying, while ST/X passes the original in postCopyFrom: |
|
2471 |
(see there)" |
|
2472 |
||
2473 |
^ self |
|
2474 |
! |
|
2475 |
||
2476 |
postDeepCopy |
|
8930
edd42af66c0a
deepCopy should not invoke postCopy
Claus Gittinger <cg@exept.de>
parents:
8913
diff
changeset
|
2477 |
"allows for cleanup after deep copying. |
edd42af66c0a
deepCopy should not invoke postCopy
Claus Gittinger <cg@exept.de>
parents:
8913
diff
changeset
|
2478 |
To be redefined in subclasses." |
5755 | 2479 |
! |
2480 |
||
2481 |
postDeepCopyFrom:aSource |
|
2482 |
"allows for cleanup after deep copying" |
|
2483 |
||
2484 |
^ self postDeepCopy |
|
2485 |
! |
|
2486 |
||
2487 |
setHashFrom:anObject |
|
10460 | 2488 |
"set my identity-hash key to be the same as anObjects hash key. |
2489 |
This is an ST/X speciality, which is NOT available in other (especially OT based) |
|
5755 | 2490 |
Smalltalks, and may not be available in future ST/X versions. |
2491 |
DO NEVER use this for normal application code." |
|
2492 |
||
2493 |
%{ /* NOCONTEXT */ |
|
2494 |
||
2495 |
REGISTER unsigned h; |
|
2496 |
||
2497 |
if (__isNonNilObject(self) && __isNonNilObject(anObject)) { |
|
10460 | 2498 |
h = __GET_HASH(anObject); |
2499 |
__SET_HASH(self, h); |
|
2500 |
RETURN (self); |
|
5755 | 2501 |
} |
2502 |
%}. |
|
2503 |
self primitiveFailed "neither receiver not arg may be nil or SmallInteger" |
|
2504 |
! |
|
2505 |
||
2506 |
shallowCopy |
|
2507 |
"return a copy of the object with shared subobjects (a shallow copy) |
|
2508 |
i.e. the copy shares referenced instvars with its original." |
|
2509 |
||
2510 |
%{ /* NOCONTEXT */ |
|
2511 |
int ninsts, spc; |
|
2512 |
int sz; |
|
2513 |
OBJ theCopy; |
|
2514 |
OBJ cls; |
|
2515 |
int flags; |
|
2516 |
||
2517 |
cls = __qClass(self); |
|
2518 |
flags = __intVal(__ClassInstPtr(cls)->c_flags); |
|
2519 |
||
2520 |
/* |
|
2521 |
* bail out for special objects .. |
|
2522 |
*/ |
|
2523 |
if (((flags & ~ARRAYMASK) == 0) |
|
2524 |
&& ((flags & ARRAYMASK) != WKPOINTERARRAY)) { |
|
10460 | 2525 |
sz = __qSize(self); |
2526 |
__PROTECT__(self); |
|
2527 |
__qNew(theCopy, sz); /* OBJECT ALLOCATION */ |
|
2528 |
__UNPROTECT__(self); |
|
2529 |
if (theCopy) { |
|
2530 |
cls = __qClass(self); |
|
2531 |
spc = __qSpace(theCopy); |
|
2532 |
||
2533 |
theCopy->o_class = cls; __STORE_SPC(theCopy, cls, spc); |
|
2534 |
||
2535 |
sz = sz - OHDR_SIZE; |
|
2536 |
if (sz) { |
|
2537 |
char *src, *dst; |
|
2538 |
||
2539 |
src = (char *)(__InstPtr(self)->i_instvars); |
|
2540 |
dst = (char *)(__InstPtr(theCopy)->i_instvars); |
|
5755 | 2541 |
#ifdef bcopy4 |
10460 | 2542 |
{ |
2543 |
/* care for odd-number of longs */ |
|
2544 |
int nW = sz >> 2; |
|
2545 |
||
2546 |
if (sz & 3) { |
|
2547 |
nW++; |
|
2548 |
} |
|
2549 |
||
2550 |
bcopy4(src, dst, nW); |
|
2551 |
} |
|
5755 | 2552 |
#else |
10460 | 2553 |
bcopy(src, dst, sz); |
5755 | 2554 |
#endif |
2555 |
||
10460 | 2556 |
flags &= ARRAYMASK; |
2557 |
if (flags == POINTERARRAY) { |
|
2558 |
ninsts = __BYTES2OBJS__(sz); |
|
2559 |
} else { |
|
2560 |
ninsts = __intVal(__ClassInstPtr(cls)->c_ninstvars); |
|
2561 |
} |
|
2562 |
if (ninsts) { |
|
2563 |
do { |
|
2564 |
OBJ el; |
|
2565 |
||
2566 |
el = __InstPtr(theCopy)->i_instvars[ninsts-1]; |
|
2567 |
__STORE_SPC(theCopy, el, spc); |
|
2568 |
} while (--ninsts); |
|
2569 |
} |
|
2570 |
} |
|
2571 |
RETURN (theCopy); |
|
2572 |
} |
|
5755 | 2573 |
} |
2574 |
%}. |
|
2575 |
"/ fallBack for special objects & memoryAllocation failure case |
|
2576 |
||
2577 |
^ self slowShallowCopy |
|
2578 |
! |
|
2579 |
||
2580 |
simpleDeepCopy |
|
2581 |
"return a copy of the object with all subobjects also copied. |
|
10460 | 2582 |
This method does NOT handle cycles - but is included to allow this |
5755 | 2583 |
slightly faster copy in situations where it is known that |
2584 |
no recursive references occur (LargeIntegers for example). |
|
2585 |
NOTICE: you will run into trouble, when trying this with recursive |
|
2586 |
objects (usually recursionInterrupt or memory-alert). |
|
8383 | 2587 |
This method corresponds to the 'traditional' deepCopy found in the Blue book." |
5755 | 2588 |
|
2589 |
|myClass aCopy| |
|
2590 |
||
2591 |
(myClass := self class) isVariable ifTrue:[ |
|
10460 | 2592 |
aCopy := myClass basicNew:(self basicSize). |
5755 | 2593 |
] ifFalse:[ |
10460 | 2594 |
aCopy := myClass basicNew |
5755 | 2595 |
]. |
2596 |
||
2597 |
"copy the instance variables" |
|
2598 |
aCopy cloneFrom:self performing:#simpleDeepCopy. |
|
2599 |
^ aCopy |
|
2600 |
||
2601 |
"a bad example (but ST/X should survive ...)" |
|
2602 |
" |
|
2603 |
|a| |
|
2604 |
a := Array new:3. |
|
2605 |
a at:3 put:a. |
|
2606 |
a simpleDeepCopy |
|
2607 |
" |
|
2608 |
! |
|
2609 |
||
2610 |
skipInstvarIndexInDeepCopy:index |
|
2611 |
"a helper for deepCopy; only indices for which this method returns |
|
2612 |
false are copied in a deep copy. |
|
2613 |
The default is false here - which means that everything is copied. |
|
2614 |
Can be redefined in subclasses for partial copies" |
|
2615 |
||
2616 |
^ false |
|
2617 |
! |
|
2618 |
||
2619 |
slowShallowCopy |
|
2620 |
"return a copy of the object with shared subobjects (a shallow copy) |
|
2621 |
i.e. the copy shares referenced instvars with its original. |
|
2622 |
This method is only invoked as a fallback from #shallowCopy." |
|
2623 |
||
2624 |
|myClass aCopy| |
|
2625 |
||
2626 |
(myClass := self class) isVariable ifTrue:[ |
|
10460 | 2627 |
aCopy := myClass basicNew:(self basicSize). |
5755 | 2628 |
] ifFalse:[ |
10460 | 2629 |
aCopy := myClass basicNew |
5755 | 2630 |
]. |
2631 |
||
2632 |
"copy the instance variables" |
|
2633 |
aCopy cloneFrom:self performing:#yourself. |
|
2634 |
^ aCopy |
|
2635 |
! ! |
|
2636 |
||
2637 |
!Object methodsFor:'debugging'! |
|
2638 |
||
7621 | 2639 |
assert:aBooleanOrBlock |
11044
fa13d9423e71
allow for encounteredBreakPoints to be monitored
Claus Gittinger <cg@exept.de>
parents:
11025
diff
changeset
|
2640 |
"fail, if the argument does not evaluate to true and report an error" |
6964 | 2641 |
|
11021 | 2642 |
<resource: #skipInDebuggersWalkBack> |
2643 |
||
8876 | 2644 |
aBooleanOrBlock == true ifTrue:[^ self]. |
11141
b96ed3ac5825
assertions can be globally disabled
Claus Gittinger <cg@exept.de>
parents:
11132
diff
changeset
|
2645 |
(Smalltalk at:#IgnoreAssertion ifAbsent:false) == true ifTrue:[^ self]. |
11044
fa13d9423e71
allow for encounteredBreakPoints to be monitored
Claus Gittinger <cg@exept.de>
parents:
11025
diff
changeset
|
2646 |
|
8876 | 2647 |
"/ could still be a block or false. |
10460 | 2648 |
self |
11021 | 2649 |
assert:aBooleanOrBlock |
2650 |
message:('Assertion failed in ' , thisContext sender printString) |
|
7621 | 2651 |
! |
2652 |
||
2653 |
assert:aBooleanOrBlock message:messageIfFailing |
|
11044
fa13d9423e71
allow for encounteredBreakPoints to be monitored
Claus Gittinger <cg@exept.de>
parents:
11025
diff
changeset
|
2654 |
"fail, if the argument does not evaluate to true and report an error" |
6961 | 2655 |
|
2656 |
"{ Pragma: +optSpace }" |
|
2657 |
||
11021 | 2658 |
<resource: #skipInDebuggersWalkBack> |
2659 |
||
11141
b96ed3ac5825
assertions can be globally disabled
Claus Gittinger <cg@exept.de>
parents:
11132
diff
changeset
|
2660 |
aBooleanOrBlock == true ifTrue:[^ self]. |
b96ed3ac5825
assertions can be globally disabled
Claus Gittinger <cg@exept.de>
parents:
11132
diff
changeset
|
2661 |
(Smalltalk at:#IgnoreAssertion ifAbsent:false) == true ifTrue:[^ self]. |
b96ed3ac5825
assertions can be globally disabled
Claus Gittinger <cg@exept.de>
parents:
11132
diff
changeset
|
2662 |
|
7621 | 2663 |
(aBooleanOrBlock value) ifFalse:[ |
10651 | 2664 |
AssertionFailedError raiseRequestWith:self errorString:messageIfFailing |
2665 |
]. |
|
2666 |
||
2667 |
" |
|
2668 |
self assert:false |
|
2669 |
" |
|
6961 | 2670 |
! |
2671 |
||
5755 | 2672 |
basicInspect |
2673 |
"{ Pragma: +optSpace }" |
|
2674 |
||
2675 |
"launch an inspector on the receiver. |
|
2676 |
this method should NOT be redefined in subclasses." |
|
2677 |
||
2678 |
Inspector isNil ifTrue:[ |
|
10460 | 2679 |
" |
2680 |
for systems without GUI |
|
2681 |
" |
|
2682 |
self warn:'No Inspector defined (Inspector is nil).' |
|
5755 | 2683 |
] ifFalse:[ |
10460 | 2684 |
Inspector openOn:self |
5755 | 2685 |
] |
2686 |
||
2687 |
"Modified: 18.5.1996 / 15:43:25 / cg" |
|
2688 |
! |
|
2689 |
||
11025 | 2690 |
breakPoint:someKey |
6954 | 2691 |
"{ Pragma: +optSpace }" |
2692 |
||
2693 |
"Like halt, but disabled by default. |
|
2694 |
Can be easily enabled. |
|
2695 |
Can be filtered on the arguments value (typically: a symbol). |
|
2696 |
Code with breakpoints may be even checked into the source repository" |
|
2697 |
||
2698 |
"Example: nil breakPoint:#stefan" |
|
2699 |
||
11025 | 2700 |
<resource: #skipInDebuggersWalkBack> |
2701 |
||
11048 | 2702 |
"/ dont send #breakPoint:info: here - ask cg why. |
2703 |
(self isBreakPointEnabled:someKey) ifTrue:[ |
|
2704 |
^ HaltSignal |
|
2705 |
raiseRequestWith:someKey |
|
2706 |
errorString:('Breakpoint encountered: %1' bindWith:someKey) |
|
2707 |
]. |
|
11025 | 2708 |
|
2709 |
" |
|
2710 |
nil breakPoint:#stefan |
|
2711 |
nil breakPoint:#stefan info:'Hello' |
|
2712 |
Smalltalk enableBreakPoint:#stefan. |
|
2713 |
Smalltalk disableBreakPoint:#stefan. |
|
11048 | 2714 |
|
2715 |
EncounteredBreakPoints. |
|
2716 |
Smalltalk enableBreakPoint:#cg. |
|
2717 |
Smalltalk disableBreakPoint:#cg. |
|
11025 | 2718 |
" |
2719 |
! |
|
2720 |
||
2721 |
breakPoint:someKey info:infoString |
|
2722 |
"{ Pragma: +optSpace }" |
|
2723 |
||
2724 |
"Like halt, but disabled by default. |
|
2725 |
Can be easily enabled. |
|
2726 |
Can be filtered on the arguments value (typically: a symbol). |
|
2727 |
Code with breakpoints may be even checked into the source repository" |
|
2728 |
||
2729 |
"Example: nil breakPoint:#stefan" |
|
2730 |
||
2731 |
<resource: #skipInDebuggersWalkBack> |
|
2732 |
||
2733 |
(self isBreakPointEnabled:someKey) ifTrue:[ |
|
2734 |
^ HaltSignal |
|
2735 |
raiseRequestWith:someKey |
|
2736 |
errorString:(infoString bindWith:someKey) |
|
2737 |
]. |
|
6954 | 2738 |
! |
2739 |
||
5995 | 2740 |
browse |
2741 |
"open a browser on the receivers class" |
|
2742 |
||
2743 |
self class theNonMetaclass browse |
|
2744 |
||
2745 |
" |
|
2746 |
10 browse |
|
2747 |
Collection browse |
|
2748 |
Collection class browse |
|
2749 |
" |
|
2750 |
! |
|
2751 |
||
11025 | 2752 |
disableBreakPoint:someKey |
2753 |
"disable a breakPoint" |
|
2754 |
||
2755 |
"{ Pragma: +optSpace }" |
|
2756 |
||
2757 |
EnabledBreakPoints notNil ifTrue:[ |
|
11142
4be78ca76701
changed #disableBreakPoint:
Claus Gittinger <cg@exept.de>
parents:
11141
diff
changeset
|
2758 |
EnabledBreakPoints remove:someKey ifAbsent:[]. |
11025 | 2759 |
EnabledBreakPoints isEmpty ifTrue:[ |
2760 |
EnabledBreakPoints := nil |
|
2761 |
]. |
|
2762 |
]. |
|
2763 |
||
2764 |
" |
|
2765 |
nil enableBreakPoint:#cg. |
|
2766 |
nil breakPoint:#cg. |
|
2767 |
nil disableBreakPoint:#cg |
|
2768 |
nil breakPoint:#cg. |
|
2769 |
" |
|
2770 |
! |
|
2771 |
||
2772 |
enableBreakPoint:someKey |
|
2773 |
"enable a breakPoint" |
|
2774 |
||
2775 |
"{ Pragma: +optSpace }" |
|
2776 |
||
2777 |
EnabledBreakPoints isNil ifTrue:[ |
|
2778 |
EnabledBreakPoints := Set new. |
|
2779 |
]. |
|
2780 |
EnabledBreakPoints add:someKey. |
|
2781 |
||
2782 |
" |
|
2783 |
nil enableBreakPoint:#cg. |
|
2784 |
nil breakPoint:#cg. |
|
2785 |
nil disableBreakPoint:#cg |
|
2786 |
nil breakPoint:#cg. |
|
2787 |
" |
|
2788 |
! |
|
2789 |
||
11048 | 2790 |
halt |
2791 |
"{ Pragma: +optSpace }" |
|
2792 |
||
2793 |
"enter debugger with halt-message. |
|
2794 |
The error is reported by raising the HaltSignal exception." |
|
2795 |
||
2796 |
<resource: #skipInDebuggersWalkBack> |
|
2797 |
||
2798 |
"/ dont send #halt: here - ask cg why. |
|
2799 |
(Smalltalk at:#IgnoreHalt ifAbsent:false) == true ifTrue:[^ self]. |
|
2800 |
^ HaltInterrupt raiseRequestWith:#halt |
|
2801 |
||
2802 |
"Modified: / 2.8.1999 / 17:00:29 / stefan" |
|
2803 |
"Modified: / 17.11.2001 / 22:47:44 / cg" |
|
2804 |
! |
|
2805 |
||
2806 |
halt:aString |
|
2807 |
"{ Pragma: +optSpace }" |
|
2808 |
||
2809 |
"enter debugger with halt-message. |
|
2810 |
The error is reported by raising the HaltSignal exception." |
|
2811 |
||
2812 |
<resource: #skipInDebuggersWalkBack> |
|
2813 |
||
2814 |
(Smalltalk at:#IgnoreHalt ifAbsent:false) == true ifTrue:[^ self]. |
|
2815 |
^ HaltInterrupt raiseRequestWith:#halt: errorString:aString |
|
2816 |
||
2817 |
"Modified: 8.5.1996 / 09:13:23 / cg" |
|
2818 |
! |
|
2819 |
||
5755 | 2820 |
inspect |
2821 |
"{ Pragma: +optSpace }" |
|
2822 |
||
2823 |
"launch an inspector on the receiver. |
|
10460 | 2824 |
this method (or better: inspectorClass) can be redefined in subclasses |
5755 | 2825 |
to start special inspectors." |
2826 |
||
2827 |
|cls| |
|
2828 |
||
2829 |
cls := self inspectorClass. |
|
2830 |
cls isNil ifTrue:[ |
|
10460 | 2831 |
^ self basicInspect |
5755 | 2832 |
]. |
2833 |
cls openOn:self |
|
2834 |
||
2835 |
" |
|
2836 |
Object new inspect |
|
2837 |
(1 @ 2) inspect |
|
2838 |
Smalltalk inspect |
|
2839 |
#(1 2 3) asOrderedCollection inspect |
|
2840 |
(Color red) inspect |
|
2841 |
(Image fromFile:'bitmaps/garfield.gif') inspect |
|
2842 |
" |
|
2843 |
! |
|
2844 |
||
2845 |
inspectorClass |
|
2846 |
"{ Pragma: +optSpace }" |
|
2847 |
||
10460 | 2848 |
"return the class to use for inspect. |
5755 | 2849 |
Can (should) be redefined in classes for which a better inspector is available" |
2850 |
||
2851 |
^ Inspector |
|
2852 |
! |
|
2853 |
||
11025 | 2854 |
isBreakPointEnabled:someKey |
2855 |
"{ Pragma: +optSpace }" |
|
2856 |
||
2857 |
"controls which breakpoints to be enabled." |
|
2858 |
||
2859 |
"/ something = OperatingSystem getLoginName ifTrue:[^ true]. |
|
2860 |
"/ something = 'testThis' ifTrue:[^ true]. |
|
11044
fa13d9423e71
allow for encounteredBreakPoints to be monitored
Claus Gittinger <cg@exept.de>
parents:
11025
diff
changeset
|
2861 |
EncounteredBreakPoints notNil ifTrue:[ |
fa13d9423e71
allow for encounteredBreakPoints to be monitored
Claus Gittinger <cg@exept.de>
parents:
11025
diff
changeset
|
2862 |
EncounteredBreakPoints add:someKey |
fa13d9423e71
allow for encounteredBreakPoints to be monitored
Claus Gittinger <cg@exept.de>
parents:
11025
diff
changeset
|
2863 |
]. |
fa13d9423e71
allow for encounteredBreakPoints to be monitored
Claus Gittinger <cg@exept.de>
parents:
11025
diff
changeset
|
2864 |
|
fa13d9423e71
allow for encounteredBreakPoints to be monitored
Claus Gittinger <cg@exept.de>
parents:
11025
diff
changeset
|
2865 |
^ (EnabledBreakPoints notNil and:[ EnabledBreakPoints includes:someKey ]) |
11025 | 2866 |
|
2867 |
" |
|
2868 |
nil enableBreakPoint:#cg. |
|
2869 |
nil breakPoint:#cg. |
|
2870 |
nil disableBreakPoint:#cg |
|
2871 |
nil breakPoint:#cg. |
|
11045
85315d8893e4
allow for encounteredBreakPoints to be monitored
Claus Gittinger <cg@exept.de>
parents:
11044
diff
changeset
|
2872 |
|
85315d8893e4
allow for encounteredBreakPoints to be monitored
Claus Gittinger <cg@exept.de>
parents:
11044
diff
changeset
|
2873 |
EncounteredBreakPoints := Set new. |
11025 | 2874 |
" |
2875 |
! |
|
2876 |
||
5755 | 2877 |
mustBeBoolean |
2878 |
"this message is sent by the VM, if a non-Boolean receiver is encountered |
|
2879 |
in an if* or while* message. |
|
2880 |
Caveat: for now, this is only sent by the interpreter; |
|
2881 |
both the JIT and the stc compiler treat it as undefined." |
|
2882 |
||
11021 | 2883 |
<resource: #skipInDebuggersWalkBack> |
2884 |
||
5755 | 2885 |
self error:'Non boolean receiver - proceed for truth' mayProceed:true. |
2886 |
^ true |
|
2887 |
! |
|
2888 |
||
2889 |
mustBeKindOf:aClass |
|
10460 | 2890 |
"for compatibility & debugging support: |
5755 | 2891 |
check if the receiver isKindOf:aClass and raise an error if not. |
2892 |
Notice: |
|
11021 | 2893 |
it is VERY questionable, if it makes sense to add manual |
2894 |
type checks to a dynamically typed language like smalltalk. |
|
2895 |
It will, at least, slow down performance, |
|
2896 |
make your code less reusable and clutter your code with stupid sends |
|
2897 |
of this selector. Also, read the comment in isKindOf:, regarding the |
|
2898 |
use of isXXX check methods. |
|
5755 | 2899 |
You see: The author does not like this at all ..." |
2900 |
||
11021 | 2901 |
<resource: #skipInDebuggersWalkBack> |
2902 |
||
5755 | 2903 |
(self isKindOf:aClass) ifFalse:[ |
11021 | 2904 |
self error:'argument is not of expected type' |
5755 | 2905 |
] |
2906 |
! |
|
2907 |
||
6950 | 2908 |
obsoleteFeatureWarning |
2909 |
"{ Pragma: +optSpace }" |
|
2910 |
||
2911 |
"in methods which are going to be changed, a send to |
|
2912 |
this method is used to tell programmers that some feature/semantics is |
|
2913 |
used which is going to be changed in later ST/X versions. |
|
6963 | 2914 |
Hopefully, this warning message is annoying enough for you to change the code... ;-)." |
6950 | 2915 |
|
2916 |
self obsoleteFeatureWarning:nil from:thisContext sender |
|
2917 |
! |
|
2918 |
||
2919 |
obsoleteFeatureWarning:message |
|
2920 |
"{ Pragma: +optSpace }" |
|
2921 |
||
2922 |
"in methods which are going to be changed, a send to |
|
2923 |
this method is used to tell programmers that some feature/semantics is |
|
2924 |
used which is going to be changed in later ST/X versions. |
|
6963 | 2925 |
Hopefully, this warning message is annoying enough for you to change the code... ;-). |
2926 |
This message is intended for application developers, so its printed as info message." |
|
6950 | 2927 |
|
2928 |
self obsoleteFeatureWarning:message from:thisContext sender |
|
2929 |
! |
|
2930 |
||
2931 |
obsoleteFeatureWarning:message from:aContext |
|
2932 |
"{ Pragma: +optSpace }" |
|
2933 |
||
2934 |
"in methods which are going to be changed, a send to |
|
2935 |
this method is used to tell programmers that some feature/semantics is |
|
2936 |
used which is going to be changed in later ST/X versions. |
|
6963 | 2937 |
Hopefully, this warning message is annoying enough for you to change the code... ;-). |
2938 |
This message is intended for application developers, so its printed as info message." |
|
6950 | 2939 |
|
2940 |
|spec| |
|
2941 |
||
2942 |
spec := aContext methodPrintString. |
|
2943 |
('WARNING: the ''' , spec , ''' semantics will be changed.') infoPrintCR. |
|
2944 |
(' Its behavior may be different in future ST/X versions.') infoPrintCR. |
|
2945 |
(' called from ' , aContext sender printString) infoPrintCR. |
|
7204 | 2946 |
(aContext sender selector startsWith:'perform:') ifTrue:[ |
2947 |
(' called from ' , aContext sender sender printString) infoPrintCR. |
|
2948 |
]. |
|
6950 | 2949 |
message notNil ifTrue:[ |
10460 | 2950 |
'------> ' infoPrint. message infoPrintCR |
6950 | 2951 |
] |
2952 |
||
2953 |
" |
|
2954 |
Object obsoleteFeatureWarning:'foo' from:thisContext sender sender |
|
2955 |
" |
|
2956 |
! |
|
2957 |
||
5755 | 2958 |
obsoleteMethodWarning |
2959 |
"{ Pragma: +optSpace }" |
|
2960 |
||
2961 |
"in methods which are going to be obsoleted, a self send to |
|
2962 |
this method is used to tell programmers that a method is |
|
2963 |
used which is going to be removed in later ST/X versions. |
|
6963 | 2964 |
Find all methods which will be obsolete soon by looking at senders of this message. |
2965 |
Hopefully, this warning message is annoying enough for you to change the code... ;-)" |
|
5755 | 2966 |
|
2967 |
self obsoleteMethodWarning:nil from:thisContext sender |
|
2968 |
! |
|
2969 |
||
2970 |
obsoleteMethodWarning:message |
|
2971 |
"{ Pragma: +optSpace }" |
|
2972 |
||
2973 |
"in methods which are going to be obsoleted, a self send to |
|
2974 |
this method is used to tell programmers that a method is |
|
2975 |
used which is going to be removed in later ST/X versions. |
|
6963 | 2976 |
Find all methods which will be obsolete soon by looking at senders of this message. |
2977 |
Hopefully, this warning message is annoying enough for you to change the code... ;-)" |
|
5755 | 2978 |
|
2979 |
self obsoleteMethodWarning:message from:thisContext sender |
|
8829
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2980 |
! |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2981 |
|
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2982 |
obsoleteMethodWarning:message from:aContext |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2983 |
"{ Pragma: +optSpace }" |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2984 |
|
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2985 |
"in methods which are going to be obsoleted, a self-send to |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2986 |
this method is used to tell programmers that a method is |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2987 |
used which is going to be removed in later ST/X versions. |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2988 |
Find all methods which will be obsolete soon by looking at senders of this message. |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2989 |
Hopefully, this warning message is annoying enough for you to change the code... ;-). |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2990 |
This message is intended for application developers, so its printed as info message." |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2991 |
|
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2992 |
|spec sender| |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2993 |
|
9509 | 2994 |
Smalltalk isSmalltalkDevelopmentSystem ifFalse:[ |
10460 | 2995 |
"ignore in production systems" |
2996 |
^ self. |
|
8829
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2997 |
]. |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2998 |
|
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
2999 |
spec := aContext methodPrintString. |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3000 |
sender := aContext sender. |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3001 |
('WARNING: the ''' , spec , ''' method is obsolete.') infoPrintCR. |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3002 |
(' And may not be present in future ST/X versions.') infoPrintCR. |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3003 |
(' called from ' , sender printString) infoPrintCR. |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3004 |
(sender selector startsWith:'perform:') ifTrue:[ |
10460 | 3005 |
sender := sender sender. |
3006 |
(sender selector startsWith:'perform:') ifTrue:[ |
|
3007 |
sender := sender sender. |
|
3008 |
]. |
|
3009 |
(' called from ' , sender printString) infoPrintCR. |
|
8829
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3010 |
]. |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3011 |
message notNil ifTrue:[ |
10460 | 3012 |
'------> ' infoPrint. message infoPrintCR |
8829
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3013 |
] |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3014 |
|
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3015 |
" |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3016 |
Object obsoleteMethodWarning:'foo' from:thisContext sender sender |
9e640b6c0679
No obsolete messages in standalone apps
Stefan Vogel <sv@exept.de>
parents:
8827
diff
changeset
|
3017 |
" |
9509 | 3018 |
|
3019 |
"Modified: / 10-08-2006 / 13:13:11 / cg" |
|
10558 | 3020 |
! |
3021 |
||
3022 |
todo:aBlock |
|
3023 |
"used to mark code pieces that have to be implemented" |
|
3024 |
||
3025 |
"/ self halt. |
|
3026 |
"/ aBlock value. |
|
3027 |
||
3028 |
" |
|
3029 |
example: |
|
3030 |
||
3031 |
... |
|
3032 |
self todo:[ |
|
3033 |
code which needs more work ... |
|
3034 |
]. |
|
3035 |
... |
|
3036 |
" |
|
3037 |
||
3038 |
"Created: / 25-05-2007 / 21:34:39 / cg" |
|
3039 |
"Modified: / 29-05-2007 / 12:11:33 / cg" |
|
5755 | 3040 |
! ! |
3041 |
||
3042 |
!Object methodsFor:'dependents access'! |
|
3043 |
||
3044 |
addDependent:anObject |
|
3045 |
"make the argument, anObject be a dependent of the receiver" |
|
3046 |
||
3047 |
|wasBlocked| |
|
3048 |
||
3049 |
"/ must do this save from interrupts, since the dependents collection |
|
3050 |
"/ is possibly accessed from multiple threads. |
|
3051 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
|
3052 |
"/ faster execution. |
|
3053 |
||
3054 |
wasBlocked := OperatingSystem blockInterrupts. |
|
3055 |
[ |
|
10460 | 3056 |
|deps dep| |
3057 |
||
3058 |
deps := self dependents. |
|
3059 |
||
3060 |
"/ to save a fair amount of memory in case of |
|
3061 |
"/ many dependencies, we store a single dependent in |
|
3062 |
"/ a WeakArray, and switch to a WeakSet if more dependents are |
|
3063 |
"/ added. |
|
3064 |
||
3065 |
(deps isNil or:[deps size == 0]) ifTrue:[ |
|
3066 |
self dependents:(WeakArray with:anObject) |
|
3067 |
] ifFalse:[ |
|
3068 |
deps class == WeakArray ifTrue:[ |
|
3069 |
dep := deps at:1. |
|
3070 |
dep ~~ anObject ifTrue:[ |
|
3071 |
(dep isNil or:[dep == 0]) ifTrue:[ |
|
3072 |
deps at:1 put:anObject |
|
3073 |
] ifFalse:[ |
|
3074 |
self dependents:(WeakIdentitySet with:dep with:anObject) |
|
3075 |
] |
|
3076 |
] |
|
3077 |
] ifFalse:[ |
|
3078 |
deps add:anObject |
|
3079 |
] |
|
3080 |
] |
|
6421
58dca33cf0fc
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
6418
diff
changeset
|
3081 |
] ensure:[ |
10460 | 3082 |
wasBlocked ifFalse:[ |
3083 |
OperatingSystem unblockInterrupts |
|
3084 |
] |
|
5755 | 3085 |
] |
3086 |
||
3087 |
"Modified: / 27.10.1997 / 19:35:52 / cg" |
|
3088 |
! |
|
3089 |
||
3090 |
breakDependents |
|
3091 |
"remove all dependencies from the receiver" |
|
3092 |
||
3093 |
self dependents:nil. |
|
3094 |
self nonWeakDependents:nil |
|
3095 |
||
3096 |
"Modified: / 19.4.1996 / 10:55:36 / cg" |
|
3097 |
"Created: / 27.2.1998 / 11:26:11 / stefan" |
|
3098 |
! |
|
3099 |
||
8542 | 3100 |
breakDependentsRecursively |
10460 | 3101 |
"remove all dependencies from the receiver and |
8542 | 3102 |
recursively from all objects referred to by the receiver." |
3103 |
||
3104 |
self breakDependents. |
|
10460 | 3105 |
1 to:self class instSize do:[:idx | |
3106 |
(self instVarAt:idx) breakDependentsRecursively. |
|
3107 |
]. |
|
3108 |
1 to:self basicSize do:[:idx | |
|
3109 |
(self basicAt:idx) breakDependentsRecursively. |
|
8542 | 3110 |
] |
3111 |
! |
|
3112 |
||
5755 | 3113 |
dependents |
3114 |
"return a Collection of dependents. |
|
3115 |
The default implementation here uses a global WeakDictionary to store |
|
10460 | 3116 |
dependents |
5755 | 3117 |
This may be too slow for high frequency change&update, |
3118 |
therefore, some classes (Model) redefine this for better performance. |
|
3119 |
Notice the mentioning of a WeakDictionary - read the classes documentation." |
|
3120 |
||
3121 |
|deps| |
|
3122 |
||
3123 |
(deps := Dependencies at:self ifAbsent:nil) isNil ifTrue:[ |
|
10460 | 3124 |
^ #(). |
5755 | 3125 |
]. |
3126 |
^ deps |
|
3127 |
||
3128 |
"Modified: / 26.1.1998 / 11:18:15 / cg" |
|
3129 |
! |
|
3130 |
||
3131 |
dependents:aCollection |
|
3132 |
"set the collection of dependents. |
|
3133 |
The default implementation here uses a global Dictionary to store |
|
3134 |
dependents which may be too slow for high frequency change&update. |
|
3135 |
Therefore, some classes (Model) redefine this for better performance." |
|
3136 |
||
3137 |
"/ must do this save from interrupts, since the dependents collection |
|
3138 |
"/ is possibly accessed from multiple threads. |
|
3139 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
|
3140 |
"/ faster execution (and to avoid creation of garbage blocks). |
|
3141 |
||
3142 |
(OperatingSystem blockInterrupts) ifTrue:[ |
|
10460 | 3143 |
"/ the common case - already blocked |
3144 |
||
3145 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[ |
|
3146 |
Dependencies removeKey:self ifAbsent:nil |
|
3147 |
] ifFalse:[ |
|
3148 |
Dependencies at:self put:aCollection |
|
3149 |
]. |
|
3150 |
^ self |
|
5755 | 3151 |
]. |
3152 |
||
3153 |
[ |
|
10460 | 3154 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[ |
3155 |
Dependencies removeKey:self ifAbsent:nil |
|
3156 |
] ifFalse:[ |
|
3157 |
Dependencies at:self put:aCollection |
|
3158 |
]. |
|
6421
58dca33cf0fc
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
6418
diff
changeset
|
3159 |
] ensure:[ |
10460 | 3160 |
OperatingSystem unblockInterrupts |
5755 | 3161 |
] |
3162 |
||
3163 |
"Modified: 30.1.1997 / 21:22:10 / cg" |
|
3164 |
! |
|
3165 |
||
3166 |
dependentsDo:aBlock |
|
3167 |
"evaluate aBlock for all of my dependents" |
|
3168 |
||
3169 |
|deps nwDeps| |
|
3170 |
||
3171 |
deps := self dependents. |
|
3172 |
deps size ~~ 0 ifTrue:[ |
|
10460 | 3173 |
deps do:[:d | |
3174 |
(d notNil and:[d ~~ 0]) ifTrue:[ |
|
3175 |
aBlock value:d |
|
3176 |
] |
|
3177 |
] |
|
5755 | 3178 |
]. |
3179 |
nwDeps := self nonWeakDependents. |
|
3180 |
(nwDeps ~~ deps and:[nwDeps size ~~ 0]) ifTrue:[ |
|
10460 | 3181 |
nwDeps do:aBlock |
5755 | 3182 |
]. |
3183 |
||
3184 |
"Modified: / 30.1.1998 / 14:03:40 / cg" |
|
3185 |
! |
|
3186 |
||
3187 |
myDependents |
|
3188 |
"same as dependents - ST-80 compatibility" |
|
3189 |
||
3190 |
^ self dependents |
|
3191 |
! |
|
3192 |
||
3193 |
release |
|
3194 |
"remove all references to objects that may refer to self. |
|
3195 |
Subclasses may redefine this method but should do a 'super release'." |
|
3196 |
||
3197 |
self breakDependents |
|
3198 |
||
3199 |
"Modified: / 27.2.1998 / 11:29:35 / stefan" |
|
3200 |
! |
|
3201 |
||
3202 |
removeDependent:anObject |
|
3203 |
"make the argument, anObject be independent of the receiver" |
|
3204 |
||
3205 |
|wasBlocked| |
|
3206 |
||
3207 |
"/ must do this save from interrupts, since the dependents collection |
|
3208 |
"/ is possibly accessed from multiple threads. |
|
3209 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
|
3210 |
"/ faster execution. |
|
3211 |
||
3212 |
wasBlocked := OperatingSystem blockInterrupts. |
|
3213 |
[ |
|
10460 | 3214 |
|deps n d| |
3215 |
||
3216 |
deps := self dependents. |
|
3217 |
deps size ~~ 0 ifTrue:[ |
|
3218 |
||
3219 |
"/ to save a fair amount of memory in case of |
|
3220 |
"/ many dependencies, we store a single dependent in |
|
3221 |
"/ a WeakArray, and switch to a WeakSet if more dependents are |
|
3222 |
"/ added. Here we have to do the inverse ... |
|
3223 |
||
3224 |
((deps class == WeakArray) or:[deps class == Array]) ifTrue:[ |
|
3225 |
((d := deps at:1) == anObject |
|
3226 |
or:[d isNil |
|
3227 |
or:[d == 0]]) ifTrue:[ |
|
3228 |
self dependents:nil |
|
3229 |
] |
|
3230 |
] ifFalse:[ |
|
3231 |
deps remove:anObject ifAbsent:[]. |
|
3232 |
(n := deps size) == 0 ifTrue:[ |
|
3233 |
self dependents:nil |
|
3234 |
] ifFalse:[ |
|
3235 |
n == 1 ifTrue:[ |
|
3236 |
d := deps firstIfEmpty:nil. |
|
3237 |
d notNil ifTrue:[ |
|
3238 |
deps := (deps isWeakCollection ifTrue:WeakArray ifFalse:Array) with:d |
|
3239 |
] ifFalse:[ |
|
3240 |
deps := nil |
|
3241 |
]. |
|
3242 |
self dependents:deps. |
|
3243 |
] |
|
3244 |
] |
|
3245 |
] |
|
3246 |
] |
|
6421
58dca33cf0fc
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
6418
diff
changeset
|
3247 |
] ensure:[ |
10460 | 3248 |
wasBlocked ifFalse:[ |
3249 |
OperatingSystem unblockInterrupts |
|
3250 |
] |
|
5755 | 3251 |
] |
3252 |
||
3253 |
"Modified: / 26.1.1998 / 19:51:50 / cg" |
|
3254 |
! ! |
|
3255 |
||
7266 | 3256 |
!Object methodsFor:'dependents access (non weak)'! |
5755 | 3257 |
|
3258 |
addNonWeakDependent:anObject |
|
3259 |
"make the argument, anObject be a nonWeak dependent of the receiver. |
|
10460 | 3260 |
Be careful: this nonWeakDependency will prevent the dependent from being |
5755 | 3261 |
garbage collected unless the dependency is removed. |
3262 |
This is a private mechanism, for directed dependencies." |
|
3263 |
||
3264 |
|wasBlocked| |
|
3265 |
||
3266 |
"/ must do this save from interrupts, since the dependents collection |
|
3267 |
"/ is possibly accessed from multiple threads. |
|
3268 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
|
3269 |
"/ faster execution. |
|
3270 |
||
3271 |
wasBlocked := OperatingSystem blockInterrupts. |
|
3272 |
[ |
|
10460 | 3273 |
|deps dep| |
3274 |
||
3275 |
deps := self nonWeakDependents. |
|
3276 |
||
3277 |
"/ to save a fair amount of memory in case of |
|
3278 |
"/ many dependencies, we store a single dependent in |
|
3279 |
"/ an Array, and switch to a Set if more dependents are |
|
3280 |
"/ added. |
|
3281 |
||
3282 |
deps size == 0 ifTrue:[ |
|
3283 |
anObject notNil ifTrue:[ |
|
3284 |
self nonWeakDependents:(Array with:anObject). |
|
3285 |
] ifFalse:[ |
|
3286 |
"adding nil causes problems when adding the next one |
|
3287 |
(see below: trying to add nil to IdentitySet)" |
|
9442 | 3288 |
"/ self halt:'try to add nil to list of dependents'. |
10460 | 3289 |
]. |
3290 |
] ifFalse:[ |
|
3291 |
deps class == Array ifTrue:[ |
|
3292 |
dep := deps at:1. |
|
3293 |
dep ~~ anObject ifTrue:[ |
|
3294 |
self nonWeakDependents:(IdentitySet with:dep with:anObject) |
|
3295 |
] |
|
3296 |
] ifFalse:[ |
|
3297 |
deps add:anObject |
|
3298 |
] |
|
3299 |
] |
|
6421
58dca33cf0fc
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
6418
diff
changeset
|
3300 |
] ensure:[ |
10460 | 3301 |
wasBlocked ifFalse:[ |
3302 |
OperatingSystem unblockInterrupts |
|
3303 |
] |
|
5755 | 3304 |
] |
3305 |
||
3306 |
"Created: / 19.4.1996 / 10:54:08 / cg" |
|
3307 |
"Modified: / 30.1.1998 / 14:03:08 / cg" |
|
3308 |
! |
|
3309 |
||
3310 |
nonWeakDependents |
|
3311 |
"return a Collection of nonWeakDependents - empty if there is none. |
|
3312 |
This is a private mechanism for directed dependencies." |
|
3313 |
||
3314 |
NonWeakDependencies isNil ifTrue:[^ #()]. |
|
3315 |
^ NonWeakDependencies at:self ifAbsent:#() |
|
3316 |
||
3317 |
"Created: / 19.4.1996 / 10:55:06 / cg" |
|
3318 |
"Modified: / 30.1.1998 / 14:06:47 / cg" |
|
3319 |
! |
|
3320 |
||
3321 |
nonWeakDependents:aCollection |
|
3322 |
"set the collection of nonWeak dependents. |
|
3323 |
This is a private helper for directed dependencies." |
|
3324 |
||
3325 |
[ |
|
10460 | 3326 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[ |
3327 |
NonWeakDependencies removeKey:self ifAbsent:nil |
|
3328 |
] ifFalse:[ |
|
3329 |
NonWeakDependencies at:self put:aCollection |
|
3330 |
] |
|
5755 | 3331 |
] valueUninterruptably |
3332 |
||
3333 |
"Created: 19.4.1996 / 11:07:47 / cg" |
|
3334 |
! |
|
3335 |
||
3336 |
removeNonWeakDependent:anObject |
|
3337 |
"remove a nonWeak dependency from the receiver to the argument, anObject. |
|
3338 |
(i.e. make it independent of the receiver)" |
|
3339 |
||
3340 |
|wasBlocked| |
|
3341 |
||
3342 |
"/ must do this save from interrupts, since the dependents collection |
|
3343 |
"/ is possibly accessed from multiple threads. |
|
3344 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
|
3345 |
"/ faster execution. |
|
3346 |
||
3347 |
wasBlocked := OperatingSystem blockInterrupts. |
|
3348 |
[ |
|
10460 | 3349 |
|deps n| |
3350 |
||
3351 |
deps := self nonWeakDependents. |
|
3352 |
deps size ~~ 0 ifTrue:[ |
|
3353 |
deps class == Array ifTrue:[ |
|
3354 |
(deps at:1) == anObject ifTrue:[ |
|
3355 |
self nonWeakDependents:nil |
|
3356 |
] |
|
3357 |
] ifFalse:[ |
|
3358 |
deps remove:anObject ifAbsent:[]. |
|
3359 |
(n := deps size) == 0 ifTrue:[ |
|
3360 |
self nonWeakDependents:nil |
|
3361 |
] ifFalse:[ |
|
3362 |
n == 1 ifTrue:[ |
|
3363 |
self nonWeakDependents:(Array with:(deps first)) |
|
3364 |
] |
|
3365 |
] |
|
3366 |
] |
|
3367 |
] |
|
6421
58dca33cf0fc
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
6418
diff
changeset
|
3368 |
] ensure:[ |
10460 | 3369 |
wasBlocked ifFalse:[ |
3370 |
OperatingSystem unblockInterrupts |
|
3371 |
] |
|
5755 | 3372 |
] |
3373 |
||
3374 |
"Created: / 19.4.1996 / 11:44:44 / cg" |
|
3375 |
"Modified: / 30.1.1998 / 14:04:01 / cg" |
|
3376 |
! ! |
|
3377 |
||
9279 | 3378 |
|
3379 |
!Object methodsFor:'dependents-st/v event simulation'! |
|
3380 |
||
3381 |
removeActionsForEvent:eventName |
|
3382 |
"remove ST/V-style event triggers." |
|
3383 |
||
3384 |
self retractInterestsIn:eventName |
|
3385 |
! |
|
3386 |
||
3387 |
removeAllActionsWithReceiver:anObject |
|
3388 |
"remove ST/V-style event triggers." |
|
3389 |
||
3390 |
self retractInterestsFor:anObject |
|
3391 |
! |
|
3392 |
||
3393 |
triggerEvent:eventSymbol withArguments:parameters |
|
3394 |
"perform ST/V-style event triggering." |
|
3395 |
||
3396 |
self changed:eventSymbol with:parameters. |
|
3397 |
! ! |
|
3398 |
||
5755 | 3399 |
!Object methodsFor:'displaying'! |
3400 |
||
7081
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3401 |
ascentOn:aGC |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3402 |
"when displayed via displayOn:, some objects assume that the given y coordinate |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3403 |
is the baseline (strings, text etc. do), while others assume that the topY |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3404 |
coordinate is given by y. |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3405 |
In other words: some draw above the given y coordinate. |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3406 |
This method returns the number of pixels by which the receiver will draw above |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3407 |
the given y coordinate." |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3408 |
|
11065
17c01b01000f
Simplify (and speed up) #ascentOn:
Stefan Vogel <sv@exept.de>
parents:
11048
diff
changeset
|
3409 |
^ aGC fontAscent |
7081
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3410 |
! |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3411 |
|
6900 | 3412 |
displayOn:aGCOrStream |
7081
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3413 |
"Compatibility |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3414 |
append a printed desription on some stream (Dolphin, Squeak) |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3415 |
OR: |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3416 |
display the receiver in a graphicsContext at 0@0 (ST80). |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3417 |
This method allows for any object to be displayed in some view |
5755 | 3418 |
(although the fallBack is to display its printString ...)" |
3419 |
||
7081
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3420 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3421 |
"/ ST/X (and some old ST80's) mean: draw-yourself on a GC. |
6900 | 3422 |
(aGCOrStream isStream or:[aGCOrStream == Transcript]) ifTrue:[ |
10460 | 3423 |
self printOn:aGCOrStream. |
3424 |
^ self |
|
6900 | 3425 |
]. |
3426 |
^ self displayOn:aGCOrStream x:0 y:0. |
|
5755 | 3427 |
|
3428 |
"Created: 29.5.1996 / 16:28:58 / cg" |
|
3429 |
! |
|
3430 |
||
3431 |
displayOn:aGC at:aPoint |
|
3432 |
"ST-80 Compatibility |
|
3433 |
display the receiver in a graphicsContext - this method allows |
|
3434 |
for any object to be displayed in a ListView - for example." |
|
3435 |
||
3436 |
^ self displayOn:aGC x:(aPoint x) y:(aPoint y). |
|
3437 |
! |
|
3438 |
||
3439 |
displayOn:aGC x:x y:y |
|
3440 |
"display the receiver in a graphicsContext - this method allows |
|
3441 |
for any object to be displayed in a ListView - for example." |
|
3442 |
||
3443 |
self displayOn:aGC x:x y:y opaque:false |
|
3444 |
||
3445 |
"Modified: 29.5.1996 / 16:29:38 / cg" |
|
3446 |
! |
|
3447 |
||
3448 |
displayOn:aGc x:x y:y opaque:opaque |
|
3449 |
"display the receiver in a graphicsContext - this method allows |
|
3450 |
for any object to be displayed in a ListView - for example. |
|
7215
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3451 |
The fallBack here shows the receivers displayString. |
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3452 |
Notice, that the string is displayed on the baseLine; |
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3453 |
ask using #ascentOn: if required" |
5755 | 3454 |
|
3455 |
|s yBaseline| |
|
3456 |
||
3457 |
s := self displayString. |
|
7215
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3458 |
yBaseline := y "+ aGc font ascent". |
5755 | 3459 |
opaque ifTrue:[ |
10460 | 3460 |
aGc displayOpaqueString:s x:x y:yBaseline. |
5755 | 3461 |
] ifFalse:[ |
10460 | 3462 |
aGc displayString:s x:x y:yBaseline. |
5755 | 3463 |
]. |
3464 |
||
3465 |
"Modified: 29.5.1996 / 16:29:38 / cg" |
|
3466 |
! |
|
3467 |
||
3468 |
displayOpaqueOn:aGC x:x y:y |
|
3469 |
"display the receiver in a graphicsContext - this method allows |
|
3470 |
for any object to be displayed in a ListView - for example." |
|
3471 |
||
3472 |
self displayOn:aGC x:x y:y opaque:true |
|
3473 |
||
3474 |
"Modified: / 29.5.1996 / 16:29:38 / cg" |
|
3475 |
"Created: / 26.10.1997 / 15:01:36 / cg" |
|
3476 |
! |
|
3477 |
||
3478 |
displayString |
|
3479 |
"return a string used when displaying the receiver in a view; |
|
3480 |
for example an Inspector. This is usually the same as printString, |
|
3481 |
but sometimes redefined for a better look." |
|
3482 |
||
7081
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3483 |
|s| |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3484 |
|
8322
95ca965f65ed
Handle unicode in #displayString
Stefan Vogel <sv@exept.de>
parents:
8300
diff
changeset
|
3485 |
s := CharacterWriteStream on:(String new:32). |
7081
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3486 |
self displayOn:s. |
4e1ae4a0b3c1
added ascentOn: (display-ascent);
Claus Gittinger <cg@exept.de>
parents:
7048
diff
changeset
|
3487 |
^ s contents |
5755 | 3488 |
|
3489 |
" |
|
10460 | 3490 |
#(1 2 3) printString |
3491 |
#(1 2 3) displayString |
|
5755 | 3492 |
#(1 2 3) storeString |
3493 |
" |
|
3494 |
! |
|
3495 |
||
3496 |
heightOn:aGC |
|
3497 |
"return the height of the receiver, if it is to be displayed on aGC" |
|
3498 |
||
3499 |
^ (aGC font onDevice:aGC device) heightOf:(self displayString) |
|
3500 |
! |
|
3501 |
||
6654 | 3502 |
widthFrom:startIndex to:endIndex on:aGC |
3503 |
"return the width of the receiver, if it is to be displayed on aGC" |
|
3504 |
||
3505 |
^ (aGC font onDevice:aGC device) widthOf:(self displayString) from:startIndex to:endIndex |
|
3506 |
! |
|
3507 |
||
5755 | 3508 |
widthOn:aGC |
3509 |
"return the width of the receiver, if it is to be displayed on aGC" |
|
3510 |
||
3511 |
^ (aGC font onDevice:aGC device) widthOf:(self displayString) |
|
3512 |
! ! |
|
3513 |
||
7359 | 3514 |
!Object methodsFor:'double dispatching'! |
3515 |
||
3516 |
equalFromComplex:aComplex |
|
3517 |
"adding this method here allows for any non-number to be compared to a complex |
|
3518 |
and return false from this comparison. |
|
3519 |
Reason: we want to be able to put both numbers and non-numbers into a collection |
|
3520 |
which uses #= (i.e. a Set or Dictionary)." |
|
3521 |
||
3522 |
^ false |
|
3523 |
! |
|
3524 |
||
3525 |
equalFromFixedPoint:aFixedPoint |
|
3526 |
"adding this method here allows for any non-number to be compared to a fixedPoint |
|
3527 |
and return false from this comparison. |
|
3528 |
Reason: we want to be able to put both numbers and non-numbers into a collection |
|
3529 |
which uses #= (i.e. a Set or Dictionary)." |
|
3530 |
||
3531 |
^ false |
|
3532 |
! |
|
3533 |
||
3534 |
equalFromFloat:aFloat |
|
3535 |
"adding this method here allows for any non-number to be compared to a float |
|
3536 |
and return false from this comparison. |
|
3537 |
Reason: we want to be able to put both numbers and non-numbers into a collection |
|
3538 |
which uses #= (i.e. a Set or Dictionary)." |
|
3539 |
||
3540 |
^ false |
|
3541 |
! |
|
3542 |
||
3543 |
equalFromFraction:aFraction |
|
3544 |
"adding this method here allows for any non-number to be compared to a fraction |
|
3545 |
and return false from this comparison. |
|
3546 |
Reason: we want to be able to put both numbers and non-numbers into a collection |
|
3547 |
which uses #= (i.e. a Set or Dictionary)." |
|
3548 |
||
3549 |
^ false |
|
3550 |
! |
|
3551 |
||
3552 |
equalFromInteger:anInteger |
|
3553 |
"adding this method here allows for any non-number to be compared to an integer |
|
3554 |
and return false from this comparison. |
|
3555 |
Reason: we want to be able to put both numbers and non-numbers into a collection |
|
3556 |
which uses #= (i.e. a Set or Dictionary)." |
|
3557 |
||
3558 |
^ false |
|
3559 |
! |
|
3560 |
||
7455 | 3561 |
equalFromLargeFloat:aLargeFloat |
3562 |
"adding this method here allows for any non-number to be compared to a largeFloat |
|
3563 |
and return false from this comparison. |
|
3564 |
Reason: we want to be able to put both numbers and non-numbers into a collection |
|
3565 |
which uses #= (i.e. a Set or Dictionary)." |
|
3566 |
||
3567 |
^ false |
|
3568 |
! |
|
3569 |
||
7359 | 3570 |
equalFromLongFloat:aLongFloat |
3571 |
"adding this method here allows for any non-number to be compared to a longFloat |
|
3572 |
and return false from this comparison. |
|
3573 |
Reason: we want to be able to put both numbers and non-numbers into a collection |
|
3574 |
which uses #= (i.e. a Set or Dictionary)." |
|
3575 |
||
3576 |
^ false |
|
3577 |
! |
|
3578 |
||
3579 |
equalFromShortFloat:aShortFloat |
|
3580 |
"adding this method here allows for any non-number to be compared to a shortFloat |
|
3581 |
and return false from this comparison. |
|
3582 |
Reason: we want to be able to put both numbers and non-numbers into a collection |
|
3583 |
which uses #= (i.e. a Set or Dictionary)." |
|
3584 |
||
3585 |
^ false |
|
3586 |
! ! |
|
3587 |
||
5755 | 3588 |
!Object methodsFor:'encoding & decoding'! |
3589 |
||
3590 |
decodeAsLiteralArray |
|
8832 | 3591 |
"given a literalEncoding in the receiver, |
3592 |
create & return the corresponding object. |
|
3593 |
The inverse operation to #literalArrayEncoding." |
|
3594 |
||
5755 | 3595 |
^ self |
3596 |
! |
|
3597 |
||
3598 |
encodeOn:anEncoder with:aParameter |
|
8397
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3599 |
"not used any longer. Kept for backward comaptibility" |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3600 |
|
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3601 |
<resource: #obsolete> |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3602 |
|
8404 | 3603 |
self acceptVisitor:anEncoder with:aParameter |
6718 | 3604 |
! |
3605 |
||
3606 |
encodingVectorForInstanceVariables |
|
8397
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3607 |
"OBSOLETE, use elementDescriptorForInstanceVariables" |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3608 |
|
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3609 |
<resource: #obsolete> |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3610 |
|
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3611 |
^ self elementDescriptorForInstanceVariablesMatching:[:val | true]. |
6718 | 3612 |
|
3613 |
" |
|
3614 |
#(1 2 3 nil true symbol) encodingVectorForInstanceVariables |
|
3615 |
Dictionary new encodingVectorForInstanceVariables |
|
3616 |
(5 @ nil) encodingVectorForInstanceVariables |
|
3617 |
" |
|
3618 |
! |
|
3619 |
||
3620 |
encodingVectorForNonNilInstanceVariables |
|
8397
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3621 |
"OBSOLETE, use elementDescriptorForNonNilInstanceVariables" |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3622 |
|
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3623 |
<resource: #obsolete> |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3624 |
|
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3625 |
^ self elementDescriptorForInstanceVariablesMatching:[:varVal | varVal notNil]. |
6718 | 3626 |
|
3627 |
" |
|
3628 |
#(1 2 3 nil true symbol) encodingVectorForNonNilInstanceVariables |
|
3629 |
(5 @ nil) encodingVectorForNonNilInstanceVariables |
|
3630 |
" |
|
3631 |
! |
|
3632 |
||
5755 | 3633 |
fromLiteralArrayEncoding:aSpecArray |
8798 | 3634 |
"read my attributes from aSpecArray. |
3635 |
Recursively decodes arguments." |
|
3636 |
||
3637 |
|sel litVal val |
|
5755 | 3638 |
stop "{ Class:SmallInteger }" | |
3639 |
||
3640 |
stop := aSpecArray size. |
|
3641 |
||
3642 |
2 to:stop by:2 do:[:i| |
|
10460 | 3643 |
sel := aSpecArray at:i. |
3644 |
litVal := aSpecArray at:i + 1. |
|
3645 |
||
3646 |
(self respondsTo:sel) ifTrue:[ |
|
3647 |
val := litVal decodeAsLiteralArray. |
|
3648 |
self perform:sel with:val |
|
3649 |
] ifFalse:[ |
|
3650 |
Transcript show:self class name; show:': unhandled literalArrayEncoding attribute: '. |
|
3651 |
Transcript showCR:sel. |
|
3652 |
||
3653 |
"/ thats a debug halt, |
|
3654 |
"/ it should probably be removed (to simply ignore unhandled attributes)... |
|
3655 |
"/ for now, it is left in, in order to easily find incompatibilities between |
|
3656 |
"/ VW and ST/X. |
|
3657 |
self halt:('Unrecognized attribute in spec: #', sel). "/ value is: val / litVal. |
|
3658 |
] |
|
5755 | 3659 |
] |
3660 |
! |
|
3661 |
||
3662 |
literalArrayEncoding |
|
3663 |
"generate a literalArrayEncoding array for myself. |
|
3664 |
This uses #literalArrayEncodingSlotOrder which defines the slots and |
|
3665 |
order and #skippedInLiteralEncoding which defines slots to skip. |
|
3666 |
For most subclasses, there is no need to redefine those." |
|
3667 |
||
8832 | 3668 |
|names encoding cls skipped slots| |
5755 | 3669 |
|
3670 |
self isLiteral ifTrue:[ |
|
10460 | 3671 |
^ self |
5755 | 3672 |
]. |
3673 |
||
8832 | 3674 |
slots := self literalArrayEncodingSlotOrder. |
5755 | 3675 |
skipped := self skippedInLiteralEncoding. |
3676 |
cls := self class. |
|
3677 |
names := cls allInstVarNames. |
|
8832 | 3678 |
encoding := OrderedCollection new:(1 + (2 * (slots size - skipped size))). |
8839
c4471cb2799f
stefan: bitte vor Einchecken Testen !
Claus Gittinger <cg@exept.de>
parents:
8833
diff
changeset
|
3679 |
encoding add:cls name. |
8832 | 3680 |
|
3681 |
slots do:[:instSlot | |
|
10460 | 3682 |
|value nm| |
3683 |
||
3684 |
nm := names at:instSlot. |
|
3685 |
(skipped includes:nm) ifFalse:[ |
|
3686 |
(value := self instVarAt:instSlot) notNil ifTrue:[ |
|
3687 |
encoding add:(nm , ':') asSymbol. |
|
3688 |
encoding add:value literalArrayEncoding |
|
3689 |
] |
|
3690 |
] |
|
5755 | 3691 |
]. |
3692 |
^ encoding asArray |
|
8841 | 3693 |
|
3694 |
" |
|
10460 | 3695 |
(1 -> 2) literalArrayEncoding |
3696 |
DebugView menuSpec decodeAsLiteralArray literalArrayEncoding = |
|
3697 |
DebugView menuSpec |
|
8841 | 3698 |
" |
5755 | 3699 |
! |
3700 |
||
3701 |
literalArrayEncodingSlotOrder |
|
3702 |
"define the order in which inst-slots are saved when generating |
|
8397
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3703 |
a literalArrayEncoding" |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3704 |
|
5755 | 3705 |
^ 1 to:self class instSize |
3706 |
! |
|
3707 |
||
7112 | 3708 |
postDecodeFrom:aDecoder aspect:aspectSymbol |
3709 |
"invoked by xmlDecoder (and others in the future), after an |
|
3710 |
object has been decoded (i.e. its instance variables have been restored)" |
|
3711 |
||
8397
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3712 |
^ self |
7112 | 3713 |
! |
3714 |
||
5755 | 3715 |
skippedInLiteralEncoding |
8397
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3716 |
"return a Collection with it's elements are slots for skipping" |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
3717 |
|
5755 | 3718 |
^ #() |
3719 |
! ! |
|
3720 |
||
3721 |
!Object methodsFor:'error handling'! |
|
3722 |
||
3723 |
appropriateDebugger:aSelector |
|
3724 |
"{ Pragma: +optSpace }" |
|
3725 |
||
3726 |
"return an appropriate debugger to use. |
|
3727 |
If there is already a debugger active on the stack, and it is |
|
3728 |
the DebugView, return MiniDebugger (as a last chance) otherwise abort." |
|
3729 |
||
3730 |
|context| |
|
3731 |
||
3732 |
"DebugView cannot run without system processes" |
|
3733 |
||
10460 | 3734 |
(Processor isNil |
5755 | 3735 |
or:[Processor activeProcessIsSystemProcess |
3736 |
or:[Smalltalk isInitialized not]]) ifTrue:[ |
|
10460 | 3737 |
^ MiniDebugger |
5755 | 3738 |
]. |
6778
87e2d95ce8a4
Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents:
6764
diff
changeset
|
3739 |
(Screen isNil or:[Screen default isNil or:[Screen default isOpen not]]) ifTrue:[ |
10460 | 3740 |
Debugger isNil ifTrue:[^ nil]. |
3741 |
^ MiniDebugger |
|
5755 | 3742 |
]. |
3743 |
||
3744 |
context := thisContext. |
|
3745 |
context := context findNextContextWithSelector:aSelector or:nil or:nil. |
|
3746 |
[context notNil] whileTrue:[ |
|
10460 | 3747 |
((context receiver class == Debugger) |
3748 |
and:[context selector == aSelector]) ifTrue:[ |
|
3749 |
"we are already in some Debugger" |
|
3750 |
(Debugger == MiniDebugger) ifTrue:[ |
|
3751 |
"we are already in the MiniDebugger" |
|
3752 |
ErrorRecursion ifFalse:[ |
|
3753 |
Smalltalk fatalAbort:'recursive error ...' |
|
3754 |
] |
|
3755 |
]. |
|
3756 |
MiniDebugger isNil ifTrue:[ |
|
3757 |
Smalltalk fatalAbort:'no debugger' |
|
3758 |
]. |
|
3759 |
||
3760 |
"ok, an error occured while in the graphical debugger; |
|
3761 |
lets try MiniDebugger" |
|
3762 |
^ MiniDebugger |
|
3763 |
]. |
|
3764 |
context := context findNextContextWithSelector:aSelector or:nil or:nil. |
|
5755 | 3765 |
]. |
3766 |
"not within Debugger - no problem" |
|
3767 |
^ Debugger |
|
3768 |
||
3769 |
"Modified: / 23.9.1996 / 12:14:52 / stefan" |
|
3770 |
"Modified: / 19.5.1999 / 18:05:00 / cg" |
|
3771 |
! |
|
3772 |
||
3773 |
cannotSendMessage:aMessage to:someReceiver |
|
3774 |
"this message is sent by the runtime system (VM), |
|
3775 |
when a message is sent to some object, whose class is not |
|
3776 |
a valid behavior (see documentation in Behavior)." |
|
3777 |
||
11021 | 3778 |
<resource: #skipInDebuggersWalkBack> |
3779 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3780 |
^ VMInternalError |
11021 | 3781 |
raiseWith:someReceiver |
3782 |
errorString:('bad class in send of #' , aMessage selector) |
|
5755 | 3783 |
|
3784 |
"Modified: 23.1.1997 / 00:05:39 / cg" |
|
3785 |
! |
|
3786 |
||
11132
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
3787 |
conversionErrorSignal |
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
3788 |
"return the signal used for conversion error handling" |
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
3789 |
|
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
3790 |
^ self class conversionErrorSignal |
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
3791 |
! |
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
3792 |
|
5755 | 3793 |
doesNotUnderstand:aMessage |
3794 |
"this message is sent by the runtime system (VM) when |
|
3795 |
a message is not understood by some object (i.e. there |
|
3796 |
is no method for that selector). The original message has |
|
3797 |
been packed into aMessage (i.e. the receiver, selector and |
|
3798 |
any arguments) and the original receiver is then sent the |
|
3799 |
#doesNotUnderstand: message. |
|
3800 |
Here, we raise another signal which usually enters the debugger. |
|
3801 |
You can of course redefine #doesNotUnderstand: in your classes |
|
10460 | 3802 |
to implement message delegation, |
8500
10d47cede03c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
8481
diff
changeset
|
3803 |
or handle the MessageNotUnderstood exception gracefully." |
5755 | 3804 |
|
3805 |
<context: #return> |
|
11021 | 3806 |
<resource: #skipInDebuggersWalkBack> |
5755 | 3807 |
|
8500
10d47cede03c
Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents:
8481
diff
changeset
|
3808 |
^ MessageNotUnderstood raiseRequestWith:aMessage |
5755 | 3809 |
! |
3810 |
||
3811 |
elementBoundsError |
|
3812 |
"{ Pragma: +optSpace }" |
|
3813 |
||
10460 | 3814 |
"report an error that badElement is out of bounds |
5755 | 3815 |
(i.e. cannot be put into that collection). |
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3816 |
The error is reported by raising the ElementBoundsError exception." |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3817 |
|
11021 | 3818 |
<resource: #skipInDebuggersWalkBack> |
3819 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3820 |
^ ElementBoundsError raise |
5755 | 3821 |
|
3822 |
"Modified: 8.5.1996 / 09:12:45 / cg" |
|
3823 |
! |
|
3824 |
||
7215
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3825 |
elementBoundsError:aValue |
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3826 |
"{ Pragma: +optSpace }" |
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3827 |
|
10460 | 3828 |
"report an error that aValue is not valid as element |
7215
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3829 |
(i.e. cannot be put into that collection). |
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3830 |
The error is reported by raising the ElementBoundsError exception." |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3831 |
|
11021 | 3832 |
<resource: #skipInDebuggersWalkBack> |
3833 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3834 |
^ ElementBoundsError raiseWith:aValue |
7215
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3835 |
|
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3836 |
"Modified: 8.5.1996 / 09:12:45 / cg" |
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3837 |
! |
733294e1a8cc
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
7211
diff
changeset
|
3838 |
|
5755 | 3839 |
elementNotCharacter |
3840 |
"{ Pragma: +optSpace }" |
|
3841 |
||
3842 |
"report an error that object to be stored is no Character. |
|
3843 |
(usually when storing into Strings). |
|
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3844 |
The error is reported by raising the ElementBoundsError exception." |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3845 |
|
11021 | 3846 |
<resource: #skipInDebuggersWalkBack> |
3847 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3848 |
^ ElementBoundsError raise |
5755 | 3849 |
|
3850 |
"Modified: 8.5.1996 / 09:12:49 / cg" |
|
3851 |
! |
|
3852 |
||
3853 |
elementNotInteger |
|
3854 |
"{ Pragma: +optSpace }" |
|
3855 |
||
3856 |
"report an error that object to be stored is not Integer. |
|
3857 |
(in collections that store integers only). |
|
3858 |
The error is reported by raising the ElementOutOfBoundsSignal exception." |
|
3859 |
||
11021 | 3860 |
<resource: #skipInDebuggersWalkBack> |
3861 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3862 |
^ ElementBoundsError raise |
5755 | 3863 |
|
3864 |
"Modified: 8.5.1996 / 09:12:51 / cg" |
|
3865 |
! |
|
3866 |
||
3867 |
error |
|
3868 |
"{ Pragma: +optSpace }" |
|
3869 |
||
3870 |
"report error that an error occured. |
|
3871 |
The error is reported by raising the Error exception, |
|
3872 |
which is non-proceedable. |
|
3873 |
If no handler has been setup, a debugger is entered." |
|
3874 |
||
11021 | 3875 |
<context: #return> |
3876 |
<resource: #skipInDebuggersWalkBack> |
|
3877 |
||
5755 | 3878 |
Error raiseWith:#error: |
3879 |
||
3880 |
" |
|
3881 |
nil error |
|
3882 |
" |
|
3883 |
||
3884 |
"Modified: / 8.5.1996 / 09:13:01 / cg" |
|
3885 |
"Modified: / 2.8.1999 / 17:00:19 / stefan" |
|
3886 |
! |
|
3887 |
||
3888 |
error:aString |
|
3889 |
"{ Pragma: +optSpace }" |
|
3890 |
||
3891 |
"Raise an error with error message aString. |
|
3892 |
The error is reported by raising the Error exception, |
|
3893 |
which is non-proceedable. |
|
3894 |
If no handler has been setup, a debugger is entered." |
|
3895 |
||
11021 | 3896 |
<context: #return> |
3897 |
<resource: #skipInDebuggersWalkBack> |
|
3898 |
||
10460 | 3899 |
Error raiseWith:#error: errorString:aString |
5755 | 3900 |
|
3901 |
" |
|
3902 |
nil error:' bad bad bad' |
|
3903 |
" |
|
3904 |
||
3905 |
"Modified: 8.5.1996 / 09:13:04 / cg" |
|
3906 |
! |
|
3907 |
||
3908 |
error:aString mayProceed:mayProceed |
|
3909 |
"{ Pragma: +optSpace }" |
|
3910 |
||
3911 |
"enter debugger with error-message aString. |
|
10460 | 3912 |
The error is reported by raising either the |
5755 | 3913 |
non-proceedable Error exception, |
3914 |
or the ProceedableError exception." |
|
3915 |
||
11021 | 3916 |
<resource: #skipInDebuggersWalkBack> |
3917 |
||
5755 | 3918 |
mayProceed ifTrue:[ |
11021 | 3919 |
^ ProceedableError raiseRequestWith:#error: errorString:aString |
10460 | 3920 |
]. |
3921 |
||
3922 |
Error raiseWith:#error: errorString:aString |
|
5755 | 3923 |
|
3924 |
"Modified: 8.5.1996 / 09:13:04 / cg" |
|
3925 |
! |
|
3926 |
||
6900 | 3927 |
errorInvalidFormat |
3928 |
"{ Pragma: +optSpace }" |
|
3929 |
||
3930 |
"report an error that some conversion to/from string representation failed |
|
3931 |
typically when converting numbers, date, time etc." |
|
3932 |
||
11021 | 3933 |
<context: #return> |
3934 |
<resource: #skipInDebuggersWalkBack> |
|
3935 |
||
6900 | 3936 |
^ ConversionError raiseErrorString:'invalid format' |
3937 |
! |
|
3938 |
||
5755 | 3939 |
errorKeyNotFound:aKey |
3940 |
"{ Pragma: +optSpace }" |
|
3941 |
||
3942 |
"report an error that a key was not found in a collection. |
|
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3943 |
The error is reported by raising the KeyNotFoundError exception." |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3944 |
|
11021 | 3945 |
<resource: #skipInDebuggersWalkBack> |
3946 |
||
10918
a4635305501e
#instVarNamed* - raise KeyNotFoundError if an instaver does not exist
Stefan Vogel <sv@exept.de>
parents:
10877
diff
changeset
|
3947 |
^ KeyNotFoundError raiseRequestWith:aKey errorString:(' ', aKey printString) |
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3948 |
|
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3949 |
" |
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
3950 |
Dictionary new at:#nonExistantElement |
5755 | 3951 |
" |
3952 |
! |
|
3953 |
||
3954 |
errorNotFound |
|
3955 |
"{ Pragma: +optSpace }" |
|
3956 |
||
3957 |
"report an error that no element was found in a collection. |
|
3958 |
The error is reported by raising the NotFoundSignal exception." |
|
3959 |
||
11021 | 3960 |
<resource: #skipInDebuggersWalkBack> |
3961 |
||
6946
905fcfc8699b
signal-classVars replaced by error-class access
Claus Gittinger <cg@exept.de>
parents:
6932
diff
changeset
|
3962 |
^ NotFoundError raiseRequestWith:nil |
5755 | 3963 |
|
3964 |
"Modified: / 8.5.1996 / 09:13:11 / cg" |
|
3965 |
"Modified: / 26.7.1999 / 10:51:50 / stefan" |
|
3966 |
! |
|
3967 |
||
6874 | 3968 |
errorNotFound:errorString |
3969 |
"{ Pragma: +optSpace }" |
|
3970 |
||
3971 |
"report an error that no element was found in a collection. |
|
3972 |
The error is reported by raising the NotFoundSignal exception." |
|
3973 |
||
11021 | 3974 |
<resource: #skipInDebuggersWalkBack> |
3975 |
||
10837
63d19c75d762
changed #errorNotFound: raise it proceedable
Stefan Vogel <sv@exept.de>
parents:
10834
diff
changeset
|
3976 |
^ NotFoundError raiseRequestErrorString:errorString |
6874 | 3977 |
! |
3978 |
||
5755 | 3979 |
errorSignal |
11132
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
3980 |
"return the signal used for error/error: handling" |
e5bd3a66ca80
conversion errors (specific error classes)
Claus Gittinger <cg@exept.de>
parents:
11068
diff
changeset
|
3981 |
|
5755 | 3982 |
^ self class errorSignal |
3983 |
||
3984 |
"Created: / 19.6.1998 / 02:32:32 / cg" |
|
3985 |
! |
|
3986 |
||
7322
178e33c2a376
catch non-block/non-signal/non-exception being
Claus Gittinger <cg@exept.de>
parents:
7320
diff
changeset
|
3987 |
handlerForSignal:exceptionHandler context:theContext originator:originator |
178e33c2a376
catch non-block/non-signal/non-exception being
Claus Gittinger <cg@exept.de>
parents:
7320
diff
changeset
|
3988 |
" should never be invoked for non-blocks/non-exceptions/non-signals" |
178e33c2a376
catch non-block/non-signal/non-exception being
Claus Gittinger <cg@exept.de>
parents:
7320
diff
changeset
|
3989 |
|
7566 | 3990 |
thisContext isRecursive ifTrue:[^ nil]. |
3991 |
||
7322
178e33c2a376
catch non-block/non-signal/non-exception being
Claus Gittinger <cg@exept.de>
parents:
7320
diff
changeset
|
3992 |
'Warning: handlerForSignal invoked for: ' print. self printCR. |
178e33c2a376
catch non-block/non-signal/non-exception being
Claus Gittinger <cg@exept.de>
parents:
7320
diff
changeset
|
3993 |
' context: ' print. theContext printCR. |
178e33c2a376
catch non-block/non-signal/non-exception being
Claus Gittinger <cg@exept.de>
parents:
7320
diff
changeset
|
3994 |
' originator: ' print. originator printCR. |
178e33c2a376
catch non-block/non-signal/non-exception being
Claus Gittinger <cg@exept.de>
parents:
7320
diff
changeset
|
3995 |
' sender: ' print. thisContext sender printCR. |
178e33c2a376
catch non-block/non-signal/non-exception being
Claus Gittinger <cg@exept.de>
parents:
7320
diff
changeset
|
3996 |
|
7566 | 3997 |
"/ MiniDebugger enter:thisContext withMessage:'oops' mayProceed:true. |
3998 |
self error:'this method should only be invoked for blocks, exceptions and signals'. |
|
7322
178e33c2a376
catch non-block/non-signal/non-exception being
Claus Gittinger <cg@exept.de>
parents:
7320
diff
changeset
|
3999 |
! |
178e33c2a376
catch non-block/non-signal/non-exception being
Claus Gittinger <cg@exept.de>
parents:
7320
diff
changeset
|
4000 |
|
5755 | 4001 |
implementedBySubclass |
4002 |
"{ Pragma: +optSpace }" |
|
4003 |
||
4004 |
"this is sent by ST/V code - its the same as #subclassResponsibility" |
|
4005 |
||
11021 | 4006 |
<resource: #skipInDebuggersWalkBack> |
4007 |
||
6721
e5f47c6e2f40
#subclassResponsibility & #subclassResponsibility:
Claus Gittinger <cg@exept.de>
parents:
6718
diff
changeset
|
4008 |
^ self subclassResponsibility:'method must be reimplemented in ST/V subclass' |
5755 | 4009 |
! |
4010 |
||
4011 |
indexNotInteger |
|
4012 |
"{ Pragma: +optSpace }" |
|
4013 |
||
4014 |
"report an error that index is not an Integer. |
|
4015 |
(when accessing collections indexed by an integer key). |
|
4016 |
The error is reported by raising the NonIntegerIndexSignal exception." |
|
4017 |
||
11021 | 4018 |
<resource: #skipInDebuggersWalkBack> |
4019 |
||
6946
905fcfc8699b
signal-classVars replaced by error-class access
Claus Gittinger <cg@exept.de>
parents:
6932
diff
changeset
|
4020 |
^ NonIntegerIndexError raiseRequestWith:nil |
5755 | 4021 |
|
4022 |
"Modified: / 8.5.1996 / 09:13:37 / cg" |
|
4023 |
"Modified: / 26.7.1999 / 10:57:43 / stefan" |
|
4024 |
! |
|
4025 |
||
4026 |
indexNotInteger:anIndex |
|
4027 |
"{ Pragma: +optSpace }" |
|
4028 |
||
4029 |
"report an error that index is not an Integer. |
|
4030 |
(when accessing collections indexed by an integer key). |
|
4031 |
The error is reported by raising the NonIntegerIndexSignal exception." |
|
4032 |
||
11021 | 4033 |
<resource: #skipInDebuggersWalkBack> |
4034 |
||
10460 | 4035 |
^ NonIntegerIndexError raiseRequestWith:anIndex |
5755 | 4036 |
|
4037 |
"Created: / 16.5.1998 / 19:39:41 / cg" |
|
4038 |
! |
|
4039 |
||
7216 | 4040 |
indexNotIntegerOrOutOfBounds:index |
4041 |
"{ Pragma: +optSpace }" |
|
4042 |
||
4043 |
"report an error that index is either non-integral or out of bounds" |
|
4044 |
||
11021 | 4045 |
<resource: #skipInDebuggersWalkBack> |
4046 |
||
7216 | 4047 |
index isInteger ifFalse:[ |
11021 | 4048 |
^ self indexNotInteger:index |
7216 | 4049 |
]. |
4050 |
^ self subscriptBoundsError:index |
|
4051 |
! |
|
4052 |
||
5755 | 4053 |
integerCheckError |
4054 |
"{ Pragma: +optSpace }" |
|
4055 |
||
4056 |
"generated when a variable declared with an integer type gets a bad |
|
4057 |
value assigned" |
|
4058 |
||
11021 | 4059 |
<resource: #skipInDebuggersWalkBack> |
4060 |
||
10460 | 4061 |
^ self error:'bad assign of ' , self printString , |
11021 | 4062 |
' (' , self class name , ') to integer-typed variable' |
5755 | 4063 |
! |
4064 |
||
4065 |
invalidCodeObject |
|
4066 |
"{ Pragma: +optSpace }" |
|
4067 |
||
11021 | 4068 |
<resource: #skipInDebuggersWalkBack> |
4069 |
||
5755 | 4070 |
self error:'not an executable code object' |
4071 |
||
4072 |
"Created: 1.8.1997 / 00:16:44 / cg" |
|
4073 |
! |
|
4074 |
||
10460 | 4075 |
invalidMessage |
5755 | 4076 |
"{ Pragma: +optSpace }" |
4077 |
||
4078 |
"this is sent by ST/V code - its the same as #shouldNotImplement" |
|
4079 |
||
11021 | 4080 |
<resource: #skipInDebuggersWalkBack> |
4081 |
||
5755 | 4082 |
^ self shouldNotImplement |
4083 |
! |
|
4084 |
||
4085 |
mustBeRectangle |
|
4086 |
"{ Pragma: +optSpace }" |
|
4087 |
||
4088 |
"report an argument-not-rectangle-error" |
|
4089 |
||
11021 | 4090 |
<resource: #skipInDebuggersWalkBack> |
4091 |
||
5755 | 4092 |
^ self error:'argument must be a Rectangle' |
4093 |
! |
|
4094 |
||
4095 |
mustBeString |
|
4096 |
"{ Pragma: +optSpace }" |
|
4097 |
||
4098 |
"report an argument-not-string-error" |
|
4099 |
||
11021 | 4100 |
<resource: #skipInDebuggersWalkBack> |
4101 |
||
5755 | 4102 |
^ self error:'argument must be a String' |
4103 |
! |
|
4104 |
||
4105 |
notIndexed |
|
4106 |
"{ Pragma: +optSpace }" |
|
4107 |
||
4108 |
"report an error that receiver has no indexed instance variables. |
|
4109 |
The error is reported by raising the SubscriptOutOfBoundsSignal exception." |
|
4110 |
||
11021 | 4111 |
<context: #return> |
4112 |
<resource: #skipInDebuggersWalkBack> |
|
4113 |
||
10460 | 4114 |
^ SubscriptOutOfBoundsError |
11021 | 4115 |
raiseErrorString:'receiver has no indexed variables' |
5755 | 4116 |
|
4117 |
"Modified: 26.7.1996 / 16:43:13 / cg" |
|
4118 |
! |
|
4119 |
||
4120 |
openDebuggerOnException:ex |
|
4121 |
"{ Pragma: +optSpace }" |
|
4122 |
||
4123 |
"enter the debugger on some unhandled exception" |
|
4124 |
||
6884 | 4125 |
|msgString debugger answer| |
5755 | 4126 |
|
7208 | 4127 |
msgString := ex description. |
5755 | 4128 |
" |
4129 |
if there is no debugger, |
|
8397
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
4130 |
ask for ignore or exit. Exit will terminate the application. |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
4131 |
ignore will raise an AbortOperationRequest. |
5755 | 4132 |
" |
4133 |
Debugger isNil ifTrue:[ |
|
10732
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4134 |
msgString := 'Error: ' , msgString. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4135 |
|
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4136 |
thisContext isRecursive ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4137 |
msgString errorPrintCR. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4138 |
Smalltalk fatalAbort:'recursive unhandled exception' |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4139 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4140 |
|
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4141 |
Smalltalk isStandAloneApp ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4142 |
(ex signal == NoHandlerError and:[HaltInterrupt handles:ex unhandledException]) ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4143 |
"/ 'Halt ignored' infoPrintCR. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4144 |
^ self |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4145 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4146 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4147 |
|
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4148 |
Smalltalk isSmalltalkDevelopmentSystem ifFalse:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4149 |
(Dialog notNil and:[Screen default notNil]) ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4150 |
AbortOperationRequest isHandled ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4151 |
answer := OptionBox |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4152 |
request:msgString |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4153 |
label:msgString |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4154 |
buttonLabels:#('Exit' 'Terminate Thread' 'Ignore' 'Abort' ) |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4155 |
values:#(exit terminate ignore abort) |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4156 |
default:#abort. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4157 |
] ifFalse:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4158 |
answer := OptionBox |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4159 |
request:msgString |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4160 |
label:msgString |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4161 |
buttonLabels:#('Exit' 'Terminate Thread' 'Ignore' ) |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4162 |
values:#(exit terminate ignore ) |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4163 |
default:#terminate. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4164 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4165 |
answer isNil ifTrue:[ answer := #ignore]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4166 |
|
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4167 |
answer == #abort ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4168 |
^ AbortOperationRequest raiseRequest |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4169 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4170 |
answer == #ignore ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4171 |
^ nil |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4172 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4173 |
answer == #terminate ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4174 |
Processor activeProcess isSystemProcess ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4175 |
(Dialog confirm:'Are you sure (this might finish the application)') ifFalse:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4176 |
^ nil |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4177 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4178 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4179 |
^ Processor activeProcess terminate. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4180 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4181 |
"asking second time here to prevent the user from accidently closing his app" |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4182 |
answer == #exit ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4183 |
answer := OptionBox |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4184 |
request:'Do you really wish to exit this application (all changes will be lost)?' |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4185 |
label:msgString |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4186 |
buttonLabels:#('Yes' 'No' ) |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4187 |
values:#(exit abort) |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4188 |
default:#abort. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4189 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4190 |
answer == #abort ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4191 |
^ AbortOperationRequest raiseRequest |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4192 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4193 |
|
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4194 |
(Dialog confirm:'Are you sure you want to finish the application ?') ifFalse:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4195 |
^ nil |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4196 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4197 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4198 |
|
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4199 |
"don't output the message, if the exception is a UserInterrupt (CTRL-C)" |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4200 |
(ex signal == NoHandlerError |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4201 |
and:[ex unhandledException signal == UserInterrupt]) ifTrue:[ |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4202 |
OperatingSystem exit:130. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4203 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4204 |
msgString errorPrintCR. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4205 |
thisContext fullPrintAll. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4206 |
OperatingSystem exit:1 |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4207 |
]. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4208 |
|
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4209 |
msgString errorPrintCR. |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4210 |
Smalltalk fatalAbort:'no Debugger defined' |
5755 | 4211 |
]. |
4212 |
||
4213 |
" |
|
4214 |
find an appropriate debugger to use |
|
4215 |
" |
|
4216 |
debugger := self appropriateDebugger:(thisContext selector). |
|
4217 |
debugger isNil ifTrue:[ |
|
10732
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4218 |
^ AbortOperationRequest raiseRequest |
10460 | 4219 |
]. |
4220 |
||
4221 |
^ debugger |
|
10732
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4222 |
enter:ex returnableSuspendedContext |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4223 |
withMessage:msgString |
cb163e107c24
changed #openDebuggerOnException:
Stefan Vogel <sv@exept.de>
parents:
10651
diff
changeset
|
4224 |
mayProceed:(ex mayProceed). |
5755 | 4225 |
|
10234 | 4226 |
"Modified: / 06-12-2006 / 18:51:55 / cg" |
5755 | 4227 |
! |
4228 |
||
4229 |
primitiveFailed |
|
4230 |
"{ Pragma: +optSpace }" |
|
4231 |
||
4232 |
"report an error that some primitive code failed. |
|
8324
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4233 |
The error is reported by raising the PrimitiveFailure exception." |
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4234 |
|
11021 | 4235 |
<resource: #skipInDebuggersWalkBack> |
4236 |
||
8324
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4237 |
|sender| |
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4238 |
|
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4239 |
sender := thisContext sender. |
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4240 |
|
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4241 |
^ PrimitiveFailure raiseRequestWith:(Message selector:sender selector arguments:sender args) |
11021 | 4242 |
in:sender. |
5755 | 4243 |
|
6005 | 4244 |
" |
4245 |
1234 primitiveFailed |
|
8324
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4246 |
|
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4247 |
[ |
11021 | 4248 |
ExternalBytes new basicAt:40 |
8324
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4249 |
] on:PrimitiveFailure do:[:ex| |
11021 | 4250 |
ex inspect |
8324
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4251 |
] |
c6e8039f0d83
Set message as parameter in #primitiveFailed
Stefan Vogel <sv@exept.de>
parents:
8322
diff
changeset
|
4252 |
" |
5755 | 4253 |
! |
4254 |
||
8977
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4255 |
primitiveFailed:messageString |
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4256 |
"{ Pragma: +optSpace }" |
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4257 |
|
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4258 |
"report an error that some primitive code failed. |
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4259 |
The error is reported by raising the PrimitiveFailureSignal exception." |
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4260 |
|
11021 | 4261 |
<resource: #skipInDebuggersWalkBack> |
4262 |
||
8977
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4263 |
|sender| |
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4264 |
|
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4265 |
sender := thisContext sender. |
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4266 |
|
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4267 |
^ PrimitiveFailure raiseRequestWith:(Message selector:sender selector arguments:sender args) |
11021 | 4268 |
errorString:messageString |
4269 |
in:sender. |
|
8977
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4270 |
|
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4271 |
" |
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4272 |
1234 primitiveFailed:'this is a test' |
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4273 |
" |
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4274 |
! |
fff5644c031d
#primitiveFailed: remember the message implementing the failure
Stefan Vogel <sv@exept.de>
parents:
8975
diff
changeset
|
4275 |
|
6815 | 4276 |
shouldImplement |
4277 |
"{ Pragma: +optSpace }" |
|
4278 |
||
4279 |
"report an error that this message should be implemented. |
|
4280 |
This is send by automatically generated method bodies" |
|
4281 |
||
11021 | 4282 |
<resource: #skipInDebuggersWalkBack> |
4283 |
||
9216
6396192d71c6
use UnimplementedFunctionalityError in #subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
9203
diff
changeset
|
4284 |
|sender| |
6396192d71c6
use UnimplementedFunctionalityError in #subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
9203
diff
changeset
|
4285 |
|
6396192d71c6
use UnimplementedFunctionalityError in #subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
9203
diff
changeset
|
4286 |
sender := thisContext sender. |
6396192d71c6
use UnimplementedFunctionalityError in #subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
9203
diff
changeset
|
4287 |
|
6396192d71c6
use UnimplementedFunctionalityError in #subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
9203
diff
changeset
|
4288 |
^ UnimplementedFunctionalityError raiseRequestWith:(Message selector:sender selector arguments:sender args) |
6396192d71c6
use UnimplementedFunctionalityError in #subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
9203
diff
changeset
|
4289 |
|
6396192d71c6
use UnimplementedFunctionalityError in #subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
9203
diff
changeset
|
4290 |
|
6396192d71c6
use UnimplementedFunctionalityError in #subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
9203
diff
changeset
|
4291 |
" |
11021 | 4292 |
self shouldImplement |
9216
6396192d71c6
use UnimplementedFunctionalityError in #subclassResponsibility
Stefan Vogel <sv@exept.de>
parents:
9203
diff
changeset
|
4293 |
" |
6815 | 4294 |
! |
4295 |
||
5755 | 4296 |
shouldNotImplement |
4297 |
"{ Pragma: +optSpace }" |
|
4298 |
||
4299 |
"report an error that this message should not be implemented" |
|
4300 |
||
11021 | 4301 |
<resource: #skipInDebuggersWalkBack> |
4302 |
||
8729 | 4303 |
^ self error:'method/functionality not appropriate for this class' |
5755 | 4304 |
|
4305 |
"Modified: 8.5.1996 / 09:09:44 / cg" |
|
4306 |
! |
|
4307 |
||
4308 |
subclassResponsibility |
|
4309 |
"{ Pragma: +optSpace }" |
|
4310 |
||
4311 |
"report an error that this message should have been reimplemented in a |
|
4312 |
subclass" |
|
4313 |
||
11021 | 4314 |
<resource: #skipInDebuggersWalkBack> |
4315 |
||
10877
0666d48f91d1
show the affected method-selector in the subclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
10856
diff
changeset
|
4316 |
^ SubclassResponsibilityError raiseRequestWith:thisContext sender selector |
5755 | 4317 |
! |
4318 |
||
6721
e5f47c6e2f40
#subclassResponsibility & #subclassResponsibility:
Claus Gittinger <cg@exept.de>
parents:
6718
diff
changeset
|
4319 |
subclassResponsibility:msg |
e5f47c6e2f40
#subclassResponsibility & #subclassResponsibility:
Claus Gittinger <cg@exept.de>
parents:
6718
diff
changeset
|
4320 |
"{ Pragma: +optSpace }" |
e5f47c6e2f40
#subclassResponsibility & #subclassResponsibility:
Claus Gittinger <cg@exept.de>
parents:
6718
diff
changeset
|
4321 |
|
e5f47c6e2f40
#subclassResponsibility & #subclassResponsibility:
Claus Gittinger <cg@exept.de>
parents:
6718
diff
changeset
|
4322 |
"report an error that this message should have been reimplemented in a subclass" |
e5f47c6e2f40
#subclassResponsibility & #subclassResponsibility:
Claus Gittinger <cg@exept.de>
parents:
6718
diff
changeset
|
4323 |
|
11021 | 4324 |
<resource: #skipInDebuggersWalkBack> |
4325 |
||
7334 | 4326 |
^ SubclassResponsibilityError raiseRequestErrorString:msg |
6721
e5f47c6e2f40
#subclassResponsibility & #subclassResponsibility:
Claus Gittinger <cg@exept.de>
parents:
6718
diff
changeset
|
4327 |
! |
e5f47c6e2f40
#subclassResponsibility & #subclassResponsibility:
Claus Gittinger <cg@exept.de>
parents:
6718
diff
changeset
|
4328 |
|
5755 | 4329 |
subscriptBoundsError |
4330 |
"{ Pragma: +optSpace }" |
|
4331 |
||
4332 |
"report an error that some index is out of bounds. |
|
4333 |
(when accessing indexable collections). |
|
4334 |
The error is reported by raising the SubscriptOutOfBoundsSignal exception." |
|
4335 |
||
11021 | 4336 |
<resource: #skipInDebuggersWalkBack> |
4337 |
||
5755 | 4338 |
^ SubscriptOutOfBoundsSignal raiseRequestWith:nil |
4339 |
||
4340 |
"Modified: / 26.7.1996 / 16:45:42 / cg" |
|
4341 |
"Modified: / 26.7.1999 / 10:58:27 / stefan" |
|
4342 |
! |
|
4343 |
||
4344 |
subscriptBoundsError:anIndex |
|
4345 |
"{ Pragma: +optSpace }" |
|
4346 |
||
4347 |
"report an error that anIndex is out of bounds. |
|
4348 |
(when accessing indexable collections). |
|
4349 |
The error is reported by raising the SubscriptOutOfBoundsSignal exception." |
|
4350 |
||
11021 | 4351 |
<resource: #skipInDebuggersWalkBack> |
4352 |
||
10460 | 4353 |
^ SubscriptOutOfBoundsError |
11021 | 4354 |
raiseRequestWith:anIndex |
4355 |
errorString:('subscript (' , anIndex printString , ') out of bounds') |
|
5755 | 4356 |
|
6221 | 4357 |
"Modified: / 17.11.2001 / 22:49:56 / cg" |
5755 | 4358 |
! |
4359 |
||
4360 |
typeCheckError |
|
4361 |
"{ Pragma: +optSpace }" |
|
4362 |
||
4363 |
"generated when a variable declared with a type hint gets a bad |
|
4364 |
value assigned" |
|
4365 |
||
11021 | 4366 |
<resource: #skipInDebuggersWalkBack> |
4367 |
||
5755 | 4368 |
^ self error:'bad assign of ' , self printString , |
11021 | 4369 |
' (' , self class name , ') to typed variable' |
5755 | 4370 |
! ! |
4371 |
||
4372 |
!Object methodsFor:'evaluation'! |
|
4373 |
||
8690
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4374 |
argumentCount |
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4375 |
"compatibility with Blocks and Messages. |
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4376 |
Answer 0, since we only understand #value. |
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4377 |
|
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4378 |
By implementing this, you can pass any object as an exception handler." |
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4379 |
|
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4380 |
^ 0 |
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4381 |
|
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4382 |
" |
10460 | 4383 |
[1 // 0] on:ArithmeticError do:9999 |
8690
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4384 |
" |
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4385 |
! |
5894d98a4a61
Implement #argumentCount for Block-compatibility.
Stefan Vogel <sv@exept.de>
parents:
8637
diff
changeset
|
4386 |
|
5755 | 4387 |
value |
4388 |
"return the receiver itself. |
|
4389 |
This allows every object to be used where blocks or valueHolders |
|
4390 |
are typically used, and allows for valueHolders and blocks to be |
|
4391 |
used interchangably in some situations. |
|
4392 |
||
4393 |
Time will show, if this is a good idea or leads to sloppy programming |
|
4394 |
style ... (the idea was borrowed from the Self language). |
|
4395 |
||
10460 | 4396 |
WARNING: dont 'optimize' away ifXXX: blocks |
4397 |
(i.e. do NOT replace |
|
4398 |
foo ifTrue:[var1] ifFalse:[var2] |
|
4399 |
by: |
|
4400 |
foo ifTrue:var1 ifFalse:var2 |
|
4401 |
) |
|
4402 |
- the compilers will only generate inline code for the if, |
|
4403 |
iff the argument(s) are blocks - otherwise, a true send is |
|
4404 |
generated. |
|
4405 |
This 'oprimization' will work semantically correct, |
|
4406 |
but execute SLOWER instead." |
|
5755 | 4407 |
|
4408 |
^ self |
|
4409 |
||
4410 |
" |
|
10460 | 4411 |
#(1 2 3 4) indexOf:5 ifAbsent:0 |
4412 |
#(1 2 3 4) indexOf:5 ifAbsent:[0] |
|
4413 |
1 > 2 ifTrue:['yes'] ifFalse:['no'] |
|
4414 |
1 > 2 ifTrue:'yes' ifFalse:'no' |
|
5755 | 4415 |
" |
4416 |
||
4417 |
"DO NOT DO THIS (its slower) |
|
7458 | 4418 |
(1 > 4) ifTrue:a ifFalse:b |
5755 | 4419 |
|
4420 |
USE (the compiler optimizes blocks in if/while): |
|
7458 | 4421 |
(1 > 4) ifTrue:[a] ifFalse:[b] |
5755 | 4422 |
" |
4423 |
||
4424 |
"Modified: 3.5.1996 / 11:57:08 / cg" |
|
4425 |
! ! |
|
4426 |
||
4427 |
!Object methodsFor:'finalization'! |
|
4428 |
||
4429 |
disposed |
|
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4430 |
"OBSOLETE INTERFACE: use #finalize |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4431 |
this is invoked for objects which have been registered |
5755 | 4432 |
in a Registry, when the original object dies. |
4433 |
Subclasses may redefine this method" |
|
4434 |
||
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4435 |
<resource: #obsolete> |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4436 |
|
5755 | 4437 |
^ self |
4438 |
! |
|
4439 |
||
4440 |
executor |
|
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4441 |
"Return the object which does the finalization for me. |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4442 |
This interface is also VW & Sqeak compatible," |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4443 |
|
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4444 |
"for now, send #shallowCopyForFinalization, to be compatible with |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4445 |
classes designed for old ST/X versions" |
5755 | 4446 |
|
4447 |
^ self shallowCopyForFinalization |
|
4448 |
! |
|
4449 |
||
6461
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4450 |
finalizationLobby |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4451 |
"answer a Registry used for finalization. |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4452 |
Use a generic Registry for any object. |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4453 |
Subclasses using their own Registry should redefine this" |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4454 |
|
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4455 |
^ FinalizationLobby |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4456 |
! |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4457 |
|
5755 | 4458 |
finalize |
6439
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4459 |
"this is invoked for executor objects which have been registered |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4460 |
in a Registry, when the original object dies. |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4461 |
Subclasses may redefine this method |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4462 |
This interface is also VW-compatible" |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4463 |
|
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4464 |
"send #disposed for compatibility with existing classes that still |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4465 |
implement the obsolete #disposed message" |
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4466 |
|
0f841258ec4a
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
6421
diff
changeset
|
4467 |
^ self disposed |
5755 | 4468 |
! |
4469 |
||
4470 |
reRegisterForFinalization |
|
4471 |
"re-register mySelf for later finalization. |
|
6461
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4472 |
This will create a new executor, which will receive a #finalize message when |
5755 | 4473 |
the receiver is garbage collected." |
4474 |
||
6461
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4475 |
self finalizationLobby registerChange:self |
5755 | 4476 |
! |
4477 |
||
4478 |
registerForFinalization |
|
4479 |
"register mySelf for later finalization. |
|
6461
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4480 |
Once registered, the executor of the receiver will receive a #finalize message when |
5755 | 4481 |
the receiver is garbage collected." |
4482 |
||
6461
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4483 |
self finalizationLobby register:self |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4484 |
! |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4485 |
|
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4486 |
shallowCopyForFinalization |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4487 |
"OBSOLETE INTERFACE: use #executor. |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4488 |
This is used to aquire a copy to be used for finalization - |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4489 |
(the copy will be sent a #finalize message; see the documentation in the Registry class) |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4490 |
This method can be redefined for more efficient copying - especially for large objects." |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4491 |
|
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4492 |
<resource: #obsolete> |
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4493 |
|
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4494 |
^ self shallowCopy |
5755 | 4495 |
! |
4496 |
||
4497 |
unregisterForFinalization |
|
4498 |
"unregister mySelf from later finalization" |
|
4499 |
||
6461
f5efaff3457b
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
6439
diff
changeset
|
4500 |
self finalizationLobby unregister:self |
5755 | 4501 |
! ! |
4502 |
||
4503 |
!Object methodsFor:'initialization'! |
|
4504 |
||
4505 |
initialize |
|
4506 |
"just to ignore initialize to objects which do not need it" |
|
4507 |
||
4508 |
^ self |
|
4509 |
! ! |
|
4510 |
||
4511 |
!Object methodsFor:'interrupt handling'! |
|
4512 |
||
4513 |
childSignalInterrupt |
|
4514 |
"death of a child process (unix process) - do nothing" |
|
4515 |
||
4516 |
^ self |
|
4517 |
! |
|
4518 |
||
4519 |
customInterrupt |
|
4520 |
"{ Pragma: +optSpace }" |
|
4521 |
||
4522 |
"a custom interrupt - but no handler has defined" |
|
4523 |
||
4524 |
self error:'custom interrupt' mayProceed:true |
|
4525 |
! |
|
4526 |
||
4527 |
errorInterrupt:errorID with:aParameter |
|
4528 |
"subsystem error. The arguments errorID and aParameter are the values passed |
|
10460 | 4529 |
to the 'errorInterruptWithIDAndParameter(id, param)' function, |
5755 | 4530 |
which can be called from C subsystems to raise an (asynchronous) |
4531 |
error exception. |
|
4532 |
||
4533 |
Currently, this is used to map XErrors to smalltalk errors, but can be |
|
4534 |
used from other C subsystems too, to upcast errors. |
|
4535 |
Especially, for subsystems which call errorHandler functions asynchronously. |
|
4536 |
IDs (currently) used: |
|
10460 | 4537 |
#DisplayError ..... x-error interrupt |
4538 |
#XtError ..... xt-error interrupt (Xt interface is not yet published) |
|
5755 | 4539 |
" |
4540 |
||
6263
4e7a970e4cfc
errorInterrupt:with: fixed (care for nil handlers in Objmem)
Claus Gittinger <cg@exept.de>
parents:
6235
diff
changeset
|
4541 |
|handlers handler| |
4e7a970e4cfc
errorInterrupt:with: fixed (care for nil handlers in Objmem)
Claus Gittinger <cg@exept.de>
parents:
6235
diff
changeset
|
4542 |
|
4e7a970e4cfc
errorInterrupt:with: fixed (care for nil handlers in Objmem)
Claus Gittinger <cg@exept.de>
parents:
6235
diff
changeset
|
4543 |
handlers := ObjectMemory registeredErrorInterruptHandlers. |
4e7a970e4cfc
errorInterrupt:with: fixed (care for nil handlers in Objmem)
Claus Gittinger <cg@exept.de>
parents:
6235
diff
changeset
|
4544 |
handlers notNil ifTrue:[ |
10460 | 4545 |
handler := handlers at:errorID ifAbsent:nil. |
4546 |
handler notNil ifTrue:[ |
|
4547 |
"/ |
|
4548 |
"/ handler found; let it do whatever it wants ... |
|
4549 |
"/ |
|
4550 |
handler errorInterrupt:errorID with:aParameter. |
|
4551 |
^ self |
|
4552 |
]. |
|
5755 | 4553 |
]. |
4554 |
||
4555 |
"/ |
|
4556 |
"/ no handler - raise errorSignal passing the errorId as parameter |
|
4557 |
"/ |
|
10460 | 4558 |
^ Error |
4559 |
raiseRequestWith:errorID |
|
4560 |
errorString:('Subsystem error. ErrorID = ' , errorID printString) |
|
5755 | 4561 |
! |
4562 |
||
4563 |
exceptionInterrupt |
|
4564 |
"{ Pragma: +optSpace }" |
|
4565 |
||
4566 |
"exception interrupt - enter debugger" |
|
4567 |
||
4568 |
self error:'exception Interrupt' mayProceed:true |
|
4569 |
! |
|
4570 |
||
4571 |
fpExceptionInterrupt |
|
4572 |
"{ Pragma: +optSpace }" |
|
4573 |
||
4574 |
"a floating point exception occured - this one |
|
4575 |
has to be handled differently since it comes asynchronous |
|
4576 |
on some machines (for example, on machines with a separate FPU |
|
4577 |
or superscalar architectures. Also, errors from within primitive code |
|
4578 |
(or library functions such as GL) are sent via the Unix-signal |
|
4579 |
mechanism this way." |
|
4580 |
||
4581 |
|where rec| |
|
4582 |
||
4583 |
where := thisContext sender. |
|
4584 |
rec := where receiver. |
|
4585 |
rec isNumber ifTrue:[ |
|
10460 | 4586 |
^ rec class |
4587 |
raise:#domainErrorSignal |
|
4588 |
receiver:rec |
|
4589 |
selector:where selector |
|
4590 |
arguments:(where args asArray) |
|
4591 |
errorString:'floating point exception' |
|
5755 | 4592 |
]. |
4593 |
||
4594 |
"/ could be in some C-library ... |
|
7402 | 4595 |
^ DomainError raise |
5755 | 4596 |
! |
4597 |
||
4598 |
internalError:msg |
|
4599 |
"{ Pragma: +optSpace }" |
|
4600 |
||
4601 |
"this is triggered, when VM hits some bad error, |
|
4602 |
such as corrupted class, corrupted method/selector array |
|
4603 |
etc. The argument string gives some more information on what happened. |
|
4604 |
(for example, if you set an objects class to a non-behavior, nil etc.). |
|
4605 |
Its not guaranteed, that the system is in a working condition once |
|
4606 |
this error occurred ...." |
|
4607 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
4608 |
VMInternalError raiseWith:self errorString:msg |
5755 | 4609 |
! |
4610 |
||
4611 |
ioInterrupt |
|
4612 |
"{ Pragma: +optSpace }" |
|
4613 |
||
4614 |
"I/O (SIGIO/SIGPOLL) interrupt (supposed to be sent to Processor). |
|
4615 |
If we arrive here, there is either no handler (ObjMem>>ioInterruptHandler) |
|
4616 |
or it does not understand the ioInterrupt message. |
|
4617 |
In any case, this is a sign of some big trouble. Enter debugger." |
|
4618 |
||
4619 |
self error:'I/O Interrupt - but no handler' mayProceed:true |
|
4620 |
! |
|
4621 |
||
4622 |
memoryInterrupt |
|
4623 |
"{ Pragma: +optSpace }" |
|
4624 |
||
4625 |
"out-of-memory interrupt and no handler - enter debugger" |
|
4626 |
||
4627 |
self error:'almost out of memory' mayProceed:true |
|
4628 |
! |
|
4629 |
||
4630 |
recursionInterrupt |
|
4631 |
"{ Pragma: +optSpace }" |
|
4632 |
||
4633 |
"recursion limit (actually: stack overflow) interrupt. |
|
4634 |
This interrupt is triggered, when a process stack grows above |
|
4635 |
its stackLimit - usually, this leads into the debugger, but |
|
6175
e9970db3e02f
recursionInterrupt fixes for win32 (& comment changed)
Claus Gittinger <cg@exept.de>
parents:
6157
diff
changeset
|
4636 |
could be caught. |
e9970db3e02f
recursionInterrupt fixes for win32 (& comment changed)
Claus Gittinger <cg@exept.de>
parents:
6157
diff
changeset
|
4637 |
Under Unix, the stackLimit may be increased in the handler, |
e9970db3e02f
recursionInterrupt fixes for win32 (& comment changed)
Claus Gittinger <cg@exept.de>
parents:
6157
diff
changeset
|
4638 |
and the exception can be resumed. |
e9970db3e02f
recursionInterrupt fixes for win32 (& comment changed)
Claus Gittinger <cg@exept.de>
parents:
6157
diff
changeset
|
4639 |
Sorry, but under win32, the stack cannot grow, and the exception |
e9970db3e02f
recursionInterrupt fixes for win32 (& comment changed)
Claus Gittinger <cg@exept.de>
parents:
6157
diff
changeset
|
4640 |
is not proceedable. |
10460 | 4641 |
At the time we arrive here, the system has still some stack |
6175
e9970db3e02f
recursionInterrupt fixes for win32 (& comment changed)
Claus Gittinger <cg@exept.de>
parents:
6157
diff
changeset
|
4642 |
as a reserve so we can continue to do some useful work, or cleanup, |
e9970db3e02f
recursionInterrupt fixes for win32 (& comment changed)
Claus Gittinger <cg@exept.de>
parents:
6157
diff
changeset
|
4643 |
or debug for a while. |
5755 | 4644 |
If the signal is ignored, and the stack continues to grow, there |
4645 |
will be a few more chances (and more interrupts) before the VM |
|
6175
e9970db3e02f
recursionInterrupt fixes for win32 (& comment changed)
Claus Gittinger <cg@exept.de>
parents:
6157
diff
changeset
|
4646 |
terminates the process." |
5755 | 4647 |
|
7838
4cf3d0dad430
skip recursive contexts when shwing backtrace of recursionInterrupt
Claus Gittinger <cg@exept.de>
parents:
7685
diff
changeset
|
4648 |
|con remaining sender nSkipped| |
5755 | 4649 |
|
4650 |
(con := thisContext) isRecursive ifFalse:[ |
|
4651 |
"/ Processor activeProcess usedStackSize < Processor activeProcess maximumStackSize ifTrue:[ |
|
4652 |
"/ "/ mhmh - it hit me, but I am not responsible ... |
|
4653 |
"/ 'Stray recursionInterrupt ...' infoPrintCR. |
|
4654 |
"/ ^ self |
|
4655 |
"/ ]. |
|
10460 | 4656 |
ObjectMemory infoPrinting ifTrue:[ |
4657 |
'Object [info]: recursionInterrupt from:' printCR. |
|
4658 |
con := con sender. |
|
4659 |
remaining := 50. |
|
4660 |
[con notNil and:[remaining > 0]] whileTrue:[ |
|
4661 |
sender := con sender. |
|
4662 |
'| ' print. con fullPrint. |
|
4663 |
||
4664 |
nSkipped := 0. |
|
4665 |
[sender notNil and:[sender sender notNil |
|
4666 |
and:[sender selector == con selector |
|
4667 |
and:[sender sender selector == con selector |
|
4668 |
and:[sender method == con method]]]]] whileTrue:[ |
|
4669 |
nSkipped := nSkipped + 1. |
|
4670 |
con := sender. |
|
4671 |
sender := con sender. |
|
4672 |
]. |
|
4673 |
nSkipped > 0 ifTrue:[ |
|
4674 |
'| ... ***** ' print. nSkipped print. ' recursive contexts skipped *****' printCR. |
|
4675 |
]. |
|
4676 |
con := sender. |
|
4677 |
remaining := remaining - 1 |
|
4678 |
]. |
|
4679 |
]. |
|
4680 |
^ RecursionInterruptSignal raiseSignal |
|
5755 | 4681 |
] |
4682 |
||
6175
e9970db3e02f
recursionInterrupt fixes for win32 (& comment changed)
Claus Gittinger <cg@exept.de>
parents:
6157
diff
changeset
|
4683 |
"Modified: / 10.11.2001 / 15:15:56 / cg" |
5755 | 4684 |
! |
4685 |
||
4686 |
schedulerInterrupt |
|
4687 |
"{ Pragma: +optSpace }" |
|
4688 |
||
4689 |
"scheduler interrupt (supposed to be sent to Processor). |
|
4690 |
If we arrive here, either the Processor does not understand it, |
|
4691 |
or it has been set to nil. In any case, this is a sign of some |
|
4692 |
big trouble. Enter debugger." |
|
4693 |
||
4694 |
self error:'schedulerInterrupt - but no Processor' mayProceed:true |
|
4695 |
! |
|
4696 |
||
4697 |
signalInterrupt:signalNumber |
|
4698 |
"{ Pragma: +optSpace }" |
|
4699 |
||
10460 | 4700 |
"unix signal occured - some signals are handled as Smalltalk Exceptions |
10016 | 4701 |
(SIGPIPE), others (SIGBUS) are rather fatal... |
5755 | 4702 |
In any case, IF a smalltalk-signal has been connected to the OS signal, |
4703 |
that one is raised. |
|
4704 |
Otherwise, a dialog is shown, asking the user on how to handle the |
|
4705 |
signal. |
|
4706 |
TODO: add another argument, giving more detailed signal info (PC, VADDR, |
|
4707 |
exact cause etc.). This helps if segvs occur in primitive code. |
|
4708 |
Currently (temporary kludge), these are passed as global variables." |
|
4709 |
||
6537
7906825ad5c3
Do not allow to proceed in debugger on SIGSEGV
Stefan Vogel <sv@exept.de>
parents:
6533
diff
changeset
|
4710 |
|name here sig fatal titles actions badContext msg pc addr |
6388
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4711 |
action title screen| |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4712 |
|
5755 | 4713 |
"if there has been an ST-signal installed, use it ..." |
4714 |
sig := OperatingSystem operatingSystemSignal:signalNumber. |
|
4715 |
sig notNil ifTrue:[ |
|
10922 | 4716 |
sig raiseSignalWith:signalNumber. |
4717 |
^ self. |
|
5755 | 4718 |
]. |
4719 |
||
4720 |
"/ if handled, raise OSSignalInterruptSignal |
|
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
4721 |
OSSignalInterrupt isHandled ifTrue:[ |
10922 | 4722 |
OSSignalInterrupt raiseRequestWith:signalNumber. |
4723 |
^ self. |
|
10460 | 4724 |
]. |
4725 |
||
4726 |
" |
|
4727 |
special cases |
|
10922 | 4728 |
- SIGPWR: power failure - write a crash image and continue |
4729 |
- SIGHUP: hang up - write a crash image and exit |
|
4730 |
" |
|
4731 |
(signalNumber == OperatingSystem sigPWR) ifTrue:[ |
|
4732 |
SnapshotError ignoreIn:[ObjectMemory writeCrashImage]. |
|
4733 |
^ self. |
|
4734 |
]. |
|
4735 |
(signalNumber == OperatingSystem sigHUP) ifTrue:[ |
|
4736 |
SnapshotError ignoreIn:[ObjectMemory writeCrashImage]. |
|
4737 |
'Object [info]: exit due to hangup signal.' errorPrintCR. |
|
4738 |
Smalltalk exit:1. |
|
7031 | 4739 |
]. |
5856
6d3df9ad361e
save crash image when sigPWR or sigHUP arrives
Claus Gittinger <cg@exept.de>
parents:
5824
diff
changeset
|
4740 |
|
5755 | 4741 |
name := OperatingSystem nameForSignal:signalNumber. |
6388
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4742 |
|
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4743 |
"if there is no screen at all, bring up a mini debugger" |
10460 | 4744 |
(Screen isNil |
6388
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4745 |
or:[(screen := Screen current) isNil |
6778
87e2d95ce8a4
Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents:
6764
diff
changeset
|
4746 |
or:[(screen := Screen default) isNil |
87e2d95ce8a4
Raise #drawingOnClosedDeviceSignal instead of #error
Stefan Vogel <sv@exept.de>
parents:
6764
diff
changeset
|
4747 |
or:[screen isOpen not]]]) ifTrue:[ |
10922 | 4748 |
^ self startMiniDebuggerOrExit:'OS-Signal (' , name, ')'. |
6388
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4749 |
]. |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4750 |
|
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4751 |
"ungrab - in case it happened in a box/popupview |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4752 |
otherwise display stays locked" |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4753 |
screen ungrabPointer; ungrabKeyboard. |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4754 |
|
7031 | 4755 |
here := thisContext. |
4756 |
badContext := here sender. "the context, in which the signal occurred" |
|
4757 |
||
6388
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4758 |
"there is a screen. use it to bring up a box asking for what to do ..." |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4759 |
Screen currentScreenQuerySignal answer:screen do:[ |
10922 | 4760 |
" |
4761 |
SIGBUS, SIGSEGV and SIGILL do not make sense to ignore (i.e. continue) |
|
4762 |
since the system will retry the faulty instruction, which leads to |
|
4763 |
another signal - to avoid frustration, better not offer this option. |
|
4764 |
" |
|
4765 |
fatal := OperatingSystem isFatalSignal:signalNumber. |
|
4766 |
fatal ifTrue:[ |
|
4767 |
(Debugger isNil or:[here isRecursive]) ifTrue:[ |
|
4768 |
'Object [hard error]: signal ' errorPrint. signalNumber errorPrintCR. |
|
4769 |
^ self startMiniDebuggerOrExit:'OS-Signal (' , name, ')'. |
|
4770 |
]. |
|
4771 |
" |
|
4772 |
a hard signal - go into debugger immediately |
|
4773 |
" |
|
4774 |
msg := 'OS-signal: ', name. |
|
4775 |
||
4776 |
"/ the IRQ-PC is passed as low-hi, to avoid the need |
|
4777 |
"/ to allocate a LargeInteger in the VM during signal |
|
4778 |
"/ time. I know, this is ugly. |
|
4779 |
||
4780 |
InterruptPcLow notNil ifTrue:[ |
|
4781 |
pc := InterruptPcLow + (InterruptPcHi bitShift:((SmallInteger maxBits + 1) // 2)). |
|
4782 |
pc ~~ 0 ifTrue:[ |
|
4783 |
msg := msg , ' PC=' , (pc printStringRadix:16) |
|
4784 |
]. |
|
4785 |
]. |
|
4786 |
InterruptAddrLow notNil ifTrue:[ |
|
4787 |
addr := InterruptAddrLow + (InterruptAddrHi bitShift:((SmallInteger maxBits + 1) // 2)). |
|
4788 |
addr ~~ 0 ifTrue:[ |
|
4789 |
msg := msg , ' ADDR=' , (addr printStringRadix:16) |
|
4790 |
]. |
|
4791 |
]. |
|
4792 |
Debugger enter:here withMessage:msg mayProceed:false. |
|
4793 |
"unreachable" |
|
4794 |
^ nil. |
|
4795 |
]. |
|
4796 |
||
4797 |
"if possible, open an option box asking the user what do. |
|
4798 |
Otherwise, start a debugger" |
|
4799 |
Dialog notNil ifTrue:[ |
|
4800 |
titles := #('save crash image' 'dump core' 'exit ST/X' 'debug'). |
|
4801 |
actions := #(save core exit debug). |
|
4802 |
||
4803 |
action := nil. |
|
4804 |
title := 'OS Signal caught (' , name, ')'. |
|
4805 |
title := (title , '\[in ST-process: ' , Processor activeProcess nameOrId ,']') withCRs. |
|
4806 |
||
4807 |
"/ if cought while in the scheduler or event dispatcher, |
|
4808 |
"/ a modal dialog is not possible ... |
|
4809 |
"/ (therefore, abort & return does not makes sense) |
|
4810 |
||
4811 |
Processor activeProcess isSystemProcess ifFalse:[ |
|
4812 |
titles := #('abort') , titles. |
|
4813 |
actions := #(abort), actions. |
|
4814 |
||
4815 |
badContext canReturn ifTrue:[ |
|
4816 |
titles := #('return') , titles. |
|
4817 |
actions := #(return), actions. |
|
4818 |
]. |
|
4819 |
]. |
|
4820 |
||
4821 |
fatal ifFalse:[ |
|
4822 |
titles := titles, #('ignore'). |
|
4823 |
actions := actions , #(ignore). |
|
4824 |
]. |
|
4825 |
action := Dialog choose:title |
|
4826 |
labels:titles |
|
4827 |
values:actions |
|
4828 |
default:(fatal ifTrue:[nil] ifFalse:[#ignore]). |
|
4829 |
||
4830 |
"Dialog may fail (if system process), default action is debug" |
|
4831 |
action isEmptyOrNil ifTrue:[action := #debug]. |
|
4832 |
] ifFalse:[ |
|
4833 |
action := #debug. |
|
4834 |
]. |
|
4835 |
||
4836 |
action == #save ifTrue:[ |
|
4837 |
ObjectMemory writeCrashImage |
|
4838 |
]. |
|
4839 |
action == #core ifTrue:[ |
|
4840 |
Smalltalk fatalAbort |
|
4841 |
]. |
|
4842 |
action == #exit ifTrue:[ |
|
4843 |
Smalltalk exit |
|
4844 |
]. |
|
4845 |
action == #return ifTrue:[ |
|
4846 |
badContext return |
|
4847 |
]. |
|
4848 |
action == #abort ifTrue:[ |
|
4849 |
AbortOperationRequest raise. |
|
4850 |
]. |
|
4851 |
||
4852 |
action == #debug ifTrue:[ |
|
4853 |
Debugger isNil ifTrue:[ |
|
4854 |
^ self startMiniDebuggerOrExit:'OS-Signal (' , name, ')'. |
|
4855 |
]. |
|
4856 |
Debugger enter:here withMessage:('OS-Signal ', name) mayProceed:true. |
|
4857 |
]. |
|
4858 |
"action == #ignore" |
|
6388
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4859 |
]. |
10016 | 4860 |
|
4861 |
"Modified: / 29-09-2006 / 12:27:20 / cg" |
|
5755 | 4862 |
! |
4863 |
||
4864 |
spyInterrupt |
|
4865 |
"{ Pragma: +optSpace }" |
|
4866 |
||
4867 |
"spy interrupt and no handler - enter debugger" |
|
4868 |
||
4869 |
self error:'spy Interrupt - but no handler' mayProceed:true |
|
4870 |
! |
|
4871 |
||
6388
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4872 |
startMiniDebuggerOrExit:text |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4873 |
"some critical condition happened. |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4874 |
Start a mini debugger or exit if none is present" |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4875 |
|
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4876 |
MiniDebugger isNil ifTrue:[ |
10460 | 4877 |
"a system without debugging facilities (i.e. a standalone system) |
4878 |
output a message and exit." |
|
4879 |
('Object [error]: exit due to ', text, ' - and no debugger.') errorPrintCR. |
|
4880 |
OperatingSystem exit:99. |
|
6388
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4881 |
]. |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4882 |
MiniDebugger enterWithMessage:text mayProceed:true. |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4883 |
! |
41396e0cc89f
Fix #signalInterrupt: for multi-display and headless.
Stefan Vogel <sv@exept.de>
parents:
6328
diff
changeset
|
4884 |
|
5755 | 4885 |
timerInterrupt |
4886 |
"{ Pragma: +optSpace }" |
|
4887 |
||
4888 |
"timer interrupt and no handler - enter debugger" |
|
4889 |
||
4890 |
self error:'timer Interrupt - but no handler' mayProceed:true |
|
4891 |
! |
|
4892 |
||
4893 |
userInterrupt |
|
4894 |
"{ Pragma: +optSpace }" |
|
4895 |
||
4896 |
"user (^c) interrupt. |
|
4897 |
This is typically sent by the VM, when a ctrl-C is typed at the |
|
4898 |
controlling tty (i.e. in the xterm)." |
|
4899 |
||
6466 | 4900 |
UserInterruptSignal raiseRequest |
5755 | 4901 |
! |
4902 |
||
4903 |
userInterruptIn:aContext |
|
4904 |
"{ Pragma: +optSpace }" |
|
4905 |
||
4906 |
"user (^c) interrupt - enter debugger, but show aContext |
|
10460 | 4907 |
as top-context. |
4908 |
This is used to hide any intermediate scheduler contexts, |
|
5755 | 4909 |
in case of an interrupted process. Typically, this is sent by |
4910 |
the WindowGroup, when a keyboardEvent for the ctrl-C key is |
|
4911 |
processed." |
|
4912 |
||
4913 |
<context: #return> |
|
4914 |
||
4915 |
UserInterruptSignal raiseRequestWith:nil errorString:nil in:aContext |
|
4916 |
||
4917 |
"Created: / 18.10.1996 / 20:46:04 / cg" |
|
4918 |
"Modified: / 20.10.1996 / 13:06:38 / cg" |
|
4919 |
"Modified: / 26.7.1999 / 10:58:49 / stefan" |
|
4920 |
! ! |
|
4921 |
||
4922 |
!Object methodsFor:'message sending'! |
|
4923 |
||
4924 |
perform:aSelector |
|
4925 |
"send the message aSelector to the receiver" |
|
4926 |
||
4927 |
%{ |
|
4928 |
REGISTER OBJ sel = aSelector; |
|
4929 |
||
4930 |
if (InterruptPending == nil) { |
|
10460 | 4931 |
struct inlineCache *pIlc; |
4932 |
static struct inlineCache ilc_0 = __ILCPERF0(@line); |
|
4933 |
static struct inlineCache ilc_1 = __ILCPERF0(@line); |
|
4934 |
static struct inlineCache ilc_2 = __ILCPERF0(@line); |
|
4935 |
static struct inlineCache ilc_3 = __ILCPERF0(@line); |
|
4936 |
static struct inlineCache ilc_4 = __ILCPERF0(@line); |
|
4937 |
static OBJ last_0 = nil; |
|
4938 |
static OBJ last_1 = nil; |
|
4939 |
static OBJ last_2 = nil; |
|
4940 |
static OBJ last_3 = nil; |
|
4941 |
static OBJ last_4 = nil; |
|
4942 |
static flip = 0; |
|
4943 |
||
4944 |
if (sel == last_0) { |
|
4945 |
pIlc = &ilc_0; |
|
4946 |
} else if (sel == last_1) { |
|
4947 |
pIlc = &ilc_1; |
|
4948 |
} else if (sel == last_2) { |
|
4949 |
pIlc = &ilc_2; |
|
4950 |
} else if (sel == last_3) { |
|
4951 |
pIlc = &ilc_3; |
|
4952 |
} else if (sel == last_4) { |
|
4953 |
pIlc = &ilc_4; |
|
4954 |
} else { |
|
4955 |
if (flip == 0) { |
|
4956 |
pIlc = &ilc_0; |
|
4957 |
flip = 1; |
|
4958 |
last_0 = sel; |
|
4959 |
} else if (flip == 1) { |
|
4960 |
pIlc = &ilc_1; |
|
4961 |
flip = 2; |
|
4962 |
last_1 = sel; |
|
4963 |
} else if (flip == 2) { |
|
4964 |
pIlc = &ilc_2; |
|
4965 |
flip = 3; |
|
4966 |
last_2 = sel; |
|
4967 |
} else if (flip == 3) { |
|
4968 |
pIlc = &ilc_3; |
|
4969 |
flip = 4; |
|
4970 |
last_3 = sel; |
|
4971 |
} else { |
|
4972 |
pIlc = &ilc_4; |
|
4973 |
flip = 0; |
|
4974 |
last_4 = sel; |
|
4975 |
} |
|
4976 |
pIlc->ilc_func = __SEND0ADDR__; |
|
4977 |
if (pIlc->ilc_poly) { |
|
4978 |
__flushPolyCache(pIlc->ilc_poly); |
|
4979 |
pIlc->ilc_poly = 0; |
|
4980 |
} |
|
4981 |
} |
|
4982 |
RETURN ( (*(pIlc->ilc_func))(self, sel, nil, pIlc) ); |
|
5755 | 4983 |
} else { |
10460 | 4984 |
static struct inlineCache ilc0 = __DUMMYILCSELF0(@line+1); |
4985 |
RETURN (_SEND0(self, aSelector, nil, &ilc0)); |
|
5755 | 4986 |
} |
4987 |
%}. |
|
4988 |
^ self perform:aSelector withArguments:#() |
|
4989 |
! |
|
4990 |
||
4991 |
perform:aSelector inClass:aClass withArguments:argArray |
|
10460 | 4992 |
"send the message aSelector with all args taken from argArray |
5755 | 4993 |
to the receiver as a super-send message. |
4994 |
This is actually more flexible than the normal super-send, since it allows |
|
4995 |
to execute a method in ANY superclass of the receiver (not just the |
|
4996 |
immediate superclass). |
|
10460 | 4997 |
Thus, it is (theoretically) possible to do |
4998 |
'5 perform:#< inClass:Magnitude withArguments:#(6)' |
|
5755 | 4999 |
and evaluate Magnitudes compare method even if there was one in Number. |
5000 |
This method is used by the interpreter to evaluate super sends |
|
5001 |
and could be used for very special behavior (language extension ?). |
|
5002 |
||
5003 |
WARNING: this is an ST/X feature - probably not found in other smalltalks." |
|
5004 |
||
5769
8f874be55bc9
lookup-class check in #perform:inClass was too strong.
Claus Gittinger <cg@exept.de>
parents:
5755
diff
changeset
|
5005 |
|numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 myClass| |
5755 | 5006 |
|
5007 |
" |
|
5008 |
check, if aClass is really a superclass of the receiver |
|
5009 |
" |
|
5769
8f874be55bc9
lookup-class check in #perform:inClass was too strong.
Claus Gittinger <cg@exept.de>
parents:
5755
diff
changeset
|
5010 |
myClass := self class. |
8f874be55bc9
lookup-class check in #perform:inClass was too strong.
Claus Gittinger <cg@exept.de>
parents:
5755
diff
changeset
|
5011 |
(myClass == aClass or:[myClass isSubclassOf:aClass]) ifFalse:[ |
10460 | 5012 |
self error:'lookup-class argument is not a superclass of the receiver'. |
5013 |
^ nil |
|
5755 | 5014 |
]. |
5015 |
%{ |
|
5016 |
REGISTER OBJ *argP; |
|
5017 |
int nargs, i; |
|
5018 |
||
8934 | 5019 |
if (__isArrayLike(argArray)) { |
10460 | 5020 |
nargs = __arraySize(argArray); |
5021 |
argP = __arrayVal(argArray); |
|
5755 | 5022 |
} else { |
10460 | 5023 |
if (__isNonNilObject(argArray)) { |
5024 |
static struct inlineCache ilcSize = __ILC0(@line+1); |
|
5025 |
numberOfArgs = (*ilcSize.ilc_func)(argArray, @symbol(size), nil, &ilcSize); |
|
5026 |
if (!__isSmallInteger(numberOfArgs)) |
|
5027 |
goto bad; |
|
5028 |
nargs = __intVal(numberOfArgs); |
|
5029 |
argP = (OBJ *)(&a1); |
|
5030 |
for (i=1; i <= nargs; i++) { |
|
5031 |
*argP++ = __AT_(argArray, __mkSmallInteger(i)); |
|
5032 |
} |
|
5033 |
argP = (OBJ *)(&a1); |
|
5034 |
} else { |
|
5035 |
nargs = 0; |
|
5036 |
} |
|
5755 | 5037 |
} |
5038 |
switch (nargs) { |
|
10460 | 5039 |
case 0: |
5040 |
{ |
|
5041 |
static struct inlineCache ilc0 = __DUMMYILCSELF0(@line+1); |
|
5042 |
RETURN ( _SEND0(self, aSelector, aClass, &ilc0)); |
|
5043 |
} |
|
5044 |
||
5045 |
case 1: |
|
5046 |
{ |
|
5047 |
static struct inlineCache ilc1 = __DUMMYILCSELF1(@line+1); |
|
5048 |
RETURN ( _SEND1(self, aSelector, aClass, &ilc1, argP[0])); |
|
5049 |
} |
|
5050 |
||
5051 |
case 2: |
|
5052 |
{ |
|
5053 |
static struct inlineCache ilc2 = __DUMMYILCSELF2(@line+1); |
|
5054 |
RETURN ( _SEND2(self, aSelector, aClass, &ilc2, argP[0], argP[1])); |
|
5055 |
} |
|
5056 |
||
5057 |
case 3: |
|
5058 |
{ |
|
5059 |
static struct inlineCache ilc3 = __DUMMYILCSELF3(@line+1); |
|
5060 |
RETURN ( _SEND3(self, aSelector, aClass, &ilc3, |
|
5061 |
argP[0], argP[1], argP[2])); |
|
5062 |
} |
|
5063 |
||
5064 |
case 4: |
|
5065 |
{ |
|
5066 |
static struct inlineCache ilc4 = __DUMMYILCSELF4(@line+1); |
|
5067 |
RETURN ( _SEND4(self, aSelector, aClass, &ilc4, |
|
5068 |
argP[0], argP[1], argP[2], argP[3])); |
|
5069 |
} |
|
5070 |
||
5071 |
case 5: |
|
5072 |
{ |
|
5073 |
static struct inlineCache ilc5 = __DUMMYILCSELF5(@line+1); |
|
5074 |
RETURN ( _SEND5(self, aSelector, aClass, &ilc5, |
|
5075 |
argP[0], argP[1], argP[2], argP[3], argP[4])); |
|
5076 |
} |
|
5077 |
||
5078 |
case 6: |
|
5079 |
{ |
|
5080 |
static struct inlineCache ilc6 = __DUMMYILCSELF6(@line+1); |
|
5081 |
RETURN ( _SEND6(self, aSelector, aClass, &ilc6, |
|
5082 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5])); |
|
5083 |
} |
|
5084 |
||
5085 |
case 7: |
|
5086 |
{ |
|
5087 |
static struct inlineCache ilc7 = __DUMMYILCSELF7(@line+1); |
|
5088 |
RETURN ( _SEND7(self, aSelector, aClass, &ilc7, |
|
5089 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5090 |
argP[6])); |
|
5091 |
} |
|
5092 |
||
5093 |
case 8: |
|
5094 |
{ |
|
5095 |
static struct inlineCache ilc8 = __DUMMYILCSELF8(@line+1); |
|
5096 |
RETURN ( _SEND8(self, aSelector, aClass, &ilc8, |
|
5097 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5098 |
argP[6], argP[7])); |
|
5099 |
} |
|
5100 |
||
5101 |
case 9: |
|
5102 |
{ |
|
5103 |
static struct inlineCache ilc9 = __DUMMYILCSELF9(@line+1); |
|
5104 |
RETURN ( _SEND9(self, aSelector, aClass, &ilc9, |
|
5105 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5106 |
argP[6], argP[7], argP[8])); |
|
5107 |
} |
|
5108 |
||
5109 |
case 10: |
|
5110 |
{ |
|
5111 |
static struct inlineCache ilc10 = __DUMMYILCSELF10(@line+1); |
|
5112 |
RETURN ( _SEND10(self, aSelector, aClass, &ilc10, |
|
5113 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5114 |
argP[6], argP[7], argP[8], argP[9])); |
|
5115 |
} |
|
5116 |
||
5117 |
case 11: |
|
5118 |
{ |
|
5119 |
static struct inlineCache ilc11 = __DUMMYILCSELF11(@line+1); |
|
5120 |
RETURN ( _SEND11(self, aSelector, aClass, &ilc11, |
|
5121 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5122 |
argP[6], argP[7], argP[8], argP[9], argP[10])); |
|
5123 |
} |
|
5124 |
||
5125 |
case 12: |
|
5126 |
{ |
|
5127 |
static struct inlineCache ilc12 = __DUMMYILCSELF12(@line+1); |
|
5128 |
RETURN ( _SEND12(self, aSelector, aClass, &ilc12, |
|
5129 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5130 |
argP[6], argP[7], argP[8], argP[9], argP[10], |
|
5131 |
argP[11])); |
|
5132 |
} |
|
5133 |
||
5134 |
case 13: |
|
5135 |
{ |
|
5136 |
static struct inlineCache ilc13 = __DUMMYILCSELF13(@line+1); |
|
5137 |
RETURN ( _SEND13(self, aSelector, aClass, &ilc13, |
|
5138 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5139 |
argP[6], argP[7], argP[8], argP[9], argP[10], |
|
5140 |
argP[11], argP[12])); |
|
5141 |
} |
|
5142 |
||
5143 |
case 14: |
|
5144 |
{ |
|
5145 |
static struct inlineCache ilc14 = __DUMMYILCSELF14(@line+1); |
|
5146 |
RETURN ( _SEND14(self, aSelector, aClass, &ilc14, |
|
5147 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5148 |
argP[6], argP[7], argP[8], argP[9], argP[10], |
|
5149 |
argP[11], argP[12], argP[13])); |
|
5150 |
} |
|
5151 |
||
5152 |
case 15: |
|
5153 |
{ |
|
5154 |
static struct inlineCache ilc15 = __DUMMYILCSELF15(@line+1); |
|
5155 |
RETURN ( _SEND15(self, aSelector, aClass, &ilc15, |
|
5156 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5157 |
argP[6], argP[7], argP[8], argP[9], argP[10], |
|
5158 |
argP[11], argP[12], argP[13], argP[14])); |
|
5159 |
} |
|
5755 | 5160 |
|
5161 |
#ifdef _SEND16 |
|
10460 | 5162 |
case 16: |
5163 |
{ |
|
5164 |
static struct inlineCache ilc16 = __DUMMYILCSELF16(@line+1); |
|
5165 |
RETURN ( _SEND16(self, aSelector, aClass, &ilc15, |
|
5166 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5167 |
argP[6], argP[7], argP[8], argP[9], argP[10], |
|
5168 |
argP[11], argP[12], argP[13], argP[14], argP[15])); |
|
5169 |
} |
|
5755 | 5170 |
#endif |
5171 |
#ifdef _SEND17 |
|
10460 | 5172 |
case 17: |
5173 |
{ |
|
5174 |
static struct inlineCache ilc17 = __DUMMYILCSELF17(@line+1); |
|
5175 |
RETURN ( _SEND17(self, aSelector, aClass, &ilc15, |
|
5176 |
argP[0], argP[1], argP[2], argP[3], argP[4], argP[5], |
|
5177 |
argP[6], argP[7], argP[8], argP[9], argP[10], |
|
5178 |
argP[11], argP[12], argP[13], argP[14], argP[15], argP[16])); |
|
5179 |
} |
|
5755 | 5180 |
#endif |
5181 |
||
5182 |
||
5183 |
} |
|
5184 |
bad:; |
|
5185 |
%}. |
|
5186 |
"/ arrive here, if bad number of arguments (too many) |
|
5187 |
"/ ST/X (currently) only allows up to 15 method arguments |
|
5188 |
||
5189 |
^ self primitiveFailed |
|
5190 |
! |
|
5191 |
||
5192 |
perform:aSelector with:arg |
|
5193 |
"send the one-arg-message aSelector to the receiver" |
|
5194 |
||
5195 |
%{ |
|
5196 |
REGISTER OBJ sel = aSelector; |
|
5197 |
||
5198 |
if (InterruptPending == nil) { |
|
10460 | 5199 |
struct inlineCache *pIlc; |
5200 |
static struct inlineCache ilc_0 = __ILCPERF1(@line); |
|
5201 |
static struct inlineCache ilc_1 = __ILCPERF1(@line); |
|
5202 |
static struct inlineCache ilc_2 = __ILCPERF1(@line); |
|
5203 |
static struct inlineCache ilc_3 = __ILCPERF1(@line); |
|
5204 |
static struct inlineCache ilc_4 = __ILCPERF1(@line); |
|
5205 |
static OBJ last_0 = nil; |
|
5206 |
static OBJ last_1 = nil; |
|
5207 |
static OBJ last_2 = nil; |
|
5208 |
static OBJ last_3 = nil; |
|
5209 |
static OBJ last_4 = nil; |
|
5210 |
static flip = 0; |
|
5211 |
||
5212 |
if (sel == last_0) { |
|
5213 |
pIlc = &ilc_0; |
|
5214 |
} else if (sel == last_1) { |
|
5215 |
pIlc = &ilc_1; |
|
5216 |
} else if (sel == last_2) { |
|
5217 |
pIlc = &ilc_2; |
|
5218 |
} else if (sel == last_3) { |
|
5219 |
pIlc = &ilc_3; |
|
5220 |
} else if (sel == last_4) { |
|
5221 |
pIlc = &ilc_4; |
|
5222 |
} else { |
|
5223 |
if (flip == 0) { |
|
5224 |
pIlc = &ilc_0; |
|
5225 |
flip = 1; |
|
5226 |
last_0 = sel; |
|
5227 |
} else if (flip == 1) { |
|
5228 |
pIlc = &ilc_1; |
|
5229 |
flip = 2; |
|
5230 |
last_1 = sel; |
|
5231 |
} else if (flip == 2) { |
|
5232 |
pIlc = &ilc_2; |
|
5233 |
flip = 3; |
|
5234 |
last_2 = sel; |
|
5235 |
} else if (flip == 3) { |
|
5236 |
pIlc = &ilc_3; |
|
5237 |
flip = 4; |
|
5238 |
last_3 = sel; |
|
5239 |
} else { |
|
5240 |
pIlc = &ilc_4; |
|
5241 |
flip = 0; |
|
5242 |
last_4 = sel; |
|
5243 |
} |
|
5244 |
pIlc->ilc_func = __SEND1ADDR__; |
|
5245 |
if (pIlc->ilc_poly) { |
|
5246 |
__flushPolyCache(pIlc->ilc_poly); |
|
5247 |
pIlc->ilc_poly = 0; |
|
5248 |
} |
|
5249 |
} |
|
5250 |
RETURN ( (*(pIlc->ilc_func))(self, sel, nil, pIlc, arg) ); |
|
5755 | 5251 |
} else { |
10460 | 5252 |
static struct inlineCache ilc1 = __DUMMYILCSELF1(@line+1); |
5253 |
RETURN (_SEND1(self, aSelector, nil, &ilc1, arg)); |
|
5755 | 5254 |
} |
5255 |
%}. |
|
5256 |
^ self perform:aSelector withArguments:(Array with:arg) |
|
5257 |
||
5258 |
! |
|
5259 |
||
5260 |
perform:aSelector with:arg1 with:arg2 |
|
5261 |
"send the two-arg-message aSelector to the receiver" |
|
5262 |
||
5263 |
%{ |
|
5264 |
struct inlineCache *pIlc; |
|
5265 |
||
5266 |
if (InterruptPending == nil) { |
|
10460 | 5267 |
static struct inlineCache ilc_0 = __ILCPERF2(@line); |
5268 |
static struct inlineCache ilc_1 = __ILCPERF2(@line); |
|
5269 |
static OBJ last_0 = nil; |
|
5270 |
static OBJ last_1 = nil; |
|
5271 |
static flip = 0; |
|
5272 |
||
5273 |
if (aSelector == last_0) { |
|
5274 |
pIlc = &ilc_0; |
|
5275 |
} else if (aSelector == last_1) { |
|
5276 |
pIlc = &ilc_1; |
|
5277 |
} else { |
|
5278 |
if (flip == 0) { |
|
5279 |
pIlc = &ilc_0; |
|
5280 |
flip = 1; |
|
5281 |
last_0 = aSelector; |
|
5282 |
} else { |
|
5283 |
pIlc = &ilc_1; |
|
5284 |
flip = 0; |
|
5285 |
last_1 = aSelector; |
|
5286 |
} |
|
5287 |
pIlc->ilc_func = __SEND2ADDR__; |
|
5288 |
if (pIlc->ilc_poly) { |
|
5289 |
__flushPolyCache(pIlc->ilc_poly); |
|
5290 |
pIlc->ilc_poly = 0; |
|
5291 |
} |
|
5292 |
} |
|
5293 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, nil, pIlc, arg1, arg2) ); |
|
5755 | 5294 |
} else { |
10460 | 5295 |
static struct inlineCache ilc2 = __DUMMYILCSELF2(@line+1); |
5296 |
RETURN (_SEND2(self, aSelector, nil, &ilc2, arg1, arg2)); |
|
5755 | 5297 |
} |
5298 |
%}. |
|
5299 |
^ self perform:aSelector withArguments:(Array with:arg1 with:arg2) |
|
5300 |
||
5301 |
! |
|
5302 |
||
5303 |
perform:aSelector with:arg1 with:arg2 with:arg3 |
|
5304 |
"send the three-arg-message aSelector to the receiver" |
|
5305 |
||
5306 |
%{ |
|
5307 |
struct inlineCache *pIlc; |
|
5308 |
static struct inlineCache ilc_0 = __ILCPERF3(@line); |
|
5309 |
static struct inlineCache ilc_1 = __ILCPERF3(@line); |
|
5310 |
static OBJ last_0 = nil; |
|
5311 |
static OBJ last_1 = nil; |
|
5312 |
static flip = 0; |
|
5313 |
||
5314 |
if (InterruptPending == nil) { |
|
10460 | 5315 |
if (aSelector != last_0) { |
5316 |
if (aSelector != last_1) { |
|
5317 |
if (flip) { |
|
5318 |
pIlc = &ilc_0; |
|
5319 |
flip = 0; |
|
5320 |
last_0 = aSelector; |
|
5321 |
} else { |
|
5322 |
pIlc = &ilc_1; |
|
5323 |
flip = 1; |
|
5324 |
last_1 = aSelector; |
|
5325 |
} |
|
5326 |
pIlc->ilc_func = __SEND3ADDR__; |
|
5327 |
if (pIlc->ilc_poly) { |
|
5328 |
__flushPolyCache(pIlc->ilc_poly); |
|
5329 |
pIlc->ilc_poly = 0; |
|
5330 |
} |
|
5331 |
} else { |
|
5332 |
pIlc = &ilc_1; |
|
5333 |
} |
|
5334 |
} else { |
|
5335 |
pIlc = &ilc_0; |
|
5336 |
} |
|
5337 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, nil, pIlc, arg1, arg2, arg3) ); |
|
5755 | 5338 |
} else { |
10460 | 5339 |
static struct inlineCache ilc3 = __DUMMYILCSELF3(@line+1); |
5340 |
RETURN (_SEND3(self, aSelector, nil, &ilc3, arg1, arg2, arg3)); |
|
5755 | 5341 |
} |
5342 |
%}. |
|
5343 |
^ self perform:aSelector withArguments:(Array with:arg1 with:arg2 with:arg3) |
|
5344 |
||
5345 |
! |
|
5346 |
||
5347 |
perform:aSelector with:arg1 with:arg2 with:arg3 with:arg4 |
|
5348 |
"send the four-arg-message aSelector to the receiver" |
|
5349 |
||
5350 |
%{ |
|
5351 |
struct inlineCache *pIlc; |
|
5352 |
static struct inlineCache ilc_0 = __ILCPERF4(@line); |
|
5353 |
static struct inlineCache ilc_1 = __ILCPERF4(@line); |
|
5354 |
static OBJ last_0 = nil; |
|
5355 |
static OBJ last_1 = nil; |
|
5356 |
static flip = 0; |
|
5357 |
||
5358 |
if (InterruptPending == nil) { |
|
10460 | 5359 |
if (aSelector != last_0) { |
5360 |
if (aSelector != last_1) { |
|
5361 |
if (flip) { |
|
5362 |
pIlc = &ilc_0; |
|
5363 |
flip = 0; |
|
5364 |
last_0 = aSelector; |
|
5365 |
} else { |
|
5366 |
pIlc = &ilc_1; |
|
5367 |
flip = 1; |
|
5368 |
last_1 = aSelector; |
|
5369 |
} |
|
5370 |
pIlc->ilc_func = __SEND4ADDR__; |
|
5371 |
if (pIlc->ilc_poly) { |
|
5372 |
__flushPolyCache(pIlc->ilc_poly); |
|
5373 |
pIlc->ilc_poly = 0; |
|
5374 |
} |
|
5375 |
} else { |
|
5376 |
pIlc = &ilc_1; |
|
5377 |
} |
|
5378 |
} else { |
|
5379 |
pIlc = &ilc_0; |
|
5380 |
} |
|
5381 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, nil, pIlc, |
|
5382 |
arg1, arg2, arg3, arg4) ); |
|
5755 | 5383 |
} else { |
10460 | 5384 |
static struct inlineCache ilc4 = __DUMMYILCSELF4(@line+1); |
5385 |
RETURN (_SEND4(self, aSelector, nil, &ilc4, |
|
5386 |
arg1, arg2, arg3, arg4)); |
|
5755 | 5387 |
} |
5388 |
%}. |
|
5389 |
^ self perform:aSelector withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
|
5390 |
||
5391 |
! |
|
5392 |
||
5393 |
perform:aSelector with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 |
|
5394 |
"send the five-arg-message aSelector to the receiver" |
|
5395 |
||
5396 |
%{ |
|
5397 |
struct inlineCache *pIlc; |
|
5398 |
static struct inlineCache ilc_0 = __ILCPERF5(@line); |
|
5399 |
static struct inlineCache ilc_1 = __ILCPERF5(@line); |
|
5400 |
static OBJ last_0 = nil; |
|
5401 |
static OBJ last_1 = nil; |
|
5402 |
static flip = 0; |
|
5403 |
||
5404 |
if (InterruptPending == nil) { |
|
10460 | 5405 |
if (aSelector != last_0) { |
5406 |
if (aSelector != last_1) { |
|
5407 |
if (flip) { |
|
5408 |
pIlc = &ilc_0; |
|
5409 |
flip = 0; |
|
5410 |
last_0 = aSelector; |
|
5411 |
} else { |
|
5412 |
pIlc = &ilc_1; |
|
5413 |
flip = 1; |
|
5414 |
last_1 = aSelector; |
|
5415 |
} |
|
5416 |
pIlc->ilc_func = __SEND5ADDR__; |
|
5417 |
if (pIlc->ilc_poly) { |
|
5418 |
__flushPolyCache(pIlc->ilc_poly); |
|
5419 |
pIlc->ilc_poly = 0; |
|
5420 |
} |
|
5421 |
} else { |
|
5422 |
pIlc = &ilc_1; |
|
5423 |
} |
|
5424 |
} else { |
|
5425 |
pIlc = &ilc_0; |
|
5426 |
} |
|
5427 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, nil, pIlc, |
|
5428 |
arg1, arg2, arg3, arg4, arg5) ); |
|
5755 | 5429 |
} else { |
10460 | 5430 |
static struct inlineCache ilc5 = __DUMMYILCSELF5(@line+1); |
5431 |
RETURN (_SEND5(self, aSelector, nil, &ilc5, |
|
5432 |
arg1, arg2, arg3, arg4, arg5)); |
|
5755 | 5433 |
} |
5434 |
%}. |
|
5435 |
^ self perform:aSelector withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4 |
|
10460 | 5436 |
with:arg5) |
5755 | 5437 |
|
5438 |
! |
|
5439 |
||
5440 |
perform:aSelector with:arg1 with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 |
|
5441 |
"send the six-arg-message aSelector to the receiver" |
|
5442 |
||
5443 |
%{ |
|
5444 |
struct inlineCache *pIlc; |
|
5445 |
static struct inlineCache ilc_0 = __ILCPERF6(@line); |
|
5446 |
static struct inlineCache ilc_1 = __ILCPERF6(@line); |
|
5447 |
static OBJ last_0 = nil; |
|
5448 |
static OBJ last_1 = nil; |
|
5449 |
static flip = 0; |
|
5450 |
||
5451 |
if (InterruptPending == nil) { |
|
10460 | 5452 |
if (aSelector != last_0) { |
5453 |
if (aSelector != last_1) { |
|
5454 |
if (flip) { |
|
5455 |
pIlc = &ilc_0; |
|
5456 |
flip = 0; |
|
5457 |
last_0 = aSelector; |
|
5458 |
} else { |
|
5459 |
pIlc = &ilc_1; |
|
5460 |
flip = 1; |
|
5461 |
last_1 = aSelector; |
|
5462 |
} |
|
5463 |
pIlc->ilc_func = __SEND6ADDR__; |
|
5464 |
if (pIlc->ilc_poly) { |
|
5465 |
__flushPolyCache(pIlc->ilc_poly); |
|
5466 |
pIlc->ilc_poly = 0; |
|
5467 |
} |
|
5468 |
} else { |
|
5469 |
pIlc = &ilc_1; |
|
5470 |
} |
|
5471 |
} else { |
|
5472 |
pIlc = &ilc_0; |
|
5473 |
} |
|
5474 |
||
5475 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, nil, pIlc, |
|
5476 |
arg1, arg2, arg3, arg4, arg5, arg6) ); |
|
5755 | 5477 |
} else { |
10460 | 5478 |
static struct inlineCache ilc6 = __DUMMYILCSELF6(@line+1); |
5479 |
RETURN (_SEND6(self, aSelector, nil, &ilc6, |
|
5480 |
arg1, arg2, arg3, arg4, arg5, arg6)); |
|
5755 | 5481 |
} |
5482 |
%}. |
|
5483 |
^ self perform:aSelector withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4 |
|
10460 | 5484 |
with:arg5 with:arg6) |
5755 | 5485 |
|
5486 |
! |
|
5487 |
||
5488 |
perform:aSelector withArguments:argArray |
|
10460 | 5489 |
"send the message aSelector with all args taken from argArray |
5755 | 5490 |
to the receiver." |
5491 |
||
5492 |
|numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
|
5493 |
||
5494 |
%{ |
|
5495 |
REGISTER OBJ *argP; |
|
5496 |
int nargs; |
|
5497 |
OBJ l; |
|
5498 |
||
8934 | 5499 |
if (__isArrayLike(argArray)) { |
10460 | 5500 |
nargs = __arraySize(argArray); |
5501 |
argP = __arrayVal(argArray); |
|
5755 | 5502 |
} else { |
10460 | 5503 |
if (__isNonNilObject(argArray)) { |
5504 |
static struct inlineCache ilcSize = __ILC0(@line); |
|
5505 |
int i; |
|
5506 |
||
5507 |
numberOfArgs = (*ilcSize.ilc_func)(argArray, @symbol(size), nil, &ilcSize); |
|
5508 |
if (!__isSmallInteger(numberOfArgs)) |
|
5509 |
goto bad; |
|
5510 |
nargs = __intVal(numberOfArgs); |
|
5511 |
argP = (OBJ *)(&a1); |
|
5512 |
for (i=1; i <= nargs; i++) { |
|
5513 |
*argP++ = __AT_(argArray, __mkSmallInteger(i)); |
|
5514 |
} |
|
5515 |
argP = (OBJ *)(&a1); |
|
5516 |
} else { |
|
5517 |
nargs = 0; |
|
5518 |
} |
|
5755 | 5519 |
} |
5520 |
switch (nargs) { |
|
10460 | 5521 |
case 0: |
5522 |
if (InterruptPending == nil) { |
|
5523 |
static OBJ last0_0 = nil; static struct inlineCache ilc0_0 = __ILCPERF0(@line); |
|
5524 |
static OBJ last0_1 = nil; static struct inlineCache ilc0_1 = __ILCPERF0(@line); |
|
5525 |
static OBJ last0_2 = nil; static struct inlineCache ilc0_2 = __ILCPERF0(@line); |
|
5526 |
static OBJ last0_3 = nil; static struct inlineCache ilc0_3 = __ILCPERF0(@line); |
|
5527 |
static int flip0 = 0; |
|
5528 |
struct inlineCache *pIlc; |
|
5529 |
||
5530 |
if (aSelector == last0_0) { |
|
5531 |
pIlc = &ilc0_0; |
|
5532 |
} else if (aSelector == last0_1) { |
|
5533 |
pIlc = &ilc0_1; |
|
5534 |
} else if (aSelector == last0_2) { |
|
5535 |
pIlc = &ilc0_2; |
|
5536 |
} else if (aSelector == last0_3) { |
|
5537 |
pIlc = &ilc0_3; |
|
5538 |
} else { |
|
5539 |
if (flip0 == 0) { |
|
5540 |
pIlc = &ilc0_0; |
|
5541 |
flip0 = 1; |
|
5542 |
last0_0 = aSelector; |
|
5543 |
} else if (flip0 == 1) { |
|
5544 |
pIlc = &ilc0_1; |
|
5545 |
flip0 = 2; |
|
5546 |
last0_1 = aSelector; |
|
5547 |
} else if (flip0 == 2) { |
|
5548 |
pIlc = &ilc0_2; |
|
5549 |
flip0 = 3; |
|
5550 |
last0_2 = aSelector; |
|
5551 |
} else { |
|
5552 |
pIlc = &ilc0_3; |
|
5553 |
flip0 = 0; |
|
5554 |
last0_3 = aSelector; |
|
5555 |
} |
|
5556 |
||
5557 |
pIlc->ilc_func = __SEND0ADDR__; |
|
5558 |
if (pIlc->ilc_poly) { |
|
5559 |
__flushPolyCache(pIlc->ilc_poly); |
|
5560 |
pIlc->ilc_poly = 0; |
|
5561 |
} |
|
5562 |
} |
|
5563 |
RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc)); |
|
5564 |
} else { |
|
5565 |
static struct inlineCache ilc0 = __DUMMYILCSELF0(@line+1); |
|
5566 |
RETURN (_SEND0(self, aSelector, nil, &ilc0)); |
|
5567 |
} |
|
5568 |
||
5569 |
case 1: |
|
5570 |
if (InterruptPending == nil) { |
|
5571 |
static OBJ last1_0 = nil; static struct inlineCache ilc1_0 = __ILCPERF1(@line); |
|
5572 |
static OBJ last1_1 = nil; static struct inlineCache ilc1_1 = __ILCPERF1(@line); |
|
5573 |
static OBJ last1_2 = nil; static struct inlineCache ilc1_2 = __ILCPERF1(@line); |
|
5574 |
static OBJ last1_3 = nil; static struct inlineCache ilc1_3 = __ILCPERF1(@line); |
|
5575 |
static int flip1 = 0; |
|
5576 |
struct inlineCache *pIlc; |
|
5577 |
||
5578 |
if (aSelector == last1_0) { |
|
5579 |
pIlc = &ilc1_0; |
|
5580 |
} else if (aSelector == last1_1) { |
|
5581 |
pIlc = &ilc1_1; |
|
5582 |
} else if (aSelector == last1_2) { |
|
5583 |
pIlc = &ilc1_2; |
|
5584 |
} else if (aSelector == last1_3) { |
|
5585 |
pIlc = &ilc1_3; |
|
5586 |
} else { |
|
5587 |
if (flip1 == 0) { |
|
5588 |
pIlc = &ilc1_0; |
|
5589 |
flip1 = 1; |
|
5590 |
last1_0 = aSelector; |
|
5591 |
} else if (flip1 == 1) { |
|
5592 |
pIlc = &ilc1_1; |
|
5593 |
flip1 = 2; |
|
5594 |
last1_1 = aSelector; |
|
5595 |
} else if (flip1 == 2) { |
|
5596 |
pIlc = &ilc1_2; |
|
5597 |
flip1 = 3; |
|
5598 |
last1_2 = aSelector; |
|
5599 |
} else { |
|
5600 |
pIlc = &ilc1_3; |
|
5601 |
flip1 = 0; |
|
5602 |
last1_3 = aSelector; |
|
5603 |
} |
|
5604 |
||
5605 |
pIlc->ilc_func = __SEND1ADDR__; |
|
5606 |
if (pIlc->ilc_poly) { |
|
5607 |
__flushPolyCache(pIlc->ilc_poly); |
|
5608 |
pIlc->ilc_poly = 0; |
|
5609 |
} |
|
5610 |
} |
|
5611 |
RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc, argP[0])); |
|
5612 |
} else { |
|
5613 |
static struct inlineCache ilc1 = __DUMMYILCSELF1(@line+1); |
|
5614 |
RETURN (_SEND1(self, aSelector, nil, &ilc1, argP[0])); |
|
5615 |
} |
|
5616 |
||
5617 |
case 2: |
|
5618 |
if (InterruptPending == nil) { |
|
5619 |
static OBJ last2_0 = nil; static struct inlineCache ilc2_0 = __ILCPERF2(@line); |
|
5620 |
static OBJ last2_1 = nil; static struct inlineCache ilc2_1 = __ILCPERF2(@line); |
|
5621 |
static int flip2 = 0; |
|
5622 |
struct inlineCache *pIlc; |
|
5623 |
||
5624 |
if (aSelector == last2_0) { |
|
5625 |
pIlc = &ilc2_0; |
|
5626 |
} else if (aSelector == last2_1) { |
|
5627 |
pIlc = &ilc2_1; |
|
5628 |
} else { |
|
5629 |
if (flip2 == 0) { |
|
5630 |
pIlc = &ilc2_0; |
|
5631 |
flip2 = 1; |
|
5632 |
last2_0 = aSelector; |
|
5633 |
} else { |
|
5634 |
pIlc = &ilc2_1; |
|
5635 |
flip2 = 0; |
|
5636 |
last2_1 = aSelector; |
|
5637 |
} |
|
5638 |
||
5639 |
pIlc->ilc_func = __SEND2ADDR__; |
|
5640 |
if (pIlc->ilc_poly) { |
|
5641 |
__flushPolyCache(pIlc->ilc_poly); |
|
5642 |
pIlc->ilc_poly = 0; |
|
5643 |
} |
|
5644 |
} |
|
5645 |
RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc, argP[0], argP[1])); |
|
5646 |
} else { |
|
5647 |
static struct inlineCache ilc2 = __DUMMYILCSELF2(@line+1); |
|
5648 |
RETURN (_SEND2(self, aSelector, nil, &ilc2, argP[0], argP[1])); |
|
5649 |
} |
|
5650 |
||
5651 |
case 3: |
|
5652 |
if (InterruptPending == nil) { |
|
5653 |
static OBJ last3_0 = nil; static struct inlineCache ilc3_0 = __ILCPERF3(@line); |
|
5654 |
static OBJ last3_1 = nil; static struct inlineCache ilc3_1 = __ILCPERF3(@line); |
|
5655 |
static int flip3 = 0; |
|
5656 |
struct inlineCache *pIlc; |
|
5657 |
||
5658 |
if (aSelector == last3_0) { |
|
5659 |
pIlc = &ilc3_0; |
|
5660 |
} else if (aSelector == last3_1) { |
|
5661 |
pIlc = &ilc3_1; |
|
5662 |
} else { |
|
5663 |
if (flip3 == 0) { |
|
5664 |
pIlc = &ilc3_0; |
|
5665 |
flip3 = 1; |
|
5666 |
last3_0 = aSelector; |
|
5667 |
} else { |
|
5668 |
pIlc = &ilc3_1; |
|
5669 |
flip3 = 0; |
|
5670 |
last3_1 = aSelector; |
|
5671 |
} |
|
5672 |
||
5673 |
pIlc->ilc_func = __SEND3ADDR__; |
|
5674 |
if (pIlc->ilc_poly) { |
|
5675 |
__flushPolyCache(pIlc->ilc_poly); |
|
5676 |
pIlc->ilc_poly = 0; |
|
5677 |
} |
|
5678 |
} |
|
5679 |
RETURN ((*pIlc->ilc_func)(self, aSelector, nil, pIlc, argP[0], argP[1], argP[2])); |
|
5680 |
} else { |
|
5681 |
static struct inlineCache ilc3 = __DUMMYILCSELF3(@line+1); |
|
5682 |
RETURN (_SEND3(self, aSelector, nil, &ilc3, argP[0], argP[1], argP[2])); |
|
5683 |
} |
|
5684 |
||
5685 |
case 4: |
|
5686 |
{ |
|
5687 |
static OBJ last4 = nil; static struct inlineCache ilc4 = __ILCPERF4(@line); |
|
5688 |
||
5689 |
if ((InterruptPending != nil) || (aSelector != last4)) { |
|
5690 |
ilc4.ilc_func = __SEND4ADDR__; |
|
5691 |
if (ilc4.ilc_poly) { |
|
5692 |
__flushPolyCache(ilc4.ilc_poly); |
|
5693 |
ilc4.ilc_poly = 0; |
|
5694 |
} |
|
5695 |
last4 = aSelector; |
|
5696 |
} |
|
5697 |
RETURN ( (*ilc4.ilc_func)(self, aSelector, nil, &ilc4, |
|
5698 |
argP[0], argP[1], argP[2], argP[3])); |
|
5699 |
} |
|
5700 |
||
5701 |
case 5: |
|
5702 |
{ |
|
5703 |
static OBJ last5 = nil; static struct inlineCache ilc5 = __ILCPERF5(@line); |
|
5704 |
||
5705 |
if ((InterruptPending != nil) || (aSelector != last5)) { |
|
5706 |
ilc5.ilc_func = __SEND5ADDR__; |
|
5707 |
if (ilc5.ilc_poly) { |
|
5708 |
__flushPolyCache(ilc5.ilc_poly); |
|
5709 |
ilc5.ilc_poly = 0; |
|
5710 |
} |
|
5711 |
last5 = aSelector; |
|
5712 |
} |
|
5713 |
RETURN ( (*ilc5.ilc_func)(self, aSelector, nil, &ilc5, |
|
5714 |
argP[0], argP[1], argP[2], argP[3], argP[4])); |
|
5715 |
} |
|
5716 |
||
5717 |
case 6: |
|
5718 |
{ |
|
5719 |
static OBJ last6 = nil; static struct inlineCache ilc6 = __ILCPERF6(@line); |
|
5720 |
||
5721 |
if ((InterruptPending != nil) || (aSelector != last6)) { |
|
5722 |
ilc6.ilc_func = __SEND6ADDR__; |
|
5723 |
if (ilc6.ilc_poly) { |
|
5724 |
__flushPolyCache(ilc6.ilc_poly); |
|
5725 |
ilc6.ilc_poly = 0; |
|
5726 |
} |
|
5727 |
last6 = aSelector; |
|
5728 |
} |
|
5729 |
RETURN ( (*ilc6.ilc_func)(self, aSelector, nil, &ilc6, |
|
5730 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
5731 |
argP[5])); |
|
5732 |
} |
|
5733 |
||
5734 |
case 7: |
|
5735 |
{ |
|
5736 |
static OBJ last7 = nil; static struct inlineCache ilc7 = __ILCPERF7(@line); |
|
5737 |
||
5738 |
if ((InterruptPending != nil) || (aSelector != last7)) { |
|
5739 |
ilc7.ilc_func = __SEND7ADDR__; |
|
5740 |
if (ilc7.ilc_poly) { |
|
5741 |
__flushPolyCache(ilc7.ilc_poly); |
|
5742 |
ilc7.ilc_poly = 0; |
|
5743 |
} |
|
5744 |
last7 = aSelector; |
|
5745 |
} |
|
5746 |
RETURN ( (*ilc7.ilc_func)(self, aSelector, nil, &ilc7, |
|
5747 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
5748 |
argP[5], argP[6])); |
|
5749 |
} |
|
5750 |
||
5751 |
case 8: |
|
5752 |
{ |
|
5753 |
static OBJ last8 = nil; static struct inlineCache ilc8 = __ILCPERF8(@line); |
|
5754 |
||
5755 |
if ((InterruptPending != nil) || (aSelector != last8)) { |
|
5756 |
ilc8.ilc_func = __SEND8ADDR__; |
|
5757 |
if (ilc8.ilc_poly) { |
|
5758 |
__flushPolyCache(ilc8.ilc_poly); |
|
5759 |
ilc8.ilc_poly = 0; |
|
5760 |
} |
|
5761 |
last8 = aSelector; |
|
5762 |
} |
|
5763 |
RETURN ( (*ilc8.ilc_func)(self, aSelector, nil, &ilc8, |
|
5764 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
5765 |
argP[5], argP[6], argP[7])); |
|
5766 |
} |
|
5767 |
||
5768 |
case 9: |
|
5769 |
{ |
|
5770 |
static OBJ last9 = nil; static struct inlineCache ilc9 = __ILCPERF9(@line); |
|
5771 |
||
5772 |
if ((InterruptPending != nil) || (aSelector != last9)) { |
|
5773 |
ilc9.ilc_func = __SEND9ADDR__; |
|
5774 |
if (ilc9.ilc_poly) { |
|
5775 |
__flushPolyCache(ilc9.ilc_poly); |
|
5776 |
ilc9.ilc_poly = 0; |
|
5777 |
} |
|
5778 |
last9 = aSelector; |
|
5779 |
} |
|
5780 |
RETURN ( (*ilc9.ilc_func)(self, aSelector, nil, &ilc9, |
|
5781 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
5782 |
argP[5], argP[6], argP[7], argP[8])); |
|
5783 |
} |
|
5784 |
||
5785 |
case 10: |
|
5786 |
{ |
|
5787 |
static OBJ last10 = nil; static struct inlineCache ilc10 = __ILCPERF10(@line); |
|
5788 |
||
5789 |
if ((InterruptPending != nil) || (aSelector != last10)) { |
|
5790 |
ilc10.ilc_func = __SEND10ADDR__; |
|
5791 |
if (ilc10.ilc_poly) { |
|
5792 |
__flushPolyCache(ilc10.ilc_poly); |
|
5793 |
ilc10.ilc_poly = 0; |
|
5794 |
} |
|
5795 |
last10 = aSelector; |
|
5796 |
} |
|
5797 |
RETURN ( (*ilc10.ilc_func)(self, aSelector, nil, &ilc10, |
|
5798 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
5799 |
argP[5], argP[6], argP[7], argP[8], argP[9])); |
|
5800 |
} |
|
5801 |
||
5802 |
case 11: |
|
5803 |
{ |
|
5804 |
static OBJ last11 = nil; static struct inlineCache ilc11 = __ILCPERF11(@line); |
|
5805 |
||
5806 |
if ((InterruptPending != nil) || (aSelector != last11)) { |
|
5807 |
ilc11.ilc_func = __SEND11ADDR__; |
|
5808 |
if (ilc11.ilc_poly) { |
|
5809 |
__flushPolyCache(ilc11.ilc_poly); |
|
5810 |
ilc11.ilc_poly = 0; |
|
5811 |
} |
|
5812 |
last11 = aSelector; |
|
5813 |
} |
|
5814 |
RETURN ( (*ilc11.ilc_func)(self, aSelector, nil, &ilc11, |
|
5815 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
5816 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
|
5817 |
argP[10])); |
|
5818 |
} |
|
5819 |
||
5820 |
case 12: |
|
5821 |
{ |
|
5822 |
static OBJ last12 = nil; static struct inlineCache ilc12 = __ILCPERF12(@line); |
|
5823 |
||
5824 |
if ((InterruptPending != nil) || (aSelector != last12)) { |
|
5825 |
ilc12.ilc_func = __SEND12ADDR__; |
|
5826 |
if (ilc12.ilc_poly) { |
|
5827 |
__flushPolyCache(ilc12.ilc_poly); |
|
5828 |
ilc12.ilc_poly = 0; |
|
5829 |
} |
|
5830 |
last12 = aSelector; |
|
5831 |
} |
|
5832 |
RETURN ( (*ilc12.ilc_func)(self, aSelector, nil, &ilc12, |
|
5833 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
5834 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
|
5835 |
argP[10], argP[11])); |
|
5836 |
} |
|
5837 |
||
5838 |
case 13: |
|
5839 |
{ |
|
5840 |
static OBJ last13 = nil; static struct inlineCache ilc13 = __ILCPERF13(@line); |
|
5841 |
||
5842 |
if ((InterruptPending != nil) || (aSelector != last13)) { |
|
5843 |
ilc13.ilc_func = __SEND13ADDR__; |
|
5844 |
if (ilc13.ilc_poly) { |
|
5845 |
__flushPolyCache(ilc13.ilc_poly); |
|
5846 |
ilc13.ilc_poly = 0; |
|
5847 |
} |
|
5848 |
last13 = aSelector; |
|
5849 |
} |
|
5850 |
RETURN ( (*ilc13.ilc_func)(self, aSelector, nil, &ilc13, |
|
5851 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
5852 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
|
5853 |
argP[10], argP[11], argP[12])); |
|
5854 |
} |
|
5855 |
||
5856 |
case 14: |
|
5857 |
{ |
|
5858 |
static OBJ last14 = nil; static struct inlineCache ilc14 = __ILCPERF14(@line); |
|
5859 |
||
5860 |
if ((InterruptPending != nil) || (aSelector != last14)) { |
|
5861 |
ilc14.ilc_func = __SEND14ADDR__; |
|
5862 |
if (ilc14.ilc_poly) { |
|
5863 |
__flushPolyCache(ilc14.ilc_poly); |
|
5864 |
ilc14.ilc_poly = 0; |
|
5865 |
} |
|
5866 |
last14 = aSelector; |
|
5867 |
} |
|
5868 |
RETURN ( (*ilc14.ilc_func)(self, aSelector, nil, &ilc14, |
|
5869 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
5870 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
|
5871 |
argP[10], argP[11], argP[12], argP[13])); |
|
5872 |
} |
|
5873 |
||
5874 |
case 15: |
|
5875 |
{ |
|
5876 |
static OBJ last15 = nil; static struct inlineCache ilc15 = __ILCPERF15(@line); |
|
5877 |
||
5878 |
if ((InterruptPending != nil) || (aSelector != last15)) { |
|
5879 |
ilc15.ilc_func = __SEND15ADDR__; |
|
5880 |
if (ilc15.ilc_poly) { |
|
5881 |
__flushPolyCache(ilc15.ilc_poly); |
|
5882 |
ilc15.ilc_poly = 0; |
|
5883 |
} |
|
5884 |
last15 = aSelector; |
|
5885 |
} |
|
5886 |
RETURN ( (*ilc15.ilc_func)(self, aSelector, nil, &ilc15, |
|
5887 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
|
5888 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
|
5889 |
argP[10], argP[11], argP[12], argP[13], |
|
5890 |
argP[14])); |
|
5891 |
} |
|
5755 | 5892 |
} |
5893 |
bad:; |
|
5894 |
%}. |
|
5895 |
||
5896 |
"/ arrive here, if bad number of arguments (too many) |
|
5897 |
"/ ST/X (currently) only allows up to 15 method arguments |
|
5898 |
||
5899 |
^ self primitiveFailed |
|
5900 |
! |
|
5901 |
||
6316 | 5902 |
perform:aSelector withOptionalArgument:arg |
5903 |
"send aSelector-message to the receiver. |
|
6318 | 5904 |
If the message expects an argument, pass arg." |
6316 | 5905 |
|
5906 |
aSelector numArgs == 1 ifTrue:[ |
|
10460 | 5907 |
^ self perform:aSelector with:arg |
6316 | 5908 |
]. |
5909 |
^ self perform:aSelector |
|
6319 | 5910 |
|
5911 |
" |
|
5912 |
|rec sel| |
|
5913 |
||
5914 |
rec := -1. |
|
5915 |
sel := #abs. |
|
5916 |
rec perform:sel withOptionalArgument:2. |
|
5917 |
||
5918 |
sel := #max:. |
|
5919 |
rec perform:sel withOptionalArgument:2. |
|
5920 |
" |
|
6316 | 5921 |
! |
5922 |
||
6321
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5923 |
perform:aSelector withOptionalArgument:optionalArg1 and:optionalArg2 |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5924 |
"send aSelector-message to the receiver. |
6728 | 5925 |
Depending on the number of arguments the message expects, |
5926 |
pass either none, 1, or 2 arguments." |
|
6321
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5927 |
|
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5928 |
|numArgs| |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5929 |
|
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5930 |
numArgs := aSelector numArgs. |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5931 |
numArgs == 0 ifTrue:[ |
10460 | 5932 |
^ self perform:aSelector |
6321
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5933 |
]. |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5934 |
numArgs == 1 ifTrue:[ |
10460 | 5935 |
^ self perform:aSelector with:optionalArg1 |
6321
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5936 |
]. |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5937 |
^ self perform:aSelector with:optionalArg1 with:optionalArg2. |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5938 |
|
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5939 |
" |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5940 |
|rec sel| |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5941 |
|
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5942 |
rec := -1. |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5943 |
sel := #abs. |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5944 |
rec perform:sel withOptionalArgument:2. |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5945 |
|
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5946 |
sel := #max:. |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5947 |
rec perform:sel withOptionalArgument:2. |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5948 |
" |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5949 |
! |
8af99331b6e8
#perform:withOptionalArgument:and:
Claus Gittinger <cg@exept.de>
parents:
6319
diff
changeset
|
5950 |
|
6728 | 5951 |
perform:aSelector withOptionalArgument:optionalArg1 and:optionalArg2 and:optionalArg3 |
5952 |
"send aSelector-message to the receiver. |
|
5953 |
Depending on the number of arguments the message expects, |
|
5954 |
pass either none, 1, 2 or 3 arguments." |
|
5955 |
||
5956 |
|numArgs| |
|
5957 |
||
5958 |
numArgs := aSelector numArgs. |
|
5959 |
numArgs == 0 ifTrue:[ |
|
10460 | 5960 |
^ self perform:aSelector |
6728 | 5961 |
]. |
5962 |
numArgs == 1 ifTrue:[ |
|
10460 | 5963 |
^ self perform:aSelector with:optionalArg1 |
6728 | 5964 |
]. |
5965 |
numArgs == 2 ifTrue:[ |
|
10460 | 5966 |
^ self perform:aSelector with:optionalArg1 with:optionalArg2 |
6728 | 5967 |
]. |
5968 |
^ self perform:aSelector with:optionalArg1 with:optionalArg2 with:optionalArg3. |
|
5969 |
||
5970 |
" |
|
5971 |
|rec sel| |
|
5972 |
||
5973 |
rec := -1. |
|
5974 |
sel := #abs. |
|
5975 |
rec perform:sel withOptionalArgument:2. |
|
5976 |
||
5977 |
sel := #max:. |
|
5978 |
rec perform:sel withOptionalArgument:2. |
|
5979 |
" |
|
5980 |
! |
|
5981 |
||
6764 | 5982 |
perform:aSelector withOptionalArgument:optionalArg1 and:optionalArg2 and:optionalArg3 and:optionalArg4 |
5983 |
"send aSelector-message to the receiver. |
|
5984 |
Depending on the number of arguments the message expects, |
|
5985 |
pass either none, 1, 2, 3 or 4 arguments." |
|
5986 |
||
5987 |
|numArgs| |
|
5988 |
||
5989 |
numArgs := aSelector numArgs. |
|
5990 |
numArgs == 0 ifTrue:[ |
|
10460 | 5991 |
^ self perform:aSelector |
6764 | 5992 |
]. |
5993 |
numArgs == 1 ifTrue:[ |
|
10460 | 5994 |
^ self perform:aSelector with:optionalArg1 |
6764 | 5995 |
]. |
5996 |
numArgs == 2 ifTrue:[ |
|
10460 | 5997 |
^ self perform:aSelector with:optionalArg1 with:optionalArg2 |
6764 | 5998 |
]. |
5999 |
numArgs == 3 ifTrue:[ |
|
10460 | 6000 |
^ self perform:aSelector with:optionalArg1 with:optionalArg2 with:optionalArg3 |
6764 | 6001 |
]. |
6002 |
^ self perform:aSelector with:optionalArg1 with:optionalArg2 with:optionalArg3 with:optionalArg4. |
|
6003 |
||
6004 |
" |
|
6005 |
|rec sel| |
|
6006 |
||
6007 |
rec := -1. |
|
6008 |
sel := #abs. |
|
6009 |
rec perform:sel withOptionalArgument:2. |
|
6010 |
||
6011 |
sel := #max:. |
|
6012 |
rec perform:sel withOptionalArgument:2. |
|
6013 |
" |
|
6014 |
! |
|
6015 |
||
5755 | 6016 |
performMethod:aMethod |
6017 |
"invoke aMethod on the receiver. |
|
6018 |
The method should be a zero-argument method. |
|
6019 |
This is a non-object-oriented entry, applying a method |
|
6020 |
in a functional way on a receiver. |
|
6021 |
Warning: |
|
10460 | 6022 |
Take care for the method to be appropriate for the |
6023 |
receiver - no checking is done by the VM." |
|
5755 | 6024 |
|
6025 |
^ aMethod valueWithReceiver:self arguments:#() |
|
6026 |
||
6027 |
" |
|
6028 |
|mthd| |
|
6029 |
||
6030 |
mthd := SmallInteger compiledMethodAt:#negated. |
|
6031 |
Transcript showCR:(1 performMethod:mthd) |
|
6032 |
" |
|
6033 |
||
6034 |
"BAD USE example: |
|
6035 |
||
6036 |
|mthd| |
|
6037 |
||
6038 |
mthd := Point compiledMethodAt:#x. |
|
6039 |
Transcript showCR:((1->2) performMethod:mthd) |
|
6040 |
" |
|
6041 |
||
6042 |
"Modified: 31.7.1997 / 17:41:50 / cg" |
|
6043 |
! |
|
6044 |
||
6045 |
performMethod:aMethod arguments:argumentArray |
|
6046 |
"invoke aMethod on the receiver, passing an argumentArray. |
|
6047 |
The size of the argumentArray should match the number of args |
|
6048 |
expected by the method. |
|
6049 |
This is a non-object-oriented entry, applying a method |
|
6050 |
in a functional way on a receiver. |
|
6051 |
Warning: |
|
10460 | 6052 |
Take care for the method to be appropriate for the |
6053 |
receiver - no checking is done by the VM." |
|
5755 | 6054 |
|
6055 |
^ aMethod valueWithReceiver:self arguments:argumentArray |
|
6056 |
||
6057 |
" |
|
6058 |
|mthd| |
|
6059 |
||
6060 |
mthd := SmallInteger compiledMethodAt:#+. |
|
6061 |
Transcript showCR:(1 performMethod:mthd arguments:#(2)) |
|
6062 |
" |
|
6063 |
||
6064 |
"Created: 31.7.1997 / 17:46:31 / cg" |
|
6065 |
! |
|
6066 |
||
6067 |
performMethod:aMethod with:arg |
|
6068 |
"invoke aMethod on the receiver, passing an argument. |
|
6069 |
The method should be a one-argument method. |
|
6070 |
This is a non-object-oriented entry, applying a method |
|
6071 |
in a functional way on a receiver. |
|
6072 |
Warning: |
|
10460 | 6073 |
Take care for the method to be appropriate for the |
6074 |
receiver - no checking is done by the VM." |
|
5755 | 6075 |
|
6076 |
^ aMethod valueWithReceiver:self arguments:(Array with:arg) |
|
6077 |
||
6078 |
" |
|
6079 |
|mthd| |
|
6080 |
||
6081 |
mthd := SmallInteger compiledMethodAt:#+. |
|
6082 |
Transcript showCR:(1 performMethod:mthd with:2) |
|
6083 |
" |
|
6084 |
||
6085 |
"Modified: 31.7.1997 / 17:42:32 / cg" |
|
6086 |
! |
|
6087 |
||
6088 |
performMethod:aMethod with:arg1 with:arg2 |
|
6089 |
"invoke aMethod on the receiver, passing two arguments. |
|
6090 |
The method should be a two-argument method. |
|
6091 |
This is a non-object-oriented entry, applying a method |
|
6092 |
in a functional way on a receiver. |
|
6093 |
Warning: |
|
10460 | 6094 |
Take care for the method to be appropriate for the |
6095 |
receiver - no checking is done by the VM." |
|
5755 | 6096 |
|
6097 |
^ aMethod valueWithReceiver:self arguments:(Array with:arg1 with:arg2) |
|
6098 |
||
6099 |
" |
|
6100 |
|mthd arr| |
|
6101 |
||
6102 |
arr := Array new:1. |
|
6103 |
mthd := Array compiledMethodAt:#basicAt:put:. |
|
6104 |
arr performMethod:mthd with:1 with:'foo'. |
|
6105 |
Transcript showCR:arr |
|
6106 |
" |
|
6107 |
||
6108 |
"Modified: 31.7.1997 / 17:44:54 / cg" |
|
6109 |
! |
|
6110 |
||
6111 |
performMethod:aMethod with:arg1 with:arg2 with:arg3 |
|
6112 |
"invoke aMethod on the receiver, passing three arguments. |
|
6113 |
The method should be a three-argument method. |
|
6114 |
This is a non-object-oriented entry, applying a method |
|
6115 |
in a functional way on a receiver. |
|
6116 |
Warning: |
|
10460 | 6117 |
Take care for the method to be appropriate for the |
6118 |
receiver - no checking is done by the VM." |
|
5755 | 6119 |
|
6120 |
^ aMethod valueWithReceiver:self arguments:(Array with:arg1 with:arg2 with:arg3) |
|
6121 |
||
6122 |
"Created: 31.7.1997 / 17:45:20 / cg" |
|
6123 |
! ! |
|
6124 |
||
10834 | 6125 |
!Object methodsFor:'object persistency'! |
6126 |
||
6127 |
elementDescriptorFor:anAspectSymbol |
|
6128 |
"support for persistency: |
|
6129 |
answer a collection of associations containing the |
|
6130 |
objects state to be encoded for aspect. |
|
6131 |
Association key is the instance variable name or access selector, |
|
6132 |
association value is the contents of the instance variable. |
|
6133 |
||
6134 |
The default is to return the contents of all non-nil instance variables" |
|
6135 |
||
6136 |
|ret| |
|
6137 |
||
6138 |
ret := 0. |
|
6139 |
anAspectSymbol notNil ifTrue:[ |
|
6140 |
ret := self perform:anAspectSymbol ifNotUnderstood:[0]. |
|
6141 |
]. |
|
6142 |
ret == 0 ifTrue:[ |
|
6143 |
^ self elementDescriptorForNonNilInstanceVariables |
|
6144 |
]. |
|
6145 |
^ ret. |
|
6146 |
! |
|
6147 |
||
6148 |
elementDescriptorForInstanceVariables |
|
6149 |
"return all instance variables for visiting/encoding" |
|
6150 |
||
6151 |
^ self elementDescriptorForInstanceVariablesMatching:[:val | true]. |
|
6152 |
||
6153 |
" |
|
6154 |
#(1 2 3 nil true symbol) elementDescriptorForInstanceVariables |
|
6155 |
Dictionary new elementDescriptorForInstanceVariables |
|
6156 |
(5 @ nil) elementDescriptorForInstanceVariables |
|
6157 |
" |
|
6158 |
! |
|
6159 |
||
6160 |
elementDescriptorForInstanceVariablesMatching:aBlock |
|
6161 |
"return all instance variables which conform to aBlock, for encoding/visiting. |
|
6162 |
Indexed vars are all included." |
|
6163 |
||
6164 |
|instVarNames theClass children |
|
6165 |
instSize "{ Class: SmallInteger }" |
|
6166 |
varSize "{ Class: SmallInteger }"| |
|
6167 |
||
6168 |
theClass := self class. |
|
6169 |
||
6170 |
instSize := theClass instSize. |
|
6171 |
varSize := theClass isVariable ifTrue:[self basicSize] ifFalse:[0]. |
|
6172 |
children := OrderedCollection new:(instSize + varSize). |
|
6173 |
||
6174 |
instVarNames := theClass allInstVarNames. |
|
6175 |
1 to:instSize do:[:i | |var| |
|
6176 |
var := self instVarAt:i. |
|
6177 |
(aBlock value:var) ifTrue:[ |
|
6178 |
children add:((instVarNames at:i) -> var) |
|
6179 |
] |
|
6180 |
]. |
|
6181 |
||
6182 |
varSize ~~ 0 ifTrue:[ |
|
6183 |
1 to:varSize do:[:i | |
|
6184 |
children add:(i -> (self basicAt:i)) |
|
6185 |
] |
|
6186 |
]. |
|
6187 |
||
6188 |
^ children. |
|
6189 |
||
6190 |
" |
|
6191 |
#(1 2 3 nil true symbol) elementDescriptorForInstanceVariables |
|
6192 |
Dictionary new elementDescriptorForInstanceVariables |
|
6193 |
(5 @ nil) elementDescriptorForInstanceVariables |
|
6194 |
" |
|
6195 |
! |
|
6196 |
||
6197 |
elementDescriptorForNonNilInstanceVariables |
|
6198 |
"return all non-nil instance variables for visiting/encoding" |
|
6199 |
||
6200 |
^ self elementDescriptorForInstanceVariablesMatching:[:val | val notNil]. |
|
6201 |
||
6202 |
" |
|
6203 |
#(1 2 3 nil true symbol) elementDescriptorForNonNilInstanceVariables |
|
6204 |
Dictionary new elementDescriptorForNonNilInstanceVariables |
|
6205 |
(5 @ nil) elementDescriptorForNonNilInstanceVariables |
|
6206 |
" |
|
6207 |
! ! |
|
6208 |
||
5755 | 6209 |
!Object methodsFor:'printing & storing'! |
6210 |
||
6235 | 6211 |
basicPrintOn:aStream |
6212 |
"append the receivers className with an articel to the argument, aStream" |
|
6213 |
||
6214 |
aStream nextPutAll:self classNameWithArticle |
|
6215 |
! |
|
6216 |
||
5755 | 6217 |
className |
6218 |
"return the classname of the receivers class" |
|
6219 |
||
6220 |
^ self class name |
|
6221 |
||
6222 |
" |
|
6223 |
1 className |
|
10460 | 6224 |
1 class className |
5755 | 6225 |
$a className |
9105 | 6226 |
$a class className |
5755 | 6227 |
" |
6228 |
! |
|
6229 |
||
6230 |
classNameWithArticle |
|
6231 |
"return a string consisting of classname preceeded by an article. |
|
6232 |
(dont expect me to write national variants for this ... :-) |
|
6233 |
If you have special preferences, redefine it ..." |
|
6234 |
||
6829 | 6235 |
| cls| |
5755 | 6236 |
|
6237 |
(cls := self class) == self ifTrue:[ |
|
10460 | 6238 |
^ 'a funny object' |
5755 | 6239 |
]. |
6829 | 6240 |
^ cls nameWithArticle |
5755 | 6241 |
|
6242 |
" |
|
10460 | 6243 |
1 classNameWithArticle |
6244 |
(1->2) classNameWithArticle |
|
5755 | 6245 |
XWorkstation basicNew classNameWithArticle |
10460 | 6246 |
XWorkstation classNameWithArticle |
5755 | 6247 |
" |
6248 |
||
6249 |
"Modified: 13.5.1996 / 12:16:14 / cg" |
|
6250 |
! |
|
6251 |
||
6252 |
errorPrint |
|
10530
0f3d3ddd3837
#errorPrint* and #infoPrint* print to Transcript.
Stefan Vogel <sv@exept.de>
parents:
10527
diff
changeset
|
6253 |
"print the receiver on the Transcript. |
0f3d3ddd3837
#errorPrint* and #infoPrint* print to Transcript.
Stefan Vogel <sv@exept.de>
parents:
10527
diff
changeset
|
6254 |
The Transcript is directed to the standard error stream on |
0f3d3ddd3837
#errorPrint* and #infoPrint* print to Transcript.
Stefan Vogel <sv@exept.de>
parents:
10527
diff
changeset
|
6255 |
headless applications." |
5755 | 6256 |
|
10564
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6257 |
|s| |
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6258 |
|
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6259 |
s := Processor activeProcess isSystemProcess |
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6260 |
ifTrue:Stderr |
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6261 |
ifFalse:Transcript. |
7285
76ff65cdd7e7
Stream streamErrorSignal -> StreamError
Stefan Vogel <sv@exept.de>
parents:
7266
diff
changeset
|
6262 |
StreamError catch:[ |
10564
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6263 |
self printOn:s |
5755 | 6264 |
] |
6265 |
||
10564
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6266 |
"Modified: / 29-05-2007 / 20:00:54 / cg" |
5755 | 6267 |
! |
6268 |
||
6269 |
errorPrintCR |
|
6270 |
"{ Pragma: +optSpace }" |
|
6271 |
||
10530
0f3d3ddd3837
#errorPrint* and #infoPrint* print to Transcript.
Stefan Vogel <sv@exept.de>
parents:
10527
diff
changeset
|
6272 |
"print the receiver followed by a cr on the standard error stream. |
0f3d3ddd3837
#errorPrint* and #infoPrint* print to Transcript.
Stefan Vogel <sv@exept.de>
parents:
10527
diff
changeset
|
6273 |
The Transcript is directed to the standard error stream on |
0f3d3ddd3837
#errorPrint* and #infoPrint* print to Transcript.
Stefan Vogel <sv@exept.de>
parents:
10527
diff
changeset
|
6274 |
headless applications." |
5755 | 6275 |
|
10564
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6276 |
|s| |
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6277 |
|
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6278 |
s := Processor activeProcess isSystemProcess |
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6279 |
ifTrue:Stderr |
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6280 |
ifFalse:Transcript. |
7285
76ff65cdd7e7
Stream streamErrorSignal -> StreamError
Stefan Vogel <sv@exept.de>
parents:
7266
diff
changeset
|
6281 |
StreamError catch:[ |
10564
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6282 |
self printOn:s. |
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6283 |
s cr |
5755 | 6284 |
] |
6285 |
||
10564
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6286 |
"Created: / 20-05-1996 / 10:20:41 / cg" |
7d25403688ba
dont errorPrint on Transcript when I am a system process.
Claus Gittinger <cg@exept.de>
parents:
10558
diff
changeset
|
6287 |
"Modified: / 29-05-2007 / 20:00:49 / cg" |
5755 | 6288 |
! |
6289 |
||
6290 |
errorPrintNL |
|
6291 |
"{ Pragma: +optSpace }" |
|
5893
f92054b38d3c
Assign #obsolete resource to obsolete methods
Stefan Vogel <sv@exept.de>
parents:
5879
diff
changeset
|
6292 |
<resource:#obsolete> |
5755 | 6293 |
|
6294 |
"print the receiver followed by a cr on the standard error stream. |
|
6295 |
Please use #errorPrintCR - this method exists for backward compatibility." |
|
6296 |
||
6297 |
^ self errorPrintCR |
|
6298 |
||
6299 |
"Modified: 20.5.1996 / 10:24:45 / cg" |
|
6300 |
! |
|
6301 |
||
6302 |
errorPrintNewline |
|
6303 |
"{ Pragma: +optSpace }" |
|
5893
f92054b38d3c
Assign #obsolete resource to obsolete methods
Stefan Vogel <sv@exept.de>
parents:
5879
diff
changeset
|
6304 |
<resource:#obsolete> |
5755 | 6305 |
|
6306 |
"print the receiver followed by a cr on the standard error stream. |
|
6307 |
Please use #errorPrintCR - this method exists for backward compatibility." |
|
6308 |
||
6309 |
self errorPrintCR. |
|
6310 |
||
6311 |
"Modified: 20.5.1996 / 10:24:38 / cg" |
|
6312 |
! |
|
6313 |
||
6314 |
infoPrint |
|
6315 |
"{ Pragma: +optSpace }" |
|
6316 |
||
6317 |
"print the receiver on the standard error stream. |
|
6318 |
This is meant for information messages which are not warnings |
|
6319 |
or fatal messages. |
|
6320 |
These messages can be turned on/off by 'Object infoPrinting:true/false'" |
|
6321 |
||
6322 |
InfoPrinting == true ifTrue:[ |
|
10460 | 6323 |
self errorPrint |
5755 | 6324 |
] |
6325 |
! |
|
6326 |
||
6327 |
infoPrintCR |
|
6328 |
"{ Pragma: +optSpace }" |
|
6329 |
||
6330 |
"print the receiver followed by a cr on the standard error stream. |
|
6331 |
This is meant for information messages which are not warnings |
|
6332 |
or fatal messages. |
|
6333 |
These messages can be turned on/off by 'Object infoPrinting:true/false'" |
|
6334 |
||
6335 |
InfoPrinting == true ifTrue:[ |
|
10460 | 6336 |
self errorPrintCR |
5755 | 6337 |
] |
6338 |
||
6339 |
"Created: 20.5.1996 / 10:21:28 / cg" |
|
6340 |
! |
|
6341 |
||
6342 |
infoPrintNL |
|
6343 |
"{ Pragma: +optSpace }" |
|
5893
f92054b38d3c
Assign #obsolete resource to obsolete methods
Stefan Vogel <sv@exept.de>
parents:
5879
diff
changeset
|
6344 |
<resource:#obsolete> |
5755 | 6345 |
|
6346 |
"print the receiver followed by a cr on the standard error stream. |
|
6347 |
Please use #infoPrintCR - this method exists for backward compatibility." |
|
6348 |
||
6349 |
^ self infoPrintCR |
|
6350 |
! |
|
6351 |
||
6352 |
||
6353 |
"print the receiver on the standard output stream (which is not the Transcript)" |
|
6354 |
||
6355 |
"/ the following allows printCR to be used during |
|
6356 |
"/ the early init-phase, when no Stdout has been set up. |
|
6357 |
"/ (depends on string to respond to #print) |
|
6358 |
||
6359 |
Stdout isNil ifTrue:[ |
|
10460 | 6360 |
self printString print. |
6361 |
^ self |
|
5755 | 6362 |
]. |
6363 |
self printOn:Stdout |
|
6364 |
||
6365 |
"Modified: 4.11.1996 / 23:36:58 / cg" |
|
6366 |
! |
|
6367 |
||
6368 |
printCR |
|
6369 |
"print the receiver followed by a cr on the standard output stream (which is not the Transcript)" |
|
6370 |
||
6371 |
"/ the following allows printCR to be used during |
|
6372 |
"/ the early init-phase, when no Stdout has been set up. |
|
6373 |
"/ (depends on string to respond to #printCR) |
|
6374 |
||
6375 |
Stdout isNil ifTrue:[ |
|
10460 | 6376 |
self printString printCR. |
6377 |
^ self |
|
5755 | 6378 |
]. |
6379 |
self printOn:Stdout. |
|
6380 |
Stdout cr |
|
6381 |
||
6382 |
"Created: 20.5.1996 / 10:21:37 / cg" |
|
6383 |
"Modified: 4.11.1996 / 23:37:06 / cg" |
|
6384 |
! |
|
6385 |
||
6386 |
printNL |
|
6387 |
"print the receiver followed by a cr on the standard output stream |
|
6388 |
This exists for GNU Smalltalk compatibility - please use #printCR." |
|
6389 |
||
5893
f92054b38d3c
Assign #obsolete resource to obsolete methods
Stefan Vogel <sv@exept.de>
parents:
5879
diff
changeset
|
6390 |
<resource:#obsolete> |
f92054b38d3c
Assign #obsolete resource to obsolete methods
Stefan Vogel <sv@exept.de>
parents:
5879
diff
changeset
|
6391 |
|
5755 | 6392 |
^ self printCR |
6393 |
||
6394 |
"Modified: 20.5.1996 / 10:25:31 / cg" |
|
6395 |
! |
|
6396 |
||
6397 |
printNewline |
|
6398 |
"print the receiver followed by a cr on the standard output stream. |
|
6399 |
This exists for backward compatibility - please use #printCR." |
|
6400 |
||
5893
f92054b38d3c
Assign #obsolete resource to obsolete methods
Stefan Vogel <sv@exept.de>
parents:
5879
diff
changeset
|
6401 |
<resource:#obsolete> |
f92054b38d3c
Assign #obsolete resource to obsolete methods
Stefan Vogel <sv@exept.de>
parents:
5879
diff
changeset
|
6402 |
|
5755 | 6403 |
self printCR |
6404 |
||
6405 |
"Modified: 20.5.1996 / 10:25:46 / cg" |
|
6406 |
! |
|
6407 |
||
6408 |
printOn:aStream |
|
6409 |
"append a user printed representation of the receiver to aStream. |
|
6410 |
The format is suitable for a human - not meant to be read back. |
|
6411 |
||
6412 |
The default here is to output the receivers class name. |
|
6413 |
BUT: this method is heavily redefined for objects which |
|
6414 |
can print prettier." |
|
6415 |
||
6235 | 6416 |
self basicPrintOn:aStream. |
6417 |
||
6418 |
" |
|
6419 |
(1@2) printOn:Transcript |
|
6420 |
(1@2) basicPrintOn:Transcript |
|
6421 |
" |
|
5755 | 6422 |
! |
6423 |
||
11068
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6424 |
printOn:aStream format:format |
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6425 |
"this may be redefined in subclasses. |
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6426 |
Defined here for compatibility with subclasses" |
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6427 |
|
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6428 |
self printOn:aStream. |
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6429 |
! |
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6430 |
|
5755 | 6431 |
printOn:aStream leftPaddedTo:size |
6432 |
"print the receiver on aStream, padding with spaces up to size. |
|
6433 |
padding is done on the left." |
|
6434 |
||
6435 |
self printOn:aStream leftPaddedTo:size with:(Character space) |
|
6436 |
||
6437 |
" |
|
6438 |
123 printOn:Transcript leftPaddedTo:10. Transcript cr |
|
6439 |
123 printOn:Transcript leftPaddedTo:2. Transcript cr |
|
6440 |
" |
|
6441 |
! |
|
6442 |
||
6443 |
printOn:aStream leftPaddedTo:size with:padCharacter |
|
6444 |
"print the receiver on aStream, padding with padCharacters up to size. |
|
6445 |
padding is done on the left." |
|
6446 |
||
6447 |
aStream nextPutAll:(self printStringLeftPaddedTo:size with:padCharacter) |
|
6448 |
||
6449 |
" |
|
6450 |
123 printOn:Transcript leftPaddedTo:10 with:$_ . Transcript cr |
|
6451 |
123 printOn:Transcript leftPaddedTo:10 with:$. . Transcript cr |
|
6452 |
" |
|
6453 |
! |
|
6454 |
||
6455 |
printOn:aStream paddedTo:size |
|
6456 |
"print the receiver on aStream, padding with spaces up to size." |
|
6457 |
||
6458 |
self printOn:aStream paddedTo:size with:(Character space) |
|
6459 |
||
6460 |
" |
|
6461 |
123.0 printOn:Transcript paddedTo:10. Transcript nextPut:$|. Transcript cr |
|
6462 |
" |
|
6463 |
! |
|
6464 |
||
6465 |
printOn:aStream paddedTo:size with:padCharacter |
|
6466 |
"print the receiver on aStream, padding with padCharacter up to size" |
|
6467 |
||
6468 |
aStream nextPutAll:(self printStringPaddedTo:size with:padCharacter). |
|
6469 |
||
6470 |
" |
|
6471 |
123 printOn:Transcript paddedTo:10 with:$_ . Transcript cr |
|
6472 |
123 printOn:Transcript paddedTo:10 with:$. . Transcript cr |
|
6473 |
" |
|
6474 |
! |
|
6475 |
||
6476 |
printOn:aStream zeroPaddedTo:size |
|
6477 |
"print the receiver on aStream, padding with zeros up to size. |
|
6478 |
Usually used with float numbers." |
|
6479 |
||
6480 |
self printOn:aStream paddedTo:size with:$0. |
|
6481 |
||
6482 |
" |
|
6483 |
123.0 printOn:Transcript zeroPaddedTo:10 |
|
6484 |
" |
|
6485 |
! |
|
6486 |
||
6487 |
printRightAdjustLen:size |
|
11068
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6488 |
<resource: #obsolete> |
5755 | 6489 |
"obsolete - just a name confusion. |
6490 |
This method will go away ..." |
|
6491 |
||
6492 |
(self printStringLeftPaddedTo:size) printOn:Stdout |
|
6493 |
! |
|
6494 |
||
6495 |
printString |
|
6496 |
"return a string for printing the receiver. |
|
6497 |
Since we now use printOn: as the basic print mechanism, |
|
6498 |
we have to create a stream and print into it." |
|
6499 |
||
6500 |
|s| |
|
6501 |
||
8300
d15ead94361f
Use CharacterWriteStream in #printString (speedup)
Stefan Vogel <sv@exept.de>
parents:
8287
diff
changeset
|
6502 |
s := CharacterWriteStream on:(String basicNew:30). |
5755 | 6503 |
self printOn:s. |
8300
d15ead94361f
Use CharacterWriteStream in #printString (speedup)
Stefan Vogel <sv@exept.de>
parents:
8287
diff
changeset
|
6504 |
^ s contents. |
7978
4ce7575e1cfc
care for 16bit chars in #printString
Claus Gittinger <cg@exept.de>
parents:
7838
diff
changeset
|
6505 |
|
4ce7575e1cfc
care for 16bit chars in #printString
Claus Gittinger <cg@exept.de>
parents:
7838
diff
changeset
|
6506 |
" |
4ce7575e1cfc
care for 16bit chars in #printString
Claus Gittinger <cg@exept.de>
parents:
7838
diff
changeset
|
6507 |
Date today printString. |
4ce7575e1cfc
care for 16bit chars in #printString
Claus Gittinger <cg@exept.de>
parents:
7838
diff
changeset
|
6508 |
" |
5755 | 6509 |
! |
6510 |
||
11068
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6511 |
printStringFormat:orintFormat |
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6512 |
"subclasses may redefine this. |
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6513 |
Defined here to avoid type checks" |
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6514 |
|
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6515 |
^ self printString |
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6516 |
! |
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6517 |
|
5755 | 6518 |
printStringLeftPaddedTo:size |
6519 |
"return my printString as a right-adjusted string of length size; |
|
6520 |
characters on the left are filled with spaces. |
|
10460 | 6521 |
If the printString is longer than size, |
5755 | 6522 |
it is returned unchanged (i.e. not truncated)" |
6523 |
||
6524 |
^ self printStringLeftPaddedTo:size with:(Character space) |
|
6525 |
||
6526 |
" |
|
6527 |
10 printStringLeftPaddedTo:10 |
|
6528 |
1 printStringLeftPaddedTo:10 |
|
6529 |
" |
|
6530 |
! |
|
6531 |
||
6532 |
printStringLeftPaddedTo:size ifLarger:alternative |
|
6533 |
"return my printString as a right-adjusted string of length size; |
|
6534 |
characters on the left are filled with spaces. |
|
6535 |
If the printString is larger than size, |
|
6536 |
return the result from evaluating alternative." |
|
6537 |
||
6538 |
^ self printStringLeftPaddedTo:size with:(Character space) ifLarger:alternative |
|
6539 |
||
6540 |
" |
|
6541 |
12 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
6542 |
123 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
6543 |
1234 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
6544 |
" |
|
6545 |
! |
|
6546 |
||
6547 |
printStringLeftPaddedTo:size with:padCharacter |
|
6548 |
"return my printString as a right-adjusted string of length size; |
|
6549 |
characters on the left are filled with padCharacter. |
|
10460 | 6550 |
If the printString is longer than size, |
5755 | 6551 |
it is returned unchanged (i.e. not truncated)" |
6552 |
||
6553 |
^ (self printString) leftPaddedTo:size with:padCharacter |
|
6554 |
||
6555 |
" |
|
10460 | 6556 |
123 printStringLeftPaddedTo:10 with:$. |
6557 |
1 printStringLeftPaddedTo:10 with:$. |
|
5755 | 6558 |
(Float pi) printStringLeftPaddedTo:20 with:$* |
6559 |
" |
|
6560 |
! |
|
6561 |
||
6562 |
printStringLeftPaddedTo:size with:padCharacter ifLarger:alternative |
|
6563 |
"return my printString as a right-adjusted string of length size; |
|
6564 |
characters on the left are filled with padCharacter. |
|
6565 |
If the printString is larger than size, |
|
6566 |
return the result from evaluating alternative." |
|
6567 |
||
6568 |
|s| |
|
6569 |
||
6570 |
s := self printString. |
|
6571 |
s size > size ifTrue:[^ alternative value]. |
|
6572 |
^ s leftPaddedTo:size with:padCharacter |
|
6573 |
||
6574 |
" |
|
10460 | 6575 |
12 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
6576 |
123 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
|
6577 |
1234 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
|
5755 | 6578 |
" |
6579 |
! |
|
6580 |
||
8576 | 6581 |
printStringLimitedTo:sizeLimit |
6582 |
"return a string for printing the receiver, but limit the result string in its size." |
|
6583 |
||
6584 |
|s| |
|
6585 |
||
6586 |
s := CharacterWriteStream on:(String basicNew:30). |
|
6587 |
s writeLimit:sizeLimit. |
|
6588 |
self printOn:s. |
|
6589 |
^ s contents. |
|
6590 |
||
6591 |
" |
|
6592 |
Date today printStringLimitedTo:5. |
|
10460 | 6593 |
'12345678901234567890' printStringLimitedTo:5. |
8576 | 6594 |
" |
6595 |
! |
|
6596 |
||
5755 | 6597 |
printStringOnError:exceptionBlock |
6598 |
"return a string for printing the receiver; if any error occurs, return the result from |
|
6599 |
evaluating exceptionBlock. Useful to print something in an exceptionHandler or other |
|
6600 |
cleanup code." |
|
6601 |
||
6602 |
|rslt| |
|
6603 |
||
6604 |
Error handle:[:ex | |
|
10460 | 6605 |
rslt := exceptionBlock value |
5755 | 6606 |
] do:[ |
10460 | 6607 |
rslt := self printString |
5755 | 6608 |
]. |
6609 |
^ rslt |
|
6610 |
! |
|
6611 |
||
6612 |
printStringPaddedTo:size |
|
6613 |
"return a printed representation of the receiver, |
|
6614 |
padded with spaces (at the right) up to size. |
|
10460 | 6615 |
If the printString is longer than size, |
5755 | 6616 |
it is returned unchanged (i.e. not truncated)" |
6617 |
||
6618 |
^ self printStringPaddedTo:size with:(Character space) |
|
6619 |
||
6620 |
" |
|
10460 | 6621 |
123 printStringPaddedTo:10 |
6622 |
1234567890123456 printStringPaddedTo:10 |
|
6623 |
'hello' printStringPaddedTo:10 |
|
5755 | 6624 |
" |
6625 |
! |
|
6626 |
||
6627 |
printStringPaddedTo:size ifLarger:alternative |
|
6628 |
"return a printed representation of the receiver, |
|
6629 |
padded with spaces (at the right) up to size. |
|
10460 | 6630 |
If the resulting printString is too large, |
5755 | 6631 |
return the result from evaluating alternative." |
6632 |
||
6633 |
^ self printStringPaddedTo:size with:(Character space) ifLarger:alternative |
|
6634 |
||
6635 |
" |
|
10460 | 6636 |
12 printStringPaddedTo:3 ifLarger:['***'] |
6637 |
123 printStringPaddedTo:3 ifLarger:['***'] |
|
6638 |
1234 printStringPaddedTo:3 ifLarger:['***'] |
|
5755 | 6639 |
" |
6640 |
! |
|
6641 |
||
6642 |
printStringPaddedTo:size with:padCharacter |
|
6643 |
"return a printed representation of the receiver, |
|
6644 |
padded with padCharacter (at the right) up to size. |
|
10460 | 6645 |
If the printString is longer than size, |
5755 | 6646 |
it is returned unchanged (i.e. not truncated)" |
6647 |
||
6648 |
^ (self printString) paddedTo:size with:padCharacter |
|
6649 |
||
6650 |
" |
|
6651 |
123 printStringPaddedTo:10 with:$. |
|
6652 |
123 printStringPaddedTo:10 with:$* |
|
10460 | 6653 |
123 printStringPaddedTo:3 with:$* |
6654 |
1234 printStringPaddedTo:3 with:$* |
|
5755 | 6655 |
" |
6656 |
! |
|
6657 |
||
6658 |
printStringPaddedTo:size with:padCharacter ifLarger:alternative |
|
6659 |
"return a printed representation of the receiver, |
|
6660 |
padded with padCharacter (at the right) up to size. |
|
10460 | 6661 |
If the resulting printString is too large, |
5755 | 6662 |
return the result from evaluating alternative." |
6663 |
||
6664 |
|s| |
|
6665 |
||
6666 |
s := self printString. |
|
6667 |
s size > size ifTrue:[^ alternative value]. |
|
6668 |
^ s paddedTo:size with:padCharacter |
|
6669 |
||
6670 |
" |
|
6671 |
123 printStringPaddedTo:3 with:$. ifLarger:['***'] |
|
6672 |
12345 printStringPaddedTo:3 with:$. ifLarger:['***'] |
|
6673 |
" |
|
6674 |
! |
|
6675 |
||
6676 |
printStringRightAdjustLen:size |
|
6677 |
"obsolete - just a name confusion. |
|
6678 |
This method will go away ..." |
|
11068
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6679 |
<resource: #obsolete> |
5755 | 6680 |
|
6681 |
^ self printStringLeftPaddedTo:size |
|
6682 |
! |
|
6683 |
||
6684 |
printStringZeroPaddedTo:size |
|
10460 | 6685 |
"return a printed representation of the receiver, |
5755 | 6686 |
padded with zero (at the right) characters up to size. |
6687 |
Usually used with float numbers." |
|
6688 |
||
6689 |
^ self printStringPaddedTo:size with:$0 |
|
6690 |
||
6691 |
" |
|
10460 | 6692 |
123.0 printStringZeroPaddedTo:10 |
5755 | 6693 |
" |
6694 |
! |
|
6695 |
||
8287 | 6696 |
printfPrintString:ignoredFormat |
6697 |
"fallback to default printString |
|
6698 |
(for compatibility with float and integer-printing)" |
|
6699 |
||
6700 |
^ self printString |
|
6701 |
! |
|
6702 |
||
5755 | 6703 |
store |
6704 |
"store the receiver on standard output. |
|
6705 |
this method is useless, but included for compatibility." |
|
6706 |
||
6707 |
self storeOn:Stdout |
|
6708 |
! |
|
6709 |
||
7600
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7576
diff
changeset
|
6710 |
storeArrayElementOn:aStream |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7576
diff
changeset
|
6711 |
"store an object as an Array element. |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7576
diff
changeset
|
6712 |
Subclasses may redefine this to omit a leading '#'" |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7576
diff
changeset
|
6713 |
|
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7576
diff
changeset
|
6714 |
^ self storeOn:aStream |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7576
diff
changeset
|
6715 |
! |
5a3fee21c032
#storeString - omit # from Symbols and Arrays that are elements of an array.
Stefan Vogel <sv@exept.de>
parents:
7576
diff
changeset
|
6716 |
|
5755 | 6717 |
storeCR |
6718 |
"store the receiver on standard output; append a carriage return." |
|
6719 |
||
6720 |
self store. |
|
11068
a5ef673886fd
#printOn:format: and #printStringFormat for Date/Time compatibility
Stefan Vogel <sv@exept.de>
parents:
11065
diff
changeset
|
6721 |
Stdout cr. |
5755 | 6722 |
|
6723 |
"Created: 20.5.1996 / 10:26:01 / cg" |
|
6724 |
"Modified: 20.5.1996 / 10:26:57 / cg" |
|
6725 |
! |
|
6726 |
||
6727 |
storeNl |
|
6728 |
"store the receiver on standard output; append a newline. |
|
6729 |
This method is included for backward compatibility- use #storeCR." |
|
6730 |
||
5893
f92054b38d3c
Assign #obsolete resource to obsolete methods
Stefan Vogel <sv@exept.de>
parents:
5879
diff
changeset
|
6731 |
<resource:#obsolete> |
f92054b38d3c
Assign #obsolete resource to obsolete methods
Stefan Vogel <sv@exept.de>
parents:
5879
diff
changeset
|
6732 |
|
5755 | 6733 |
self storeCR. |
6734 |
||
6735 |
"Modified: 20.5.1996 / 10:26:49 / cg" |
|
6736 |
! |
|
6737 |
||
6738 |
storeOn:aStream |
|
6739 |
"store the receiver on aStream; i.e. print an expression which will |
|
6740 |
reconstruct the receiver. |
|
6741 |
Notice, that no self referencing or cyclic objects can be represented |
|
6742 |
in this format. |
|
6743 |
Use storeBinaryOn:, which handles these cases correctly." |
|
6744 |
||
6745 |
|myClass hasSemi sz "{ Class: SmallInteger }" | |
|
6746 |
||
6747 |
thisContext isRecursive ifTrue:[ |
|
10460 | 6748 |
Object recursiveStoreStringSignal raiseRequestWith:self. |
6749 |
('Object [error]: storeString of self referencing object.') errorPrintCR. |
|
6750 |
aStream nextPutAll:'#("recursive")'. |
|
6751 |
^ self |
|
5755 | 6752 |
]. |
6753 |
||
6754 |
myClass := self class. |
|
6755 |
aStream nextPut:$(. |
|
6756 |
aStream nextPutAll:self class name. |
|
6757 |
||
6758 |
hasSemi := false. |
|
6759 |
myClass isVariable ifTrue:[ |
|
10460 | 6760 |
aStream nextPutAll:' basicNew:'. |
6761 |
self basicSize printOn:aStream |
|
5755 | 6762 |
] ifFalse:[ |
10460 | 6763 |
aStream nextPutAll:' basicNew' |
5755 | 6764 |
]. |
6765 |
||
6766 |
sz := myClass instSize. |
|
10460 | 6767 |
1 to:sz do:[:i | |
6768 |
aStream nextPutAll:' instVarAt:'. |
|
6769 |
i printOn:aStream. |
|
6770 |
aStream nextPutAll:' put:'. |
|
6771 |
(self instVarAt:i) storeOn:aStream. |
|
6772 |
aStream nextPut:$;. |
|
6773 |
hasSemi := true |
|
5755 | 6774 |
]. |
6775 |
myClass isVariable ifTrue:[ |
|
10460 | 6776 |
sz := self basicSize. |
6777 |
1 to:sz do:[:i | |
|
6778 |
aStream nextPutAll:' basicAt:'. |
|
6779 |
i printOn:aStream. |
|
6780 |
aStream nextPutAll:' put:'. |
|
6781 |
(self basicAt:i) storeOn:aStream. |
|
6782 |
aStream nextPut:$;. |
|
6783 |
hasSemi := true |
|
6784 |
] |
|
5755 | 6785 |
]. |
6786 |
hasSemi ifTrue:[ |
|
10460 | 6787 |
aStream nextPutAll:' yourself' |
5755 | 6788 |
]. |
6789 |
aStream nextPut:$). |
|
6790 |
||
6791 |
" |
|
6792 |
|s| |
|
6793 |
||
6794 |
s := WriteStream on:(String new). |
|
6795 |
('hello' -> 'world') storeOn:s. |
|
6796 |
s := ReadStream on:(s contents). |
|
6797 |
(Object readFrom:s) inspect |
|
6798 |
" |
|
6799 |
" |
|
6800 |
|s| |
|
6801 |
||
6802 |
s := 'data' asFilename writeStream. |
|
6803 |
('hello' -> 'world') storeOn:s. |
|
6804 |
s close. |
|
6805 |
||
6806 |
s := 'data' asFilename readStream. |
|
6807 |
(Object readFrom:s) inspect |
|
6808 |
" |
|
6809 |
||
6810 |
"does not work example:" |
|
6811 |
" |
|
6812 |
|s a| |
|
6813 |
||
6814 |
a := Array new:2. |
|
6815 |
a at:1 put:a. |
|
6816 |
||
6817 |
s := 'data' asFilename writeStream. |
|
6818 |
a storeOn:s. |
|
6819 |
s close. |
|
6820 |
||
6821 |
s := 'data' asFilename readStream. |
|
6822 |
(Object readFrom:s) inspect |
|
6823 |
" |
|
6824 |
||
6825 |
"Modified: 28.1.1997 / 00:36:12 / cg" |
|
6826 |
! |
|
6827 |
||
6828 |
storeString |
|
6829 |
"return a string representing an expression to reconstruct the receiver. |
|
6830 |
Notice, that no self referencing or cyclic objects can be represented |
|
6831 |
in this format. |
|
6832 |
Use storeBinaryOn:, which handles these cases correctly." |
|
6833 |
||
6834 |
|s| |
|
6835 |
||
6836 |
s := WriteStream on:(String new:50). |
|
6837 |
self storeOn:s. |
|
6838 |
^ s contents |
|
6839 |
! ! |
|
6840 |
||
6841 |
!Object methodsFor:'queries'! |
|
6842 |
||
6843 |
basicSize |
|
6844 |
"return the number of the receivers indexed instance variables, |
|
6845 |
0 if it has none. |
|
6846 |
||
6847 |
This method should NOT be redefined in any subclass (except with great care, for tuning)" |
|
6848 |
||
6849 |
%{ /* NOCONTEXT */ |
|
6850 |
||
8909 | 6851 |
REGISTER INT nbytes; |
5755 | 6852 |
REGISTER OBJ myClass; |
6853 |
int nInstBytes; |
|
6854 |
||
6855 |
/* |
|
6856 |
* notice the missing test for self being a nonNilObject - |
|
6857 |
* this can be done since basicSize is defined both in UndefinedObject |
|
6858 |
* and SmallInteger |
|
6859 |
*/ |
|
6860 |
myClass = __qClass(self); |
|
6861 |
nbytes = __qSize(self); |
|
6862 |
nInstBytes = OHDR_SIZE + __OBJS2BYTES__( __intVal(__ClassInstPtr(myClass)->c_ninstvars) ); |
|
6863 |
||
6864 |
switch ((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK)) { |
|
10460 | 6865 |
case __MASKSMALLINT(POINTERARRAY): |
6866 |
case __MASKSMALLINT(WKPOINTERARRAY): |
|
6867 |
nbytes -= nInstBytes; |
|
6868 |
RETURN ( __mkSmallInteger(__BYTES2OBJS__(nbytes)) ); |
|
6869 |
||
6870 |
case __MASKSMALLINT(BYTEARRAY): |
|
6871 |
nbytes -= nInstBytes; |
|
6872 |
RETURN ( __mkSmallInteger(nbytes / sizeof(char)) ); |
|
6873 |
||
6874 |
case __MASKSMALLINT(FLOATARRAY): |
|
6875 |
nbytes -= nInstBytes; |
|
6876 |
RETURN ( __mkSmallInteger(nbytes / sizeof(float)) ); |
|
6877 |
||
6878 |
case __MASKSMALLINT(DOUBLEARRAY): |
|
5755 | 6879 |
#ifdef __NEED_DOUBLE_ALIGN |
10460 | 6880 |
nInstBytes = (nInstBytes-1+__DOUBLE_ALIGN) &~ (__DOUBLE_ALIGN-1); |
5755 | 6881 |
#endif |
10460 | 6882 |
nbytes -= nInstBytes; |
6883 |
RETURN ( __mkSmallInteger(nbytes / sizeof(double)) ); |
|
6884 |
||
6885 |
case __MASKSMALLINT(WORDARRAY): |
|
6886 |
case __MASKSMALLINT(SWORDARRAY): |
|
6887 |
nbytes -= nInstBytes; |
|
6888 |
RETURN ( __mkSmallInteger(nbytes>>1) ); /* notice the hardcoded 2 here - not sizeof(short) */ |
|
6889 |
||
6890 |
case __MASKSMALLINT(LONGARRAY): |
|
6891 |
case __MASKSMALLINT(SLONGARRAY): |
|
6892 |
nbytes -= nInstBytes; |
|
6893 |
RETURN ( __mkSmallInteger(nbytes>>2) ); /* notice the hardcoded 4 here - not sizeof(int) */ |
|
6894 |
||
6895 |
case __MASKSMALLINT(LONGLONGARRAY): |
|
6896 |
case __MASKSMALLINT(SLONGLONGARRAY): |
|
5755 | 6897 |
#ifdef __NEED_LONGLONG_ALIGN |
10460 | 6898 |
nInstBytes = (nInstBytes-1+__LONGLONG_ALIGN) &~ (__LONGLONG_ALIGN-1); |
5755 | 6899 |
#endif |
10460 | 6900 |
nbytes -= nInstBytes; |
6901 |
RETURN ( __mkSmallInteger(nbytes>>3) ); /* notice the hardcoded 8 here - not sizeof(long long) */ |
|
5755 | 6902 |
} |
6903 |
%}. |
|
6904 |
^ 0 |
|
6905 |
! |
|
6906 |
||
6907 |
byteSize |
|
6908 |
"return the number of bytes in the receivers indexed instance variables, |
|
6909 |
0 if it has none. This only returns non-zero for non-pointer indexed |
|
6910 |
instvars i.e. byteArrays, wordArrays etc. |
|
6911 |
Notice: for Strings the returned size may look strange. |
|
6912 |
Only useful with binary storage." |
|
6913 |
||
6914 |
|myClass| |
|
6915 |
||
6916 |
myClass := self class. |
|
6917 |
myClass isVariable ifTrue:[ |
|
10460 | 6918 |
myClass isPointers ifFalse:[ |
6919 |
myClass isBytes ifTrue:[ |
|
6920 |
^ self basicSize. |
|
6921 |
]. |
|
6922 |
myClass isWords ifTrue:[ |
|
6923 |
^ self basicSize * 2. |
|
6924 |
]. |
|
6925 |
myClass isSignedWords ifTrue:[ |
|
6926 |
^ self basicSize * 2. |
|
6927 |
]. |
|
6928 |
myClass isLongs ifTrue:[ |
|
6929 |
^ self basicSize * 4. |
|
6930 |
]. |
|
6931 |
myClass isSignedLongs ifTrue:[ |
|
6932 |
^ self basicSize * 4. |
|
6933 |
]. |
|
6934 |
myClass isLongLongs ifTrue:[ |
|
6935 |
^ self basicSize * 8. |
|
6936 |
]. |
|
6937 |
myClass isSignedLongLongs ifTrue:[ |
|
6938 |
^ self basicSize * 8. |
|
6939 |
]. |
|
6940 |
myClass isFloats ifTrue:[ |
|
6941 |
^ self basicSize * (ExternalBytes sizeofFloat) |
|
6942 |
]. |
|
6943 |
myClass isDoubles ifTrue:[ |
|
6944 |
^ self basicSize * (ExternalBytes sizeofDouble) |
|
6945 |
]. |
|
6946 |
self error:'unknown variable size class species'. |
|
6947 |
] |
|
5755 | 6948 |
]. |
6949 |
^ 0 |
|
6950 |
||
6951 |
" |
|
10460 | 6952 |
Point new byteSize |
6953 |
'hello' byteSize |
|
6954 |
(ByteArray with:1 with:2) byteSize |
|
6955 |
(FloatArray with:1.5) byteSize |
|
6956 |
(DoubleArray with:1.5) byteSize |
|
6957 |
(WordArray with:1 with:2) byteSize |
|
5755 | 6958 |
" |
6959 |
! |
|
6960 |
||
6961 |
class |
|
6962 |
"return the receivers class" |
|
6963 |
||
6964 |
%{ /* NOCONTEXT */ |
|
6965 |
||
6966 |
RETURN ( __Class(self) ); |
|
6967 |
%} |
|
6968 |
! |
|
6969 |
||
6970 |
respondsTo:aSelector |
|
6971 |
"return true, if the receiver implements a method with selector equal |
|
6972 |
to aSelector; i.e. if there is a method for aSelector in either the |
|
6973 |
receivers class or one of its superclasses. |
|
6974 |
||
6975 |
Notice, that this does not imply, that such a message can be sent without |
|
6976 |
an error being raised. For example, an implementation could send |
|
6977 |
#shouldNotImplement or #subclassResponsibility." |
|
6978 |
||
6979 |
" |
|
6980 |
should we go via the cache, or search (by class) ? |
|
6981 |
The first is faster, most of the time; while the 2nd fills |
|
6982 |
the cache with useless data if this is sent in a loop over all objects. |
|
6983 |
For now, use the cache ... |
|
6984 |
" |
|
6985 |
%{ /* NOCONTEXT */ |
|
6986 |
||
6987 |
if (__lookup(__Class(self), aSelector) == nil) { |
|
10460 | 6988 |
RETURN ( false ); |
5755 | 6989 |
} |
6990 |
RETURN ( true ); |
|
6991 |
%} |
|
6992 |
. |
|
6993 |
^ self class canUnderstand:aSelector |
|
6994 |
||
6995 |
||
6996 |
"'aString' respondsTo:#+" |
|
6997 |
"'aString' respondsTo:#," |
|
6998 |
"'aString' respondsTo:#collect:" |
|
6999 |
! |
|
7000 |
||
7001 |
respondsToArithmetic |
|
7002 |
"return true, if the receiver responds to arithmetic messages. |
|
7003 |
false is returned here - the method is redefined in ArithmeticValue." |
|
7004 |
||
7005 |
^ false |
|
7006 |
! |
|
7007 |
||
7008 |
size |
|
7009 |
"return the number of the receivers indexed instance variables; |
|
7010 |
this method may be redefined in subclasses" |
|
7011 |
||
7012 |
^ self basicSize |
|
7013 |
! |
|
7014 |
||
7015 |
species |
|
7016 |
"return a class which is similar to (or the same as) the receivers class. |
|
7017 |
This is used to create an appropriate object when creating derived |
|
7018 |
copies in the collection classes (sometimes redefined)." |
|
7019 |
||
7020 |
^ self class |
|
7021 |
! |
|
7022 |
||
7023 |
yourself |
|
7024 |
"return the receiver - used for cascades to return self at the end" |
|
7025 |
||
7026 |
^ self |
|
7027 |
! ! |
|
7028 |
||
7029 |
!Object methodsFor:'secure message sending'! |
|
7030 |
||
7031 |
askFor:aSelector |
|
7032 |
"try to send the receiver the message, aSelector. |
|
10460 | 7033 |
If it does not understand it, return false. |
5755 | 7034 |
Otherwise the real value returned. |
7035 |
Useful to send messages such as: #isColor to unknown |
|
7036 |
receivers." |
|
7037 |
||
7038 |
^ self perform:aSelector ifNotUnderstood:[false] |
|
7039 |
||
7040 |
" |
|
10460 | 7041 |
1 askFor:#isColor |
7042 |
Color red askFor:#isColor |
|
7043 |
||
7044 |
1 askFor:#isFoo |
|
7045 |
Color red askFor:#isFoo |
|
5755 | 7046 |
" |
7047 |
! |
|
7048 |
||
7049 |
perform:aSelector ifNotUnderstood:exceptionBlock |
|
7050 |
"try to send message aSelector to the receiver. |
|
7051 |
If its understood, return the methods returned value, |
|
7052 |
otherwise return the value of the exceptionBlock" |
|
7053 |
||
7054 |
|val ok| |
|
7055 |
||
6146 | 7056 |
MessageNotUnderstood handle:[:ex | |
10460 | 7057 |
"/ reject, if the bad message is not the one |
7058 |
"/ we have sent originally |
|
7059 |
ex selector == aSelector ifFalse:[ |
|
7060 |
ex reject |
|
7061 |
]. |
|
7062 |
ex receiver == self ifFalse:[ |
|
7063 |
ex reject |
|
7064 |
]. |
|
5755 | 7065 |
] do:[ |
10460 | 7066 |
val := self perform:aSelector. |
7067 |
ok := true. |
|
5755 | 7068 |
]. |
7069 |
ok isNil ifTrue:[ |
|
10460 | 7070 |
^ exceptionBlock value |
5755 | 7071 |
]. |
7072 |
^ val |
|
7073 |
||
7074 |
" |
|
10460 | 7075 |
1.2345 perform:#foo ifNotUnderstood:['sorry'] |
7076 |
1.2345 perform:#sqrt ifNotUnderstood:['sorry'] |
|
7077 |
12345 perform:#sqrt ifNotUnderstood:['sorry'] |
|
5755 | 7078 |
" |
7079 |
! |
|
7080 |
||
7081 |
perform:aSelector with:argument ifNotUnderstood:exceptionBlock |
|
7082 |
"try to send message aSelector to the receiver. |
|
7083 |
If its understood, return the methods returned value, |
|
7084 |
otherwise return the value of the exceptionBlock" |
|
7085 |
||
7086 |
|val ok| |
|
7087 |
||
8939
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7088 |
MessageNotUnderstood handle:[:ex | |
10460 | 7089 |
"/ reject, if the bad message is not the one |
7090 |
"/ we have sent originally |
|
7091 |
ex selector == aSelector ifFalse:[ |
|
7092 |
ex reject |
|
7093 |
]. |
|
7094 |
ex receiver == self ifFalse:[ |
|
7095 |
ex reject |
|
7096 |
] |
|
5755 | 7097 |
] do:[ |
10460 | 7098 |
val := self perform:aSelector with:argument. |
7099 |
ok := true. |
|
5755 | 7100 |
]. |
7101 |
ok isNil ifTrue:[ |
|
10460 | 7102 |
^ exceptionBlock value |
5755 | 7103 |
]. |
7104 |
^ val |
|
7105 |
||
7106 |
" |
|
7107 |
|unknown| |
|
7108 |
||
8939
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7109 |
unknown := 4. |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7110 |
(unknown perform:#- with:2 ifNotUnderstood:['sorry']) printNewline. |
5755 | 7111 |
unknown := 'high there'. |
8939
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7112 |
(unknown perform:#- with:2 ifNotUnderstood:['sorry']) printNewline. |
5755 | 7113 |
" |
7114 |
! |
|
7115 |
||
5926 | 7116 |
perform:aSelector with:arg1 with:arg2 ifNotUnderstood:exceptionBlock |
7117 |
"try to send message aSelector to the receiver. |
|
7118 |
If its understood, return the methods returned value, |
|
7119 |
otherwise return the value of the exceptionBlock" |
|
7120 |
||
7121 |
|val ok| |
|
7122 |
||
8939
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7123 |
MessageNotUnderstood handle:[:ex | |
10460 | 7124 |
"/ reject, if the bad message is not the one |
7125 |
"/ we have sent originally |
|
7126 |
ex selector == aSelector ifFalse:[ |
|
7127 |
ex reject |
|
7128 |
]. |
|
7129 |
ex receiver == self ifFalse:[ |
|
7130 |
ex reject |
|
7131 |
] |
|
5926 | 7132 |
] do:[ |
10460 | 7133 |
val := self perform:aSelector with:arg1 with:arg2. |
7134 |
ok := true. |
|
5926 | 7135 |
]. |
7136 |
ok isNil ifTrue:[ |
|
10460 | 7137 |
^ exceptionBlock value |
5926 | 7138 |
]. |
7139 |
^ val |
|
7140 |
! |
|
7141 |
||
5755 | 7142 |
perform:aSelector withArguments:argumentArray ifNotUnderstood:exceptionBlock |
7143 |
"try to send message aSelector to the receiver. |
|
7144 |
If its understood, return the methods returned value, |
|
7145 |
otherwise return the value of the exceptionBlock" |
|
7146 |
||
7147 |
|val ok| |
|
7148 |
||
8939
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7149 |
MessageNotUnderstood handle:[:ex | |
10460 | 7150 |
"/ reject, if the bad message is not the one |
7151 |
"/ we have sent originally |
|
7152 |
ex selector == aSelector ifFalse:[ |
|
7153 |
ex reject |
|
7154 |
]. |
|
7155 |
ex receiver == self ifFalse:[ |
|
7156 |
ex reject |
|
7157 |
] |
|
5755 | 7158 |
] do:[ |
10460 | 7159 |
val := self perform:aSelector withArguments:argumentArray. |
7160 |
ok := true. |
|
5755 | 7161 |
]. |
7162 |
ok isNil ifTrue:[ |
|
10460 | 7163 |
^ exceptionBlock value |
5755 | 7164 |
]. |
7165 |
^ val |
|
7166 |
||
7167 |
" |
|
7168 |
|unknown| |
|
7169 |
||
8939
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7170 |
unknown := 4. |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7171 |
(unknown perform:#- withArguments:#(2) ifNotUnderstood:['sorry']) printNewline. |
5755 | 7172 |
unknown := 'high there'. |
8939
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7173 |
(unknown perform:#- withArguments:#(2) ifNotUnderstood:['sorry']) printNewline. |
5755 | 7174 |
" |
7175 |
||
7176 |
"Modified: 27.3.1997 / 14:13:16 / cg" |
|
7177 |
! ! |
|
7178 |
||
7179 |
!Object methodsFor:'signal constants'! |
|
7180 |
||
7181 |
messageNotUnderstoodSignal |
|
6146 | 7182 |
^ MessageNotUnderstood |
5755 | 7183 |
|
7184 |
"Created: 6.3.1997 / 15:46:52 / cg" |
|
7185 |
! ! |
|
7186 |
||
7187 |
!Object methodsFor:'special queries'! |
|
7188 |
||
7189 |
allOwners |
|
7190 |
"return a collection of all objects referencing the receiver" |
|
7191 |
||
7192 |
^ ObjectMemory whoReferences:self |
|
7193 |
! |
|
7194 |
||
7195 |
references:anObject |
|
7196 |
"return true, if the receiver refers to the argument, anObject. |
|
7197 |
- for debugging only" |
|
7198 |
||
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7199 |
^ self referencesObject:anObject |
5755 | 7200 |
|
7201 |
" |
|
7202 |
|v| |
|
7203 |
||
7204 |
v := View new initialize. |
|
10460 | 7205 |
v references:Display. |
5755 | 7206 |
" |
7207 |
! |
|
7208 |
||
7209 |
referencesAny:aCollection |
|
10460 | 7210 |
"return true, if the receiver refers to any object from |
5755 | 7211 |
the argument, aCollection. |
7212 |
- for debugging only" |
|
7213 |
||
10460 | 7214 |
%{ |
5755 | 7215 |
OBJ cls, flags; |
7216 |
int nInsts, inst; |
|
7217 |
||
7218 |
if (! __isNonNilObject(self)) { |
|
10460 | 7219 |
RETURN (false); |
5755 | 7220 |
} |
7221 |
||
8934 | 7222 |
if (__isArrayLike(aCollection)) { |
10460 | 7223 |
int nObjs = __arraySize(aCollection); |
7224 |
char *minAddr = 0, *maxAddr = 0; |
|
7225 |
||
7226 |
if (nObjs == 0) { |
|
7227 |
RETURN (false); |
|
7228 |
} |
|
7229 |
||
7230 |
/* |
|
7231 |
* a little optimization: use the fact that all old objects |
|
7232 |
* refering to a new object are on the remSet; if I am not, |
|
7233 |
* a trivial reject is possible, if all objects are newbees. |
|
7234 |
* as a side effect, gather min/max addresses |
|
7235 |
*/ |
|
7236 |
if ((__qSpace(self) <= OLDSPACE) && !__isRemembered(self)) { |
|
7237 |
int allNewBees = 1; |
|
7238 |
int i; |
|
7239 |
||
7240 |
minAddr = (char *)(__ArrayInstPtr(aCollection)->a_element[0]); |
|
7241 |
maxAddr = minAddr; |
|
7242 |
||
7243 |
for (i=0; i<nObjs; i++) { |
|
7244 |
OBJ anObject; |
|
7245 |
||
7246 |
anObject = __ArrayInstPtr(aCollection)->a_element[i]; |
|
7247 |
||
7248 |
if (__isNonNilObject(anObject)) { |
|
7249 |
int spc; |
|
7250 |
||
7251 |
if (((spc = __qSpace(anObject)) != NEWSPACE) && (spc != SURVSPACE)) { |
|
7252 |
allNewBees = 0; |
|
7253 |
} |
|
7254 |
} |
|
7255 |
||
7256 |
if ((char *)anObject < minAddr) { |
|
7257 |
minAddr = (char *)anObject; |
|
7258 |
} else if ((char *)anObject > maxAddr) { |
|
7259 |
maxAddr = (char *)anObject; |
|
7260 |
} |
|
7261 |
} |
|
7262 |
if (allNewBees) { |
|
7263 |
RETURN (false); |
|
7264 |
} |
|
7265 |
} |
|
7266 |
||
7267 |
/* |
|
7268 |
* fetch min/max in searchList (if not already done) |
|
7269 |
*/ |
|
7270 |
if (minAddr == 0) { |
|
7271 |
int i; |
|
7272 |
||
7273 |
for (i=0; i<nObjs; i++) { |
|
7274 |
OBJ anObject; |
|
7275 |
||
7276 |
anObject = __ArrayInstPtr(aCollection)->a_element[i]; |
|
7277 |
if ((char *)anObject < minAddr) { |
|
7278 |
minAddr = (char *)anObject; |
|
7279 |
} else if ((char *)anObject > maxAddr) { |
|
7280 |
maxAddr = (char *)anObject; |
|
7281 |
} |
|
7282 |
} |
|
7283 |
} |
|
7284 |
||
7285 |
cls = __qClass(self); |
|
7286 |
if (((char *)cls >= minAddr) && ((char *)cls <= maxAddr)) { |
|
5755 | 7287 |
#if defined(memsrch4) |
10460 | 7288 |
if (memsrch4(__arrayVal(aCollection), (INT)cls, nObjs)) { |
7289 |
RETURN (true); |
|
7290 |
} |
|
5755 | 7291 |
#else |
10460 | 7292 |
int i; |
7293 |
||
7294 |
for (i=0; i<nObjs; i++) { |
|
7295 |
OBJ anObject; |
|
7296 |
||
7297 |
anObject = __ArrayInstPtr(aCollection)->a_element[i]; |
|
7298 |
if (cls == anObject) { |
|
7299 |
RETURN (true); |
|
7300 |
} |
|
7301 |
} |
|
5755 | 7302 |
#endif /* memsrch4 */ |
10460 | 7303 |
} |
7304 |
||
7305 |
flags = __ClassInstPtr(cls)->c_flags; |
|
7306 |
if (((INT)flags & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(POINTERARRAY)) { |
|
7307 |
nInsts = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
|
7308 |
} else { |
|
7309 |
nInsts = __intVal(__ClassInstPtr(cls)->c_ninstvars); |
|
7310 |
} |
|
7311 |
if (! nInsts) { |
|
7312 |
RETURN (false); |
|
7313 |
} |
|
7314 |
||
7315 |
if (nObjs == 1) { |
|
7316 |
/* better reverse the loop */ |
|
7317 |
OBJ anObject; |
|
7318 |
||
7319 |
anObject = __ArrayInstPtr(aCollection)->a_element[0]; |
|
5755 | 7320 |
#if defined(memsrch4) |
10460 | 7321 |
if (memsrch4(__InstPtr(self)->i_instvars, (INT)anObject, nInsts)) { |
7322 |
RETURN (true); |
|
7323 |
} |
|
5755 | 7324 |
#else |
10460 | 7325 |
for (inst=0; inst<nInsts; inst++) { |
7326 |
if ((__InstPtr(self)->i_instvars[inst]) == anObject) { |
|
7327 |
RETURN (true); |
|
7328 |
} |
|
7329 |
} |
|
5755 | 7330 |
#endif |
10460 | 7331 |
RETURN (false); |
7332 |
} |
|
7333 |
||
7334 |
for (inst=0; inst<nInsts; inst++) { |
|
7335 |
OBJ instVar = __InstPtr(self)->i_instvars[inst]; |
|
7336 |
int i; |
|
7337 |
||
7338 |
if (((char *)instVar >= minAddr) && ((char *)instVar <= maxAddr)) { |
|
5755 | 7339 |
#if defined(memsrch4) |
10460 | 7340 |
if (memsrch4(__arrayVal(aCollection), (INT)instVar, nObjs)) { |
7341 |
RETURN (true); |
|
7342 |
} |
|
5755 | 7343 |
#else |
10460 | 7344 |
for (i=0; i<nObjs; i++) { |
7345 |
OBJ anObject; |
|
7346 |
||
7347 |
anObject = __ArrayInstPtr(aCollection)->a_element[i]; |
|
7348 |
if (instVar == anObject) { |
|
7349 |
RETURN (true); |
|
7350 |
} |
|
7351 |
} |
|
5755 | 7352 |
#endif /* memsrch4 */ |
10460 | 7353 |
} |
7354 |
} |
|
7355 |
RETURN (false); |
|
5755 | 7356 |
} |
7357 |
%}. |
|
7358 |
||
7359 |
aCollection do:[:el | |
|
10460 | 7360 |
(self referencesObject:el) ifTrue:[^ true]. |
5755 | 7361 |
]. |
7362 |
^ false |
|
7363 |
! |
|
7364 |
||
7365 |
referencesDerivedInstanceOf:aClass |
|
7366 |
"return true, if the receiver refers to an instance of |
|
7367 |
the argument, aClass or its subclass. This method exists |
|
7368 |
to support searching for users of a class." |
|
7369 |
||
10460 | 7370 |
|myClass |
5755 | 7371 |
numInst "{ Class: SmallInteger }" | |
7372 |
||
6631
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
7373 |
"check the class" |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
7374 |
(self isKindOf:aClass) ifTrue:[^ true]. |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
7375 |
|
5755 | 7376 |
myClass := self class. |
7377 |
"check the instance variables" |
|
7378 |
numInst := myClass instSize. |
|
10460 | 7379 |
1 to:numInst do:[:i | |
7380 |
((self instVarAt:i) isKindOf:aClass) ifTrue:[^ true] |
|
5755 | 7381 |
]. |
7382 |
||
7383 |
"check the indexed variables" |
|
7384 |
myClass isVariable ifTrue:[ |
|
10460 | 7385 |
myClass isPointers ifFalse:[ |
7386 |
"no need to search in non pointer fields" |
|
7387 |
((aClass == Number) or:[aClass isSubclassOf:Number]) ifFalse:[^ false]. |
|
7388 |
]. |
|
7389 |
numInst := self basicSize. |
|
7390 |
1 to:numInst do:[:i | |
|
7391 |
((self basicAt:i) isKindOf:aClass) ifTrue:[^ true] |
|
7392 |
] |
|
5755 | 7393 |
]. |
7394 |
^ false |
|
7395 |
||
7396 |
" |
|
10460 | 7397 |
(1 @ 3.4) referencesDerivedInstanceOf:Number |
7398 |
(1 @ 3.4) referencesDerivedInstanceOf:Array |
|
7399 |
View new initialize referencesDerivedInstanceOf:DeviceWorkstation |
|
5755 | 7400 |
" |
7401 |
! |
|
7402 |
||
9279 | 7403 |
referencesForWhich:checkBlock do:actionBlock |
7404 |
|myClass inst |
|
7405 |
numInst "{ Class: SmallInteger }" | |
|
7406 |
||
7407 |
myClass := self class. |
|
7408 |
"check the instance variables" |
|
7409 |
numInst := myClass instSize. |
|
10460 | 7410 |
1 to:numInst do:[:i | |
7411 |
inst := self instVarAt:i. |
|
7412 |
(checkBlock value:inst) ifTrue:[actionBlock value:inst]. |
|
9279 | 7413 |
]. |
7414 |
||
7415 |
"check the indexed variables" |
|
7416 |
myClass isVariable ifTrue:[ |
|
10460 | 7417 |
myClass isPointers ifTrue:[ |
7418 |
"no need to search in non pointer fields" |
|
7419 |
||
7420 |
numInst := self basicSize. |
|
7421 |
1 to:numInst do:[:i | |
|
7422 |
inst := self basicAt:i. |
|
7423 |
(checkBlock value:inst) ifTrue:[actionBlock value:inst]. |
|
7424 |
] |
|
7425 |
] |
|
7426 |
]. |
|
7427 |
||
7428 |
" |
|
7429 |
(1 @ 3.4) referencesForWhich:[:i | i isFloat] do:[:i | Transcript showCR:i] |
|
9279 | 7430 |
" |
7431 |
! |
|
7432 |
||
5755 | 7433 |
referencesInstanceOf:aClass |
7434 |
"return true, if the receiver refers to an instance of |
|
7435 |
the argument, aClass.This method exists |
|
7436 |
to support searching for users of a class." |
|
7437 |
||
10460 | 7438 |
|myClass |
5755 | 7439 |
numInst "{ Class: SmallInteger }" | |
7440 |
||
7441 |
myClass := self class. |
|
7442 |
||
7443 |
"check the class" |
|
7444 |
(myClass isMemberOf:aClass) ifTrue:[^ true]. |
|
7445 |
||
7446 |
"check the instance variables" |
|
7447 |
numInst := myClass instSize. |
|
10460 | 7448 |
1 to:numInst do:[:i | |
7449 |
((self instVarAt:i) isMemberOf:aClass) ifTrue:[^ true] |
|
5755 | 7450 |
]. |
7451 |
||
7452 |
"check the indexed variables" |
|
7453 |
myClass isVariable ifTrue:[ |
|
10460 | 7454 |
myClass isPointers ifFalse:[ |
7455 |
"no need to search in non-pointer indexed fields" |
|
7456 |
myClass isLongs ifTrue:[ |
|
7457 |
(aClass == SmallInteger or:[aClass == LargeInteger]) ifFalse:[^ false]. |
|
7458 |
] ifFalse:[ |
|
7459 |
myClass isFloatsOrDoubles ifTrue:[^ aClass == Float]. |
|
7460 |
^ aClass == SmallInteger |
|
7461 |
] |
|
7462 |
]. |
|
7463 |
numInst := self basicSize. |
|
7464 |
1 to:numInst do:[:i | |
|
7465 |
((self basicAt:i) isMemberOf:aClass) ifTrue:[^ true] |
|
7466 |
] |
|
5755 | 7467 |
]. |
7468 |
^ false |
|
7469 |
||
7470 |
" |
|
10460 | 7471 |
(1 @ 3.4) referencesInstanceOf:Float |
7472 |
(1 @ 3.4) referencesInstanceOf:Fraction |
|
7473 |
View new initialize referencesInstanceOf:(Display class) |
|
5755 | 7474 |
" |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7475 |
! |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7476 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7477 |
referencesObject:anObject |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7478 |
"return true, if the receiver refers to the argument, anObject. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7479 |
- for debugging only" |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7480 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7481 |
%{ /* NOCONTEXT */ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7482 |
OBJ cls, flags; |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7483 |
int nInsts, i; |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7484 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7485 |
if (! __isNonNilObject(self)) { |
10460 | 7486 |
RETURN (false); |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7487 |
} |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7488 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7489 |
/* |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7490 |
* a little optimization: use the fact that all old objects |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7491 |
* refering to a new object are on the remSet; if I am not, |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7492 |
* a trivial reject is possible, if anObject is a newbee |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7493 |
*/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7494 |
if (__isNonNilObject(anObject)) { |
10460 | 7495 |
if ((__qSpace(self) <= OLDSPACE) && !__isRemembered(self)) { |
7496 |
int spc; |
|
7497 |
||
7498 |
if (((spc = __qSpace(anObject)) == NEWSPACE) || (spc == SURVSPACE)) { |
|
7499 |
RETURN (false); |
|
7500 |
} |
|
7501 |
} |
|
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7502 |
} |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7503 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7504 |
cls = __qClass(self); |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7505 |
if (cls == anObject) { |
10460 | 7506 |
RETURN (true); |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7507 |
} |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7508 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7509 |
flags = __ClassInstPtr(cls)->c_flags; |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7510 |
if (((INT)flags & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(POINTERARRAY)) { |
10460 | 7511 |
nInsts = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7512 |
} else { |
10460 | 7513 |
nInsts = __intVal(__ClassInstPtr(cls)->c_ninstvars); |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7514 |
} |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7515 |
if (! nInsts) { |
10460 | 7516 |
RETURN (false); |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7517 |
} |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7518 |
#if defined(memsrch4) |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7519 |
if (memsrch4(__InstPtr(self)->i_instvars, (INT)anObject, nInsts)) { |
10460 | 7520 |
RETURN (true); |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7521 |
} |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7522 |
#else |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7523 |
for (i=0; i<nInsts; i++) { |
10460 | 7524 |
if (__InstPtr(self)->i_instvars[i] == anObject) { |
7525 |
RETURN (true); |
|
7526 |
} |
|
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7527 |
} |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7528 |
#endif /* memsrch4 */ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7529 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7530 |
%}. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7531 |
|
10460 | 7532 |
"/ |myClass |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7533 |
"/ numInst "{ Class: SmallInteger }" | |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7534 |
"/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7535 |
"/ myClass := self class. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7536 |
"/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7537 |
"/ "check the class" |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7538 |
"/ (myClass == anObject) ifTrue:[^ true]. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7539 |
"/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7540 |
"/ "check the instance variables" |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7541 |
"/ numInst := myClass instSize. |
10460 | 7542 |
"/ 1 to:numInst do:[:i | |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7543 |
"/ ((self instVarAt:i) == anObject) ifTrue:[^ true] |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7544 |
"/ ]. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7545 |
"/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7546 |
"/ "check the indexed variables" |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7547 |
"/ myClass isVariable ifTrue:[ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7548 |
"/ myClass isPointers ifFalse:[ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7549 |
"/ "/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7550 |
"/ "/ we could argue about the following unconditional return: |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7551 |
"/ "/ it says that a non pointer array never has a reference to the |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7552 |
"/ "/ corresponding object - not mimicing a reference to a copy of the |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7553 |
"/ "/ integer. However, it avoids useless searches in huge byteArray |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7554 |
"/ "/ like objects when searching for owners. If in doubt, remove it. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7555 |
"/ "/ A consequence of the return below is that #[1 2 3] will say that it |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7556 |
"/ "/ does not refer to the number 2 (think of keeping a copy instead) |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7557 |
"/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7558 |
"/ ^ false. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7559 |
"/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7560 |
"/ "/ alternative: |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7561 |
"/ "/ anObject isNumber ifFalse:[^ false]. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7562 |
"/ ]. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7563 |
"/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7564 |
"/ "/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7565 |
"/ "/ because arrays are so common, and those have a highly tuned |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7566 |
"/ "/ idenitytIndex method, use it |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7567 |
"/ "/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7568 |
"/ myClass == Array ifTrue:[ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7569 |
"/ ^ (self identityIndexOf:anObject) ~~ 0 |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7570 |
"/ ]. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7571 |
"/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7572 |
"/ "/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7573 |
"/ "/ otherwise, do it the slow way |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7574 |
"/ "/ |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7575 |
"/ numInst := self basicSize. |
10460 | 7576 |
"/ 1 to:numInst do:[:i | |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7577 |
"/ ((self basicAt:i) == anObject) ifTrue:[^ true] |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7578 |
"/ ] |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7579 |
"/ ]. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7580 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7581 |
^ false |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7582 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7583 |
" |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7584 |
|v| |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7585 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7586 |
v := View new initialize. |
10460 | 7587 |
v references:Display. |
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6069
diff
changeset
|
7588 |
" |
5755 | 7589 |
! ! |
7590 |
||
11161 | 7591 |
|
5755 | 7592 |
!Object methodsFor:'synchronized evaluation'! |
7593 |
||
10460 | 7594 |
freeSynchronizationSemaphore |
5755 | 7595 |
"free synchronizationSemaphore. May be used, to save memory when |
7596 |
an object is no longer used synchronized." |
|
7597 |
||
7598 |
|sema| |
|
7599 |
||
7600 |
sema := self synchronizationSemaphore. |
|
7601 |
sema notNil ifTrue:[ |
|
10460 | 7602 |
sema wait. "/ get lock |
7603 |
self synchronizationSemaphore:nil. |
|
5755 | 7604 |
]. |
7605 |
||
7606 |
" |
|
7607 |
self synchronized:[]. |
|
7608 |
self synchronizationSemaphore. |
|
7609 |
self freeSynchronizationSemaphore. |
|
7610 |
" |
|
7611 |
||
7612 |
"Created: 28.1.1997 / 19:31:20 / stefan" |
|
7613 |
"Modified: 28.1.1997 / 19:47:55 / stefan" |
|
7614 |
! |
|
7615 |
||
7616 |
synchronizationSemaphore |
|
7617 |
"return the synchronization semaphore for myself. |
|
7618 |
subclasses may redefine" |
|
7619 |
||
7620 |
^ SynchronizationSemaphores at:self ifAbsent:[]. |
|
7621 |
||
7622 |
" |
|
7623 |
self synchronizationSemaphore |
|
7624 |
" |
|
7625 |
||
7626 |
"Modified: 28.1.1997 / 19:47:09 / stefan" |
|
7627 |
! |
|
7628 |
||
7629 |
synchronizationSemaphore:aSemaphore |
|
7630 |
"set the synchronisationSemaphore for myself. |
|
7631 |
subclasses may redefine this method" |
|
7632 |
||
7633 |
aSemaphore isNil ifTrue:[ |
|
10460 | 7634 |
"/ remove Semaphore |
7635 |
SynchronizationSemaphores removeKey:self ifAbsent:nil. |
|
5755 | 7636 |
] ifFalse:[ |
10460 | 7637 |
SynchronizationSemaphores at:self put:aSemaphore. |
5755 | 7638 |
]. |
7639 |
||
7640 |
"Modified: 28.1.1997 / 19:37:48 / stefan" |
|
7641 |
! |
|
7642 |
||
7643 |
synchronized:aBlock |
|
7644 |
"evaluate aBlock synchronized, i.e. use a monitor for this object" |
|
7645 |
||
6600 | 7646 |
|sema wasBlocked| |
7647 |
||
7648 |
wasBlocked := OperatingSystem blockInterrupts. |
|
5755 | 7649 |
|
7650 |
sema := self synchronizationSemaphore. |
|
7651 |
sema isNil ifTrue:[ |
|
10460 | 7652 |
sema := RecursionLock new name:self className. |
7653 |
self synchronizationSemaphore:sema. |
|
5755 | 7654 |
]. |
7655 |
||
6600 | 7656 |
wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
7211
87f5d25b5c3d
Make synchronizationSemaphore a recursionLock
Stefan Vogel <sv@exept.de>
parents:
7208
diff
changeset
|
7657 |
sema critical:aBlock. |
5755 | 7658 |
|
7659 |
" |
|
7660 |
[Object synchronized:[Delay waitForSeconds:2. Transcript showCR:'1']] fork. |
|
7661 |
[Object synchronized:[Delay waitForSeconds:2. Transcript showCR:'2']] fork. |
|
7662 |
" |
|
7663 |
||
7664 |
"Created: 28.1.1997 / 17:52:56 / stefan" |
|
7665 |
"Modified: 30.1.1997 / 13:38:54 / cg" |
|
7666 |
"Modified: 20.2.1997 / 09:43:35 / stefan" |
|
7667 |
! ! |
|
7668 |
||
7669 |
!Object methodsFor:'system primitives'! |
|
7670 |
||
7671 |
asOop |
|
7672 |
"ST-80 compatibility: |
|
7673 |
ST-80 returns an OOP-identity based number here (I guess: its address |
|
7674 |
or index); since ST/X has no such thing, and the objects address cannot |
|
10460 | 7675 |
be used (since its changing over time), we return the objects identityHash |
5755 | 7676 |
key, which provides (at least) some identity indication. |
7677 |
However, notice that (in contrast to ST-80's #asOop), the identityHash |
|
7678 |
key of two non-identical objects may be the same. |
|
7679 |
You'd better not use it - especially do not misuse it." |
|
7680 |
||
7681 |
^ self identityHash |
|
7682 |
||
7683 |
"Created: 9.11.1996 / 19:09:56 / cg" |
|
7684 |
"Modified: 9.11.1996 / 19:16:04 / cg" |
|
7685 |
! |
|
7686 |
||
8939
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7687 |
beImmutable |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7688 |
"experimental - not yet usable; do not use" |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7689 |
|
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7690 |
%{ /* NOCONTEXT */ |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7691 |
if (! __isNonNilObject(self)) { |
10460 | 7692 |
RETURN (self); |
8939
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7693 |
} |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7694 |
__beImmutable(self); |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7695 |
%} |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7696 |
! |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7697 |
|
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7698 |
beMutable |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7699 |
"experimental - not yet usable; do not use" |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7700 |
|
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7701 |
%{ /* NOCONTEXT */ |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7702 |
if (! __isNonNilObject(self)) { |
10460 | 7703 |
RETURN (self); |
8939
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7704 |
} |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7705 |
__beMutable(self); |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7706 |
%} |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7707 |
! |
ac97eb450b97
Fix examples in #perform:*ifNotUnderstood:
Stefan Vogel <sv@exept.de>
parents:
8935
diff
changeset
|
7708 |
|
5755 | 7709 |
become:anotherObject |
7710 |
"make all references to the receiver become references to anotherObject |
|
7711 |
and vice-versa. Notice the vice-versa; see #becomeSameAs: for a one-way become. |
|
7712 |
This can be a very dangerous operation - be warned. |
|
10460 | 7713 |
In general, using #become: should be avoided if possible, since it may |
5755 | 7714 |
produce many strange effects (think of hashing in Sets, Dictionaries etc.). |
7715 |
||
10460 | 7716 |
This may also be an expensive (i.e. slow) operation, |
7717 |
since in the worst case, the whole memory has to be searched for |
|
5755 | 7718 |
references to the two objects (although the primitive tries hard to |
10460 | 7719 |
limit the search, for acceptable performance in most cases). |
7720 |
This method fails, if the receiver or the argument is a SmallInteger |
|
7721 |
or nil, or is a context of a living method (i.e. one that has not already |
|
5755 | 7722 |
returned). |
10460 | 7723 |
(notice that #become: is not used heavily by the system |
5755 | 7724 |
- the Collection-classes have been rewritten to not use it.)" |
7725 |
%{ |
|
7726 |
if (__primBecome(self, anotherObject)) { |
|
10460 | 7727 |
RETURN ( self ); |
5755 | 7728 |
} |
7729 |
%}. |
|
7730 |
self primitiveFailed |
|
7731 |
! |
|
7732 |
||
7733 |
becomeNil |
|
7734 |
"make all references to the receiver become nil - effectively getting |
|
10460 | 7735 |
rid of the receiver. |
5755 | 7736 |
This can be a very dangerous operation - be warned. |
7737 |
||
7738 |
This may be an expensive (i.e. slow) operation. |
|
7739 |
The receiver may not be a SmallInteger or a context of a living method." |
|
7740 |
||
7741 |
%{ |
|
7742 |
if (__primBecomeNil(self)) { |
|
10460 | 7743 |
RETURN ( nil ); |
5755 | 7744 |
} |
7745 |
%}. |
|
7746 |
self primitiveFailed |
|
7747 |
! |
|
7748 |
||
7749 |
becomeSameAs:anotherObject |
|
7750 |
"make all references to the receiver become references to anotherObject |
|
7751 |
but NOT vice versa (as done in #become:). |
|
7752 |
This can be a very dangerous operation - be warned. |
|
10460 | 7753 |
In general, using #become: should be avoided if possible, since it may |
5755 | 7754 |
produce many strange effects (think of hashing in Sets, Dictionaries etc.). |
7755 |
||
7756 |
This may also be an expensive (i.e. slow) operation, |
|
7757 |
since in the worst case, the whole memory has to be searched for |
|
7758 |
references to the two objects (although the primitive tries hard to |
|
7759 |
limit the search, for acceptable performance in most cases). |
|
7760 |
This method fails, if the receiver or the argument is a SmallInteger |
|
7761 |
or nil, or is a context of a living method (i.e. one that has not already returned)." |
|
7762 |
%{ |
|
7763 |
if (__primBecomeSameAs(self, anotherObject)) { |
|
10460 | 7764 |
RETURN ( self ); |
5755 | 7765 |
} |
7766 |
%}. |
|
7767 |
self primitiveFailed |
|
7768 |
! |
|
7769 |
||
7770 |
changeClassTo:otherClass |
|
7771 |
"changes the class of the receiver to the argument, otherClass. |
|
7772 |
This is only allowed (possible), if the receivers class and the argument |
|
7773 |
have the same structure (i.e. number of named instance variables and |
|
10460 | 7774 |
type of indexed instance variables). |
5755 | 7775 |
If the structures do not match, or any of the original class or new class |
7776 |
is UndefinedObject or a Smallinteger, a primitive error is triggered." |
|
7777 |
||
7778 |
|myClass ok| |
|
7779 |
||
9405 | 7780 |
otherClass autoload. |
7781 |
||
5755 | 7782 |
"check for UndefinedObject/SmallInteger receiver or newClass" |
7783 |
%{ |
|
7784 |
{ |
|
10460 | 7785 |
OBJ other = otherClass; |
7786 |
||
7787 |
if (__isNonNilObject(self) |
|
7788 |
&& __isNonNilObject(other) |
|
7789 |
&& (other != UndefinedObject) |
|
7790 |
&& (other != SmallInteger)) { |
|
7791 |
ok = true; |
|
7792 |
} else { |
|
7793 |
ok = false; |
|
7794 |
} |
|
5755 | 7795 |
} |
7796 |
%}. |
|
7797 |
ok ifTrue:[ |
|
10460 | 7798 |
ok := false. |
7799 |
myClass := self class. |
|
7800 |
myClass flags == otherClass flags ifTrue:[ |
|
7801 |
myClass instSize == otherClass instSize ifTrue:[ |
|
7802 |
"same instance layout and types: its ok to do it" |
|
7803 |
ok := true. |
|
7804 |
] ifFalse:[ |
|
7805 |
myClass isPointers ifTrue:[ |
|
7806 |
myClass isVariable ifTrue:[ |
|
7807 |
ok := true |
|
7808 |
] |
|
7809 |
] |
|
7810 |
] |
|
7811 |
] ifFalse:[ |
|
7812 |
myClass isPointers ifTrue:[ |
|
7813 |
"if newClass is a variable class, with instSize <= my instsize, |
|
7814 |
we can do it (effectively mapping additional instvars into the |
|
7815 |
variable part) - usefulness is questionable, though" |
|
7816 |
||
7817 |
otherClass isPointers ifTrue:[ |
|
7818 |
otherClass isVariable ifTrue:[ |
|
7819 |
otherClass instSize <= (myClass instSize + self basicSize) |
|
7820 |
ifTrue:[ |
|
7821 |
ok := true |
|
7822 |
] |
|
7823 |
] ifFalse:[ |
|
7824 |
otherClass instSize == (myClass instSize + self basicSize) |
|
7825 |
ifTrue:[ |
|
7826 |
ok := true |
|
7827 |
] |
|
7828 |
] |
|
7829 |
] ifFalse:[ |
|
7830 |
"it does not make sense to convert pointers to bytes ..." |
|
7831 |
] |
|
7832 |
] ifFalse:[ |
|
7833 |
"does it make sense, to convert bits ?" |
|
7834 |
"could allow byteArray->wordArray->longArray->floatArray->doubleArray here ..." |
|
7835 |
(myClass isBitsExtended and:[otherClass isBitsExtended]) ifTrue:[ |
|
7836 |
ok := true |
|
7837 |
] |
|
7838 |
] |
|
7839 |
] |
|
5755 | 7840 |
]. |
7841 |
ok ifTrue:[ |
|
10460 | 7842 |
"now, change the receivers class ..." |
5755 | 7843 |
%{ |
10460 | 7844 |
{ |
7845 |
OBJ me = self; |
|
7846 |
||
7847 |
__qClass(me) = otherClass; |
|
7848 |
__STORE(me, otherClass); |
|
7849 |
RETURN (me); |
|
7850 |
} |
|
5755 | 7851 |
%}. |
7852 |
]. |
|
9405 | 7853 |
|
5755 | 7854 |
" |
7855 |
the receiver cannot be represented as a instance of |
|
7856 |
the desired class. |
|
10460 | 7857 |
For example, you cannot change a bitInstance (byteArray etc.) |
5755 | 7858 |
into a pointer object and vice versa. |
7859 |
" |
|
7860 |
self primitiveFailed |
|
7861 |
! |
|
7862 |
||
7863 |
changeClassToThatOf:anObject |
|
7864 |
"changes the class of the receiver to that of the argument, anObject. |
|
7865 |
This is only allowed (possible), if the receivers class and the arguments |
|
10460 | 7866 |
class have the same structure (i.e. number of named instance variables and |
5755 | 7867 |
type of indexed instance variables). If the structures do not match, or any |
7868 |
of the objects is nil or a Smallinteger, a primitive error is triggered." |
|
7869 |
||
7870 |
self changeClassTo:(anObject class) |
|
6033
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7871 |
! |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7872 |
|
8935 | 7873 |
isImmutable |
7874 |
"experimental - not yet usable; do not use" |
|
7875 |
||
7876 |
%{ /* NOCONTEXT */ |
|
7877 |
if (! __isNonNilObject(self)) { |
|
10460 | 7878 |
RETURN (true); |
8935 | 7879 |
} |
7880 |
RETURN (__isImmutable(self) ? true : false); |
|
7881 |
%} |
|
7882 |
! |
|
7883 |
||
6033
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7884 |
replaceReferencesTo:anObject with:newRef |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7885 |
"if the receiver refers to the argument, anObject, replace this reference with newRef. |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7886 |
Return true, if any reference was changed. |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7887 |
Notice: this does not change the class-reference." |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7888 |
|
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7889 |
%{ /* NOCONTEXT */ |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7890 |
OBJ cls, flags, anyChange; |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7891 |
int nInsts, i; |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7892 |
|
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7893 |
if (! __isNonNilObject(self)) { |
10460 | 7894 |
RETURN (false); |
6033
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7895 |
} |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7896 |
|
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7897 |
/* |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7898 |
* a little optimization: use the fact that all old objects |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7899 |
* refering to a new object are on the remSet; if I am not, |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7900 |
* a trivial reject is possible, if anObject is a newbee |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7901 |
*/ |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7902 |
if (__isNonNilObject(anObject)) { |
10460 | 7903 |
if ((__qSpace(self) <= OLDSPACE) && !__isRemembered(self)) { |
7904 |
int spc; |
|
7905 |
||
7906 |
if (((spc = __qSpace(anObject)) == NEWSPACE) || (spc == SURVSPACE)) { |
|
7907 |
RETURN (false); |
|
7908 |
} |
|
7909 |
} |
|
6033
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7910 |
} |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7911 |
|
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7912 |
cls = __qClass(self); |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7913 |
|
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7914 |
flags = __ClassInstPtr(cls)->c_flags; |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7915 |
if (((INT)flags & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(POINTERARRAY)) { |
10460 | 7916 |
nInsts = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
6033
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7917 |
} else { |
10460 | 7918 |
nInsts = __intVal(__ClassInstPtr(cls)->c_ninstvars); |
6033
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7919 |
} |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7920 |
if (! nInsts) { |
10460 | 7921 |
RETURN (false); |
6033
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7922 |
} |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7923 |
anyChange = false; |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7924 |
for (i=0; i<nInsts; i++) { |
10460 | 7925 |
if (__InstPtr(self)->i_instvars[i] == anObject) { |
7926 |
__InstPtr(self)->i_instvars[i] = newRef; |
|
7927 |
__STORE(self, newRef); |
|
7928 |
anyChange = true; |
|
7929 |
} |
|
6033
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7930 |
} |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7931 |
RETURN (anyChange); |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7932 |
%}. |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7933 |
|
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7934 |
" |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7935 |
|v| |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7936 |
|
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7937 |
v := Array with:1234 with:'hello' with:Array. |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7938 |
v replaceReferencesTo:Array with:ByteArray. |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7939 |
v inspect |
be1b7877b425
+ #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
6005
diff
changeset
|
7940 |
" |
5755 | 7941 |
! ! |
7942 |
||
7943 |
!Object methodsFor:'testing'! |
|
7944 |
||
7945 |
? defaultValue |
|
7946 |
"a syntactic shugar-piece: |
|
7947 |
if the receiver is nil, return the defaultValue; |
|
7948 |
otherwise, return the receiver. |
|
7949 |
This method is only redefined in UndefinedObject - therefore, |
|
7950 |
the recevier is retuned here. |
|
7951 |
||
7952 |
Thus, if foo and bar are simple variables or constants, |
|
10460 | 7953 |
foo ? bar |
5755 | 7954 |
is the same as: |
10460 | 7955 |
(foo isNil ifTrue:[bar] ifFalse:[foo]) |
5755 | 7956 |
|
7957 |
if they are message sends, the equivalent code is: |
|
10460 | 7958 |
[ |
7959 |
|t1 t2| |
|
7960 |
||
7961 |
t1 := foo. |
|
7962 |
t2 := bar. |
|
7963 |
t1 isNil ifTrue:[t2] ifFalse:[t1] |
|
7964 |
] value |
|
5755 | 7965 |
|
7966 |
Can be used to provide defaultValues to variables, |
|
7967 |
as in: |
|
10460 | 7968 |
foo := arg ? #defaultValue |
5755 | 7969 |
|
7970 |
Note: this method should never be redefined in classes other than UndefinedObject. |
|
7971 |
Notice: |
|
10460 | 7972 |
This method is open coded (inlined) by the compiler(s) |
7973 |
- redefining it may not work as expected." |
|
5755 | 7974 |
|
7975 |
^ self |
|
7976 |
||
7977 |
" |
|
7978 |
1 ? #default |
|
7979 |
nil ? #default |
|
7980 |
" |
|
7981 |
||
7982 |
"Created: / 4.11.1996 / 20:36:19 / cg" |
|
7983 |
"Modified: / 19.5.1998 / 17:39:56 / cg" |
|
7984 |
! |
|
7985 |
||
7986 |
?? defaultValue |
|
7987 |
"a syntactic shugar-piece: |
|
7988 |
much like ?, but sends #value to the argument if required. |
|
7989 |
(i.e. its the same as #ifNil:) |
|
7990 |
If the receiver is nil, return the defaultValues value; |
|
7991 |
otherwise, return the receiver. |
|
7992 |
This method is only redefined in UndefinedObject - therefore, |
|
7993 |
the recevier is retuned here. |
|
7994 |
||
7995 |
Thus, if foo and bar are simple variables or constants, |
|
10460 | 7996 |
foo ?? bar |
5755 | 7997 |
is the same as: |
10460 | 7998 |
(foo isNil ifTrue:[bar value] ifFalse:[foo]) |
5755 | 7999 |
|
8000 |
if they are message sends, the equivalent code is: |
|
10460 | 8001 |
[ |
8002 |
|t t2| |
|
8003 |
||
8004 |
t := foo. |
|
8005 |
t isNil ifTrue:[bar value] ifFalse:[t] |
|
8006 |
] value |
|
5755 | 8007 |
|
8008 |
Can be used to provide defaultValues to variables, |
|
8009 |
as in: |
|
10460 | 8010 |
foo := arg ?? [ self computeDefault ] |
5755 | 8011 |
|
8012 |
Note: this method should never be redefined in classes other than UndefinedObject. |
|
8013 |
" |
|
8014 |
||
8015 |
^ self |
|
8016 |
||
8017 |
" |
|
10460 | 8018 |
1 ?? #default |
5755 | 8019 |
nil ?? #default |
10460 | 8020 |
1 ?? [ self halt. 1 + 2 ] |
8021 |
nil ?? [ self halt. 1 + 2 ] |
|
8022 |
1 ?? [Date today] |
|
8023 |
nil ?? [Date today] |
|
5755 | 8024 |
" |
8025 |
||
8026 |
"Created: / 4.11.1996 / 20:36:19 / cg" |
|
8027 |
"Modified: / 19.5.1998 / 17:42:56 / cg" |
|
8028 |
! |
|
8029 |
||
8030 |
ifNil:aBlockOrValue |
|
8031 |
"return myself, or the result from evaluating the argument, if I am nil. |
|
8032 |
This is much like #?, but sends #value to the argument in case of a nil |
|
8033 |
receiver. |
|
8034 |
Notice: |
|
10460 | 8035 |
This method is open coded (inlined) by the compiler(s) |
8036 |
- redefining it may not work as expected." |
|
5755 | 8037 |
|
8038 |
^ self |
|
8039 |
! |
|
8040 |
||
8041 |
ifNil:nilBlockOrValue ifNotNil:notNilBlockOrValue |
|
8042 |
"return the value of the first arg, if I am nil, |
|
8043 |
the result from evaluating the 2nd argument, if I am not nil. |
|
8044 |
Notice: |
|
10460 | 8045 |
This method is open coded (inlined) by the compiler(s) |
8046 |
- redefining it may not work as expected." |
|
5755 | 8047 |
|
8048 |
^ notNilBlockOrValue value |
|
8049 |
||
8050 |
! |
|
8051 |
||
8052 |
ifNotNil:aBlockOrValue |
|
10460 | 8053 |
"return myself if nil, or the result from evaluating the argument, |
5755 | 8054 |
if I am not nil. |
8055 |
Notice: |
|
10460 | 8056 |
This method is open coded (inlined) by the compiler(s) |
8057 |
- redefining it may not work as expected." |
|
5755 | 8058 |
|
8059 |
^ aBlockOrValue value |
|
8060 |
||
8061 |
! |
|
8062 |
||
8063 |
ifNotNil:notNilBlockOrValue ifNil:nilBlockOrValue |
|
8064 |
"return the value of the 2nd arg, if I am nil, |
|
8065 |
the result from evaluating the 1st argument, if I am not nil. |
|
8066 |
Notice: |
|
10460 | 8067 |
This method is open coded (inlined) by the compiler(s) |
8068 |
- redefining it may not work as expected." |
|
5755 | 8069 |
|
8070 |
^ notNilBlockOrValue value |
|
8071 |
||
8072 |
||
8073 |
! |
|
8074 |
||
8574 | 8075 |
ifNotNilDo:aBlock |
8076 |
"if the reciever is non-nil, return the value of aBlock, passing myself as argument. |
|
8077 |
Otherwise do nothing and return nil." |
|
8078 |
||
8079 |
^ aBlock value:self |
|
8080 |
! |
|
8081 |
||
5755 | 8082 |
isArray |
8083 |
"return true, if the receiver is some kind of array (or weakArray etc); |
|
8084 |
false is returned here - the method is only redefined in Array." |
|
8085 |
||
8086 |
^ false |
|
8087 |
! |
|
8088 |
||
8089 |
isAssociation |
|
8090 |
"return true, if the receiver is some kind of association; |
|
8091 |
false is returned here - the method is only redefined in Association." |
|
8092 |
||
8093 |
^ false |
|
8094 |
||
8095 |
"Created: 14.5.1996 / 17:03:45 / cg" |
|
8096 |
! |
|
8097 |
||
8098 |
isBehavior |
|
9221 | 8099 |
"return true, if the receiver is describing another objects behavior. |
8100 |
False is returned here - the method is only redefined in Behavior." |
|
5755 | 8101 |
|
8102 |
^ false |
|
8103 |
! |
|
8104 |
||
8105 |
isBlock |
|
8106 |
"return true, if the receiver is some kind of block; |
|
8107 |
false returned here - the method is only redefined in Block." |
|
8108 |
||
8109 |
^ false |
|
8110 |
! |
|
8111 |
||
5824 | 8112 |
isBoolean |
8113 |
"return true, if the receiver is a boolean; |
|
8114 |
false is returned here - the method is only redefined in Boolean." |
|
8115 |
||
8116 |
^ false |
|
8117 |
! |
|
8118 |
||
5755 | 8119 |
isByteArray |
8120 |
"return true, if the receiver is some kind of bytearray; |
|
8121 |
false is returned here - the method is only redefined in ByteArray." |
|
8122 |
||
8123 |
^ false |
|
8124 |
! |
|
8125 |
||
8986 | 8126 |
isByteCollection |
8127 |
"return true, if the receiver is some kind of byte collection, |
|
10460 | 8128 |
i.e. #at: and #at:put: accesses a byte. This is different from 'self class isBytes', |
8986 | 8129 |
since e.g. in BitArray single bits are accessed, but it is implemented as variableBytes class. |
10460 | 8130 |
|
8986 | 8131 |
false is returned here - the method is only redefined in UninterpretedBytes." |
8132 |
||
8133 |
^ false |
|
8134 |
! |
|
8135 |
||
5755 | 8136 |
isCharacter |
8137 |
"return true, if the receiver is some kind of character; |
|
8138 |
false is returned here - the method is only redefined in Character." |
|
8139 |
||
8140 |
^ false |
|
8141 |
! |
|
8142 |
||
8143 |
isClass |
|
9405 | 8144 |
"return true, if the receiver is some kind of class |
8145 |
(real class, not just behavior); |
|
5755 | 8146 |
false is returned here - the method is only redefined in Class." |
8147 |
||
8148 |
^ false |
|
8149 |
! |
|
8150 |
||
8151 |
isCollection |
|
8152 |
"return true, if the receiver is some kind of collection; |
|
8153 |
false is returned here - the method is only redefined in Collection." |
|
8154 |
||
8155 |
^ false |
|
8156 |
! |
|
8157 |
||
8158 |
isColor |
|
8159 |
"return true, if the receiver is some kind of color; |
|
8160 |
false is returned here - the method is only redefined in Color." |
|
8161 |
||
8162 |
^ false |
|
8163 |
! |
|
8164 |
||
6567 | 8165 |
isCons |
8166 |
"return true, if the receiver is a cons (pair); |
|
8167 |
false is returned here - the method is only redefined in Cons." |
|
8168 |
||
8169 |
^ false |
|
8170 |
! |
|
8171 |
||
5755 | 8172 |
isContext |
8173 |
"return true, if the receiver is some kind of context; |
|
8174 |
false returned here - the method is only redefined in Context." |
|
8175 |
||
8176 |
^ false |
|
8177 |
! |
|
8178 |
||
6181 | 8179 |
isEmptyOrNil |
8833 | 8180 |
"return true if I am nil or an empty collection - return false here. |
8181 |
(from Squeak)" |
|
6181 | 8182 |
|
8183 |
^ false |
|
8184 |
||
8185 |
"Created: / 13.11.2001 / 13:17:04 / cg" |
|
6182 | 8186 |
"Modified: / 13.11.2001 / 13:28:40 / cg" |
6181 | 8187 |
! |
8188 |
||
6221 | 8189 |
isException |
6631
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8190 |
"answer true, if this ia an Exception, that may be queried about its type" |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8191 |
|
6221 | 8192 |
^ false |
8193 |
||
8194 |
"Created: / 17.11.2001 / 18:37:44 / cg" |
|
8195 |
! |
|
8196 |
||
6631
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8197 |
isExceptionCreator |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8198 |
"return true, if the receiver can create exceptions, |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8199 |
this includes #raise, #raiseRequest as well as the behavior of |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8200 |
an exception handler, such as the #accepts: and #handles: messages" |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8201 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8202 |
^ false |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8203 |
! |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8204 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8205 |
isExceptionHandler |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8206 |
"return true, if the receiver responds to the exception handler protocol, |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8207 |
especially to the #accepts: and #handles: messages" |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8208 |
|
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8209 |
^ false |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8210 |
! |
5ffa1ce7b2cc
#isExceptionCreator instead of #isSignal
Stefan Vogel <sv@exept.de>
parents:
6600
diff
changeset
|
8211 |
|
10480 | 8212 |
isExternalLibraryFunction |
8213 |
"return true, if the receiver is some kind of externalLibrary function; |
|
8214 |
false is returned here - the method is only redefined in ExternalLibraryFunction." |
|
8215 |
||
8216 |
^false |
|
8217 |
! |
|
8218 |
||
5755 | 8219 |
isExternalStream |
8220 |
"return true, if the receiver is some kind of externalStream; |
|
8221 |
false is returned here - the method is only redefined in ExternalStream." |
|
8222 |
||
8223 |
^false |
|
8224 |
! |
|
8225 |
||
8226 |
isFileStream |
|
8227 |
"return true, if the receiver is some kind of fileStream; |
|
8228 |
false is returned here - the method is only redefined in FileStream." |
|
8229 |
||
8230 |
^false |
|
8231 |
! |
|
8232 |
||
8233 |
isFilename |
|
8234 |
"return true, if the receiver is some kind of filename; |
|
8235 |
false is returned here - the method is only redefined in Filename." |
|
8236 |
||
8237 |
^false |
|
8238 |
! |
|
8239 |
||
8240 |
isFixedPoint |
|
8241 |
"return true, if the receiver is some kind of fixedPoint number; |
|
8242 |
false is returned here - the method is only redefined in FixedPoint." |
|
8243 |
||
8244 |
^ false |
|
8245 |
||
8246 |
"Created: 5.11.1996 / 19:23:04 / cg" |
|
8247 |
! |
|
8248 |
||
8249 |
isFixedSize |
|
10460 | 8250 |
"return true if the receiver cannot grow easily |
5755 | 8251 |
(i.e. a grow may be expensive, since it involves a become:)" |
8252 |
||
8253 |
^ true |
|
8254 |
! |
|
8255 |
||
6185 | 8256 |
isFloat |
8257 |
"return true, if the receiver is some kind of floating point number; |
|
8258 |
false is returned here. |
|
8259 |
Same as #isLimitedPrecisionReal, but a better name ;-)" |
|
8260 |
||
8261 |
^ false |
|
8262 |
||
8263 |
"Modified: / 14.11.2001 / 14:57:46 / cg" |
|
8264 |
! |
|
8265 |
||
5755 | 8266 |
isForm |
8267 |
"return true, if the receiver is some kind of form; |
|
8268 |
false is returned here - the method is only redefined in Form." |
|
8269 |
||
8270 |
^ false |
|
8271 |
! |
|
8272 |
||
8273 |
isFraction |
|
8274 |
"return true, if the receiver is some kind of fraction; |
|
8275 |
false is returned here - the method is only redefined in Fraction." |
|
8276 |
||
8277 |
^ false |
|
8278 |
! |
|
8279 |
||
9293 | 8280 |
isHierarchicalItem |
8281 |
"used to decide if the parent is a hierarchical item or the model" |
|
8282 |
||
8283 |
^ false |
|
8284 |
! |
|
8285 |
||
5755 | 8286 |
isImage |
8287 |
"return true, if the receiver is some kind of image; |
|
8288 |
false is returned here - the method is only redefined in Image." |
|
8289 |
||
8290 |
^ false |
|
8291 |
! |
|
8292 |
||
8293 |
isImageOrForm |
|
8294 |
"return true, if the receiver is some kind of image or form; |
|
8295 |
false is returned here - the method is only redefined in Image and Form." |
|
8296 |
||
8297 |
^ false |
|
8298 |
! |
|
8299 |
||
8300 |
isImmediate |
|
8301 |
"return true if I am an immediate object |
|
8302 |
i.e. I am represented in the pointer itself and |
|
8303 |
no real object header/storage is used me. |
|
8304 |
(currently, only SmallIntegers, some characters and nil return true)" |
|
8305 |
||
8306 |
^ self class hasImmediateInstances |
|
8307 |
||
8308 |
"Created: 3.6.1997 / 12:00:18 / cg" |
|
8309 |
! |
|
8310 |
||
8311 |
isInteger |
|
8312 |
"return true, if the receiver is some kind of integer number; |
|
8313 |
false is returned here - the method is only redefined in Integer." |
|
8314 |
||
8315 |
^ false |
|
8316 |
! |
|
8317 |
||
9279 | 8318 |
isInterestConverter |
8319 |
"return true if I am a kind of interest forwarder" |
|
8320 |
||
8321 |
^ false |
|
8322 |
! |
|
8323 |
||
10576 | 8324 |
isInternalByteStream |
8325 |
"return true, if the receiver is some kind of Stream for reading bytes; |
|
8326 |
false is returned here - the method is only redefined in PeekableStream." |
|
8327 |
||
8328 |
^false |
|
8329 |
||
8330 |
"Created: / 30-05-2007 / 16:15:33 / cg" |
|
8331 |
! |
|
8332 |
||
5755 | 8333 |
isJavaClass |
8334 |
"return true, if this is a javaClass. |
|
8335 |
false is returned here - the method is only redefined in JavaClass." |
|
8336 |
||
8337 |
^ false |
|
8338 |
||
8339 |
"Created: / 26.3.1997 / 13:34:54 / cg" |
|
8340 |
"Modified: / 8.5.1998 / 21:25:21 / cg" |
|
8341 |
! |
|
8342 |
||
8343 |
isJavaClassRef |
|
8344 |
"return true, if this is a JavaClassRef. |
|
8345 |
false is returned here - the method is only redefined in JavaClassRef." |
|
8346 |
||
8347 |
^ false |
|
8348 |
||
8349 |
"Modified: / 8.5.1998 / 21:25:46 / cg" |
|
8350 |
"Created: / 24.12.1999 / 01:46:28 / cg" |
|
8351 |
! |
|
8352 |
||
8353 |
isJavaContext |
|
8354 |
"return true, if this is a javaContext. |
|
8355 |
false is returned here - the method is only redefined in JavaContext." |
|
8356 |
||
8357 |
^ false |
|
8358 |
||
8359 |
"Created: / 8.5.1998 / 21:24:27 / cg" |
|
8360 |
"Modified: / 8.5.1998 / 21:25:35 / cg" |
|
8361 |
! |
|
8362 |
||
8363 |
isJavaMethod |
|
8364 |
"return true, if this is a JavaMethod. |
|
8365 |
false is returned here - the method is only redefined in JavaMethod." |
|
8366 |
||
8367 |
^ false |
|
8368 |
||
8369 |
"Modified: / 8.5.1998 / 21:25:46 / cg" |
|
8370 |
"Created: / 25.9.1999 / 23:26:12 / cg" |
|
8371 |
! |
|
8372 |
||
8373 |
isJavaMethodRef |
|
8374 |
"return true, if this is a JavaMethodRef. |
|
8375 |
false is returned here - the method is only redefined in JavaMethodRef." |
|
8376 |
||
8377 |
^ false |
|
8378 |
||
8379 |
"Modified: / 8.5.1998 / 21:25:46 / cg" |
|
8380 |
"Created: / 23.12.1999 / 19:44:51 / cg" |
|
8381 |
! |
|
8382 |
||
8383 |
isJavaObject |
|
8384 |
"return true, if this is a javaObject. |
|
8385 |
false is returned here - the method is only redefined in JavaObject." |
|
8386 |
||
8387 |
^ false |
|
8388 |
||
8389 |
"Created: / 26.3.1997 / 13:34:48 / cg" |
|
8390 |
"Modified: / 8.5.1998 / 21:25:46 / cg" |
|
8391 |
! |
|
8392 |
||
8393 |
isJavaScriptClass |
|
8394 |
"return true, if this is a javaScriptClass. |
|
8395 |
false is returned here - the method is only redefined in JavaScriptClass." |
|
8396 |
||
8397 |
^ false |
|
8398 |
! |
|
8399 |
||
8935 | 8400 |
isJavaScriptMetaclass |
8401 |
"return true, if this is a javaScript Metaclass. |
|
8402 |
false is returned here - the method is only redefined in JavaScriptMetaclass." |
|
8403 |
||
8404 |
^ false |
|
8405 |
! |
|
8406 |
||
5755 | 8407 |
isKindOf:aClass |
8408 |
"return true, if the receiver is an instance of aClass or one of its |
|
8409 |
subclasses, false otherwise. |
|
10460 | 8410 |
Advice: |
8411 |
use of this to check objects for certain attributes/protocoll should |
|
8412 |
be avoided; it limits the reusability of your classes by limiting use |
|
8413 |
to instances of certain classes and fences you into a specific inheritance |
|
8414 |
hierarchy. |
|
8415 |
Use check-methods to check an object for a certain attributes/protocol |
|
8416 |
(such as #isXXXX, #respondsTo: or #isNumber). |
|
8417 |
||
8418 |
Using #isKindOf: is considered BAD STYLE. |
|
5755 | 8419 |
|
8420 |
Advice2: |
|
10460 | 8421 |
Be aware, that using an #isXXX method is usually much faster than |
8422 |
using #isKindOf:; because isKindOf: has to walk up all the superclass |
|
8423 |
hierarchy, comparing every class on the way. |
|
8424 |
Due to caching in the VM, a call to #isXXX is normally reached via |
|
8425 |
a single function call. |
|
5755 | 8426 |
" |
8427 |
||
8428 |
%{ /* NOCONTEXT */ |
|
8429 |
register OBJ thisClass; |
|
8430 |
||
8431 |
thisClass = __Class(self); |
|
8432 |
while (thisClass != nil) { |
|
10460 | 8433 |
if (thisClass == aClass) { |
8434 |
RETURN ( true ); |
|
8435 |
} |
|
8436 |
thisClass = __ClassInstPtr(thisClass)->c_superclass; |
|
5755 | 8437 |
} |
8438 |
RETURN ( false ); |
|
8439 |
%} |
|
8440 |
||
8441 |
"/ |
|
8442 |
"/ the above code is equivalent to: |
|
8443 |
"/ |
|
8444 |
"/ thisClass := self class. |
|
8445 |
"/ [thisClass notNil] whileTrue:[ |
|
8446 |
"/ thisClass == aClass ifTrue:[^ true]. |
|
8447 |
"/ thisClass := thisClass superclass |
|
8448 |
"/ ]. |
|
8449 |
"/ ^ false |
|
8450 |
"/ |
|
8451 |
||
8452 |
! |
|
8453 |
||
8454 |
isLayout |
|
8455 |
"return true, if the receiver is some kind of layout; |
|
8456 |
false is returned here - the method is only redefined in Layout." |
|
8457 |
||
8458 |
^ false |
|
8459 |
! |
|
8460 |
||
6567 | 8461 |
isLazyValue |
8462 |
^ false |
|
8463 |
! |
|
8464 |
||
6086
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
6074
diff
changeset
|
8465 |
isLimitedPrecisionReal |
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
6074
diff
changeset
|
8466 |
"return true, if the receiver is some kind of floating point number; |
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
6074
diff
changeset
|
8467 |
false is returned here - the method is only redefined in LimitedPrecisionReal." |
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
6074
diff
changeset
|
8468 |
|
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
6074
diff
changeset
|
8469 |
^ false |
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
6074
diff
changeset
|
8470 |
! |
0bd476397581
added isLimitedPrecisionReal
Claus Gittinger <cg@exept.de>
parents:
6074
diff
changeset
|
8471 |
|
5755 | 8472 |
isList |
8473 |
"return true, if the receiver is some kind of list collection; |
|
8474 |
false is returned here - the method is only redefined in List." |
|
8475 |
||
8476 |
^ false |
|
8477 |
||
8478 |
"Created: / 11.2.2000 / 01:37:05 / cg" |
|
8479 |
! |
|
8480 |
||
8481 |
isLiteral |
|
8482 |
"return true, if the receiver can be represented as a literal constant in ST syntax; |
|
8483 |
false is returned here - the method is redefined in some classes." |
|
8484 |
||
8485 |
^ false |
|
8486 |
! |
|
8487 |
||
8488 |
isMemberOf:aClass |
|
8489 |
"return true, if the receiver is an instance of aClass, false otherwise. |
|
10460 | 8490 |
Advice: |
8491 |
use of this to check objects for certain attributes/protocol should |
|
8492 |
be avoided; it limits the reusability of your classes by limiting use |
|
8493 |
to instances of a certain class. |
|
8494 |
Use check-methods to check an object for a certain attributes/protocol |
|
8495 |
(such as #isXXX, #respondsTo: or #isNumber); |
|
8496 |
||
8497 |
Using #isMemberOf: is considered BAD STYLE. |
|
5755 | 8498 |
Notice: |
10460 | 8499 |
This method is open coded (inlined) by the compiler(s) |
8500 |
- redefining it may not work as expected." |
|
5755 | 8501 |
|
8502 |
^ (self class) == aClass |
|
8503 |
! |
|
8504 |
||
8505 |
isMeta |
|
8506 |
"return true, if the receiver is some kind of metaclass; |
|
8507 |
false is returned here - the method is only redefined in Metaclass." |
|
8508 |
||
8509 |
^ false |
|
8510 |
! |
|
8511 |
||
8512 |
isMethod |
|
8513 |
"return true, if the receiver is some kind of method; |
|
8514 |
false returned here - the method is only redefined in Method." |
|
8515 |
||
8516 |
^ false |
|
8517 |
! |
|
8518 |
||
8519 |
isMorph |
|
8520 |
"return true, if the receiver is some kind of morph; |
|
8521 |
false is returned here - the method is only redefined in Morph." |
|
8522 |
||
8523 |
^ false |
|
8524 |
! |
|
8525 |
||
8526 |
isNameSpace |
|
9221 | 8527 |
"return true, if the receiver is a nameSpace. |
8528 |
False is returned here - the method is only redefined in Namespace." |
|
5755 | 8529 |
|
8530 |
^ false |
|
8531 |
||
8532 |
"Created: / 11.10.1996 / 18:08:56 / cg" |
|
8533 |
"Modified: / 8.5.1998 / 21:26:05 / cg" |
|
8534 |
! |
|
8535 |
||
8536 |
isNamespace |
|
8537 |
"return true, if this is a nameSpace. |
|
8538 |
false is returned here - the method is only redefined in Namespace." |
|
8539 |
||
5869 | 8540 |
<resource:#obsolete> |
8541 |
||
5755 | 8542 |
self obsoleteMethodWarning:'use #isNameSpace'. |
6805 | 8543 |
^ self isNameSpace |
5755 | 8544 |
! |
8545 |
||
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8546 |
isNil |
9221 | 8547 |
"Return true, if the receiver is nil. |
8548 |
Because isNil is redefined in UndefinedObject, |
|
8549 |
the receiver is definitely not nil here, so unconditionally return false. |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8550 |
Notice: |
10460 | 8551 |
This method is open coded (inlined) by the compiler(s) |
8552 |
- redefining it may not work as expected." |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8553 |
|
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8554 |
^ false |
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8555 |
! |
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8556 |
|
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8557 |
isNilOrEmptyCollection |
6182 | 8558 |
"return true if I am nil or an empty collection - false here. |
8833 | 8559 |
Obsolete, use isEmptyOrNil." |
8560 |
||
8561 |
<resource:#obsolete> |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8562 |
|
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8563 |
^ false |
6182 | 8564 |
|
8565 |
"Modified: / 13.11.2001 / 13:28:06 / cg" |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8566 |
! |
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8567 |
|
9005 | 8568 |
isNonByteCollection |
8569 |
"return true, if the receiver is some kind of collection, but not a String, ByteArray etc.; |
|
8570 |
false is returned here - the method is redefined in Collection and UninterpretedBytes." |
|
8571 |
||
8572 |
^ false |
|
8573 |
||
8574 |
" |
|
10460 | 8575 |
21 isNonByteCollection |
8576 |
'abc' isNonByteCollection |
|
8577 |
#'abc' isNonByteCollection |
|
8578 |
#[1 2 3] isNonByteCollection |
|
8579 |
#(1 2 3) isNonByteCollection |
|
9005 | 8580 |
" |
8581 |
! |
|
8582 |
||
5755 | 8583 |
isNumber |
8584 |
"return true, if the receiver is some kind of number; |
|
8585 |
false is returned here - the method is only redefined in Number." |
|
8586 |
||
8587 |
^ false |
|
8588 |
! |
|
8589 |
||
8590 |
isOrderedCollection |
|
8591 |
"return true, if the receiver is some kind of ordered collection (or list etc); |
|
8592 |
false is returned here - the method is only redefined in OrderedCollection." |
|
8593 |
||
8594 |
^ false |
|
8595 |
! |
|
8596 |
||
8597 |
isPoint |
|
8598 |
"return true, if the receiver is some kind of point; |
|
8599 |
false is returned here - the method is only redefined in Point." |
|
8600 |
||
8601 |
^ false |
|
8602 |
! |
|
8603 |
||
10532 | 8604 |
isPrinterContext |
8605 |
||
8606 |
^false |
|
8607 |
! |
|
8608 |
||
9515 | 8609 |
isProjectDefinition |
8610 |
"return true, if the receiver is a projectDefinition. |
|
8611 |
False is returned here - the method is only redefined in ProjectDefinition." |
|
8612 |
||
8613 |
^ false |
|
8614 |
||
8615 |
"Created: / 10-08-2006 / 16:24:53 / cg" |
|
8616 |
! |
|
8617 |
||
10171 | 8618 |
isRealNameSpace |
8619 |
"return true, if the receiver is really a nameSpace (i.e. a NameSpace, but not Smalltalk). |
|
8620 |
False is returned here - the method is only redefined in Namespace." |
|
8621 |
||
8622 |
^ false |
|
8623 |
||
8624 |
"Created: / 10-11-2006 / 17:05:43 / cg" |
|
8625 |
! |
|
8626 |
||
5755 | 8627 |
isRectangle |
8628 |
"return true, if the receiver is some kind of rectangle; |
|
8629 |
false is returned here - the method is only redefined in Rectangle." |
|
8630 |
||
8631 |
^ false |
|
8632 |
! |
|
8633 |
||
8634 |
isRemoteObject |
|
8635 |
"return true, if the receiver is some kind of remoteObject, |
|
8636 |
false if its local - the method is only redefined in RemoteObject." |
|
8637 |
||
8638 |
^ false |
|
8639 |
||
8640 |
"Created: 28.10.1996 / 15:18:45 / cg" |
|
8641 |
"Modified: 28.10.1996 / 15:20:57 / cg" |
|
8642 |
! |
|
8643 |
||
8644 |
isSequenceable |
|
8645 |
"return true, if the receiver is some kind of sequenceable collection; |
|
8646 |
false is returned here - the method is only redefined in SequenceableCollection." |
|
8647 |
||
8648 |
^ false |
|
8649 |
! |
|
8650 |
||
8651 |
isSequenceableCollection |
|
8652 |
"OBSOLETE: use isSequenceable for ST-80 compatibility. |
|
8653 |
This method is a historic leftover and will be removed soon ... |
|
8654 |
(although its name is much better than #isSequenceable - sigh)" |
|
8655 |
||
5869 | 8656 |
<resource:#obsolete> |
8657 |
||
5755 | 8658 |
self obsoleteMethodWarning:'use #isSequenceable'. |
8659 |
^ false |
|
8660 |
! |
|
8661 |
||
10856 | 8662 |
isSharedPool |
8663 |
"return true, if the receiver is a sharedPool. |
|
8664 |
False is returned here - the method is only redefined in SharedPool." |
|
8665 |
||
8666 |
^ false |
|
8667 |
! |
|
8668 |
||
5755 | 8669 |
isStream |
8670 |
"return true, if the receiver is some kind of stream; |
|
8671 |
false is returned here - the method is only redefined in Stream." |
|
8672 |
||
8673 |
^ false |
|
8674 |
! |
|
8675 |
||
8676 |
isString |
|
8677 |
"return true, if the receiver is some kind of string; |
|
8678 |
false is returned here - the method is only redefined in CharacterArray." |
|
8679 |
||
8680 |
^ false |
|
8681 |
! |
|
8682 |
||
8683 |
isStringCollection |
|
8684 |
"return true, if the receiver is some kind of stringCollection; |
|
8685 |
false is returned here - the method is only redefined in StringCollection." |
|
8686 |
||
8687 |
^ false |
|
8688 |
! |
|
8689 |
||
8690 |
isSymbol |
|
8691 |
"return true, if the receiver is some kind of symbol; |
|
8692 |
false is returned here - the method is only redefined in Symbol." |
|
8693 |
||
8694 |
^ false |
|
8695 |
! |
|
8696 |
||
8697 |
isText |
|
8698 |
"return true, if the receiver is some kind of text object; |
|
8699 |
false is returned here - the method is only redefined in Text." |
|
8700 |
||
8701 |
^ false |
|
8702 |
||
8703 |
"Created: 12.5.1996 / 10:56:50 / cg" |
|
8704 |
! |
|
8705 |
||
8706 |
isValueModel |
|
8707 |
"return true, if the receiver is some kind of valueModel; |
|
8708 |
false is returned here - the method is only redefined in ValueModel." |
|
8709 |
||
8710 |
^ false |
|
8711 |
||
8712 |
! |
|
8713 |
||
8714 |
isVariable |
|
8715 |
"return true if the receiver has indexed instance variables, |
|
8716 |
false otherwise." |
|
8717 |
||
8718 |
^ self class isVariable |
|
8719 |
! |
|
8720 |
||
8721 |
isVariableBinding |
|
8722 |
"return true, if this is a binding for a variable. |
|
8723 |
false is returned here - the method is only redefined in Binding." |
|
8724 |
||
8725 |
^ false |
|
8726 |
||
8727 |
"Created: / 19.6.1997 / 17:38:44 / cg" |
|
8728 |
"Modified: / 8.5.1998 / 21:26:55 / cg" |
|
8729 |
! |
|
8730 |
||
8731 |
isView |
|
8732 |
"return true, if the receiver is some kind of view; |
|
8733 |
false is returned here - the method is only redefined in View." |
|
8734 |
||
8735 |
^ false |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8736 |
! |
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8737 |
|
6932 | 8738 |
notEmptyOrNil |
8739 |
"Squeak compatibility: |
|
8740 |
return true if I am neither nil nor an empty collection. |
|
8741 |
Return true here." |
|
8742 |
||
8743 |
^ true |
|
8744 |
! |
|
8745 |
||
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8746 |
notNil |
9221 | 8747 |
"Return true, if the receiver is not nil. |
8748 |
Because notNil is redefined in UndefinedObject, |
|
8749 |
the receiver is definitely not nil here, so unconditionally return true. |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8750 |
Notice: |
10460 | 8751 |
This method is open coded (inlined) by the compiler(s) |
8752 |
- redefining it may not work as expected." |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8753 |
|
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
8754 |
^ true |
5755 | 8755 |
! ! |
8756 |
||
8757 |
!Object methodsFor:'tracing'! |
|
8758 |
||
8759 |
traceInto:aRequestor level:level from:referrer |
|
8760 |
"double dispatch into tracer, passing my type implicitely in the selector" |
|
8761 |
||
8762 |
^ aRequestor traceObject:self level:level from:referrer |
|
8763 |
||
8764 |
"Created: / 2.9.1999 / 09:05:17 / stefan" |
|
8765 |
! ! |
|
8766 |
||
8767 |
!Object methodsFor:'user interaction & notifications'! |
|
8768 |
||
8769 |
activityNotification:aString |
|
8770 |
"this can be sent from deeply nested methods, which are going to perform |
|
8771 |
some long-time activity. |
|
8772 |
If there is a handler for the ActivityNotificationSignal signal, that one is raised, |
|
8773 |
passing the argument. The handler should show this message whereever it likes, |
|
8774 |
and proceed. If there is no handler, this is simply ignored. |
|
8775 |
||
8776 |
This is very useful to pass busy messages up to some higher level (typically a view) |
|
8777 |
which likes to display that message in its label or a busy-box. |
|
8778 |
It could also be put into some logfile or printed on the standard output/error." |
|
8779 |
||
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
8780 |
ActivityNotification isHandled ifTrue:[ |
10460 | 8781 |
^ ActivityNotification raiseRequestWith:self errorString:aString |
5755 | 8782 |
]. |
8783 |
||
8784 |
" |
|
8785 |
nil activityNotification:'hello there' |
|
8786 |
self activityNotification:'hello there' |
|
8787 |
" |
|
8788 |
||
8789 |
" |
|
8330
15ef95301861
Convert more instance based exceptions to class based exceptions
Stefan Vogel <sv@exept.de>
parents:
8324
diff
changeset
|
8790 |
ActivityNotification handle:[:ex | |
10460 | 8791 |
ex errorString printCR. |
8792 |
ex proceed. |
|
5755 | 8793 |
] do:[ |
10460 | 8794 |
'hello' printCR. |
8795 |
self activityNotification:'doing some long time computation'. |
|
8796 |
'world' printCR. |
|
5755 | 8797 |
] |
8798 |
" |
|
8799 |
||
8800 |
"Modified: 16.12.1995 / 18:23:42 / cg" |
|
8801 |
! |
|
8802 |
||
8803 |
confirm:aString |
|
9694 | 8804 |
"open a modal yes-no dialog. |
8805 |
Return true for yes, false for no. |
|
10527
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8806 |
If no GUI is present (headless applications), true is returned. |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8807 |
|
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8808 |
Someone in the sender chain may redefine the confirmation handler |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8809 |
by handling the UserConfirmation." |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8810 |
|
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8811 |
^ UserConfirmation raiseRequestErrorString:aString |
10460 | 8812 |
|
5755 | 8813 |
" |
8814 |
nil confirm:'hello' |
|
8815 |
self confirm:'hello' |
|
8816 |
" |
|
8817 |
! |
|
8818 |
||
8819 |
confirm:aString orCancel:cancelBlock |
|
8820 |
"launch a confirmer, which allows user to enter yes, no or cancel. |
|
8821 |
return true for yes, false for no, or the value from cancelBlock for cancel. |
|
8822 |
If no GUI is present (headless applications), cancelBlock is returned." |
|
8823 |
||
8824 |
|answer| |
|
8825 |
||
8826 |
answer := self confirmWithCancel:aString. |
|
8827 |
answer isNil ifTrue:[ |
|
10460 | 8828 |
^ cancelBlock value |
5755 | 8829 |
]. |
8830 |
^ answer |
|
10460 | 8831 |
|
5755 | 8832 |
" |
8833 |
self confirm:'hello' orCancel:[self halt] |
|
8834 |
" |
|
8835 |
||
8836 |
"Modified: 20.5.1996 / 10:28:40 / cg" |
|
8837 |
! |
|
8838 |
||
8839 |
confirmWithCancel:aString |
|
8840 |
"launch a confirmer, which allows user to enter yes, no or cancel. |
|
8841 |
return true for yes, false for no, nil for cancel. |
|
10527
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8842 |
If no GUI is present (headless applications), nil is returned. |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8843 |
|
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8844 |
Someone in the sender chain may redefine the confirmation handler |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8845 |
by handling the UserConfirmation." |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8846 |
|
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8847 |
^ UserConfirmation new |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8848 |
canCancel:true; |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8849 |
errorString:aString; |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
8850 |
raiseRequest |
10460 | 8851 |
|
8852 |
" |
|
8853 |
nil confirmWithCancel:'hello' |
|
5755 | 8854 |
self confirmWithCancel:'hello' |
8855 |
" |
|
8856 |
! |
|
8857 |
||
8858 |
errorNotify:aString |
|
8859 |
"launch a Notifier, showing top stack, telling user something |
|
8860 |
and give user a chance to enter debugger." |
|
8861 |
||
8862 |
^ self |
|
10460 | 8863 |
errorNotify:aString |
8864 |
from:thisContext sender |
|
8865 |
allowDebug:true |
|
5755 | 8866 |
|
8867 |
" |
|
8868 |
nil errorNotify:'hello there' |
|
8869 |
self errorNotify:'hello there' |
|
8870 |
" |
|
8871 |
||
6199 | 8872 |
"Modified: / 16.11.2001 / 15:36:49 / cg" |
5755 | 8873 |
! |
8874 |
||
8875 |
errorNotify:aString from:aContext |
|
10460 | 8876 |
"launch a Notifier, showing top stack (above aContext), |
5755 | 8877 |
telling user something and give user a chance to enter debugger." |
8878 |
||
8879 |
^ self errorNotify:aString from:aContext allowDebug:true |
|
8880 |
||
8881 |
"Modified: / 17.8.1998 / 10:09:27 / cg" |
|
8882 |
! |
|
8883 |
||
8884 |
errorNotify:aString from:aContext allowDebug:allowDebug |
|
10460 | 8885 |
"launch a Notifier, showing top stack (above aContext), |
5755 | 8886 |
telling user something and optionally give the user a chance to enter debugger." |
8887 |
||
6647
79c298b93c07
#errorNotify -- allow copying the backtrace
Stefan Vogel <sv@exept.de>
parents:
6631
diff
changeset
|
8888 |
|currentScreen con sender action boxLabels boxValues default| |
5755 | 8889 |
|
8890 |
Smalltalk isInitialized ifFalse:[ |
|
10460 | 8891 |
'errorNotification: ' print. aString printCR. |
8892 |
^ nil |
|
8893 |
]. |
|
8894 |
(Dialog isNil |
|
6647
79c298b93c07
#errorNotify -- allow copying the backtrace
Stefan Vogel <sv@exept.de>
parents:
6631
diff
changeset
|
8895 |
or:[Screen isNil |
79c298b93c07
#errorNotify -- allow copying the backtrace
Stefan Vogel <sv@exept.de>
parents:
6631
diff
changeset
|
8896 |
or:[(currentScreen := Screen current) isNil |
10460 | 8897 |
or:[currentScreen isOpen not]]]) ifTrue:[ |
8898 |
" |
|
8899 |
on systems without GUI, simply show |
|
8900 |
the message on the Transcript and abort. |
|
8901 |
" |
|
8902 |
Transcript showCR:aString. |
|
8903 |
AbortOperationRequest raise. |
|
8904 |
"not reached" |
|
8905 |
^ nil |
|
5755 | 8906 |
]. |
8907 |
||
8908 |
Processor activeProcessIsSystemProcess ifTrue:[ |
|
10460 | 8909 |
action := #debug. |
8910 |
sender := aContext. |
|
8911 |
Debugger isNil ifTrue:[ |
|
8912 |
'****************** Cought Error while in SystemProcess ****************' errorPrintCR. |
|
8913 |
thisContext fullPrintAll. |
|
8914 |
action := #abort. |
|
8915 |
]. |
|
5755 | 8916 |
] ifFalse:[ |
10460 | 8917 |
Dialog autoload. "in case it's autoloaded" |
8918 |
||
8919 |
Error handle:[:ex | |
|
8920 |
"/ a recursive error - quickly enter debugger |
|
8921 |
"/ this happened, when I corrupted the Dialog class ... |
|
8922 |
('Object [error]: ' , ex description , ' caught in errorNotification') errorPrintCR. |
|
8923 |
action := #debug. |
|
8924 |
ex return. |
|
8925 |
] do:[ |s| |
|
8926 |
sender := aContext. |
|
8927 |
sender isNil ifTrue:[ |
|
8928 |
sender := thisContext sender. |
|
8929 |
]. |
|
8930 |
con := sender. |
|
8931 |
||
8932 |
"/ skip intermediate (signal & exception) contexts |
|
8933 |
DebugView notNil ifTrue:[ |
|
8934 |
con := DebugView interestingContextFrom:sender |
|
8935 |
]. |
|
8936 |
||
8937 |
"/ show the first few contexts |
|
8938 |
||
8939 |
s := WriteStream with:aString. |
|
8940 |
s cr; cr. |
|
8941 |
1 to:15 do:[:n | |
|
8942 |
con notNil ifTrue:[ |
|
8943 |
con printOn:s. |
|
8944 |
s cr. |
|
8945 |
con := con sender |
|
8946 |
] |
|
8947 |
]. |
|
8948 |
||
8949 |
(allowDebug and:[Debugger notNil]) ifTrue:[ |
|
8950 |
boxLabels := #('Proceed' 'Abort' 'Copy Trace and Abort' 'Debug'). |
|
8951 |
boxValues := #(#proceed #abort #copy #debug). |
|
8952 |
default := #debug. |
|
8953 |
] ifFalse:[ |
|
8954 |
boxLabels := #('Proceed' 'Abort' 'Copy Trace and Abort'). |
|
8955 |
boxValues := #(#proceed #abort #copy). |
|
8956 |
default := #abort. |
|
8957 |
]. |
|
8958 |
||
8959 |
action := Dialog |
|
8960 |
choose:s contents |
|
8961 |
label:('Exception [' , Processor activeProcess nameOrId , ']') |
|
8962 |
image:WarningBox errorIconBitmap |
|
8963 |
labels:boxLabels |
|
8964 |
values:boxValues |
|
8965 |
default:default |
|
8966 |
onCancel:nil. |
|
8967 |
]. |
|
5755 | 8968 |
]. |
8969 |
||
8970 |
action == #debug ifTrue:[ |
|
10460 | 8971 |
^ Debugger enter:sender withMessage:aString mayProceed:true |
5755 | 8972 |
] ifFalse:[ |
10460 | 8973 |
action == #proceed ifTrue:[ |
8974 |
^ nil. |
|
8975 |
]. |
|
8976 |
action == #copy ifTrue:[ |s| |
|
8977 |
s := '' writeStream. |
|
8978 |
sender fullPrintAllOn:s. |
|
8979 |
currentScreen rootView setClipboardText:s contents. |
|
8980 |
]. |
|
8981 |
AbortOperationRequest raise. |
|
8982 |
"not reached" |
|
8397
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
8983 |
]. |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
8984 |
|
5755 | 8985 |
|
8986 |
" |
|
8987 |
nil errorNotify:'hello there' |
|
8988 |
self errorNotify:'hello there' |
|
8989 |
" |
|
8990 |
||
8991 |
"Created: / 17.8.1998 / 10:09:26 / cg" |
|
6199 | 8992 |
"Modified: / 16.11.2001 / 15:40:12 / cg" |
5755 | 8993 |
! |
8994 |
||
8995 |
information:aString |
|
10460 | 8996 |
"launch an InfoBox, telling user something. |
8997 |
These info-boxes can be suppressed by handling |
|
7033
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
8998 |
UserNotification or InformationSignal and proceeding in the handler. |
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
8999 |
Use #notify: for more important messages. |
8371 | 9000 |
If nobody handles the exception, the default action of UserNotification |
10527
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
9001 |
pops up an info dialog." |
7033
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9002 |
|
7035
1d049fb7ae5a
Make UserInformation a class based exception
Stefan Vogel <sv@exept.de>
parents:
7033
diff
changeset
|
9003 |
UserInformation raiseRequestWith:self errorString:aString |
5755 | 9004 |
|
9005 |
" |
|
9006 |
nil information:'hello there' |
|
9007 |
self information:'hello there' |
|
9008 |
" |
|
9009 |
||
9010 |
" |
|
9011 |
InformationSignal handle:[:ex | |
|
10527
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
9012 |
'no box popped' printCR. |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
9013 |
ex proceed. |
5755 | 9014 |
] do:[ |
10527
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
9015 |
'hello' printCR. |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
9016 |
self information:'some info'. |
b783c0000f54
#confirm: now uses the UserConfirmation otification to request an answer
Stefan Vogel <sv@exept.de>
parents:
10480
diff
changeset
|
9017 |
'world' printCR. |
5755 | 9018 |
] |
9019 |
" |
|
9020 |
||
9021 |
"Modified: 24.11.1995 / 22:29:49 / cg" |
|
9022 |
! |
|
9023 |
||
9024 |
notify:aString |
|
9025 |
"launch a Notifier, telling user something. |
|
7033
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9026 |
Use #information: for ignorable messages. |
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9027 |
If nobody handles the exception, the dafault action of UserNotification |
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9028 |
pops up a warn dialog." |
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9029 |
|
5755 | 9030 |
|
9031 |
Smalltalk isInitialized ifFalse:[ |
|
10460 | 9032 |
"/ thisContext fullPrintAll. |
9033 |
'information: ' print. aString printCR. |
|
9034 |
^ self |
|
5755 | 9035 |
]. |
7033
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9036 |
UserNotification raiseRequestWith:self errorString:aString. |
5755 | 9037 |
|
9038 |
" |
|
9039 |
nil notify:'hello there' |
|
9040 |
self notify:'hello there' |
|
9041 |
" |
|
9042 |
||
9043 |
"Modified: 20.5.1996 / 10:28:48 / cg" |
|
9044 |
! |
|
9045 |
||
9046 |
warn:aString |
|
9047 |
"launch a WarningBox, telling user something. |
|
10460 | 9048 |
These warn-boxes can be suppressed by handling the |
7033
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9049 |
UserNotification- or WarningSignal and proceeding in the handler. |
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9050 |
If nobody handles the exception, the dafault action of Warning |
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9051 |
pops up a warn dialog." |
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9052 |
|
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9053 |
Warning raiseRequestWith:self errorString:aString |
5755 | 9054 |
|
9055 |
" |
|
9056 |
nil warn:'hello there' |
|
9057 |
self warn:'hello there' |
|
9058 |
" |
|
9059 |
||
9060 |
" |
|
7033
c4183ea85a71
Now Warning is a subclass of UserNotification.
Stefan Vogel <sv@exept.de>
parents:
7031
diff
changeset
|
9061 |
Warning handle:[:ex | |
10460 | 9062 |
Transcript showCR:ex description. |
9063 |
ex proceed. |
|
5755 | 9064 |
] do:[ |
10460 | 9065 |
'hello' printCR. |
9066 |
self warn:'some info'. |
|
9067 |
'world' printCR. |
|
5755 | 9068 |
] |
9069 |
" |
|
9070 |
||
9071 |
"Modified: 20.5.1996 / 10:28:53 / cg" |
|
9072 |
! ! |
|
9073 |
||
8397
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
9074 |
!Object methodsFor:'visiting'! |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
9075 |
|
8426 | 9076 |
acceptVisitor:aVisitor |
9077 |
"double-dispatch onto a Visitor." |
|
9078 |
||
9079 |
^ self acceptVisitor:aVisitor with:nil |
|
9080 |
! |
|
9081 |
||
8397
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
9082 |
acceptVisitor:aVisitor with:aParameter |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
9083 |
"double-dispatch onto a Visitor. |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
9084 |
Subclasses redefine this" |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
9085 |
|
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
9086 |
^ aVisitor visitObject:self with:aParameter |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
9087 |
! ! |
a1cff241e853
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
9088 |
|
5755 | 9089 |
!Object class methodsFor:'documentation'! |
1 | 9090 |
|
5754 | 9091 |
version |
11161 | 9092 |
^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.611 2008-09-08 10:12:22 cg Exp $' |
1 | 9093 |
! ! |
6764 | 9094 |
|
5755 | 9095 |
Object initialize! |