author | Claus Gittinger <cg@exept.de> |
Thu, 27 Mar 1997 13:43:15 +0100 | |
changeset 2505 | 3c9bf86f9e9a |
parent 2502 | 8f3bf6043968 |
child 2506 | 255c87b6fb4f |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 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 |
||
783 | 13 |
nil subclass:#Object |
14 |
instanceVariableNames:'' |
|
15 |
classVariableNames:'ErrorSignal HaltSignal MessageNotUnderstoodSignal |
|
16 |
UserInterruptSignal RecursionInterruptSignal |
|
17 |
ExceptionInterruptSignal SubscriptOutOfBoundsSignal |
|
18 |
NonIntegerIndexSignal NotFoundSignal KeyNotFoundSignal |
|
19 |
ElementOutOfBoundsSignal UserNotificationSignal InformationSignal |
|
20 |
WarningSignal PrimitiveFailureSignal DeepCopyErrorSignal |
|
21 |
AbortSignal ErrorRecursion Dependencies InfoPrinting |
|
2231 | 22 |
ActivityNotificationSignal InternalErrorSignal |
2295 | 23 |
NonWeakDependencies SynchronizationSemaphores' |
783 | 24 |
poolDictionaries:'' |
25 |
category:'Kernel-Objects' |
|
1 | 26 |
! |
27 |
||
1788 | 28 |
!Object class methodsFor:'documentation'! |
71 | 29 |
|
88 | 30 |
copyright |
31 |
" |
|
32 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 33 |
All Rights Reserved |
88 | 34 |
|
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
43 |
||
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
44 |
dependencies |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
45 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
46 |
ST/X dependencies are slightly modified from ST-80's |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
47 |
(we think they are better ;-). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
48 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
49 |
One problem occuring very often in ST-80 is that some object |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
50 |
cannot be garbage collected because some dependency is present, |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
51 |
having the object as a dependent of some other object. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
52 |
In ST-80, this association remains alive (because a Dictionary |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
53 |
is used to hold dependents) - even if no other references exist to |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
54 |
to dependent or the dependee. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
55 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
56 |
This means, that in ST-80, a #release is mandatory in order to |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
57 |
prevent memory leaks. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
58 |
We think, that this is a bad solution, since after all, exactly that |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
59 |
kind of work should be performed by a garbage collector - you should not |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
60 |
need to care about dependencies. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
61 |
From a philosophical point of view, why should some object depend on |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
62 |
something that the programmer considers a dead object ? |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
63 |
(well - worse than that: it seems that some ST-80 code even depends on |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
64 |
that behavior) |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
65 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
66 |
In order to limit the trouble, ST-80 reimplemented the way dependents |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
67 |
are stored in the model class - this one keeps the dependents locally, |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
68 |
so these dependents go away, once the model is reclaimed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
69 |
That may make things even more confusing: with models, no #release is |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
70 |
needed, with general objects it is mandatory. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
71 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
72 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
73 |
In ST/X, dependencies are implemented using a WeakDictionary; this means, |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
74 |
that once the dependee dies, the dependency association is removed automatically, |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
75 |
and the dependent can be reclaimed by the garbage collector, if no other |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
76 |
references exist to the dependent. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
77 |
In order to (at least) provide a mechanism for the old behavior |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
78 |
(in case your application heavily depends on the ST-80 mechanism), complementary |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
79 |
protocol to add nonWeak dependencies is provided |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
80 |
(see #addNonWeakDependent / #removeNonWeakDependent). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
81 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
82 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
83 |
Caveat: |
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
84 |
since interests are implemented using InterestConverter (which are simply |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
85 |
forwarding messages), these must use the nonWeak mechanism (as done in ST-80 |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
86 |
automatically). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
87 |
The reason is that there are usually no direct references to the converters, |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
88 |
and those would be reclaimed if stored in a weakDictionary. |
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
89 |
This means, that those interests MUST be removed with #retractInterest |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
90 |
(which is bug-compatible to ST-80). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
91 |
We rewrite things to provide a more convenient mechanism in the future ... |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
92 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
93 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
94 |
I like to hear comments on the above - do you think its better ? |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
95 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
96 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
97 |
|
71 | 98 |
documentation |
99 |
" |
|
1294 | 100 |
Object is the superclass of most other classes. |
101 |
(except for nil-subclasses, which inherit nothing, |
|
102 |
to catch any message into their #doesNotUnderstand: method) |
|
103 |
||
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
104 |
Protocol which is common to every object is defined here. |
71 | 105 |
Also some utility stuff (like notify) and error handling is implemented here. |
106 |
||
107 |
Object has no instance variables (and may not get any added). One reason is, that |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
108 |
UndefinedObject and SmallInteger are also inheriting from Object - these two cannot |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
109 |
have instance variables (due to their implementation). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
110 |
The other reason is that the runtime system (VM) knows about the layout of some built-in |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
111 |
classes (think of Class, Method, Block and also Integer or Float). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
112 |
If you were allowed to add instance variables to Object, the VM had to be recompiled |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
113 |
(and also rewritten in some places). |
71 | 114 |
|
1294 | 115 |
[Class variables:] |
71 | 116 |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
117 |
ErrorSignal <Signal> Signal raised for error/error: messages |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
118 |
also, parent of all other signals. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
119 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
120 |
HaltSignal <Signal> Signal raised for halt/halt: messages |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
121 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
122 |
MessageNotUnderstoodSignal Signals raised for various error conditions |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
123 |
UserInterruptSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
124 |
RecursionInterruptSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
125 |
ExceptionInterruptSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
126 |
SubscriptOutOfBoundsSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
127 |
NonIntegerIndexSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
128 |
NotFoundSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
129 |
KeyNotFoundSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
130 |
ElementOutOfBoundsSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
131 |
InformationSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
132 |
WarningSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
133 |
DeepCopyErrorSignal |
2295 | 134 |
InternalErrorSignal |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
135 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
136 |
AbortSignal <Signal> Signal raised by debugger, to abort a computation |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
137 |
BUT, the debugger will only raise it if it is handled. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
138 |
By handling the abortSignal, you can control where the |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
139 |
debuggers abort-function resumes execution in case of |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
140 |
an error. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
141 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
142 |
ErrorRecursion <Boolean> controls behavior when recursive errors occur (i.e. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
143 |
an error while handling an error). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
144 |
|
2295 | 145 |
Dependencies <WeakDependencyDictionary> |
146 |
keeps track of object dependencies. |
|
147 |
||
148 |
InfoPrinting <Boolean> controls weather informational messages |
|
149 |
are printed. |
|
150 |
||
151 |
ActivityNotificationSignal <QuerySignal> |
|
152 |
raised on #activityNotification: |
|
153 |
||
154 |
NonWeakDependencies <Dictionary> keeps track of object dependencies. |
|
155 |
Dependents stay alive. |
|
156 |
||
157 |
SynchronizationSemaphores <WeakIdentityDictionary> |
|
158 |
Semaphores for per-object-monitor. |
|
159 |
||
1294 | 160 |
|
161 |
[author:] |
|
162 |
Claus Gittinger |
|
163 |
||
71 | 164 |
" |
165 |
! ! |
|
1 | 166 |
|
1788 | 167 |
!Object class methodsFor:'initialization'! |
1 | 168 |
|
169 |
initialize |
|
170 |
"called only once - initialize signals" |
|
171 |
||
172 |
ErrorSignal isNil ifTrue:[ |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
173 |
ErrorSignal := (Signal new) mayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
174 |
ErrorSignal nameClass:self message:#errorSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
175 |
ErrorSignal notifierString:'error encountered'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
176 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
177 |
HaltSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
178 |
HaltSignal nameClass:self message:#haltSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
179 |
HaltSignal notifierString:'halt encountered'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
180 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
181 |
MessageNotUnderstoodSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
182 |
MessageNotUnderstoodSignal nameClass:self message:#messageNotUnderstoodSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
183 |
MessageNotUnderstoodSignal notifierString:'message not understood'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
184 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
185 |
PrimitiveFailureSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
186 |
PrimitiveFailureSignal nameClass:self message:#primitiveFailureSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
187 |
PrimitiveFailureSignal notifierString:'primitive failed'. |
159 | 188 |
|
2227
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
189 |
InternalErrorSignal := ErrorSignal newSignalMayProceed:false. |
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
190 |
InternalErrorSignal nameClass:self message:#internalError. |
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
191 |
InternalErrorSignal notifierString:'VM internal error: '. |
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
192 |
|
362 | 193 |
"/ UserInterruptSignal := ErrorSignal newSignalMayProceed:true. |
2042 | 194 |
UserInterruptSignal := (Signal new) mayProceed:true. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
195 |
UserInterruptSignal nameClass:self message:#userInterruptSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
196 |
UserInterruptSignal notifierString:'user Interrupt'. |
159 | 197 |
|
362 | 198 |
"/ RecursionInterruptSignal := ErrorSignal newSignalMayProceed:false. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
199 |
RecursionInterruptSignal := (Signal new) mayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
200 |
RecursionInterruptSignal nameClass:self message:#recursionInterruptSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
201 |
RecursionInterruptSignal notifierString:'recursion limit reached'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
202 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
203 |
ExceptionInterruptSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
204 |
ExceptionInterruptSignal nameClass:self message:#exceptionInterruptSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
205 |
ExceptionInterruptSignal notifierString:'exception Interrupt'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
206 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
207 |
SubscriptOutOfBoundsSignal := ErrorSignal newSignalMayProceed:false. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
208 |
SubscriptOutOfBoundsSignal nameClass:self message:#subscriptOutOfBoundsSignal. |
1377 | 209 |
SubscriptOutOfBoundsSignal notifierString:'subscript out of bounds: '. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
210 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
211 |
ElementOutOfBoundsSignal := ErrorSignal newSignalMayProceed:false. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
212 |
ElementOutOfBoundsSignal nameClass:self message:#elementOutOfBoundsSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
213 |
ElementOutOfBoundsSignal notifierString:'element not appropriate or out of bounds'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
214 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
215 |
NotFoundSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
216 |
NotFoundSignal nameClass:self message:#notFoundSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
217 |
NotFoundSignal notifierString:'no such element'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
218 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
219 |
KeyNotFoundSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
220 |
KeyNotFoundSignal nameClass:self message:#keyNotFoundSignal. |
1377 | 221 |
KeyNotFoundSignal notifierString:'no such key: '. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
222 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
223 |
NonIntegerIndexSignal := ErrorSignal newSignalMayProceed:false. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
224 |
NonIntegerIndexSignal nameClass:self message:#nonIntegerIndexSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
225 |
NonIntegerIndexSignal notifierString:'index must be integer'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
226 |
|
2042 | 227 |
UserNotificationSignal := QuerySignal new. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
228 |
UserNotificationSignal nameClass:self message:#userNotificationSignal. |
2042 | 229 |
UserNotificationSignal notifierString:'user notifiaction wanted'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
230 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
231 |
InformationSignal := UserNotificationSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
232 |
InformationSignal nameClass:self message:#informationSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
233 |
InformationSignal notifierString:'information'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
234 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
235 |
WarningSignal := UserNotificationSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
236 |
WarningSignal nameClass:self message:#warnungSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
237 |
WarningSignal notifierString:'warning'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
238 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
239 |
ActivityNotificationSignal := UserNotificationSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
240 |
ActivityNotificationSignal nameClass:self message:#activityNotificationSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
241 |
ActivityNotificationSignal notifierString:'activity'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
242 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
243 |
DeepCopyErrorSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
244 |
DeepCopyErrorSignal nameClass:self message:#deepCopyErrorSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
245 |
DeepCopyErrorSignal notifierString:'object cannot be deepCopy-ed'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
246 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
247 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
248 |
AbortSignal is not a child of ErrorSignal - |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
249 |
this would complicate abort from within a signal handler |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
250 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
251 |
AbortSignal := Signal new mayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
252 |
AbortSignal nameClass:self message:#abortSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
253 |
AbortSignal notifierString:'unhandled abort signal'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
254 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
255 |
Dependencies isNil ifTrue:[ |
2096
bc7296b593ee
use new WeakDependencyDictionary
Claus Gittinger <cg@exept.de>
parents:
2082
diff
changeset
|
256 |
Dependencies := WeakDependencyDictionary new. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
257 |
]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
258 |
NonWeakDependencies isNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
259 |
NonWeakDependencies := IdentityDictionary new. |
2295 | 260 |
]. |
261 |
SynchronizationSemaphores isNil ifTrue:[ |
|
262 |
SynchronizationSemaphores := WeakIdentityDictionary new. |
|
263 |
]. |
|
356 | 264 |
]. |
2114
706cf3f9019a
initialize InfoPrinting flag from VM's setting
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
265 |
|
706cf3f9019a
initialize InfoPrinting flag from VM's setting
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
266 |
"/ initialize InfoPrinting to the VM's infoPrint setting |
706cf3f9019a
initialize InfoPrinting flag from VM's setting
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
267 |
"/ (which can be turned off via a command line argument) |
706cf3f9019a
initialize InfoPrinting flag from VM's setting
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
268 |
InfoPrinting := ObjectMemory infoPrinting. |
1 | 269 |
|
270 |
"Object initialize" |
|
812
00db9c0646fe
notificationsignals are no longer children of ErrorSignal
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
271 |
|
2096
bc7296b593ee
use new WeakDependencyDictionary
Claus Gittinger <cg@exept.de>
parents:
2082
diff
changeset
|
272 |
"Modified: 9.1.1997 / 00:28:38 / cg" |
2295 | 273 |
"Modified: 28.1.1997 / 19:38:58 / stefan" |
1 | 274 |
! ! |
275 |
||
1788 | 276 |
!Object class methodsFor:'Signal constants'! |
1 | 277 |
|
783 | 278 |
abortSignal |
279 |
"return the signal used to abort user actions. This signal is only |
|
280 |
raised if cought (by the debugger), and will lead way out of the |
|
281 |
currently active doIt/printIt or inspectIt. (also some others use |
|
282 |
this for a save abort)" |
|
283 |
||
284 |
^ AbortSignal |
|
579
2d26193415b5
allow catching of information: and warn: boxes
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
285 |
! |
2d26193415b5
allow catching of information: and warn: boxes
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
286 |
|
782 | 287 |
activityNotificationSignal |
288 |
"return the signal used for activity notifications. |
|
289 |
A handler for this signal gets all #activityNotification: sends" |
|
290 |
||
291 |
^ ActivityNotificationSignal |
|
292 |
! |
|
293 |
||
159 | 294 |
deepCopyErrorSignal |
295 |
"return the signal raised when a deepcopy is asked for |
|
296 |
an object which cannot do this (for example, BlockClosures |
|
297 |
or Contexts)." |
|
298 |
||
299 |
^ DeepCopyErrorSignal |
|
300 |
! |
|
301 |
||
783 | 302 |
elementOutOfBoundsSignal |
303 |
"return the signal used for element error reporting |
|
304 |
(this signal is used for example when a value not in 0..255 is to |
|
305 |
be put into a bytearray)" |
|
306 |
||
307 |
^ ElementOutOfBoundsSignal |
|
308 |
! |
|
309 |
||
310 |
errorSignal |
|
311 |
"return the signal used for error/error: - handling" |
|
312 |
||
313 |
^ ErrorSignal |
|
314 |
! |
|
315 |
||
316 |
exceptionInterruptSignal |
|
317 |
"return the signal used for exception (display errors) error handling" |
|
318 |
||
319 |
^ ExceptionInterruptSignal |
|
320 |
! |
|
321 |
||
322 |
haltSignal |
|
323 |
"return the signal used for halt/halt: - handling" |
|
324 |
||
325 |
^ HaltSignal |
|
326 |
! |
|
327 |
||
328 |
informationSignal |
|
329 |
"return the signal used for informations. |
|
330 |
A handler for this signal gets all #information: sends" |
|
331 |
||
332 |
^ InformationSignal |
|
333 |
! |
|
334 |
||
2227
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
335 |
internalErrorSignal |
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
336 |
"return the signal used to report internal (VM-) errors." |
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
337 |
|
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
338 |
^ InternalErrorSignal |
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
339 |
! |
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
340 |
|
783 | 341 |
keyNotFoundSignal |
342 |
"return the signal used for no such key error reporting" |
|
343 |
||
344 |
^ KeyNotFoundSignal |
|
345 |
! |
|
346 |
||
347 |
messageNotUnderstoodSignal |
|
348 |
"return the signal used for doesNotUnderstand: - error handling" |
|
349 |
||
350 |
^ MessageNotUnderstoodSignal |
|
351 |
! |
|
352 |
||
353 |
nonIntegerIndexSignal |
|
354 |
"return the signal used for bad subscript error reporting" |
|
355 |
||
356 |
^ NonIntegerIndexSignal |
|
357 |
! |
|
358 |
||
359 |
notFoundSignal |
|
360 |
"return the signal used for no element found error reporting" |
|
361 |
||
362 |
^ NotFoundSignal |
|
363 |
! |
|
364 |
||
365 |
primitiveFailureSignal |
|
366 |
"return the signal used for primitiveFailed - error handling" |
|
367 |
||
368 |
^ PrimitiveFailureSignal |
|
369 |
! |
|
370 |
||
371 |
privateMethodSignal |
|
372 |
"return the signal used for privateMethod - error handling" |
|
373 |
||
374 |
^ MessageNotUnderstoodSignal |
|
375 |
! |
|
376 |
||
377 |
recursionInterruptSignal |
|
378 |
"return the signal used for recursion overflow error handling" |
|
379 |
||
380 |
^ RecursionInterruptSignal |
|
381 |
! |
|
382 |
||
383 |
subscriptOutOfBoundsSignal |
|
384 |
"return the signal used for subscript error reporting. |
|
385 |
(this signal is used for example when an array is accessed with an |
|
386 |
index less than 1 or greater than the array size)" |
|
387 |
||
388 |
^ SubscriptOutOfBoundsSignal |
|
389 |
! |
|
390 |
||
391 |
userInterruptSignal |
|
392 |
"return the signal used for ^C interrupts handling" |
|
393 |
||
394 |
^ UserInterruptSignal |
|
395 |
! |
|
396 |
||
397 |
userNotificationSignal |
|
398 |
"the parent signal used with information and warnings. |
|
399 |
Handling this allows handling of both information- and warning notifications." |
|
400 |
||
401 |
^ UserNotificationSignal |
|
402 |
! |
|
403 |
||
404 |
warningSignal |
|
405 |
"return the signal used for warnings. |
|
406 |
A handler for this signal gets all #warn: sends" |
|
407 |
||
408 |
^ WarningSignal |
|
1 | 409 |
! ! |
410 |
||
1788 | 411 |
!Object class methodsFor:'info messages'! |
356 | 412 |
|
783 | 413 |
infoPrinting |
414 |
"return the flag which controls information messages." |
|
415 |
||
416 |
^ InfoPrinting |
|
417 |
! |
|
418 |
||
356 | 419 |
infoPrinting:aBoolean |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
420 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
421 |
|
356 | 422 |
"turn on/off printing of information messages. |
423 |
If the argument, aBoolean is false, infoPrint will not output |
|
424 |
messages. The default is true." |
|
425 |
||
426 |
InfoPrinting := aBoolean |
|
427 |
! ! |
|
428 |
||
1788 | 429 |
!Object class methodsFor:'queries'! |
3 | 430 |
|
431 |
isBuiltInClass |
|
49 | 432 |
"return true, if this class is known by the run-time-system, |
433 |
i.e. you cannot add/remove instance variables without recompiling |
|
1266 | 434 |
the VM. |
435 |
Here, true is returned for myself, false for subclasses." |
|
3 | 436 |
|
437 |
^ self == Object |
|
1266 | 438 |
|
439 |
"Modified: 23.4.1996 / 16:00:07 / cg" |
|
3 | 440 |
! ! |
441 |
||
1 | 442 |
!Object methodsFor:'accessing'! |
443 |
||
444 |
at:index |
|
445 |
"return the indexed instance variable with index, anInteger; |
|
446 |
this method can be redefined in subclasses." |
|
447 |
||
448 |
^ self basicAt:index |
|
449 |
! |
|
450 |
||
783 | 451 |
at:index put:anObject |
452 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
453 |
this method can be redefined in subclasses. Returns anObject (sigh)" |
783 | 454 |
|
455 |
^ self basicAt:index put:anObject |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
456 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
457 |
"Modified: 19.4.1996 / 11:13:29 / cg" |
783 | 458 |
! |
459 |
||
1 | 460 |
basicAt:index |
461 |
"return the indexed instance variable with index, anInteger. |
|
462 |
Trigger an error if the receiver has no indexed instance variables. |
|
2148 | 463 |
This method should NOT be redefined in any subclass (except with great care, for tuning)" |
1 | 464 |
|
465 |
%{ /* NOCONTEXT */ |
|
466 |
||
329 | 467 |
REGISTER int nbytes, indx; |
1 | 468 |
OBJ myClass; |
329 | 469 |
REGISTER char *pFirst; |
1 | 470 |
unsigned char *cp; |
471 |
unsigned short *sp; |
|
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
472 |
short *ssp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
473 |
unsigned long *lp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
474 |
long *slp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
475 |
unsigned long ul; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
476 |
long l; |
1 | 477 |
OBJ *op; |
329 | 478 |
/* int nInstBytes, nInstVars, flags; */ |
479 |
REGISTER int n; |
|
1 | 480 |
|
481 |
||
482 |
/* |
|
56 | 483 |
* notice the missing test for self being a nonNilObject - |
1 | 484 |
* this can be done since basicAt: is defined both in UndefinedObject |
485 |
* and SmallInteger |
|
486 |
*/ |
|
253 | 487 |
if (__isSmallInteger(index)) { |
2148 | 488 |
myClass = __qClass(self); |
489 |
indx = __intVal(index) - 1; |
|
490 |
n /* nInstVars */ = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
|
491 |
n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* nInstVars */); |
|
492 |
nbytes = __qSize(self) - n /* nInstBytes */; |
|
493 |
pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */; |
|
494 |
||
495 |
/* |
|
496 |
* replaced switch by open-coded if; this is slightly faster |
|
497 |
* since it avoids the range check and also handles the most common case first |
|
498 |
*/ |
|
499 |
n = (INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK); |
|
500 |
||
501 |
if ((n == __MASKSMALLINT(POINTERARRAY)) |
|
502 |
|| (n == __MASKSMALLINT(WKPOINTERARRAY))) { |
|
503 |
if ((indx >= 0) && (indx < (__BYTES2OBJS__(nbytes)))) { |
|
504 |
op = (OBJ *)pFirst + indx; |
|
505 |
RETURN ( *op ); |
|
506 |
} |
|
507 |
} else if (n == __MASKSMALLINT(BYTEARRAY)) { |
|
508 |
if ((indx >= 0) && (indx < (nbytes / sizeof(char)))) { |
|
509 |
cp = (unsigned char *)pFirst + indx; |
|
510 |
RETURN ( __MKSMALLINT(*cp & 0xFF) ); |
|
511 |
} |
|
512 |
} else if (n == __MASKSMALLINT(FLOATARRAY)) { |
|
513 |
if ((indx >= 0) && (indx < (nbytes / sizeof(float)))) { |
|
514 |
float *fp; |
|
515 |
||
516 |
fp = (float *)pFirst + indx; |
|
517 |
RETURN ( __MKFLOAT((double)(*fp))); |
|
518 |
} |
|
519 |
} else if (n == __MASKSMALLINT(DOUBLEARRAY)) { |
|
520 |
if ((indx >= 0) && (indx < (nbytes / sizeof(double)))) { |
|
521 |
double *dp; |
|
1 | 522 |
|
56 | 523 |
#ifdef NEED_DOUBLE_ALIGN |
2148 | 524 |
/* |
525 |
* care for filler |
|
526 |
*/ |
|
527 |
pFirst += sizeof(FILLTYPE); |
|
56 | 528 |
#endif |
2148 | 529 |
dp = (double *)pFirst + indx; |
530 |
RETURN ( __MKFLOAT(*dp)); |
|
531 |
} |
|
532 |
} else if (n == __MASKSMALLINT(WORDARRAY)) { |
|
533 |
if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) { |
|
534 |
sp = (unsigned short *)pFirst + indx; |
|
535 |
RETURN ( __MKSMALLINT(*sp & 0xFFFF) ); |
|
536 |
} |
|
537 |
} else if (n == __MASKSMALLINT(SWORDARRAY)) { |
|
538 |
if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) { |
|
539 |
ssp = (short *)pFirst + indx; |
|
540 |
RETURN ( __MKSMALLINT(*ssp) ); |
|
541 |
} |
|
542 |
} else if (n == __MASKSMALLINT(LONGARRAY)) { |
|
543 |
if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) { |
|
544 |
lp = (unsigned long *)pFirst + indx; |
|
545 |
ul = *lp; |
|
546 |
if (ul <= _MAX_INT) |
|
547 |
RETURN ( __MKSMALLINT(ul) ); |
|
548 |
RETURN ( __MKULARGEINT(ul) ); |
|
549 |
} |
|
550 |
} else if (n == __MASKSMALLINT(SLONGARRAY)) { |
|
551 |
if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) { |
|
552 |
slp = (long *)pFirst + indx; |
|
553 |
l = *slp; |
|
554 |
if ((l >= _MIN_INT) && (l <= _MAX_INT)) |
|
555 |
RETURN ( __MKSMALLINT(l) ); |
|
556 |
RETURN ( __MKLARGEINT(l) ); |
|
557 |
} |
|
558 |
} |
|
1 | 559 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
560 |
%}. |
10 | 561 |
index isInteger ifFalse:[ |
2148 | 562 |
^ self indexNotInteger |
1 | 563 |
]. |
159 | 564 |
^ self subscriptBoundsError:index |
1 | 565 |
! |
566 |
||
567 |
basicAt:index put:anObject |
|
568 |
"store the 2nd arg, anObject as indexed instvar with index, anInteger. |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
569 |
Returns anObject (sigh). |
1 | 570 |
Trigger an error if the receiver has no indexed instance variables. |
2148 | 571 |
|
572 |
This method should NOT be redefined in any subclass (except with great care, for tuning)" |
|
1 | 573 |
|
574 |
%{ /* NOCONTEXT */ |
|
575 |
||
576 |
register int nbytes, indx; |
|
577 |
OBJ myClass; |
|
578 |
register char *pFirst; |
|
579 |
char *cp; |
|
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
580 |
unsigned short *sp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
581 |
short *ssp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
582 |
unsigned long *lp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
583 |
long *slp; |
1 | 584 |
OBJ *op; |
329 | 585 |
/* int nInstBytes, ninstvars, flags; */ |
586 |
REGISTER int n; |
|
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
587 |
unsigned int u; |
1 | 588 |
int val; |
589 |
||
56 | 590 |
/* notice the missing test for self being a nonNilObject - |
77 | 591 |
this can be done since basicAt: is defined both in UndefinedObject |
1 | 592 |
and SmallInteger */ |
593 |
||
253 | 594 |
if (__isSmallInteger(index)) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
595 |
indx = __intVal(index) - 1; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
596 |
myClass = __qClass(self); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
597 |
n /* ninstvars */ = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
598 |
n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* ninstvars */); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
599 |
nbytes = __qSize(self) - n /* nInstBytes */; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
600 |
pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
601 |
|
2148 | 602 |
n = (INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK); |
603 |
||
604 |
/* |
|
605 |
* replaced switch by open-coded if; this is slightly faster |
|
606 |
* since it avoids the range check and also handles the most common case first |
|
607 |
*/ |
|
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
608 |
if ((n == __MASKSMALLINT(POINTERARRAY)) |
2148 | 609 |
|| (n == __MASKSMALLINT(WKPOINTERARRAY))) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
610 |
if ((indx >= 0) && (indx < (__BYTES2OBJS__(nbytes)))) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
611 |
op = (OBJ *)pFirst + indx; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
612 |
*op = anObject; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
613 |
__STORE(self, anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
614 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
615 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
616 |
} else if (n == __MASKSMALLINT(BYTEARRAY)) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
617 |
if (__isSmallInteger(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
618 |
val = __intVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
619 |
if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
620 |
if ((indx >= 0) && (indx < (nbytes / sizeof(char)))) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
621 |
cp = pFirst + indx; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
622 |
*cp = val; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
623 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
624 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
625 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
626 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
627 |
} else if (n == __MASKSMALLINT(FLOATARRAY)) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
628 |
if ((indx >= 0) && (indx < (nbytes / sizeof(float)))) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
629 |
float *fp; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
630 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
631 |
fp = (float *)pFirst + indx; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
632 |
if (__isFloatLike(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
633 |
*fp = _floatVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
634 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
635 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
636 |
if (__isSmallInteger(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
637 |
*fp = (float) __intVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
638 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
639 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
640 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
641 |
} else if (n == __MASKSMALLINT(DOUBLEARRAY)) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
642 |
if ((indx >= 0) && (indx < (nbytes / sizeof(double)))) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
643 |
double *dp; |
13 | 644 |
|
56 | 645 |
#ifdef NEED_DOUBLE_ALIGN |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
646 |
/* |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
647 |
* care for filler |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
648 |
*/ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
649 |
pFirst += sizeof(FILLTYPE); |
56 | 650 |
#endif |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
651 |
dp = (double *)pFirst + indx; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
652 |
if (__isFloatLike(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
653 |
*dp = _floatVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
654 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
655 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
656 |
if (__isSmallInteger(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
657 |
*dp = (double) __intVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
658 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
659 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
660 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
661 |
} else if (n == __MASKSMALLINT(WORDARRAY)) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
662 |
if (__isSmallInteger(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
663 |
val = __intVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
664 |
if ((val >= 0) && (val <= 0xFFFF)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
665 |
if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) { |
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
666 |
sp = (unsigned short *)pFirst + indx; |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
667 |
*sp = val; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
668 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
669 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
670 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
671 |
} |
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
672 |
} else if (n == __MASKSMALLINT(SWORDARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
673 |
if (__isSmallInteger(anObject)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
674 |
val = __intVal(anObject); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
675 |
if ((val >= -32768) && (val < 32768)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
676 |
if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
677 |
ssp = (short *)pFirst + indx; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
678 |
*ssp = val; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
679 |
RETURN ( anObject ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
680 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
681 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
682 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
683 |
} else if (n == __MASKSMALLINT(SLONGARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
684 |
if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
685 |
slp = (long *)pFirst + indx; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
686 |
if (__isSmallInteger(anObject)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
687 |
*slp = __intVal(anObject); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
688 |
RETURN ( anObject ); |
2148 | 689 |
} |
690 |
n = __signedLongIntVal(anObject); |
|
691 |
/* zero means failure for an int larger than 4 bytes ... (would be a smallInteger) */ |
|
692 |
if (n) { |
|
693 |
*slp = n; |
|
694 |
RETURN ( anObject ); |
|
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
695 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
696 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
697 |
} else if (n == __MASKSMALLINT(LONGARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
698 |
if ((indx >= 0) && (indx < (nbytes / sizeof(long)))) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
699 |
lp = (unsigned long *)pFirst + indx; |
2148 | 700 |
if (anObject == __MKSMALLINT(0)) { |
701 |
*lp = 0; |
|
702 |
RETURN ( anObject ); |
|
703 |
} |
|
704 |
u = __longIntVal(anObject); |
|
705 |
/* zero means failure for an int larger than 4 bytes ... (would be a smallInteger) */ |
|
706 |
if (u) { |
|
707 |
*lp = u; |
|
708 |
RETURN ( anObject ); |
|
709 |
} |
|
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
710 |
} |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
711 |
} |
1 | 712 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
713 |
%}. |
10 | 714 |
index isInteger ifFalse:[ |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
715 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
716 |
the index should be an integer number |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
717 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
718 |
^ self indexNotInteger |
1 | 719 |
]. |
720 |
(index between:1 and:self size) ifFalse:[ |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
721 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
722 |
the index is less than 1 or greater than the size of the |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
723 |
receiver collection |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
724 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
725 |
^ self subscriptBoundsError:index |
1 | 726 |
]. |
643 | 727 |
(self class isFloatsOrDoubles) ifTrue:[ |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
728 |
anObject isNumber ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
729 |
^ self basicAt:index put:(anObject asFloat) |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
730 |
] |
13 | 731 |
]. |
10 | 732 |
anObject isInteger ifFalse:[ |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
733 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
734 |
the object to put into the receiver collection |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
735 |
should be an integer number |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
736 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
737 |
^ self elementNotInteger |
2 | 738 |
]. |
159 | 739 |
" |
213 | 740 |
the object to put into the receiver collection |
362 | 741 |
is not an instance of the expected element class, |
742 |
or the value is not within the elements valid range. |
|
159 | 743 |
" |
2 | 744 |
^ self elementBoundsError |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
745 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
746 |
"Modified: 19.4.1996 / 11:14:10 / cg" |
1 | 747 |
! |
748 |
||
749 |
instVarAt:index |
|
750 |
"return a non-indexed instance variable; |
|
13 | 751 |
peeking into an object this way is not very object oriented |
752 |
- use with care (needed for copy, inspector etc.)" |
|
1 | 753 |
|
754 |
%{ /* NOCONTEXT */ |
|
755 |
||
756 |
OBJ myClass; |
|
757 |
int idx, ninstvars; |
|
758 |
||
253 | 759 |
if (__isSmallInteger(index)) { |
329 | 760 |
myClass = __Class(self); |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
761 |
idx = __intVal(index) - 1; |
357 | 762 |
/* |
763 |
* do not allow return of non-object fields. |
|
764 |
* if subclass did not make privisions for that, |
|
765 |
* we wont do so here ... |
|
766 |
*/ |
|
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
767 |
if (((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(NONOBJECT_INSTS))) { |
357 | 768 |
if (idx == 0) { |
769 |
RETURN ( nil ) |
|
770 |
} |
|
771 |
} |
|
1133 | 772 |
ninstvars = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
159 | 773 |
if ((idx >= 0) && (idx < ninstvars)) { |
1133 | 774 |
RETURN ( __InstPtr(self)->i_instvars[idx] ); |
159 | 775 |
} |
1 | 776 |
} |
777 |
%} |
|
778 |
. |
|
779 |
index isInteger ifFalse:[ |
|
159 | 780 |
^ self indexNotInteger |
1 | 781 |
]. |
159 | 782 |
^ self subscriptBoundsError:index |
1 | 783 |
! |
784 |
||
785 |
instVarAt:index put:value |
|
786 |
"change a non-indexed instance variable; |
|
13 | 787 |
peeking into an object this way is not very object oriented |
788 |
- use with care (needed for copy, inspector etc.)" |
|
1 | 789 |
|
790 |
%{ /* NOCONTEXT */ |
|
791 |
||
792 |
OBJ myClass; |
|
793 |
int idx, ninstvars; |
|
794 |
||
253 | 795 |
if (__isSmallInteger(index)) { |
329 | 796 |
myClass = __Class(self); |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
797 |
idx = __intVal(index) - 1; |
1133 | 798 |
ninstvars = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
357 | 799 |
/* |
800 |
* do not allow setting of non-object fields. |
|
801 |
* if subclass did not make privisions for that, |
|
802 |
* we wont do so here ... |
|
803 |
*/ |
|
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
804 |
if (((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(NONOBJECT_INSTS))) { |
357 | 805 |
if (idx == 0) { |
806 |
RETURN ( nil ) |
|
807 |
} |
|
808 |
} |
|
159 | 809 |
if ((idx >= 0) && (idx < ninstvars)) { |
1133 | 810 |
__InstPtr(self)->i_instvars[idx] = value; |
159 | 811 |
__STORE(self, value); |
812 |
RETURN ( value ); |
|
813 |
} |
|
1 | 814 |
} |
815 |
%} |
|
816 |
. |
|
817 |
index isInteger ifFalse:[ |
|
159 | 818 |
^ self indexNotInteger |
1 | 819 |
]. |
159 | 820 |
^ self subscriptBoundsError:index |
359 | 821 |
! |
822 |
||
823 |
instVarNamed:name |
|
824 |
"return a non-indexed instance variables value by name; |
|
825 |
peeking into an object this way is not very object oriented |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
826 |
- use with care if at all (provided for inspectors and memory usage monitor). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
827 |
Notice, this access is very slow (because the classes instVar-description has to be |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
828 |
parsed ad runtime)" |
359 | 829 |
|
830 |
^ self instVarAt:(self class instVarOffsetOf:name) |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
831 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
832 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
833 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
834 |
|p| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
835 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
836 |
p := Point x:10 y:20. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
837 |
p instVarNamed:'x' |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
838 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
839 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
840 |
"Modified: 19.4.1996 / 11:12:39 / cg" |
359 | 841 |
! |
842 |
||
1528
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
843 |
instVarNamed:name ifAbsent:exceptionBlock |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
844 |
"return a non-indexed instance variables value by name, |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
845 |
or the value of exceptionBlock, if there is no such instance variable. |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
846 |
peeking into an object this way is not very object oriented |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
847 |
- use with care if at all (provided for inspectors and memory usage monitor). |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
848 |
Notice, this access is very slow (because the classes instVar-description has to be |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
849 |
parsed ad runtime)" |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
850 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
851 |
|idx| |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
852 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
853 |
idx := self class instVarOffsetOf:name. |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
854 |
idx isNil ifTrue:[^ exceptionBlock value]. |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
855 |
^ self instVarAt:idx |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
856 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
857 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
858 |
" |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
859 |
|p| |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
860 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
861 |
p := Point x:10 y:20. |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
862 |
p instVarNamed:'x' |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
863 |
" |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
864 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
865 |
"Created: 6.7.1996 / 23:02:49 / cg" |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
866 |
"Modified: 6.7.1996 / 23:03:41 / cg" |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
867 |
! |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
868 |
|
359 | 869 |
instVarNamed:name put:value |
870 |
"set a non-indexed instance variable by name; |
|
871 |
peeking into an object this way is not very object oriented |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
872 |
- if at all, use with care (provided for protocol completeness). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
873 |
Notice, this access is very slow (because the classes instVar-description has to be |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
874 |
parsed ad runtime)" |
359 | 875 |
|
876 |
^ self instVarAt:(self class instVarOffsetOf:name) put:value |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
877 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
878 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
879 |
|p| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
880 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
881 |
p := Point x:10 y:20. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
882 |
p instVarNamed:'x' put:30. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
883 |
p |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
884 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
885 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
886 |
"Modified: 19.4.1996 / 11:12:49 / cg" |
1 | 887 |
! ! |
888 |
||
783 | 889 |
!Object methodsFor:'binary storage'! |
890 |
||
891 |
hasSpecialBinaryRepresentation |
|
892 |
"return true, if the receiver has a special binary representation; |
|
893 |
default here is false, but can be redefined in class which provide |
|
894 |
their own storeBinary/readBinary methods. |
|
895 |
||
896 |
Normal user classes should not use this, it is meant as a hook for |
|
897 |
special classes such as True, False, UndefinedObject or SmallInteger. |
|
898 |
||
899 |
If your instances should be stored in a special way, see |
|
900 |
#representBinaryOn: and #readBinaryContentsFromdata:manager:." |
|
901 |
||
902 |
^ false |
|
1 | 903 |
! |
904 |
||
783 | 905 |
readBinaryContentsFrom:stream manager:manager |
906 |
"reconstruct the receivers instance variables by reading a binary |
|
907 |
binary representation from stream. |
|
908 |
This is a general implementation, walking over instances |
|
909 |
and loading each recursively using manager. |
|
910 |
Redefined by some classes to read a more compact representations |
|
911 |
(see String, SmallInteger etc). |
|
912 |
||
913 |
Notice, that the object is already recreated as an empty corps |
|
914 |
with instance variables all nil and bit-instances (bytes, words etc.) |
|
915 |
already read and restored. |
|
916 |
||
917 |
Also notice: this method is not called for if a private representation |
|
918 |
has been stored (see representBinaryOn:). |
|
919 |
In that case, #readBinaryContentsFromData:manager: is called, which |
|
920 |
has to be reimplemented in the objects class." |
|
921 |
||
922 |
|size "{ Class: SmallInteger }" |
|
923 |
instvarArray| |
|
924 |
||
925 |
stream next == 1 ifTrue:[ |
|
926 |
"/ |
|
927 |
"/ special representation ... |
|
928 |
"/ |
|
929 |
instvarArray := Array new:(size := stream nextNumber:3). |
|
930 |
1 to:size do:[:i | |
|
931 |
instvarArray basicAt:i put:(manager nextObject) |
|
932 |
]. |
|
933 |
self readBinaryContentsFromData:instvarArray manager:manager. |
|
934 |
^ self |
|
935 |
]. |
|
936 |
||
937 |
"/ |
|
938 |
"/ standard representation |
|
939 |
"/ |
|
940 |
size := self basicSize. |
|
941 |
size ~~ 0 ifTrue:[ |
|
942 |
self class isPointers ifTrue:[ |
|
943 |
1 to:size do:[:i | |
|
944 |
self basicAt:i put:(manager nextObject) |
|
945 |
] |
|
946 |
] |
|
947 |
]. |
|
948 |
size := self class instSize. |
|
949 |
1 to:size do:[:i | |
|
950 |
self instVarAt:i put:(manager nextObject) |
|
951 |
]. |
|
952 |
! |
|
953 |
||
954 |
readBinaryContentsFromData:instvarArray manager:manager |
|
955 |
"reconstruct the receivers instance variables by filling instance |
|
956 |
variables with values from instvarArray. This array contains the instvars |
|
957 |
as specified in #representBinaryOn: when the object was stored. |
|
958 |
It is the receivers responsibility to set its instance variables in the |
|
959 |
same order from that array." |
|
960 |
||
961 |
^ self subclassResponsibility |
|
962 |
||
963 |
"typical implementation (see also comment in #representBinaryOn:) |
|
964 |
(for an object with foo, bar and baz as instance variables, |
|
965 |
which did not store baz and wants baz to be reinitialized to |
|
966 |
some constant string) |
|
967 |
||
968 |
foo := instvarArray at:1. |
|
969 |
bar := instvarArray at:2. |
|
970 |
baz := 'aConstant'. |
|
971 |
" |
|
972 |
! |
|
973 |
||
974 |
representBinaryOn:manager |
|
975 |
"this method is called by the storage manager to ask objects |
|
976 |
if they wish to provide their own binary representation. |
|
977 |
||
978 |
If they want to do so, they should return an array containing all |
|
979 |
instance variables (named & indexed pointer) to be stored. |
|
980 |
If not redefined, this method returns nil which means that all |
|
981 |
instance variables are to be stored. |
|
982 |
||
983 |
It should be redefined in objects which do not want all instance variables |
|
984 |
to be stored (for example: objects which keep references to a view etc.). |
|
985 |
||
986 |
If this is redefined returning non-nil, the corresponding class needs |
|
987 |
a redefined instance method named #readBinaryContentsFromData:manager: |
|
988 |
which has to fill the receivers named (and optionally indexed pointer) |
|
989 |
instance variables with corresponding values from a data array." |
|
990 |
||
991 |
^ nil |
|
992 |
||
993 |
"typical implementation: |
|
994 |
(see also comment in #readBinaryContentsFromData:manager:) |
|
995 |
for an object with foo, bar and baz as instance variables, |
|
996 |
which does not want to store baz: |
|
997 |
||
998 |
representBinaryOn:manager |
|
999 |
|data| |
|
1000 |
||
1001 |
data := Array new:2. |
|
1002 |
data at:1 put:foo. |
|
1003 |
data at:2 put:bar. |
|
1004 |
^ data |
|
1005 |
" |
|
159 | 1006 |
! |
1007 |
||
783 | 1008 |
storeBinaryContentsFromData:instvarArray on:stream manager:manager |
1009 |
"store the instvars (both named & indexed pointer) |
|
1010 |
as returned by #representBinaryOn:." |
|
1011 |
||
1012 |
|size "{ Class: SmallInteger }"| |
|
1013 |
||
1014 |
size := instvarArray size. |
|
1015 |
1 to:size do:[:i | |
|
1016 |
manager putIdOf:(instvarArray at:i) on:stream |
|
1017 |
]. |
|
1018 |
! |
|
1019 |
||
1020 |
storeBinaryContentsOn:stream manager:manager |
|
1021 |
"store the receivers instance variables in a binary representation |
|
1022 |
on a stream using manager. |
|
1023 |
This is a general implementation, walking over instances |
|
1024 |
and storing each recursively using manager. |
|
1025 |
||
1026 |
Notice, that the objects definition and bit-instances (bytes, words etc.) |
|
1027 |
are already stored. |
|
1028 |
Here, we only have to deal with indexed-pointer and named instance variables. |
|
1029 |
||
1030 |
Also notice: this method is not called for if a private representation |
|
1031 |
has been stored (see representBinaryOn:). |
|
1032 |
In that case, #storeBinaryContentsFromData:manager: is called." |
|
1033 |
||
1034 |
|size "{ Class: SmallInteger }"| |
|
1035 |
||
1036 |
size := self basicSize. |
|
1037 |
size ~~ 0 ifTrue:[ |
|
1038 |
self class isPointers ifTrue:[ |
|
1039 |
1 to:size do:[:i | |
|
1040 |
manager putIdOf:(self basicAt:i) on:stream |
|
1041 |
]. |
|
1042 |
]. |
|
1043 |
]. |
|
1044 |
size := self class instSize. |
|
1045 |
1 to:size do:[:i | |
|
1046 |
manager putIdOf:(self instVarAt:i) on:stream |
|
1047 |
]. |
|
1 | 1048 |
! |
1049 |
||
783 | 1050 |
storeBinaryDefinitionBodyOn:stream manager:manager |
1051 |
"append a binary representation of the receivers body onto stream. |
|
1052 |
This is a general implementation walking over instances storing |
|
1053 |
each recursively as an ID using manager. |
|
1054 |
Can be redefined in subclasses." |
|
1055 |
||
1056 |
|basicSize "{ Class: SmallInteger }" |
|
1057 |
instSize "{ Class: SmallInteger }" |
|
1058 |
myClass specialRep pointers| |
|
1059 |
||
1060 |
myClass := self class. |
|
1061 |
instSize := myClass instSize. |
|
1062 |
||
1063 |
(pointers := myClass isPointers) ifTrue:[ |
|
1064 |
"/ |
|
1065 |
"/ inst size not needed - if you uncomment the line below, |
|
1066 |
"/ also uncomment the corresponding line in |
|
1067 |
"/ Object>>binaryDefinitionFrom:manager: |
|
1068 |
"/ |
|
1069 |
"/ stream nextPut:instSize. "mhmh this limits us to 255 named instvars" |
|
1070 |
||
1071 |
myClass isVariable ifTrue:[ |
|
1072 |
stream nextNumber:3 put:(basicSize := self basicSize) |
|
1073 |
] ifFalse:[ |
|
1074 |
basicSize := 0 |
|
1075 |
]. |
|
1076 |
] ifFalse: [ |
|
1077 |
stream nextNumber:4 put:(basicSize := self basicSize). |
|
1078 |
myClass isBytes ifTrue:[ |
|
1079 |
1 to:basicSize do:[:i | |
|
1080 |
stream nextPut:(self basicAt:i) |
|
1081 |
] |
|
1082 |
] ifFalse:[ |
|
1083 |
myClass isWords ifTrue:[ |
|
1084 |
1 to:basicSize do:[:i | |
|
1085 |
stream nextNumber:2 put:(self basicAt: i) |
|
1086 |
] |
|
1087 |
] ifFalse:[ |
|
1088 |
myClass isLongs ifTrue:[ |
|
1089 |
1 to:basicSize do:[:i | |
|
1090 |
stream nextNumber:4 put:(self basicAt: i) |
|
1091 |
] |
|
1092 |
] ifFalse:[ |
|
1093 |
myClass isFloats ifTrue:[ |
|
1094 |
"could do it in one big write on machines which use IEEE floats ..." |
|
1095 |
1 to:basicSize do:[:i | |
|
1096 |
Float storeBinaryIEEESingle:(self basicAt:i) on:stream |
|
1097 |
] |
|
1098 |
] ifFalse:[ |
|
1099 |
myClass isDoubles ifTrue:[ |
|
1100 |
"could do it in one big write on machines which use IEEE doubles ..." |
|
1101 |
1 to:basicSize do:[:i | |
|
1102 |
Float storeBinaryIEEEDouble:(self basicAt:i) on:stream |
|
1103 |
] |
|
1104 |
] ifFalse:[ |
|
1105 |
"/ should never be reached ... |
|
1106 |
1 to:basicSize do:[:i | |
|
1107 |
manager putIdOf:(self basicAt:i) on:stream |
|
1108 |
] |
|
1109 |
] |
|
1110 |
] |
|
1111 |
] |
|
1112 |
] |
|
1113 |
]. |
|
1114 |
]. |
|
1115 |
||
1116 |
(pointers or:[instSize ~~ 0]) ifTrue:[ |
|
1117 |
specialRep := self representBinaryOn:manager. |
|
1118 |
specialRep notNil ifTrue:[ |
|
1119 |
stream nextPut:1. "/ means: private representation follows |
|
1120 |
stream nextNumber:3 put:(specialRep basicSize). |
|
1121 |
self storeBinaryContentsFromData:specialRep on:stream manager:manager |
|
1122 |
] ifFalse:[ |
|
1123 |
stream nextPut:0. "/ means: full representation follows |
|
1124 |
self storeBinaryContentsOn:stream manager:manager |
|
159 | 1125 |
] |
1 | 1126 |
] |
783 | 1127 |
|
1128 |
"Modified: 25.10.1995 / 14:00:51 / cg" |
|
1 | 1129 |
! |
1130 |
||
783 | 1131 |
storeBinaryDefinitionOn:stream manager:manager |
1132 |
"append a binary representation of the receiver onto stream. |
|
1260 | 1133 |
This is an internal interface for binary storage mechanism. |
783 | 1134 |
This method first stores the class, then the body, which is done |
1135 |
in a separate method to allow redefinition of the bodies format. |
|
1136 |
Can be redefined in subclasses to write more compact representations |
|
1137 |
(see String, SmallInteger etc)." |
|
1138 |
||
1139 |
manager putIdOfClass:(self class) on:stream. |
|
1140 |
self storeBinaryDefinitionBodyOn:stream manager:manager |
|
1260 | 1141 |
|
1142 |
"Modified: 23.4.1996 / 09:31:12 / cg" |
|
783 | 1143 |
! |
1144 |
||
1145 |
storeBinaryOn:aStream |
|
1146 |
"Writes a description of the receiver onto aStream, in a way that allows |
|
1147 |
the object's structure to be reconstructed from the stream's contents" |
|
1148 |
||
1149 |
BinaryOutputManager store:self on:aStream |
|
899 | 1150 |
|
1151 |
" |
|
1152 |
|a s1 s2| |
|
1153 |
||
1154 |
s1 := 'hello'. |
|
1155 |
s2 := 'world'. |
|
1156 |
a := Array new:5. |
|
1157 |
a at:1 put:s1. |
|
1158 |
a at:2 put:s2. |
|
1159 |
a at:3 put:s1. |
|
1160 |
a at:4 put:s2. |
|
1161 |
a storeBinaryOn:'test.boss' |
|
1162 |
" |
|
1163 |
||
1164 |
" |
|
1165 |
(BinaryObjectStorage onOld:'test.boss' asFilename readStream) |
|
1166 |
next |
|
1167 |
inspect |
|
1168 |
" |
|
783 | 1169 |
! |
1170 |
||
1171 |
storeBinaryOn:stream manager:manager |
|
1172 |
"append a binary representation of the receiver onto stream." |
|
1173 |
||
1174 |
manager putIdOf:self on:stream |
|
1 | 1175 |
! ! |
1176 |
||
1826 | 1177 |
!Object methodsFor:'change & update'! |
1 | 1178 |
|
783 | 1179 |
broadcast:aSelectorSymbol |
1180 |
"send a message with selector aSelectorSymbol to all my dependents" |
|
1181 |
||
1182 |
self dependentsDo:[:dependent | |
|
1183 |
dependent perform:aSelectorSymbol |
|
1184 |
] |
|
1185 |
! |
|
1186 |
||
1187 |
broadcast:aSelectorSymbol with:anArgument |
|
1188 |
"send a message with selector aSelectorSymbol with an additional |
|
1189 |
argument anArgument to all my dependents." |
|
1190 |
||
1191 |
self dependentsDo:[:dependent | |
|
1192 |
dependent perform:aSelectorSymbol with:anArgument |
|
1193 |
] |
|
1194 |
! |
|
1195 |
||
159 | 1196 |
changeRequest |
1197 |
"the receiver wants to change - check if all dependents |
|
1198 |
grant the request, and return true if so" |
|
1199 |
||
1200 |
self dependentsDo:[:dependent | |
|
1201 |
dependent updateRequest ifFalse:[^ false]. |
|
1202 |
]. |
|
1203 |
^ true |
|
1204 |
! |
|
1205 |
||
1206 |
changeRequest:aParameter |
|
1207 |
"the receiver wants to change - check if all dependents |
|
1208 |
grant the request, and return true if so" |
|
1209 |
||
1210 |
self dependentsDo:[:dependent | |
|
1211 |
(dependent updateRequest:aParameter) ifFalse:[^ false]. |
|
1212 |
]. |
|
1213 |
^ true |
|
1214 |
! |
|
1215 |
||
783 | 1216 |
changeRequest:aParameter from:anObject |
1217 |
"the receiver wants to change - check if all dependents |
|
1218 |
except anObject grant the request, and return true if so. |
|
1219 |
The argument anObject is typically going to be the one who is |
|
1220 |
about to send the change request." |
|
1221 |
||
1222 |
self dependentsDo:[:dependent | |
|
1223 |
dependent == anObject ifFalse:[ |
|
1224 |
(dependent updateRequest:aParameter) ifFalse:[^ false]. |
|
1225 |
] |
|
1226 |
]. |
|
1227 |
^ true |
|
1228 |
! |
|
1229 |
||
159 | 1230 |
changeRequestFrom:anObject |
1231 |
"the receiver wants to change - check if all dependents |
|
202 | 1232 |
except anObject grant the request, and return true if so. |
1233 |
The argument anObject is typically going to be the one who is |
|
1234 |
about to send the change request." |
|
159 | 1235 |
|
1236 |
self dependentsDo:[:dependent | |
|
1237 |
dependent == anObject ifFalse:[ |
|
1238 |
(dependent updateRequest) ifFalse:[^ false]. |
|
1239 |
] |
|
1240 |
]. |
|
1241 |
^ true |
|
1242 |
! |
|
1243 |
||
1 | 1244 |
changed |
1245 |
"notify all dependents that the receiver has changed. |
|
71 | 1246 |
Each dependent gets a '#update:'-message with the original |
1247 |
receiver as argument." |
|
1 | 1248 |
|
159 | 1249 |
self changed:nil |
1 | 1250 |
! |
1251 |
||
1252 |
changed:aParameter |
|
1253 |
"notify all dependents that the receiver has changed somehow. |
|
71 | 1254 |
Each dependent gets a '#update:'-message with aParameter |
1255 |
as argument." |
|
1 | 1256 |
|
159 | 1257 |
self changed:aParameter with:nil |
1 | 1258 |
! |
1259 |
||
71 | 1260 |
changed:aParameter with:anArgument |
1 | 1261 |
"notify all dependents that the receiver has changed somehow. |
159 | 1262 |
Each dependent gets a '#update:with:from:'-message, with aParameter |
71 | 1263 |
and anArgument as arguments." |
1 | 1264 |
|
159 | 1265 |
self dependentsDo:[:dependent | |
1266 |
dependent update:aParameter with:anArgument from:self |
|
1 | 1267 |
] |
1268 |
! |
|
1269 |
||
1270 |
update:aParameter |
|
71 | 1271 |
"the message is sent to a dependent, when one of the objects |
1272 |
on whom the receiver depends, has changed. The argument aParameter |
|
1273 |
is either the changed object or the argument to the #changed: message. |
|
1274 |
||
1275 |
Default behavior here is to do nothing" |
|
1 | 1276 |
|
1277 |
^ self |
|
1278 |
! |
|
1279 |
||
1280 |
update:aParameter with:anArgument |
|
1281 |
"dependent is notified of some change - |
|
159 | 1282 |
Default is to try update:" |
1 | 1283 |
|
1284 |
^ self update:aParameter |
|
1285 |
! |
|
1286 |
||
1287 |
update:aParameter with:anArgument from:sender |
|
1288 |
"dependent is notified of some change - |
|
159 | 1289 |
Default is to try update:with:" |
1 | 1290 |
|
1291 |
^ self update:aParameter with:anArgument |
|
159 | 1292 |
! |
1293 |
||
1294 |
updateRequest |
|
1295 |
"return true, if an update request is granted. |
|
1296 |
Default here is to grant updates - may be used |
|
1297 |
to lock updates if someone is making other changes |
|
202 | 1298 |
from within an update. Or if someone has locked its |
1299 |
state and does not want others to change things. |
|
1300 |
However, these dependents must all honor the |
|
1301 |
changeRequest - ifTrue - change protocol. I.e. they |
|
1302 |
must first ask all others via changeRequest, and only do the change |
|
1303 |
it returns true. The others must decide in updateRequest and |
|
1304 |
return true if they think a change is ok." |
|
159 | 1305 |
|
1306 |
^ true |
|
1307 |
! |
|
1308 |
||
1309 |
updateRequest:aSymbol |
|
1310 |
"return true, if an update request is granted. |
|
1311 |
Default here a simple updateRequest" |
|
1312 |
||
1313 |
^ self updateRequest |
|
1 | 1314 |
! ! |
1315 |
||
783 | 1316 |
!Object methodsFor:'cleanup'! |
1317 |
||
1318 |
lowSpaceCleanup |
|
1319 |
"ignored here - redefined in some classes to |
|
1320 |
cleanup in low-memory situations" |
|
1321 |
||
1322 |
^ self |
|
1323 |
! ! |
|
1324 |
||
1325 |
!Object methodsFor:'comparing'! |
|
1326 |
||
1327 |
= anObject |
|
1328 |
"return true, if the receiver and the arg have the same structure" |
|
1329 |
||
1330 |
^ self == anObject |
|
1331 |
! |
|
1332 |
||
1333 |
== anObject |
|
2505 | 1334 |
"return true, if the receiver and the arg are the same object. |
1335 |
Never redefine this in any class. |
|
1336 |
The compilers generates inline code for it - redefinition is useless." |
|
783 | 1337 |
|
1338 |
%{ /* NOCONTEXT */ |
|
1339 |
||
1340 |
RETURN ( (self == anObject) ? true : false ); |
|
1341 |
%} |
|
1342 |
! |
|
1343 |
||
1344 |
hash |
|
1345 |
"return an Integer useful as a hash key for the receiver. |
|
1346 |
This hash should return same values for objects with same |
|
1347 |
contents (i.e. use this to hash on structure)" |
|
1348 |
||
1349 |
^ self identityHash |
|
1350 |
! |
|
1351 |
||
1352 |
identityHash |
|
1353 |
"return an Integer useful as a hash key for the receiver. |
|
1354 |
This hash should return same values for the same object (i.e. use |
|
1355 |
this to hash on identity of objects). |
|
1356 |
||
1357 |
We cannot use the Objects address (as other smalltalks do) since |
|
1358 |
no object-table exists and the hashval must not change when objects |
|
1359 |
are moved by the collector. Therefore we assign each object a unique |
|
1360 |
Id in the object header itself as its hashed upon. |
|
1361 |
(luckily we have 11 bits spare to do this - unluckily its only 11 bits). |
|
1362 |
Time will show, if 11 bits are enough; if not, another entry in the |
|
1363 |
object header will be needed, adding 4 bytes to every object. Alternatively, |
|
1364 |
hashed-upon objects could add an instvar containing the hash value." |
|
1365 |
||
1366 |
%{ /* NOCONTEXT */ |
|
1367 |
||
1368 |
REGISTER unsigned hash; |
|
1369 |
static unsigned nextHash = 0; |
|
1370 |
||
1371 |
if (__isNonNilObject(self)) { |
|
1372 |
hash = __GET_HASH(self); |
|
1373 |
if (hash == 0) { |
|
2462
5ba287e9f5bf
slightly faster identityHash
Claus Gittinger <cg@exept.de>
parents:
2448
diff
changeset
|
1374 |
/* has no hash yet */ |
5ba287e9f5bf
slightly faster identityHash
Claus Gittinger <cg@exept.de>
parents:
2448
diff
changeset
|
1375 |
|
2480 | 1376 |
if (++nextHash > __MAX_HASH__) { |
1377 |
nextHash = 1; |
|
2462
5ba287e9f5bf
slightly faster identityHash
Claus Gittinger <cg@exept.de>
parents:
2448
diff
changeset
|
1378 |
} |
2480 | 1379 |
hash = nextHash; |
783 | 1380 |
__SET_HASH(self, hash); |
1381 |
} |
|
1382 |
||
1383 |
/* |
|
1384 |
* now, we got 11 bits for hashing; |
|
1385 |
* make it as large as possible; since most hashers use the returned |
|
1386 |
* key and take it modulu some prime number, this will allow for |
|
1387 |
* better distribution (i.e. bigger empty spaces) in hashed collection. |
|
1388 |
*/ |
|
2480 | 1389 |
hash = __MAKE_HASH__(hash); |
2462
5ba287e9f5bf
slightly faster identityHash
Claus Gittinger <cg@exept.de>
parents:
2448
diff
changeset
|
1390 |
RETURN ( __MKSMALLINT(hash) ); |
783 | 1391 |
} |
1392 |
%}. |
|
1393 |
^ 0 "never reached, since redefined in UndefinedObject and SmallInteger" |
|
1394 |
! |
|
1395 |
||
2479
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1396 |
identityHashForBinaryStore |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1397 |
"hash which is usable if the object does not change its class |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1398 |
and does not #become something else, while the hash is used. |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1399 |
This is only used by the binary storage mechanism, during the |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1400 |
object writing phase." |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1401 |
|
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1402 |
%{ /* NOCONTEXT */ |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1403 |
|
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1404 |
REGISTER unsigned hash, hash1, hash2, sz; |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1405 |
OBJ o; |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1406 |
static unsigned nextHash = 0; |
2480 | 1407 |
static unsigned nextClassHash = 0; |
2479
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1408 |
|
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1409 |
if (__isNonNilObject(self)) { |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1410 |
/* |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1411 |
* my own identityHash |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1412 |
*/ |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1413 |
hash1 = __GET_HASH(self); |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1414 |
if (hash1 == 0) { |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1415 |
/* has no hash yet */ |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1416 |
|
2480 | 1417 |
if (++nextHash > __MAX_HASH__) { |
1418 |
nextHash = 1; |
|
2479
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1419 |
} |
2480 | 1420 |
hash1 = nextHash; |
2479
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1421 |
__SET_HASH(self, hash1); |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1422 |
} |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1423 |
/* |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1424 |
* my classes identityHash |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1425 |
*/ |
2480 | 1426 |
o = __qClass(self); |
2479
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1427 |
hash2 = __GET_HASH(o); |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1428 |
if (hash2 == 0) { |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1429 |
/* has no hash yet */ |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1430 |
|
2480 | 1431 |
if (++nextClassHash > __MAX_HASH__) { |
1432 |
nextClassHash = 1; |
|
2479
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1433 |
} |
2480 | 1434 |
hash2 = nextClassHash; |
2479
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1435 |
__SET_HASH(o, hash2); |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1436 |
} |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1437 |
|
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1438 |
/* |
2480 | 1439 |
* some bits of my size |
2479
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1440 |
*/ |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1441 |
sz = __qSize(self); |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1442 |
|
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1443 |
/* |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1444 |
* now, we got 11 + 11 + 8 bits for hashing; |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1445 |
* make it as large as possible; since most hashers use the returned |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1446 |
* key and take it modulu some prime number, this will allow for |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1447 |
* better distribution (i.e. bigger empty spaces) in hashed collection. |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1448 |
*/ |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1449 |
hash = (hash1 << 11) | hash2; /* 22 bits */ |
2480 | 1450 |
hash = (hash << 8) | (sz & 0xFC); /* 30 bits */ |
1451 |
||
1452 |
while ((hash & 0x20000000) == 0) { |
|
1453 |
hash <<= 1; |
|
1454 |
} |
|
1455 |
||
2479
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1456 |
RETURN ( __MKSMALLINT(hash) ); |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1457 |
} |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1458 |
%}. |
2480 | 1459 |
^ nil "never reached, since UndefinedObject and SmallInteger are not hashed upon in binary storage" |
2479
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1460 |
! |
6d9c516e04d8
added special hash for binaryStorage
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
1461 |
|
783 | 1462 |
isNil |
1463 |
"return true, if the receiver is nil" |
|
1464 |
||
1465 |
^ false |
|
1466 |
! |
|
1467 |
||
1468 |
notNil |
|
1469 |
"return true, if the receiver is not nil" |
|
1470 |
||
1471 |
^ true |
|
1472 |
! |
|
1473 |
||
1474 |
~= anObject |
|
1475 |
"return true, if the receiver and the arg do not have the same structure" |
|
1476 |
||
1477 |
^ (self = anObject) not |
|
1478 |
! |
|
1479 |
||
1480 |
~~ anObject |
|
2505 | 1481 |
"return true, if the receiver and the arg are not the same object. |
1482 |
Never redefine this in any class. |
|
1483 |
The compilers generates inline code for it - redefinition is useless." |
|
783 | 1484 |
|
1485 |
%{ /* NOCONTEXT */ |
|
1486 |
RETURN ( (self == anObject) ? false : true ); |
|
1487 |
%} |
|
1488 |
! ! |
|
1489 |
||
1490 |
!Object methodsFor:'converting'! |
|
1491 |
||
1492 |
asValue |
|
1493 |
"return a valueHolder for for the receiver" |
|
1494 |
||
1495 |
^ ValueHolder with:self |
|
1496 |
! ! |
|
1497 |
||
1498 |
!Object methodsFor:'copying'! |
|
1499 |
||
1500 |
copy |
|
1501 |
"return a copy of the receiver - defaults to shallowcopy here. |
|
1502 |
Notice, that copy does not copy dependents." |
|
1503 |
||
1504 |
^ self shallowCopy postCopy |
|
1505 |
! |
|
1506 |
||
1507 |
deepCopy |
|
1508 |
"return a copy of the object with all subobjects also copied. |
|
1509 |
This method DOES handle cycles/self-refs; however the receivers |
|
1510 |
class is not copied (to avoid the 'total' copy). |
|
1511 |
This deepCopy is a bit slower than the old (unsecure) one, since it |
|
1512 |
keeps track of already copied objects. If you are sure, that your |
|
1129 | 1513 |
copied object does not include duplicates (or you do not care) and |
783 | 1514 |
no cycles, you can use the old simpleDeepCopy, which avoids this overhead, |
1515 |
but may run into trouble. |
|
1516 |
Notice, that copy does not copy dependents." |
|
1517 |
||
1518 |
^ self deepCopyUsing:(IdentityDictionary new) |
|
1519 |
||
1520 |
"an example which is not handled by the old deepCopy: |
|
1521 |
||
1522 |
|a| |
|
1523 |
a := Array new:3. |
|
1524 |
a at:3 put:a. |
|
1525 |
a deepCopy inspect |
|
1526 |
" |
|
1129 | 1527 |
|
1528 |
"Modified: 27.3.1996 / 16:31:20 / stefan" |
|
783 | 1529 |
! |
1530 |
||
1531 |
deepCopyError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1532 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1533 |
|
783 | 1534 |
"raise a signal, that deepCopy is not allowed for this object" |
1535 |
||
1536 |
^ DeepCopyErrorSignal raise |
|
1537 |
! |
|
1538 |
||
1539 |
deepCopyUsing:aDictionary |
|
1540 |
"a helper for deepCopy; return a copy of the object with |
|
1541 |
all subobjects also copied. If the to-be-copied object is in the dictionary, |
|
1542 |
use the value found there. The class of the receiver is not copied. |
|
1543 |
This method DOES handle cycles/self references." |
|
1544 |
||
1545 |
|myClass aCopy |
|
1546 |
sz "{ Class: SmallInteger }" |
|
1547 |
iOrig iCopy| |
|
1548 |
||
1549 |
myClass := self class. |
|
1550 |
myClass isVariable ifTrue:[ |
|
1551 |
sz := self basicSize. |
|
1552 |
aCopy := myClass basicNew:sz. |
|
1553 |
] ifFalse:[ |
|
1554 |
sz := 0. |
|
1555 |
aCopy := myClass basicNew |
|
1556 |
]. |
|
1557 |
aCopy setHashFrom:self. |
|
1558 |
||
1559 |
aDictionary at:self put:aCopy. |
|
143 | 1560 |
|
1561 |
" |
|
783 | 1562 |
copy indexed instvars - if any |
1563 |
" |
|
1564 |
sz ~~ 0 ifTrue:[ |
|
1565 |
myClass isBits ifTrue:[ |
|
1566 |
"block-copy indexed instvars" |
|
1567 |
aCopy replaceFrom:1 to:sz with:self startingAt:1 |
|
1568 |
] ifFalse:[ |
|
1569 |
"individual deep copy the indexed variables" |
|
1570 |
1 to:sz do:[:i | |
|
1571 |
iOrig := self basicAt:i. |
|
1572 |
iOrig notNil ifTrue:[ |
|
1573 |
(aDictionary includesKey:iOrig) ifTrue:[ |
|
1574 |
iCopy := aDictionary at:iOrig |
|
1575 |
] ifFalse:[ |
|
1576 |
iCopy := iOrig deepCopyUsing:aDictionary. |
|
1577 |
]. |
|
1578 |
aCopy basicAt:i put:iCopy |
|
1579 |
] |
|
1580 |
] |
|
1581 |
] |
|
1582 |
]. |
|
1583 |
||
1584 |
" |
|
1585 |
copy the instance variables |
|
1586 |
" |
|
1587 |
sz := myClass instSize. |
|
1588 |
sz ~~ 0 ifTrue:[ |
|
1589 |
1 to:sz do:[:i | |
|
1590 |
iOrig := self instVarAt:i. |
|
1591 |
iOrig notNil ifTrue:[ |
|
1592 |
(aDictionary includesKey:iOrig) ifTrue:[ |
|
1593 |
iCopy := aDictionary at:iOrig |
|
1594 |
] ifFalse:[ |
|
1595 |
iCopy := iOrig deepCopyUsing:aDictionary. |
|
1596 |
]. |
|
1597 |
aCopy instVarAt:i put:iCopy |
|
1598 |
] |
|
1599 |
]. |
|
1600 |
]. |
|
1601 |
||
1602 |
^ aCopy |
|
1603 |
! |
|
1604 |
||
1605 |
postCopy |
|
1606 |
"this is for compatibility with ST-80 code, which uses postCopy for |
|
1607 |
cleanup after copying, while ST/X passes the original in postCopyFrom: |
|
1608 |
(see there)" |
|
1609 |
||
1610 |
^ self |
|
1611 |
! |
|
1612 |
||
1613 |
postCopyFrom:original |
|
1614 |
"sent to a freshly deep-copied object to give it a chance to adjust things. |
|
1615 |
(a font could flush its device-handle for example). |
|
1616 |
Notice, that for Sets/Dicts etc. a rehash is not needed, since the deepCopy |
|
1617 |
will have the same hash key as the receiver (as long as ST/X provides the |
|
1618 |
setHash: functionality)." |
|
1619 |
||
1620 |
"for ST-80 compatibility, we try postCopy here ..." |
|
1621 |
^ self postCopy |
|
1622 |
! |
|
1623 |
||
1624 |
setHashFrom:anObject |
|
1625 |
"set my identity-hash key to be the same as anObjects hash key. |
|
1626 |
This is an ST/X speciality, which is NOT available in other (especially OT based) |
|
1627 |
Smalltalks, and may not be available in future ST/X versions. |
|
1628 |
DO NEVER use this for normal application code." |
|
1629 |
||
1630 |
%{ /* NOCONTEXT */ |
|
1631 |
||
1632 |
REGISTER unsigned h; |
|
1633 |
||
1634 |
if (__isNonNilObject(self) && __isNonNilObject(anObject)) { |
|
1635 |
h = __GET_HASH(anObject); |
|
1636 |
__SET_HASH(self, h); |
|
1637 |
RETURN (self); |
|
1638 |
} |
|
1639 |
%} |
|
1640 |
. |
|
1641 |
self primitiveFailed "neither receiver not arg may be nil or SmallInteger" |
|
1642 |
! |
|
1643 |
||
1644 |
shallowCopy |
|
1645 |
"return a copy of the object with shared subobjects (a shallow copy) |
|
1646 |
i.e. the copy shares referenced instvars with its original." |
|
1647 |
||
1648 |
|myClass aCopy |
|
1649 |
sz "{ Class: SmallInteger }" | |
|
1650 |
||
1651 |
myClass := self class. |
|
1652 |
myClass isVariable ifTrue:[ |
|
1653 |
sz := self basicSize. |
|
1654 |
aCopy := myClass basicNew:sz. |
|
1655 |
||
1656 |
"copy the indexed variables" |
|
1657 |
1 to:sz do:[:i | |
|
1658 |
aCopy basicAt:i put:(self basicAt:i) |
|
1659 |
] |
|
1660 |
] ifFalse:[ |
|
1661 |
aCopy := myClass basicNew |
|
1662 |
]. |
|
1663 |
||
1664 |
"copy the instance variables" |
|
1665 |
sz := myClass instSize. |
|
1666 |
1 to:sz do:[:i | |
|
1667 |
aCopy instVarAt:i put:(self instVarAt:i) |
|
1668 |
]. |
|
1669 |
||
1670 |
^ aCopy |
|
1671 |
! |
|
1672 |
||
1673 |
shallowCopyForFinalization |
|
1674 |
"this is used to aquire a copy to be used for finalization - |
|
1675 |
(the copy will get a dispose-notification; see the documentation in the Registry class) |
|
1676 |
This method can be redefined for more efficient copying - especially for large objects." |
|
1677 |
||
1678 |
^ self shallowCopy |
|
1679 |
! |
|
1680 |
||
1681 |
simpleDeepCopy |
|
1682 |
"return a copy of the object with all subobjects also copied. |
|
1683 |
This method does NOT handle cycles - but is included to allow this |
|
1684 |
slightly faster copy in situations where it is known that |
|
1685 |
no recursive references occur (LargeIntegers for example). |
|
1686 |
NOTICE: you will run into trouble, when trying this with recursive |
|
1687 |
objects (usually recursionInterrupt or memory-alert). |
|
1688 |
This method corresponds to the 'traditional' deepCopy found in |
|
1689 |
the Blue book." |
|
1690 |
||
1691 |
|myClass aCopy |
|
1692 |
sz "{ Class: SmallInteger }" | |
|
1693 |
||
1694 |
myClass := self class. |
|
1695 |
myClass isVariable ifTrue:[ |
|
1696 |
sz := self basicSize. |
|
1697 |
aCopy := myClass basicNew:sz. |
|
1698 |
||
1699 |
"copy the indexed variables" |
|
1700 |
1 to:sz do:[:i | |
|
1701 |
aCopy basicAt:i put:((self basicAt:i) simpleDeepCopy) |
|
1702 |
] |
|
1703 |
] ifFalse:[ |
|
1704 |
aCopy := myClass basicNew |
|
1705 |
]. |
|
1706 |
||
1707 |
"copy the instance variables" |
|
1708 |
sz := myClass instSize. |
|
1709 |
1 to:sz do:[:i | |
|
1710 |
aCopy instVarAt:i put:((self instVarAt:i) simpleDeepCopy) |
|
1711 |
]. |
|
1712 |
||
1713 |
^ aCopy |
|
1714 |
||
1715 |
"a bad example (but ST/X should survive ...)" |
|
1716 |
" |
|
1717 |
|a| |
|
1718 |
a := Array new:3. |
|
1719 |
a at:3 put:a. |
|
1720 |
a simpleDeepCopy |
|
1721 |
" |
|
1722 |
! ! |
|
1723 |
||
1724 |
!Object methodsFor:'debugging'! |
|
1725 |
||
1726 |
basicInspect |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1727 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1728 |
|
783 | 1729 |
"launch an inspector on the receiver. |
1730 |
this method should NOT be redefined in subclasses." |
|
1731 |
||
1732 |
Inspector isNil ifTrue:[ |
|
1417 | 1733 |
" |
1734 |
for systems without GUI |
|
1735 |
" |
|
1736 |
Transcript showCR:'no Inspector' |
|
783 | 1737 |
] ifFalse:[ |
1417 | 1738 |
Inspector openOn:self |
783 | 1739 |
] |
1417 | 1740 |
|
1741 |
"Modified: 18.5.1996 / 15:43:25 / cg" |
|
783 | 1742 |
! |
1743 |
||
1744 |
inspect |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1745 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1746 |
|
783 | 1747 |
"launch an inspector on the receiver. |
1748 |
this method (or better: inspectorClass) can be redefined in subclasses |
|
1749 |
to start special inspectors." |
|
1750 |
||
1751 |
|cls| |
|
1752 |
||
1753 |
cls := self inspectorClass. |
|
1754 |
cls isNil ifTrue:[ |
|
1755 |
^ self basicInspect |
|
1756 |
]. |
|
1757 |
cls openOn:self |
|
1758 |
||
1759 |
" |
|
1760 |
Object new inspect |
|
1761 |
(1 @ 2) inspect |
|
1762 |
Smalltalk inspect |
|
1763 |
#(1 2 3) asOrderedCollection inspect |
|
1764 |
(Color red) inspect |
|
1765 |
(Image fromFile:'bitmaps/garfield.gif') inspect |
|
143 | 1766 |
" |
71 | 1767 |
! |
1768 |
||
783 | 1769 |
inspectorClass |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1770 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1771 |
|
783 | 1772 |
"return the class to use for inspect. |
1773 |
Can (should) be redefined in classes for which a better inspector is available" |
|
1774 |
||
1775 |
^ Inspector |
|
1776 |
! |
|
1777 |
||
1778 |
mustBeKindOf:aClass |
|
1779 |
"for compatibility & debugging support: |
|
1780 |
check if the receiver isKindOf:aClass and raise an error if not. |
|
1781 |
Notice: |
|
1782 |
it is VERY questionable, if it makes sense to add manual |
|
1783 |
type checks to a dynamically typed language like smalltalk. |
|
1784 |
It will, at least, slow down performance, |
|
1785 |
make your code less reusable and clutter your code with stupid sends |
|
1786 |
of this selector. Also, read the comment in isKindOf:, regarding the |
|
1787 |
use of isXXX check methods. |
|
1788 |
You see: The author does not like this at all ..." |
|
1789 |
||
1790 |
(self isKindOf:aClass) ifFalse:[ |
|
1791 |
self error:'argument is not of expected type' |
|
1792 |
] |
|
1793 |
! |
|
1794 |
||
1795 |
obsoleteMethodWarning |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1796 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1797 |
|
783 | 1798 |
"in methods which are going to be obsoleted, a self send to |
1799 |
this method is used to tell programmers that a method is |
|
1800 |
used which is going to be removed in later ST/X versions. |
|
1801 |
Find all methods which will be obsolete soon by looking at senders |
|
1802 |
of this message. |
|
1803 |
Hopefully, this warning message is annoying enough for you to |
|
1804 |
change the code ... ;-)" |
|
1805 |
||
1806 |
self obsoleteMethodWarning:nil from:thisContext sender |
|
1807 |
! |
|
1808 |
||
1809 |
obsoleteMethodWarning:message |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1810 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1811 |
|
783 | 1812 |
"in methods which are going to be obsoleted, a self send to |
1813 |
this method is used to tell programmers that a method is |
|
1814 |
used which is going to be removed in later ST/X versions. |
|
1815 |
Find all methods which will be obsolete soon by looking at senders |
|
1816 |
of this message. |
|
1817 |
Hopefully, this warning message is annoying enough for you to |
|
1818 |
change the code ... ;-)" |
|
1819 |
||
1820 |
self obsoleteMethodWarning:message from:thisContext sender |
|
1821 |
! |
|
1822 |
||
1823 |
obsoleteMethodWarning:message from:aContext |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1824 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1825 |
|
783 | 1826 |
"in methods which are going to be obsoleted, a self-send to |
1827 |
this method is used to tell programmers that a method is |
|
1828 |
used which is going to be removed in later ST/X versions. |
|
1829 |
Find all methods which will be obsolete soon by looking at senders |
|
1830 |
of this message. |
|
1831 |
Hopefully, this warning message is annoying enough for you to |
|
1832 |
change the code ... ;-)" |
|
1833 |
||
1834 |
|spec| |
|
1835 |
||
1836 |
spec := aContext methodPrintString. |
|
2136 | 1837 |
('WARNING: the ''' , spec , ''' method is obsolete.') errorPrintCR. |
1838 |
(' And may not be present in future ST/X versions.') errorPrintCR. |
|
1839 |
(' called from ' , aContext sender printString) errorPrintCR. |
|
783 | 1840 |
message notNil ifTrue:[ |
2136 | 1841 |
'------> ' errorPrint. message errorPrintCR |
783 | 1842 |
] |
1843 |
||
1844 |
" |
|
1845 |
Object obsoleteMethodWarning:'foo' from:thisContext sender sender |
|
1846 |
" |
|
2136 | 1847 |
|
1848 |
"Modified: 10.1.1997 / 19:08:42 / cg" |
|
783 | 1849 |
! ! |
1850 |
||
1851 |
!Object methodsFor:'dependents access'! |
|
1852 |
||
1853 |
addDependent:anObject |
|
1854 |
"make the argument, anObject be a dependent of the receiver" |
|
1855 |
||
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1856 |
|wasBlocked| |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1857 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1858 |
"/ must do this save from interrupts, since the dependents collection |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1859 |
"/ is possibly accessed from multiple threads. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1860 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1861 |
"/ faster execution. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1862 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1863 |
wasBlocked := OperatingSystem blockInterrupts. |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1864 |
[ |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1865 |
|deps dep| |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1866 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1867 |
deps := self dependents. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1868 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1869 |
"/ to save a fair amount of memory in case of |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1870 |
"/ many dependencies, we store a single dependent in |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1871 |
"/ a WeakArray, and switch to a WeakSet if more dependents are |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1872 |
"/ added. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1873 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1874 |
deps isNil ifTrue:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1875 |
self dependents:(WeakArray with:anObject) |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1876 |
] ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1877 |
deps class == WeakArray ifTrue:[ |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1878 |
dep := deps at:1. |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1879 |
dep ~~ anObject ifTrue:[ |
1780
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1880 |
(dep isNil or:[dep == 0]) ifTrue:[ |
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1881 |
deps at:1 put:anObject |
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1882 |
] ifFalse:[ |
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1883 |
self dependents:(WeakIdentitySet with:dep with:anObject) |
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1884 |
] |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1885 |
] |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1886 |
] ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1887 |
deps add:anObject |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1888 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1889 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1890 |
] valueNowOrOnUnwindDo:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1891 |
wasBlocked ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1892 |
OperatingSystem unblockInterrupts |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1893 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1894 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1895 |
|
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1896 |
"Modified: 1.8.1996 / 14:21:20 / cg" |
783 | 1897 |
! |
1898 |
||
1899 |
dependents |
|
1900 |
"return a Collection of dependents - nil if there is none. |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1901 |
The default implementation here uses a global WeakDictionary to store |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1902 |
dependents |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1903 |
This may be too slow for high frequency change&update, |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1904 |
therefore, some classes (Model) redefine this for better performance. |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1905 |
Notice the mentioning of a WeakDictionary - read the classes documentation." |
783 | 1906 |
|
1907 |
^ Dependencies at:self ifAbsent:[nil] |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1908 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1909 |
"Modified: 19.4.1996 / 12:36:46 / cg" |
783 | 1910 |
! |
1911 |
||
1912 |
dependents:aCollection |
|
1913 |
"set the collection of dependents. |
|
1914 |
The default implementation here uses a global Dictionary to store |
|
1915 |
dependents which may be too slow for high frequency change&update. |
|
1916 |
Therefore, some classes (Model) redefine this for better performance." |
|
1917 |
||
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1918 |
"/ must do this save from interrupts, since the dependents collection |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1919 |
"/ is possibly accessed from multiple threads. |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1920 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
2336 | 1921 |
"/ faster execution (and to avoid creation of garbage blocks). |
1922 |
||
1923 |
(OperatingSystem blockInterrupts) ifTrue:[ |
|
1924 |
"/ the common case - already blocked |
|
1925 |
||
1926 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[ |
|
1927 |
Dependencies removeKey:self ifAbsent:[] |
|
1928 |
] ifFalse:[ |
|
1929 |
Dependencies at:self put:aCollection |
|
1930 |
]. |
|
1931 |
^ self |
|
1932 |
]. |
|
1933 |
||
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1934 |
[ |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1935 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[ |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1936 |
Dependencies removeKey:self ifAbsent:[] |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1937 |
] ifFalse:[ |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1938 |
Dependencies at:self put:aCollection |
2336 | 1939 |
]. |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1940 |
] valueNowOrOnUnwindDo:[ |
2336 | 1941 |
OperatingSystem unblockInterrupts |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1942 |
] |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1943 |
|
2336 | 1944 |
"Modified: 30.1.1997 / 21:22:10 / cg" |
783 | 1945 |
! |
1946 |
||
1947 |
dependentsDo:aBlock |
|
1948 |
"evaluate aBlock for all of my dependents" |
|
1949 |
||
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1950 |
|deps nwDeps| |
783 | 1951 |
|
1952 |
deps := self dependents. |
|
1953 |
deps notNil ifTrue:[ |
|
1780
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1954 |
deps do:[:d | |
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1955 |
(d notNil and:[d ~~ 0]) ifTrue:[ |
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1956 |
aBlock value:d |
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1957 |
] |
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1958 |
] |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1959 |
]. |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1960 |
nwDeps := self nonWeakDependents. |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1961 |
(nwDeps notNil and:[nwDeps ~~ deps]) ifTrue:[ |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1962 |
nwDeps do:aBlock |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1963 |
]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1964 |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1965 |
"Modified: 19.4.1996 / 12:35:54 / cg" |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1966 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1967 |
|
2445 | 1968 |
myDependents |
1969 |
"same as dependents - ST-80 compatibility" |
|
1970 |
||
1971 |
^ self dependents |
|
1972 |
! |
|
1973 |
||
783 | 1974 |
release |
1975 |
"remove all dependencies from the receiver" |
|
1976 |
||
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1977 |
self dependents:nil. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1978 |
self nonWeakDependents:nil |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1979 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1980 |
"Modified: 19.4.1996 / 10:55:36 / cg" |
783 | 1981 |
! |
1982 |
||
1983 |
removeDependent:anObject |
|
1984 |
"make the argument, anObject be independent of the receiver" |
|
1985 |
||
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1986 |
|wasBlocked| |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1987 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1988 |
"/ must do this save from interrupts, since the dependents collection |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1989 |
"/ is possibly accessed from multiple threads. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1990 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1991 |
"/ faster execution. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1992 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1993 |
wasBlocked := OperatingSystem blockInterrupts. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1994 |
[ |
1780
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
1995 |
|deps n d| |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1996 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1997 |
deps := self dependents. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1998 |
deps notNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1999 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2000 |
"/ to save a fair amount of memory in case of |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2001 |
"/ many dependencies, we store a single dependent in |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2002 |
"/ a WeakArray, and switch to a WeakSet if more dependents are |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2003 |
"/ added. Here we have to do the inverse ... |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2004 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2005 |
deps class == WeakArray ifTrue:[ |
1780
1b3a4ddc5b94
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
1762
diff
changeset
|
2006 |
((d := deps at:1) == anObject |
2341 | 2007 |
or:[d isNil |
2008 |
or:[d == 0]]) ifTrue:[ |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2009 |
self dependents:nil |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2010 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2011 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2012 |
deps remove:anObject ifAbsent:[]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2013 |
(n := deps size) == 0 ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2014 |
self dependents:nil |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2015 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2016 |
n == 1 ifTrue:[ |
2341 | 2017 |
d := deps firstIfEmpty:nil. |
2018 |
d notNil ifTrue:[ |
|
2019 |
deps := WeakArray with:d |
|
2020 |
] ifFalse:[ |
|
2021 |
deps := nil |
|
2022 |
]. |
|
2023 |
self dependents:deps. |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2024 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2025 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2026 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2027 |
] |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2028 |
] valueNowOrOnUnwindDo:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2029 |
wasBlocked ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2030 |
OperatingSystem unblockInterrupts |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2031 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2032 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2033 |
|
2341 | 2034 |
"Modified: 31.1.1997 / 12:36:16 / cg" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2035 |
! ! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2036 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2037 |
!Object methodsFor:'dependents access (nonWeak)'! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2038 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2039 |
addNonWeakDependent:anObject |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2040 |
"make the argument, anObject be a nonWeak dependent of the receiver. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2041 |
Be careful: this nonWeakDependency will prevent the dependent from being |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2042 |
garbage collected unless the dependency is removed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2043 |
This is a private mechanism, for directed dependencies." |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2044 |
|
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2045 |
|wasBlocked| |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2046 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2047 |
"/ must do this save from interrupts, since the dependents collection |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2048 |
"/ is possibly accessed from multiple threads. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2049 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2050 |
"/ faster execution. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2051 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2052 |
wasBlocked := OperatingSystem blockInterrupts. |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
2053 |
[ |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
2054 |
|deps dep| |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2055 |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2056 |
deps := self nonWeakDependents. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2057 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2058 |
"/ to save a fair amount of memory in case of |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2059 |
"/ many dependencies, we store a single dependent in |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2060 |
"/ an Array, and switch to a Set if more dependents are |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2061 |
"/ added. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2062 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2063 |
deps isNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2064 |
self nonWeakDependents:(Array with:anObject) |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2065 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2066 |
deps class == Array ifTrue:[ |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
2067 |
dep := deps at:1. |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
2068 |
dep ~~ anObject ifTrue:[ |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
2069 |
self nonWeakDependents:(IdentitySet with:dep with:anObject) |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
2070 |
] |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2071 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2072 |
deps add:anObject |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2073 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2074 |
] |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2075 |
] valueNowOrOnUnwindDo:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2076 |
wasBlocked ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2077 |
OperatingSystem unblockInterrupts |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2078 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2079 |
] |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2080 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2081 |
"Created: 19.4.1996 / 10:54:08 / cg" |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
2082 |
"Modified: 1.8.1996 / 14:22:12 / cg" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2083 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2084 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2085 |
nonWeakDependents |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2086 |
"return a Collection of nonWeakDependents - nil if there is none. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2087 |
This is a private mechanism for directed dependencies." |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2088 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2089 |
NonWeakDependencies isNil ifTrue:[^nil]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2090 |
^ NonWeakDependencies at:self ifAbsent:[nil] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2091 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2092 |
"Created: 19.4.1996 / 10:55:06 / cg" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2093 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2094 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2095 |
nonWeakDependents:aCollection |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2096 |
"set the collection of nonWeak dependents. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2097 |
This is a private helper for directed dependencies." |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2098 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2099 |
[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2100 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2101 |
NonWeakDependencies removeKey:self ifAbsent:[] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2102 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2103 |
NonWeakDependencies at:self put:aCollection |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2104 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2105 |
] valueUninterruptably |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2106 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2107 |
"Created: 19.4.1996 / 11:07:47 / cg" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2108 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2109 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2110 |
removeNonWeakDependent:anObject |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2111 |
"remove a nonWeak dependency from the receiver to the argument, anObject. |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2112 |
(i.e. make it independent of the receiver)" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2113 |
|
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2114 |
|wasBlocked| |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2115 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2116 |
"/ must do this save from interrupts, since the dependents collection |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2117 |
"/ is possibly accessed from multiple threads. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2118 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2119 |
"/ faster execution. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2120 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2121 |
wasBlocked := OperatingSystem blockInterrupts. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2122 |
[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2123 |
|deps n| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2124 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2125 |
deps := self nonWeakDependents. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2126 |
deps notNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2127 |
deps class == Array ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2128 |
(deps at:1) == anObject ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2129 |
self nonWeakDependents:nil |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2130 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2131 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2132 |
deps remove:anObject ifAbsent:[]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2133 |
(n := deps size) == 0 ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2134 |
self nonWeakDependents:nil |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2135 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2136 |
n == 1 ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2137 |
self nonWeakDependents:(Array with:(deps first)) |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2138 |
] |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
2139 |
] |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
2140 |
] |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
2141 |
] |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2142 |
] valueNowOrOnUnwindDo:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2143 |
wasBlocked ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2144 |
OperatingSystem unblockInterrupts |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2145 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2146 |
] |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2147 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2148 |
"Created: 19.4.1996 / 11:44:44 / cg" |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2149 |
"Modified: 19.7.1996 / 12:42:08 / cg" |
783 | 2150 |
! ! |
2151 |
||
2152 |
!Object methodsFor:'error handling'! |
|
2153 |
||
2154 |
appropriateDebugger:aSelector |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2155 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2156 |
|
783 | 2157 |
"return an appropriate debugger to use. |
2158 |
If there is already a debugger active on the stack, and it is |
|
2159 |
the DebugView, return MiniDebugger (as a last chance) otherwise abort." |
|
2160 |
||
2161 |
|context| |
|
2162 |
||
1678
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2163 |
"DebugView cannot run without system processes" |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2164 |
|
1685 | 2165 |
(Processor isNil |
1684 | 2166 |
or:[Processor activeProcessIsSystemProcess]) ifTrue:[ |
1678
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2167 |
^ MiniDebugger |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2168 |
]. |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2169 |
|
783 | 2170 |
context := thisContext. |
2171 |
context := context sender. |
|
2172 |
[context notNil] whileTrue:[ |
|
1678
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2173 |
((context receiver class == Debugger) |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2174 |
and:[context selector == aSelector]) ifTrue:[ |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2175 |
"we are already in some Debugger" |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2176 |
(Debugger == MiniDebugger) ifTrue:[ |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2177 |
"we are already in the MiniDebugger" |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2178 |
ErrorRecursion ifFalse:[ |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2179 |
Smalltalk fatalAbort:'recursive error ...' |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2180 |
] |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2181 |
]. |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2182 |
MiniDebugger isNil ifTrue:[ |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2183 |
Smalltalk fatalAbort:'no debugger' |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2184 |
]. |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2185 |
|
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2186 |
"ok, an error occured while in the graphical debugger; |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2187 |
lets try MiniDebugger" |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2188 |
^ MiniDebugger |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2189 |
]. |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2190 |
context := context sender |
71 | 2191 |
]. |
783 | 2192 |
"not within Debugger - no problem" |
2193 |
^ Debugger |
|
1678
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2194 |
|
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2195 |
"Modified: 23.9.1996 / 12:14:52 / stefan" |
783 | 2196 |
! |
2197 |
||
2229
a9881102b243
new feature: cannotSendMessage:to:
Claus Gittinger <cg@exept.de>
parents:
2227
diff
changeset
|
2198 |
cannotSendMessage:aMessage to:someReceiver |
a9881102b243
new feature: cannotSendMessage:to:
Claus Gittinger <cg@exept.de>
parents:
2227
diff
changeset
|
2199 |
"this message is sent by the runtime system (VM), |
a9881102b243
new feature: cannotSendMessage:to:
Claus Gittinger <cg@exept.de>
parents:
2227
diff
changeset
|
2200 |
when a message is sent to some object, whose class is not |
2231 | 2201 |
a valid behavior (see documentation in Behavior)." |
2229
a9881102b243
new feature: cannotSendMessage:to:
Claus Gittinger <cg@exept.de>
parents:
2227
diff
changeset
|
2202 |
|
a9881102b243
new feature: cannotSendMessage:to:
Claus Gittinger <cg@exept.de>
parents:
2227
diff
changeset
|
2203 |
^ InternalErrorSignal |
a9881102b243
new feature: cannotSendMessage:to:
Claus Gittinger <cg@exept.de>
parents:
2227
diff
changeset
|
2204 |
raiseRequestWith:someReceiver |
2231 | 2205 |
errorString:('bad class in send of #' , aMessage selector) |
2206 |
||
2207 |
"Modified: 23.1.1997 / 00:05:39 / cg" |
|
2229
a9881102b243
new feature: cannotSendMessage:to:
Claus Gittinger <cg@exept.de>
parents:
2227
diff
changeset
|
2208 |
! |
a9881102b243
new feature: cannotSendMessage:to:
Claus Gittinger <cg@exept.de>
parents:
2227
diff
changeset
|
2209 |
|
783 | 2210 |
doesNotUnderstand:aMessage |
2211 |
"this message is sent by the runtime system (VM) when |
|
2212 |
a message is not understood by some object (i.e. there |
|
2213 |
is no method for that selector). The original message has |
|
2214 |
been packed into aMessage (i.e. the receiver, selector and |
|
2215 |
any arguments) and the original receiver is then sent the |
|
2216 |
#doesNotUnderstand: message. |
|
2217 |
Here, we raise another signal which usually enters the debugger. |
|
2218 |
You can of course redefine #doesNotUnderstand: in your classes |
|
1327 | 2219 |
to implement message delegation, |
2220 |
or handle the MessageNotUnderstoodSignal gracefully." |
|
783 | 2221 |
|
2222 |
|sel errorString cls sender| |
|
2223 |
||
2224 |
"/ handle the case of an error during early startup |
|
2225 |
"/ (output streams not yet initialized) |
|
2226 |
"/ |
|
2227 |
Stdout isNil ifTrue:[ |
|
1327 | 2228 |
Smalltalk fatalAbort:'error during init: ' , aMessage selector , ' not understood'. |
783 | 2229 |
]. |
2230 |
||
2231 |
(sel := aMessage selector) isNil ifTrue:[ |
|
1327 | 2232 |
"/ |
2233 |
"/ happens when things go mad, or a method has been |
|
2234 |
"/ called by valueWithReceiver: with a wrong receiver. |
|
2235 |
"/ To avoid later trouble (when concatenating strings), |
|
2236 |
"/ replace the selector by some (nonNil) string |
|
2237 |
"/ |
|
2238 |
sel := '(nil)' |
|
783 | 2239 |
]. |
2240 |
||
2241 |
"/ |
|
2242 |
"/ extract the class that should have implemented the message. |
|
2243 |
"/ (in case of a super-send, this is not the receivers class) |
|
2244 |
"/ |
|
2245 |
sender := thisContext sender. |
|
2246 |
cls := sender searchClass. |
|
2247 |
cls isNil ifTrue:[ |
|
1327 | 2248 |
"it was NOT a super or directed send ..." |
2249 |
cls := self class |
|
783 | 2250 |
]. |
2251 |
||
2252 |
cls notNil ifTrue:[ |
|
1327 | 2253 |
"/ |
2254 |
"/ displayString is better than 'cls name', |
|
2255 |
"/ since it appends (obsolete) for outdated classes. |
|
2256 |
"/ (this happens if you send messages to old instances |
|
2257 |
"/ after changing a classes definition) |
|
2258 |
"/ |
|
2259 |
errorString := cls displayString. |
|
783 | 2260 |
] ifFalse:[ |
1327 | 2261 |
errorString := '(** nil-class **)' |
783 | 2262 |
]. |
2263 |
errorString := errorString , ' does not understand: ' , sel. |
|
2264 |
||
2265 |
"/ |
|
2266 |
"/ this only happens, when YOU play around with my classvars ... |
|
1327 | 2267 |
"/ (or an error occurs during very early startup, when signals are not yet set) |
783 | 2268 |
"/ |
2269 |
MessageNotUnderstoodSignal isNil ifTrue:[ |
|
1674 | 2270 |
^ self |
2271 |
enterDebuggerWithMessage:'oops - MessageNotUnderstoodSignal is gone' |
|
2272 |
on:thisContext. |
|
783 | 2273 |
]. |
2274 |
||
2275 |
"/ |
|
2276 |
"/ thats where we end up normally - raise a signal which (if unhandled) opens a debugger |
|
2277 |
"/ |
|
2278 |
^ MessageNotUnderstoodSignal |
|
1327 | 2279 |
raiseRequestWith:aMessage |
2280 |
errorString:errorString |
|
2281 |
in:sender |
|
2282 |
||
2283 |
"Modified: 3.5.1996 / 11:51:45 / cg" |
|
783 | 2284 |
! |
2285 |
||
2286 |
elementBoundsError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2287 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2288 |
|
1345 | 2289 |
"report an error that badElement is out of bounds |
2290 |
(i.e. cannot be put into that collection). |
|
2291 |
The error is reported by raising the ElementOutOfBoundsSignal exception." |
|
783 | 2292 |
|
2293 |
^ ElementOutOfBoundsSignal raiseIn:thisContext sender |
|
1345 | 2294 |
|
2295 |
"Modified: 8.5.1996 / 09:12:45 / cg" |
|
783 | 2296 |
! |
2297 |
||
2298 |
elementNotCharacter |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2299 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2300 |
|
1345 | 2301 |
"report an error that object to be stored is no Character. |
2302 |
(usually when storing into Strings). |
|
2303 |
The error is reported by raising the ElementOutOfBoundsSignal exception." |
|
783 | 2304 |
|
2305 |
^ ElementOutOfBoundsSignal raiseIn:thisContext sender |
|
1345 | 2306 |
|
2307 |
"Modified: 8.5.1996 / 09:12:49 / cg" |
|
783 | 2308 |
! |
2309 |
||
2310 |
elementNotInteger |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2311 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2312 |
|
1345 | 2313 |
"report an error that object to be stored is not Integer. |
2314 |
(in collections that store integers only). |
|
2315 |
The error is reported by raising the ElementOutOfBoundsSignal exception." |
|
783 | 2316 |
|
2317 |
^ ElementOutOfBoundsSignal raiseIn:thisContext sender |
|
1345 | 2318 |
|
2319 |
"Modified: 8.5.1996 / 09:12:51 / cg" |
|
783 | 2320 |
! |
2321 |
||
2322 |
enterDebuggerWith:anException message:aString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2323 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2324 |
|
783 | 2325 |
"enter the debugger with error-message aString" |
2326 |
||
1674 | 2327 |
^ self |
2328 |
enterDebuggerWithMessage:aString |
|
2329 |
on:anException suspendedContext |
|
2330 |
! |
|
2331 |
||
2332 |
enterDebuggerWithMessage:aString on:aContext |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2333 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2334 |
|
783 | 2335 |
"enter the debugger with error-message aString. |
2336 |
The first visible context shown there is aContext |
|
2337 |
(this allows intermediate helpers to hide themselfes from what is |
|
2338 |
presented to the user)" |
|
2339 |
||
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2340 |
|debugger msg| |
71 | 2341 |
|
2342 |
" |
|
783 | 2343 |
if there is no debugger, exit smalltalk |
2344 |
" |
|
2345 |
Debugger isNil ifTrue:[ |
|
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2346 |
msg := 'error: ' , aString. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2347 |
|
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2348 |
Smalltalk isStandAloneApp ifTrue:[ |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2349 |
Dialog notNil ifTrue:[ |
1097 | 2350 |
(Dialog |
2136 | 2351 |
confirm:msg title:(Smalltalk commandName) |
2352 |
yesLabel:'ignore' noLabel:'exit' |
|
2353 |
) ifTrue:[ |
|
1095 | 2354 |
^ AbortSignal raise |
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2355 |
] |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2356 |
]. |
2136 | 2357 |
msg errorPrintCR. |
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2358 |
OperatingSystem exit:1 |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2359 |
]. |
2136 | 2360 |
msg errorPrintCR. |
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2361 |
Smalltalk fatalAbort:'no Debugger defined' |
783 | 2362 |
]. |
983 | 2363 |
|
783 | 2364 |
" |
2365 |
find an appropriate debugger to use |
|
71 | 2366 |
" |
783 | 2367 |
debugger := self appropriateDebugger:#'enter:withMessage:'. |
2368 |
^ debugger enter:aContext withMessage:aString. |
|
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2369 |
|
2136 | 2370 |
"Modified: 10.1.1997 / 19:11:52 / cg" |
783 | 2371 |
! |
2372 |
||
2373 |
error |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2374 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2375 |
|
1345 | 2376 |
"report error that an error occured. |
2377 |
The error is reported by raising the ErrorSignal exception." |
|
2378 |
||
2379 |
^ ErrorSignal raiseIn:thisContext sender |
|
2380 |
||
2381 |
"Modified: 8.5.1996 / 09:13:01 / cg" |
|
783 | 2382 |
! |
2383 |
||
2384 |
error:aString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2385 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2386 |
|
1345 | 2387 |
"enter debugger with error-message aString. |
2388 |
The error is reported by raising the ErrorSignal exception." |
|
783 | 2389 |
|
2390 |
^ ErrorSignal raiseRequestWith:#error: |
|
1345 | 2391 |
errorString:aString |
2392 |
in:thisContext sender |
|
2393 |
||
2394 |
"Modified: 8.5.1996 / 09:13:04 / cg" |
|
2395 |
! |
|
2396 |
||
2397 |
error:aString in:aContext |
|
2398 |
"{ Pragma: +optSpace }" |
|
2399 |
||
2400 |
"enter debugger with error-message aString. |
|
2401 |
The error is reported by raising the ErrorSignal exception." |
|
2402 |
||
2403 |
^ ErrorSignal raiseRequestWith:#error: |
|
2404 |
errorString:aString |
|
2405 |
in:aContext |
|
2406 |
||
2407 |
"Created: 8.5.1996 / 09:07:59 / cg" |
|
2408 |
"Modified: 8.5.1996 / 09:13:06 / cg" |
|
783 | 2409 |
! |
2410 |
||
2411 |
errorKeyNotFound:aKey |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2412 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2413 |
|
1345 | 2414 |
"report an error that a key was not found in a collection. |
2415 |
The error is reported by raising the KeyNotFoundSignal exception." |
|
783 | 2416 |
|
2417 |
^ KeyNotFoundSignal raiseRequestWith:aKey in:thisContext sender |
|
1345 | 2418 |
|
2419 |
"Modified: 8.5.1996 / 09:13:08 / cg" |
|
783 | 2420 |
! |
2421 |
||
2422 |
errorNotFound |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2423 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2424 |
|
1345 | 2425 |
"report an error that no element was found in a collection. |
2426 |
The error is reported by raising the NotFoundSignal exception." |
|
783 | 2427 |
|
2428 |
^ NotFoundSignal raiseIn:thisContext sender |
|
1345 | 2429 |
|
2430 |
"Modified: 8.5.1996 / 09:13:11 / cg" |
|
783 | 2431 |
! |
2432 |
||
2433 |
halt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2434 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2435 |
|
1345 | 2436 |
"enter debugger with halt-message. |
2437 |
The error is reported by raising the HaltSignal exception." |
|
783 | 2438 |
|
2439 |
^ HaltSignal raiseIn:thisContext sender. |
|
1345 | 2440 |
|
2441 |
"Modified: 8.5.1996 / 09:12:38 / cg" |
|
783 | 2442 |
! |
2443 |
||
2444 |
halt:aString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2445 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2446 |
|
1345 | 2447 |
"enter debugger with halt-message. |
2448 |
The error is reported by raising the HaltSignal exception." |
|
783 | 2449 |
|
2450 |
^ HaltSignal raiseRequestWith:#halt: |
|
1345 | 2451 |
errorString:aString |
2452 |
in:thisContext sender |
|
2453 |
||
2454 |
"Modified: 8.5.1996 / 09:13:23 / cg" |
|
783 | 2455 |
! |
2456 |
||
2457 |
implementedBySubclass |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2458 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2459 |
|
783 | 2460 |
"this is sent by ST/V code - its the same as #subclassResponsibility" |
2461 |
||
2462 |
^ self subclassResponsibility |
|
2463 |
! |
|
2464 |
||
2465 |
indexNotInteger |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2466 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2467 |
|
1345 | 2468 |
"report an error that index is not an Integer. |
2469 |
(when accessing collections indexed by an integer key). |
|
2470 |
The error is reported by raising the NonIntegerIndexSignal exception." |
|
783 | 2471 |
|
2472 |
^ NonIntegerIndexSignal raiseIn:thisContext sender |
|
1345 | 2473 |
|
2474 |
"Modified: 8.5.1996 / 09:13:37 / cg" |
|
783 | 2475 |
! |
2476 |
||
2477 |
integerCheckError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2478 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2479 |
|
783 | 2480 |
"generated when a variable declared with an integer type gets a bad |
2481 |
value assigned" |
|
2482 |
||
2483 |
^ self error:'bad assign of ' , self printString , |
|
2484 |
' (' , self class name , ') to integer-typed variable' |
|
71 | 2485 |
! |
2486 |
||
783 | 2487 |
invalidMessage |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2488 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2489 |
|
783 | 2490 |
"this is sent by ST/V code - its the same as #shouldNotImplement" |
2491 |
||
2492 |
^ self shouldNotImplement |
|
2493 |
! |
|
2494 |
||
2495 |
mustBeRectangle |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2496 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2497 |
|
783 | 2498 |
"report an argument-not-rectangle-error" |
2499 |
||
2500 |
^ self error:'argument must be a Rectangle' |
|
2501 |
! |
|
2502 |
||
2503 |
mustBeString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2504 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2505 |
|
783 | 2506 |
"report an argument-not-string-error" |
2507 |
||
2508 |
^ self error:'argument must be a String' |
|
2509 |
! |
|
2510 |
||
2511 |
notIndexed |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2512 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2513 |
|
1611
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2514 |
"report an error that receiver has no indexed instance variables. |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2515 |
The error is reported by raising the SubscriptOutOfBoundsSignal exception." |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2516 |
|
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2517 |
^ SubscriptOutOfBoundsSignal |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2518 |
raiseErrorString:'receiver has no indexed variables' |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2519 |
in:thisContext sender |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2520 |
|
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2521 |
"Modified: 26.7.1996 / 16:43:13 / cg" |
783 | 2522 |
! |
2523 |
||
2524 |
primitiveFailed |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2525 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2526 |
|
1345 | 2527 |
"report an error that some primitive code failed. |
2528 |
The error is reported by raising the PrimitiveFailureSignal exception." |
|
783 | 2529 |
|
2530 |
^ PrimitiveFailureSignal raiseIn:(thisContext sender) |
|
1345 | 2531 |
|
2532 |
"Modified: 8.5.1996 / 09:14:07 / cg" |
|
783 | 2533 |
! |
2534 |
||
2535 |
shouldNotImplement |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2536 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2537 |
|
1345 | 2538 |
"report an error that this message should not be implemented" |
783 | 2539 |
|
2540 |
^ self error:'method not appropriate for this class' |
|
1345 | 2541 |
|
2542 |
"Modified: 8.5.1996 / 09:09:44 / cg" |
|
783 | 2543 |
! |
2544 |
||
2545 |
subclassResponsibility |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2546 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2547 |
|
1345 | 2548 |
"report an error that this message should have been reimplemented in a |
783 | 2549 |
subclass" |
2550 |
||
1345 | 2551 |
^ self error:'method must be reimplemented in subclass' in:thisContext sender |
2552 |
||
2553 |
"Modified: 8.5.1996 / 09:09:26 / cg" |
|
783 | 2554 |
! |
2555 |
||
2556 |
subscriptBoundsError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2557 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2558 |
|
1345 | 2559 |
"report an error that some index is out of bounds. |
2560 |
(when accessing indexable collections). |
|
2561 |
The error is reported by raising the SubscriptOutOfBoundsSignal exception." |
|
783 | 2562 |
|
1611
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2563 |
^ SubscriptOutOfBoundsSignal |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2564 |
raiseIn:thisContext sender |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2565 |
|
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2566 |
"Modified: 26.7.1996 / 16:45:42 / cg" |
783 | 2567 |
! |
2568 |
||
2569 |
subscriptBoundsError:anIndex |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2570 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2571 |
|
1345 | 2572 |
"report an error that anIndex is out of bounds. |
2573 |
(when accessing indexable collections). |
|
2574 |
The error is reported by raising the SubscriptOutOfBoundsSignal exception." |
|
783 | 2575 |
|
1021
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2576 |
^ SubscriptOutOfBoundsSignal |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2577 |
raiseRequestWith:anIndex |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2578 |
errorString:('subscript (' , anIndex printString , ') out of bounds') |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2579 |
in:thisContext sender |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2580 |
|
1345 | 2581 |
"Modified: 8.5.1996 / 09:14:34 / cg" |
783 | 2582 |
! |
2583 |
||
2584 |
typeCheckError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2585 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2586 |
|
783 | 2587 |
"generated when a variable declared with a type hint gets a bad |
2588 |
value assigned" |
|
2589 |
||
2590 |
^ self error:'bad assign of ' , self printString , |
|
2591 |
' (' , self class name , ') to typed variable' |
|
2592 |
! ! |
|
2593 |
||
2594 |
!Object methodsFor:'evaluation'! |
|
2595 |
||
2596 |
value |
|
1327 | 2597 |
"return the receiver itself. |
2598 |
This allows every object to be used where blocks or valueHolders |
|
2599 |
are typically used, and allows for valueHolders and blocks to be |
|
2600 |
used interchangably in some situations. |
|
2601 |
||
783 | 2602 |
Time will show, if this is a good idea or leads to sloppy programming |
2603 |
style ... (the idea was borrowed from the Self language). |
|
1327 | 2604 |
|
2605 |
WARNING: dont 'optimize' away ifXXX: blocks |
|
2606 |
(i.e. do NOT replace |
|
2607 |
foo ifTrue:[var1] ifFalse:[var2] |
|
2608 |
by: |
|
2609 |
foo ifTrue:var1 ifFalse:var2 |
|
2610 |
) |
|
2611 |
- the compilers will only generate inline code for the if, |
|
2612 |
iff the argument(s) are blocks - otherwise, a true send is |
|
2613 |
generated. |
|
2614 |
This 'oprimization' will work semantically correct, |
|
2615 |
but execute SLOWER instead." |
|
783 | 2616 |
|
2617 |
^ self |
|
71 | 2618 |
|
2619 |
" |
|
1327 | 2620 |
#(1 2 3 4) indexOf:5 ifAbsent:0 |
2621 |
#(1 2 3 4) indexOf:5 ifAbsent:[0] |
|
2622 |
1 > 2 ifTrue:['yes'] ifFalse:['no'] |
|
2623 |
1 > 2 ifTrue:'yes' ifFalse:'no' |
|
783 | 2624 |
" |
2625 |
||
2626 |
"DO NOT DO THIS (its slower) |
|
2627 |
(1 > 4) ifTrue:'oops' ifFalse:'ok' |
|
2628 |
||
2629 |
USE (the compiler optimizes blocks in if/while): |
|
2630 |
(1 > 4) ifTrue:['oops'] ifFalse:['ok'] |
|
2631 |
" |
|
1327 | 2632 |
|
2633 |
"Modified: 3.5.1996 / 11:57:08 / cg" |
|
783 | 2634 |
! ! |
2635 |
||
2636 |
!Object methodsFor:'initialization'! |
|
2637 |
||
2638 |
initialize |
|
2639 |
"just to ignore initialize to objects which do not need it" |
|
2640 |
||
2641 |
^ self |
|
2642 |
! ! |
|
2643 |
||
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2644 |
!Object methodsFor:'interest'! |
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2645 |
|
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2646 |
addInterest:anInterest |
1762
e7267ff590ff
Fix misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1751
diff
changeset
|
2647 |
"install an interest forwarder. |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2648 |
Here, we use the nonWeakDependencies." |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2649 |
|
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2650 |
self addNonWeakDependent:anInterest |
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2651 |
|
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2652 |
"Created: 14.10.1996 / 22:27:34 / stefan" |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2653 |
! |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2654 |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2655 |
expressInterestIn:aspect for:anObject sendBack:aSelector |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2656 |
"arrange for aSelector to be sent to anObject whenever the receiver |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2657 |
changes aspect." |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2658 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2659 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2660 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2661 |
|
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2662 |
self addInterest:(InterestConverter |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2663 |
destination:anObject |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2664 |
selector:aSelector |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2665 |
aspect:aspect) |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2666 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2667 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2668 |
|p b| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2669 |
|
1422 | 2670 |
b := [Transcript showCR:' -> the point changed']. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2671 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2672 |
p := Point new. |
1422 | 2673 |
Transcript showCR:'interest in #foo:'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2674 |
p expressInterestIn:#foo for:b sendBack:#value. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2675 |
p x:1. |
1422 | 2676 |
Transcript showCR:'now changing #bar ... (expect no notification)'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2677 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2678 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2679 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2680 |
Delay waitForSeconds:1. |
1422 | 2681 |
Transcript showCR:'now changing #foo ... (expect notification)'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2682 |
p changed:#foo. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2683 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2684 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2685 |
Delay waitForSeconds:1. |
1422 | 2686 |
Transcript showCR:'no more interest in #foo:'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2687 |
p retractInterestIn:#foo for:b. |
1422 | 2688 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2689 |
p changed:#foo. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2690 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2691 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2692 |
Delay waitForSeconds:1. |
1422 | 2693 |
Transcript showCR:'interest in #bar now:'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2694 |
p expressInterestIn:#bar for:b sendBack:#value. |
1422 | 2695 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2696 |
p changed:#foo. |
1422 | 2697 |
Transcript showCR:'now changing #bar ... (expect notification)'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2698 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2699 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2700 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2701 |
Delay waitForSeconds:1. |
1422 | 2702 |
Transcript showCR:'interest in #foo now:'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2703 |
p expressInterestIn:#foo for:b sendBack:#value. |
1422 | 2704 |
Transcript showCR:'now changing #foo ... (expect notification)'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2705 |
p changed:#foo. |
1422 | 2706 |
Transcript showCR:'now changing #bar ... (expect notification)'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2707 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2708 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2709 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2710 |
Delay waitForSeconds:1. |
1422 | 2711 |
Transcript showCR:'no more interests:'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2712 |
p retractInterestsFor:b. |
1422 | 2713 |
Transcript showCR:'now changing #foo ... (expect no notification)'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2714 |
p changed:#foo. |
1422 | 2715 |
Transcript showCR:'now changing #bar... (expect no notification)'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2716 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2717 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2718 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2719 |
p release. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2720 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2721 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2722 |
"Created: 19.4.1996 / 10:26:22 / cg" |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2723 |
"Modified: 19.4.1996 / 12:34:08 / cg" |
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2724 |
"Modified: 14.10.1996 / 22:28:20 / stefan" |
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2725 |
! |
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2726 |
|
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2727 |
interests |
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2728 |
"return a Collection of interests - nil if there is none. |
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2729 |
Here, we use the nonWeakDependents for interests." |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2730 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2731 |
^ self nonWeakDependents |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2732 |
|
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2733 |
"Created: 14.10.1996 / 22:20:51 / stefan" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2734 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2735 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2736 |
onChangeSend:aSelector to:anObject |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2737 |
"arrange for aSelector to be sent to anObject whenever the receiver |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2738 |
changes." |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2739 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2740 |
"/ for now, use an interestConverter, which is somewhat less efficient. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2741 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2742 |
|
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2743 |
self addInterest:(InterestConverter |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2744 |
destination:anObject |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2745 |
selector:aSelector) |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2746 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2747 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2748 |
|p b| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2749 |
|
1422 | 2750 |
b := [Transcript showCR:'the point changed']. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2751 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2752 |
p := Point new. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2753 |
p onChangeSend:#value to:b. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2754 |
p x:1. |
1422 | 2755 |
Transcript showCR:'now changing'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2756 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2757 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2758 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2759 |
Delay waitForSeconds:1. |
1422 | 2760 |
Transcript showCR:'now changing'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2761 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2762 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2763 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2764 |
Delay waitForSeconds:1. |
1422 | 2765 |
Transcript showCR:'no more interest'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2766 |
p retractInterestsFor:b. |
1422 | 2767 |
Transcript showCR:'now changing again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2768 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2769 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2770 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2771 |
Delay waitForSeconds:1. |
1422 | 2772 |
Transcript showCR:'interest again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2773 |
p onChangeSend:#value to:b. |
1422 | 2774 |
Transcript showCR:'now changing again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2775 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2776 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2777 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2778 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2779 |
"Created: 19.4.1996 / 10:26:38 / cg" |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2780 |
"Modified: 19.4.1996 / 12:34:26 / cg" |
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2781 |
"Modified: 14.10.1996 / 22:28:27 / stefan" |
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2782 |
! |
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2783 |
|
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2784 |
removeInterest:anInterest |
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2785 |
"remove an interest forwarder. |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2786 |
Here, we use the nonWeakDependencies." |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2787 |
|
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2788 |
self removeNonWeakDependent:anInterest |
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2789 |
|
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2790 |
"Created: 14.10.1996 / 22:21:59 / stefan" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2791 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2792 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2793 |
retractInterestIn:aspect for:someOne |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2794 |
"remove the interest of someOne in the receiver changing aspect |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2795 |
(as installed with #expressInterestIn:for:sendBack:)." |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2796 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2797 |
"/ for now, remove the interestConverter. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2798 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2799 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2800 |
|deps| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2801 |
|
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2802 |
deps := self interests. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2803 |
deps notNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2804 |
deps do:[:dep | |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2805 |
(dep isMemberOf:InterestConverter) ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2806 |
dep destination == someOne ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2807 |
dep aspect == aspect ifTrue:[ |
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2808 |
self removeInterest:dep. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2809 |
^ self |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2810 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2811 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2812 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2813 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2814 |
]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2815 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2816 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2817 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2818 |
|p b| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2819 |
|
1422 | 2820 |
b := [Transcript showCR:'the point changed']. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2821 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2822 |
p := Point new. |
1422 | 2823 |
Transcript showCR:'interest in #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2824 |
p expressInterestIn:#foo for:b sendBack:#value. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2825 |
p x:1. |
1422 | 2826 |
Transcript showCR:'now changing #bar'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2827 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2828 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2829 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2830 |
Delay waitForSeconds:1. |
1422 | 2831 |
Transcript showCR:'now changing #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2832 |
p changed:#foo. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2833 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2834 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2835 |
Delay waitForSeconds:1. |
1422 | 2836 |
Transcript showCR:'no more interest in #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2837 |
p retractInterestIn:#foo for:b. |
1422 | 2838 |
Transcript showCR:'now changing #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2839 |
p changed:#foo. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2840 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2841 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2842 |
Delay waitForSeconds:1. |
1422 | 2843 |
Transcript showCR:'interest in #bar now'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2844 |
p expressInterestIn:#bar for:b sendBack:#value. |
1422 | 2845 |
Transcript showCR:'now changing #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2846 |
p changed:#foo. |
1422 | 2847 |
Transcript showCR:'now changing #bar'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2848 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2849 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2850 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2851 |
Delay waitForSeconds:1. |
1422 | 2852 |
Transcript showCR:'interest in #foo now'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2853 |
p expressInterestIn:#foo for:b sendBack:#value. |
1422 | 2854 |
Transcript showCR:'now changing #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2855 |
p changed:#foo. |
1422 | 2856 |
Transcript showCR:'now changing #bar'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2857 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2858 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2859 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2860 |
Delay waitForSeconds:1. |
1422 | 2861 |
Transcript showCR:'no more interests'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2862 |
p retractInterestsFor:b. |
1422 | 2863 |
Transcript showCR:'now changing #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2864 |
p changed:#foo. |
1422 | 2865 |
Transcript showCR:'now changing #bar'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2866 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2867 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2868 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2869 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2870 |
"Created: 19.4.1996 / 10:27:11 / cg" |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2871 |
"Modified: 19.4.1996 / 12:29:52 / cg" |
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2872 |
"Modified: 14.10.1996 / 22:21:19 / stefan" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2873 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2874 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2875 |
retractInterestsFor:someOne |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2876 |
"remove the interest of someOne in the receiver |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2877 |
(as installed with #onChangeSend:to:)." |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2878 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2879 |
"/ for now, remove the interestConverter. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2880 |
"/ In the future, a more intelligent DependencyCollection class is planned for |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2881 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2882 |
|coll deps| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2883 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2884 |
"/ cannot removeDependent within the loop - the collection rehashes |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2885 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2886 |
coll := IdentitySet new. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2887 |
|
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2888 |
deps := self interests. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2889 |
deps notNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2890 |
deps do:[:dep | |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2891 |
(dep isMemberOf:InterestConverter) ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2892 |
dep destination == someOne ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2893 |
coll add:dep. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2894 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2895 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2896 |
]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2897 |
]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2898 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2899 |
coll do:[:dep | |
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2900 |
self removeInterest:dep. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2901 |
]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2902 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2903 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2904 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2905 |
|p b| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2906 |
|
1422 | 2907 |
b := [Transcript showCR:'the point changed']. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2908 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2909 |
p := Point new. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2910 |
p onChangeSend:#value to:b. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2911 |
p x:1. |
1422 | 2912 |
Transcript showCR:'now changing'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2913 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2914 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2915 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2916 |
Delay waitForSeconds:1. |
1422 | 2917 |
Transcript showCR:'now changing'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2918 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2919 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2920 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2921 |
Delay waitForSeconds:1. |
1422 | 2922 |
Transcript showCR:'no more interest'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2923 |
p retractInterestsFor:b. |
1422 | 2924 |
Transcript showCR:'now changing again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2925 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2926 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2927 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2928 |
Delay waitForSeconds:1. |
1422 | 2929 |
Transcript showCR:'interest again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2930 |
p onChangeSend:#value to:b. |
1422 | 2931 |
Transcript showCR:'now changing again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2932 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2933 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2934 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2935 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2936 |
"Created: 19.4.1996 / 10:23:46 / cg" |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2937 |
"Modified: 19.4.1996 / 12:30:03 / cg" |
1751
0902cadafee2
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1705
diff
changeset
|
2938 |
"Modified: 14.10.1996 / 22:21:25 / stefan" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2939 |
! ! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2940 |
|
783 | 2941 |
!Object methodsFor:'interrupt handling'! |
2942 |
||
2943 |
childSignalInterrupt |
|
2944 |
"death of a child process (unix process) - do nothing" |
|
2945 |
||
2946 |
^ self |
|
2947 |
! |
|
2948 |
||
2949 |
customInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2950 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2951 |
|
783 | 2952 |
"a custom interrupt" |
2953 |
||
2954 |
^ self error:'custom interrupt' |
|
2955 |
! |
|
2956 |
||
2957 |
errorInterrupt:errorID with:aParameter |
|
2958 |
"subsystem error. The arguments errorID and aParameter are the values passed |
|
2959 |
to the 'errorInterruptWithIDAndParameter(id, param)' function, |
|
2960 |
which can be called from C subsystems to raise an (asynchronous) |
|
2961 |
error exception. |
|
2962 |
||
2963 |
Currently, this is used to map XErrors to smalltalk errors, but can be |
|
2964 |
used from other C subsystems too, to upcast errors. |
|
2965 |
Especially, for subsystems which call errorHandler functions asynchronously. |
|
2966 |
IDs (currently) used: |
|
2967 |
#DisplayError ..... x-error interrupt |
|
2968 |
#XtError ..... xt-error interrupt (Xt interface is not yet published) |
|
71 | 2969 |
" |
783 | 2970 |
|
2971 |
|handler| |
|
2972 |
||
2973 |
handler := ObjectMemory registeredErrorInterruptHandlers at:errorID ifAbsent:nil. |
|
2974 |
handler notNil ifTrue:[ |
|
2975 |
"/ |
|
2976 |
"/ handler found; let it do whatever it wants ... |
|
2977 |
"/ |
|
2978 |
handler errorInterrupt:errorID with:aParameter. |
|
2979 |
^ self |
|
2980 |
]. |
|
2981 |
||
2982 |
"/ |
|
2983 |
"/ no handler - raise errorSignal passing the errorId as parameter |
|
2984 |
"/ |
|
2985 |
^ ErrorSignal |
|
2986 |
raiseRequestWith:errorID |
|
2987 |
errorString:('Subsystem error. ErrorID = ' , errorID printString) |
|
2988 |
! |
|
2989 |
||
2990 |
exceptionInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2991 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2992 |
|
783 | 2993 |
"exception interrupt - enter debugger" |
2994 |
||
2995 |
self error:'exception Interrupt' |
|
2996 |
! |
|
2997 |
||
2998 |
fpExceptionInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2999 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3000 |
|
783 | 3001 |
"a floating point exception occured - this one |
3002 |
has to be handled differently since it comes asynchronous |
|
3003 |
on some machines (for example, on machines with a separate FPU |
|
3004 |
or superscalar architectures. Also, errors from within primitive code |
|
3005 |
(or library functions such as GL) are sent via the Unix-signal |
|
3006 |
mechanism this way." |
|
3007 |
||
3008 |
^ Float domainErrorSignal raise |
|
3009 |
! |
|
3010 |
||
3011 |
internalError:msg |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3012 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3013 |
|
2227
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
3014 |
"this is triggered, when VM hits some bad error, |
783 | 3015 |
such as corrupted class, corrupted method/selector array |
3016 |
etc. The argument string gives some more information on what happened. |
|
2227
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
3017 |
(for example, if you set an objects class to a non-behavior, nil etc.). |
783 | 3018 |
Its not guaranteed, that the system is in a working condition once |
3019 |
this error occurred ...." |
|
3020 |
||
2227
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
3021 |
^ InternalErrorSignal |
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
3022 |
raiseRequestWith:self |
eb1e28c62f14
use an extra signal for internal errors
Claus Gittinger <cg@exept.de>
parents:
2209
diff
changeset
|
3023 |
errorString:msg |
783 | 3024 |
! |
3025 |
||
3026 |
ioInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3027 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3028 |
|
783 | 3029 |
"I/O (SIGIO/SIGPOLL) interrupt (supposed to be sent to Processor). |
3030 |
If we arrive here, there is either no handler (ObjMem>>ioInterruptHandler) |
|
3031 |
or it does not understand the ioInterrupt message. |
|
3032 |
In any case, this is a sign of some big trouble. Enter debugger." |
|
3033 |
||
3034 |
self error:'I/O Interrupt - but no handler' |
|
3035 |
! |
|
3036 |
||
3037 |
memoryInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3038 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3039 |
|
783 | 3040 |
"out-of-memory interrupt and no handler - enter debugger" |
3041 |
||
3042 |
^ self error:'almost out of memory' |
|
3043 |
! |
|
3044 |
||
3045 |
recursionInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3046 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3047 |
|
783 | 3048 |
"recursion limit (actually: stack overflow) interrupt. |
3049 |
This interrupt is triggered, when a process stack grows above |
|
3050 |
its stackLimit - usually, this leads into the debugger, but |
|
3051 |
could be cought and the stackLimit increased in the handler. |
|
3052 |
At the time we arrive here, the system has still some stack |
|
3053 |
as a reserve so we can continue to do some useful work or cleanup or |
|
3054 |
debugging for a while. |
|
3055 |
If the signal is ignored, and the stack continues to grow, there |
|
3056 |
will be a few more chances (and more interrupts) before the VM |
|
3057 |
hard-terminates the process." |
|
3058 |
||
3059 |
thisContext isRecursive ifFalse:[ |
|
3060 |
^ RecursionInterruptSignal raise |
|
3061 |
] |
|
3062 |
! |
|
3063 |
||
3064 |
schedulerInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3065 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3066 |
|
783 | 3067 |
"scheduler interrupt (supposed to be sent to Processor). |
3068 |
If we arrive here, either the Processor does not understand it, |
|
3069 |
or it has been set to nil. In any case, this is a sign of some |
|
3070 |
big trouble. Enter debugger." |
|
3071 |
||
3072 |
self error:'schedulerInterrupt - but no Processor' |
|
3073 |
! |
|
3074 |
||
3075 |
signalInterrupt:signalNumber |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3076 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3077 |
|
783 | 3078 |
"unix signal occured - some signals are handled as Smalltalk Exceptions |
3079 |
(SIGPIPE), others (SIGBUS) are rather fatal ... |
|
3080 |
In any case, if a smalltalk-signal has been connected to the OS signal, |
|
3081 |
that one is raised. |
|
3082 |
TODO: add another argument, giving more detailed signal info (PC, VADDR, |
|
3083 |
exact cause etc.). This helps if segvs occur in primitive code. |
|
3084 |
Currently (temporary kludge), these are passed as global variables." |
|
3085 |
||
3086 |
|box name here sig ignorable titles actions badContext msg pc addr| |
|
3087 |
||
3088 |
" |
|
3089 |
special case - since SIGPIPE has an ST-signal associated |
|
3090 |
" |
|
3091 |
(signalNumber == 13) ifTrue:[ |
|
2043 | 3092 |
"SIGPIPE - write on a pipe with no one to read" |
3093 |
||
3094 |
^ PipeStream brokenPipeSignal raise. |
|
783 | 3095 |
]. |
3096 |
||
3097 |
"if there has been an ST-signal installed, use it ..." |
|
3098 |
||
3099 |
sig := OperatingSystem operatingSystemSignal:signalNumber. |
|
3100 |
sig notNil ifTrue:[ |
|
2043 | 3101 |
^ sig raise |
783 | 3102 |
]. |
3103 |
||
3104 |
" |
|
3105 |
... otherwise , bring up a box asking for what to do ... |
|
3106 |
" |
|
3107 |
name := OperatingSystem nameForSignal:signalNumber. |
|
3108 |
here := thisContext. |
|
3109 |
||
3110 |
" |
|
3111 |
the context, in which the signal occurred: |
|
3112 |
" |
|
3113 |
badContext := here sender. |
|
3114 |
||
3115 |
" |
|
3116 |
ungrab - in case it happened in a box/popupview |
|
3117 |
otherwise display stays locked |
|
3118 |
" |
|
3119 |
Display notNil ifTrue:[ |
|
2043 | 3120 |
Display ungrabPointer. |
783 | 3121 |
]. |
3122 |
||
3123 |
" |
|
3124 |
SIGBUS, SIGSEGV and SIGILL do not make sense to ignore (i.e. continue) |
|
3125 |
since the system will retry the faulty instruction, which leads to |
|
3126 |
another signal - to avoid frustration, better not offer this option. |
|
3127 |
" |
|
3128 |
ignorable := (signalNumber ~~ OperatingSystem sigBUS) |
|
2043 | 3129 |
and:[signalNumber ~~ OperatingSystem sigILL |
3130 |
and:[signalNumber ~~ OperatingSystem sigSEGV]]. |
|
783 | 3131 |
|
3132 |
ignorable ifFalse:[ |
|
2043 | 3133 |
here isRecursive ifTrue:[ |
2132
05d2be2d280e
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2114
diff
changeset
|
3134 |
'Object [hard error]: signal ' errorPrint. signalNumber errorPrintCR. |
2043 | 3135 |
MiniDebugger enterWithMessage:'recursive signal'. |
3136 |
^ self |
|
3137 |
]. |
|
3138 |
" |
|
3139 |
a hard signal - go into debugger immediately |
|
3140 |
" |
|
3141 |
msg := 'OS-signal: ', name. |
|
3142 |
InterruptPcLow notNil ifTrue:[ |
|
3143 |
pc := InterruptPcLow + (InterruptPcHi bitShift:16). |
|
3144 |
pc ~~ 0 ifTrue:[ |
|
3145 |
msg := msg , ' PC=' , (pc printStringRadix:16) |
|
3146 |
]. |
|
3147 |
]. |
|
3148 |
InterruptAddrLow notNil ifTrue:[ |
|
3149 |
addr := InterruptAddrLow + (InterruptAddrHi bitShift:16). |
|
3150 |
addr ~~ 0 ifTrue:[ |
|
3151 |
msg := msg , ' ADDR=' , (addr printStringRadix:16) |
|
3152 |
]. |
|
3153 |
]. |
|
3154 |
Debugger enter:here withMessage:msg. |
|
3155 |
badContext return. |
|
3156 |
^ nil. |
|
783 | 3157 |
]. |
3158 |
||
3159 |
OptionBox isNil ifTrue:[ |
|
2043 | 3160 |
" |
3161 |
a system without GUI ... |
|
3162 |
go into minidebugger (if there is one) |
|
3163 |
" |
|
3164 |
MiniDebugger isNil ifTrue:[ |
|
3165 |
" |
|
3166 |
a system without debugging facilities |
|
3167 |
(i.e. a standalone system) |
|
3168 |
output a message and exit. |
|
3169 |
" |
|
2136 | 3170 |
('Object [error]: exit due to Signal ' , name , ' - and no debugger.') errorPrintCR. |
2043 | 3171 |
Smalltalk exit. |
3172 |
]. |
|
3173 |
MiniDebugger enterWithMessage:'Signal cought (' , name, ')'. |
|
3174 |
^ self |
|
783 | 3175 |
]. |
3176 |
||
3177 |
box := OptionBox |
|
2043 | 3178 |
title:'Signal cought (' , name, ')' |
3179 |
numberOfOptions:(ignorable ifTrue:[5] ifFalse:[4]). |
|
783 | 3180 |
|
3181 |
titles := #('return' 'debug' 'dump' 'exit'). |
|
3182 |
actions := Array |
|
2043 | 3183 |
with:[badContext return] |
3184 |
with:[Debugger enter:here withMessage:('Signal ', name). ^nil] |
|
3185 |
with:[Smalltalk fatalAbort] |
|
3186 |
with:[Smalltalk exit]. |
|
783 | 3187 |
|
3188 |
ignorable ifTrue:[ |
|
2043 | 3189 |
titles := #('ignore') , titles. |
3190 |
actions := (Array with:[^ nil]) , actions. |
|
783 | 3191 |
]. |
3192 |
box buttonTitles:titles. |
|
3193 |
box actions:actions. |
|
3194 |
box showAtPointer |
|
2043 | 3195 |
|
2136 | 3196 |
"Modified: 10.1.1997 / 19:09:39 / cg" |
783 | 3197 |
! |
3198 |
||
3199 |
spyInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3200 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3201 |
|
783 | 3202 |
"spy interrupt and no handler - enter debugger" |
3203 |
||
3204 |
self error:'spy Interrupt - but no handler' |
|
3205 |
! |
|
3206 |
||
3207 |
timerInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3208 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3209 |
|
783 | 3210 |
"timer interrupt and no handler - enter debugger" |
3211 |
||
3212 |
self error:'timer Interrupt - but no handler' |
|
3213 |
! |
|
3214 |
||
3215 |
userInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3216 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3217 |
|
1792 | 3218 |
"user (^c) interrupt. |
3219 |
This is typically sent by the VM, when a ctrl-C is typed at the |
|
3220 |
controlling tty (i.e. in the xterm)." |
|
783 | 3221 |
|
3222 |
UserInterruptSignal raise |
|
1788 | 3223 |
! |
3224 |
||
3225 |
userInterruptIn:aContext |
|
3226 |
"{ Pragma: +optSpace }" |
|
3227 |
||
3228 |
"user (^c) interrupt - enter debugger, but show aContext |
|
1792 | 3229 |
as top-context. |
3230 |
This is used to hide any intermediate scheduler contexts, |
|
3231 |
in case of an interrupted process. Typically, this is sent by |
|
3232 |
the WindowGroup, when a keyboardEvent for the ctrl-C key is |
|
3233 |
processed." |
|
1788 | 3234 |
|
3235 |
UserInterruptSignal raiseIn:aContext |
|
3236 |
||
3237 |
"Created: 18.10.1996 / 20:46:04 / cg" |
|
3238 |
"Modified: 20.10.1996 / 13:06:38 / cg" |
|
71 | 3239 |
! ! |
3240 |
||
1 | 3241 |
!Object methodsFor:'message sending'! |
3242 |
||
3243 |
perform:aSelector |
|
3244 |
"send the message aSelector to the receiver" |
|
3245 |
||
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3246 |
%{ |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3247 |
struct inlineCache *pIlc; |
1820
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3248 |
static struct inlineCache ilc_0 = __ILCPERF0(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3249 |
static struct inlineCache ilc_1 = __ILCPERF0(0); |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3250 |
static OBJ last_0 = nil; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3251 |
static OBJ last_1 = nil; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3252 |
static flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3253 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3254 |
if (aSelector != last_0) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3255 |
if (aSelector != last_1) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3256 |
if (flip) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3257 |
pIlc = &ilc_0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3258 |
flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3259 |
last_0 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3260 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3261 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3262 |
flip = 1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3263 |
last_1 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3264 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3265 |
pIlc->ilc_func = __SEND0ADDR__; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3266 |
if (pIlc->ilc_poly) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3267 |
__flushPolyCache(pIlc->ilc_poly); |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3268 |
pIlc->ilc_poly = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3269 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3270 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3271 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3272 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3273 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3274 |
pIlc = &ilc_0; |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3275 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3276 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, nil, pIlc) ); |
1 | 3277 |
%} |
3278 |
! |
|
3279 |
||
783 | 3280 |
perform:aSelector inClass:aClass withArguments:argArray |
3281 |
"send the message aSelector with all args taken from argArray |
|
3282 |
to the receiver as a super-send message. |
|
3283 |
This is actually more flexible than the normal super-send, since it allows |
|
3284 |
to execute a method in ANY superclass of the receiver (not just the |
|
3285 |
immediate superclass). |
|
3286 |
Thus, it is (theoretically) possible to do |
|
1818
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3287 |
'5 perform:#< inClass:Magnitude withArguments:#(6)' |
783 | 3288 |
and evaluate Magnitudes compare method even if there was one in Number. |
3289 |
This method is used by the interpreter to evaluate super sends |
|
3290 |
and could be used for very special behavior (language extension ?). |
|
3291 |
||
3292 |
WARNING: this is an ST/X feature - probably not found in other smalltalks." |
|
3293 |
||
3294 |
|numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
|
3295 |
||
3296 |
" |
|
3297 |
check, if aClass is really a superclass of the receiver |
|
3298 |
" |
|
3299 |
(self class isSubclassOf:aClass) ifFalse:[ |
|
1818
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3300 |
self error:'class argument is not a superclass of the receiver'. |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3301 |
^ nil |
783 | 3302 |
]. |
3303 |
numberOfArgs := argArray size. |
|
3304 |
%{ |
|
3305 |
REGISTER OBJ *argP; |
|
3306 |
int nargs, i; |
|
1818
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3307 |
static struct inlineCache ilc0 = _DUMMYILCSELF0; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3308 |
static struct inlineCache ilc1 = _DUMMYILCSELF1; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3309 |
static struct inlineCache ilc2 = _DUMMYILCSELF2; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3310 |
static struct inlineCache ilc3 = _DUMMYILCSELF3; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3311 |
static struct inlineCache ilc4 = _DUMMYILCSELF4; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3312 |
static struct inlineCache ilc5 = _DUMMYILCSELF5; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3313 |
static struct inlineCache ilc6 = _DUMMYILCSELF6; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3314 |
static struct inlineCache ilc7 = _DUMMYILCSELF7; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3315 |
static struct inlineCache ilc8 = _DUMMYILCSELF8; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3316 |
static struct inlineCache ilc9 = _DUMMYILCSELF9; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3317 |
static struct inlineCache ilc10 = _DUMMYILCSELF10; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3318 |
static struct inlineCache ilc11 = _DUMMYILCSELF11; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3319 |
static struct inlineCache ilc12 = _DUMMYILCSELF12; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3320 |
static struct inlineCache ilc13 = _DUMMYILCSELF13; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3321 |
static struct inlineCache ilc14 = _DUMMYILCSELF14; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3322 |
static struct inlineCache ilc15 = _DUMMYILCSELF15; |
783 | 3323 |
|
3324 |
if (__isSmallInteger(numberOfArgs)) { |
|
1818
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3325 |
nargs = __intVal(numberOfArgs); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3326 |
if (nargs == 0) { |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3327 |
RETURN (_SEND0(self, aSelector, aClass, &ilc0)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3328 |
} |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3329 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3330 |
argP = (OBJ *)(&a1); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3331 |
if (__Class(argArray) == @global(Array)) { |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3332 |
for (i=0; i < nargs; i++) { |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3333 |
*argP++ = __ArrayInstPtr(argArray)->a_element[i]; |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3334 |
} |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3335 |
} else { |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3336 |
for (i=1; i <= nargs; i++) { |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3337 |
*argP++ = __AT_(argArray, __MKSMALLINT(i)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3338 |
} |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3339 |
} |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3340 |
switch (nargs) { |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3341 |
case 1: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3342 |
RETURN ( _SEND1(self, aSelector, aClass, &ilc1, a1)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3343 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3344 |
case 2: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3345 |
RETURN ( _SEND2(self, aSelector, aClass, &ilc2, a1, a2)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3346 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3347 |
case 3: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3348 |
RETURN ( _SEND3(self, aSelector, aClass, &ilc3, a1, a2, a3)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3349 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3350 |
case 4: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3351 |
RETURN ( _SEND4(self, aSelector, aClass, &ilc4, a1, a2, a3, a4)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3352 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3353 |
case 5: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3354 |
RETURN ( _SEND5(self, aSelector, aClass, &ilc5, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3355 |
a1, a2, a3, a4, a5)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3356 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3357 |
case 6: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3358 |
RETURN ( _SEND6(self, aSelector, aClass, &ilc6, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3359 |
a1, a2, a3, a4, a5, a6)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3360 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3361 |
case 7: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3362 |
RETURN ( _SEND7(self, aSelector, aClass, &ilc7, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3363 |
a1, a2, a3, a4, a5, a6, a7)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3364 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3365 |
case 8: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3366 |
RETURN ( _SEND8(self, aSelector, aClass, &ilc8, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3367 |
a1, a2, a3, a4, a5, a6, a7, a8)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3368 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3369 |
case 9: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3370 |
RETURN ( _SEND9(self, aSelector, aClass, &ilc9, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3371 |
a1, a2, a3, a4, a5, a6, a7, a8, a9)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3372 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3373 |
case 10: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3374 |
RETURN ( _SEND10(self, aSelector, aClass, &ilc10, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3375 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3376 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3377 |
case 11: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3378 |
RETURN ( _SEND11(self, aSelector, aClass, &ilc11, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3379 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3380 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3381 |
case 12: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3382 |
RETURN ( _SEND12(self, aSelector, aClass, &ilc12, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3383 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3384 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3385 |
case 13: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3386 |
RETURN ( _SEND13(self, aSelector, aClass, &ilc13, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3387 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3388 |
a13)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3389 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3390 |
case 14: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3391 |
RETURN ( _SEND14(self, aSelector, aClass, &ilc14, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3392 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3393 |
a13, a14)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3394 |
|
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3395 |
case 15: |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3396 |
RETURN ( _SEND15(self, aSelector, aClass, &ilc15, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3397 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3398 |
a13, a14, a15)); |
384851e6fa7e
performs must be treated like self-sends,
Claus Gittinger <cg@exept.de>
parents:
1792
diff
changeset
|
3399 |
} |
783 | 3400 |
} |
1626 | 3401 |
%}. |
3402 |
"/ arrive here, if bad number of arguments (too many) |
|
3403 |
"/ ST/X (currently) only allows up to 15 method arguments |
|
3404 |
||
783 | 3405 |
^ self primitiveFailed |
3406 |
! |
|
3407 |
||
1 | 3408 |
perform:aSelector with:anObject |
3409 |
"send the one-arg-message aSelector to the receiver" |
|
3410 |
||
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3411 |
%{ |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3412 |
struct inlineCache *pIlc; |
1820
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3413 |
static struct inlineCache ilc_0 = __ILCPERF1(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3414 |
static struct inlineCache ilc_1 = __ILCPERF1(0); |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3415 |
static OBJ last_0 = nil; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3416 |
static OBJ last_1 = nil; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3417 |
static flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3418 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3419 |
if (aSelector != last_0) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3420 |
if (aSelector != last_1) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3421 |
if (flip) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3422 |
pIlc = &ilc_0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3423 |
flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3424 |
last_0 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3425 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3426 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3427 |
flip = 1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3428 |
last_1 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3429 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3430 |
pIlc->ilc_func = __SEND1ADDR__; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3431 |
if (pIlc->ilc_poly) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3432 |
__flushPolyCache(pIlc->ilc_poly); |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3433 |
pIlc->ilc_poly = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3434 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3435 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3436 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3437 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3438 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3439 |
pIlc = &ilc_0; |
1 | 3440 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3441 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, nil, pIlc, anObject) ); |
1 | 3442 |
%} |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3443 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3444 |
! |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3445 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3446 |
perform:aSelector with:arg1 with:arg2 |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3447 |
"send the two-arg-message aSelector to the receiver" |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3448 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3449 |
%{ |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3450 |
struct inlineCache *pIlc; |
1820
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3451 |
static struct inlineCache ilc_0 = __ILCPERF2(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3452 |
static struct inlineCache ilc_1 = __ILCPERF2(0); |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3453 |
static OBJ last_0 = nil; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3454 |
static OBJ last_1 = nil; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3455 |
static flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3456 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3457 |
if (aSelector != last_0) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3458 |
if (aSelector != last_1) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3459 |
if (flip) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3460 |
pIlc = &ilc_0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3461 |
flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3462 |
last_0 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3463 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3464 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3465 |
flip = 1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3466 |
last_1 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3467 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3468 |
pIlc->ilc_func = __SEND2ADDR__; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3469 |
if (pIlc->ilc_poly) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3470 |
__flushPolyCache(pIlc->ilc_poly); |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3471 |
pIlc->ilc_poly = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3472 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3473 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3474 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3475 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3476 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3477 |
pIlc = &ilc_0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3478 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3479 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, nil, pIlc, arg1, arg2) ); |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3480 |
%} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3481 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3482 |
! |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3483 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3484 |
perform:aSelector with:arg1 with:arg2 with:arg3 |
1 | 3485 |
"send the three-arg-message aSelector to the receiver" |
3486 |
||
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3487 |
%{ |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3488 |
struct inlineCache *pIlc; |
1820
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3489 |
static struct inlineCache ilc_0 = __ILCPERF3(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3490 |
static struct inlineCache ilc_1 = __ILCPERF3(0); |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3491 |
static OBJ last_0 = nil; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3492 |
static OBJ last_1 = nil; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3493 |
static flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3494 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3495 |
if (aSelector != last_0) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3496 |
if (aSelector != last_1) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3497 |
if (flip) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3498 |
pIlc = &ilc_0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3499 |
flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3500 |
last_0 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3501 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3502 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3503 |
flip = 1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3504 |
last_1 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3505 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3506 |
pIlc->ilc_func = __SEND3ADDR__; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3507 |
if (pIlc->ilc_poly) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3508 |
__flushPolyCache(pIlc->ilc_poly); |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3509 |
pIlc->ilc_poly = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3510 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3511 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3512 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3513 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3514 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3515 |
pIlc = &ilc_0; |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3516 |
} |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3517 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, nil, pIlc, arg1, arg2, arg3) ); |
1 | 3518 |
%} |
2437 | 3519 |
! |
3520 |
||
3521 |
perform:aSelector with:arg1 with:arg2 with:arg3 with:arg4 |
|
3522 |
"send the four-arg-message aSelector to the receiver" |
|
3523 |
||
3524 |
%{ |
|
3525 |
struct inlineCache *pIlc; |
|
3526 |
static struct inlineCache ilc_0 = __ILCPERF4(0); |
|
3527 |
static struct inlineCache ilc_1 = __ILCPERF4(0); |
|
3528 |
static OBJ last_0 = nil; |
|
3529 |
static OBJ last_1 = nil; |
|
3530 |
static flip = 0; |
|
3531 |
||
3532 |
if (aSelector != last_0) { |
|
3533 |
if (aSelector != last_1) { |
|
3534 |
if (flip) { |
|
3535 |
pIlc = &ilc_0; |
|
3536 |
flip = 0; |
|
3537 |
last_0 = aSelector; |
|
3538 |
} else { |
|
3539 |
pIlc = &ilc_1; |
|
3540 |
flip = 1; |
|
3541 |
last_1 = aSelector; |
|
3542 |
} |
|
3543 |
pIlc->ilc_func = __SEND4ADDR__; |
|
3544 |
if (pIlc->ilc_poly) { |
|
3545 |
__flushPolyCache(pIlc->ilc_poly); |
|
3546 |
pIlc->ilc_poly = 0; |
|
3547 |
} |
|
3548 |
} else { |
|
3549 |
pIlc = &ilc_1; |
|
3550 |
} |
|
3551 |
} else { |
|
3552 |
pIlc = &ilc_0; |
|
3553 |
} |
|
3554 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, nil, pIlc, arg1, arg2, arg3, arg4) ); |
|
3555 |
%} |
|
1 | 3556 |
! |
3557 |
||
3558 |
perform:aSelector withArguments:argArray |
|
3559 |
"send the message aSelector with all args taken from argArray |
|
44 | 3560 |
to the receiver." |
1 | 3561 |
|
77 | 3562 |
|numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
1 | 3563 |
|
3564 |
numberOfArgs := argArray size. |
|
3565 |
%{ |
|
3566 |
REGISTER OBJ *argP; |
|
3567 |
int nargs, i; |
|
1820
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3568 |
static OBJ last0 = nil; static struct inlineCache ilc0 = __ILCPERF0(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3569 |
static OBJ last1 = nil; static struct inlineCache ilc1 = __ILCPERF1(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3570 |
static OBJ last2 = nil; static struct inlineCache ilc2 = __ILCPERF2(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3571 |
static OBJ last3 = nil; static struct inlineCache ilc3 = __ILCPERF3(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3572 |
static OBJ last4 = nil; static struct inlineCache ilc4 = __ILCPERF4(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3573 |
static OBJ last5 = nil; static struct inlineCache ilc5 = __ILCPERF5(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3574 |
static OBJ last6 = nil; static struct inlineCache ilc6 = __ILCPERF6(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3575 |
static OBJ last7 = nil; static struct inlineCache ilc7 = __ILCPERF7(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3576 |
static OBJ last8 = nil; static struct inlineCache ilc8 = __ILCPERF8(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3577 |
static OBJ last9 = nil; static struct inlineCache ilc9 = __ILCPERF9(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3578 |
static OBJ last10 = nil; static struct inlineCache ilc10 = __ILCPERF10(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3579 |
static OBJ last11 = nil; static struct inlineCache ilc11 = __ILCPERF11(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3580 |
static OBJ last12 = nil; static struct inlineCache ilc12 = __ILCPERF12(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3581 |
static OBJ last13 = nil; static struct inlineCache ilc13 = __ILCPERF13(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3582 |
static OBJ last14 = nil; static struct inlineCache ilc14 = __ILCPERF14(0); |
f56384710f2e
need another ILC-type: ILCPERF.
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
3583 |
static OBJ last15 = nil; static struct inlineCache ilc15 = __ILCPERF15(0); |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3584 |
OBJ l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3585 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3586 |
#if defined(xxxTHIS_CONTEXT) /* not because this has a context */ |
71 | 3587 |
/* |
93 | 3588 |
* must set lineno in sender by hand here ... (because of NOCONTEXT) |
71 | 3589 |
*/ |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3590 |
if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3591 |
_ContextInstPtr(__thisContext)->c_lineno = l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3592 |
} |
71 | 3593 |
#endif |
1 | 3594 |
|
253 | 3595 |
if (__isSmallInteger(numberOfArgs)) { |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3596 |
nargs = __intVal(numberOfArgs); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3597 |
if (nargs == 0) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3598 |
if (aSelector != last0) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3599 |
ilc0.ilc_func = __SEND0ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3600 |
if (ilc0.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3601 |
__flushPolyCache(ilc0.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3602 |
ilc0.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3603 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3604 |
last0 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3605 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3606 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3607 |
ilc0.ilc_lineNo = __pilc->ilc_lineNo; |
44 | 3608 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3609 |
RETURN ((*ilc0.ilc_func)(self, aSelector, nil, &ilc0)); |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3610 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3611 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3612 |
if (__isArray(argArray)) { |
1133 | 3613 |
argP = __ArrayInstPtr(argArray)->a_element; |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3614 |
} else { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3615 |
argP = (OBJ *)(&a1); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3616 |
for (i=1; i <= nargs; i++) { |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3617 |
*argP++ = __AT_(argArray, __MKSMALLINT(i)); |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3618 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3619 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3620 |
switch (nargs) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3621 |
case 1: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3622 |
if (aSelector != last1) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3623 |
ilc1.ilc_func = __SEND1ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3624 |
if (ilc1.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3625 |
__flushPolyCache(ilc1.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3626 |
ilc1.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3627 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3628 |
last1 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3629 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3630 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3631 |
ilc1.ilc_lineNo = __pilc->ilc_lineNo; |
44 | 3632 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3633 |
RETURN ( (*ilc1.ilc_func)(self, aSelector, nil, &ilc1, argP[0])); |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3634 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3635 |
case 2: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3636 |
if (aSelector != last2) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3637 |
ilc2.ilc_func = __SEND2ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3638 |
if (ilc2.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3639 |
__flushPolyCache(ilc2.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3640 |
ilc2.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3641 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3642 |
last2 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3643 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3644 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3645 |
ilc2.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3646 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3647 |
RETURN ( (*ilc2.ilc_func)(self, aSelector, nil, &ilc2, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3648 |
argP[0], argP[1])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3649 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3650 |
case 3: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3651 |
if (aSelector != last3) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3652 |
ilc3.ilc_func = __SEND3ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3653 |
if (ilc3.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3654 |
__flushPolyCache(ilc3.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3655 |
ilc3.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3656 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3657 |
last3 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3658 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3659 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3660 |
ilc3.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3661 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3662 |
RETURN ( (*ilc3.ilc_func)(self, aSelector, nil, &ilc3, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3663 |
argP[0], argP[1], argP[2])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3664 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3665 |
case 4: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3666 |
if (aSelector != last4) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3667 |
ilc4.ilc_func = __SEND4ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3668 |
if (ilc4.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3669 |
__flushPolyCache(ilc4.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3670 |
ilc4.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3671 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3672 |
last4 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3673 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3674 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3675 |
ilc4.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3676 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3677 |
RETURN ( (*ilc4.ilc_func)(self, aSelector, nil, &ilc4, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3678 |
argP[0], argP[1], argP[2], argP[3])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3679 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3680 |
case 5: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3681 |
if (aSelector != last5) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3682 |
ilc5.ilc_func = __SEND5ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3683 |
if (ilc5.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3684 |
__flushPolyCache(ilc5.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3685 |
ilc5.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3686 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3687 |
last5 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3688 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3689 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3690 |
ilc5.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3691 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3692 |
RETURN ( (*ilc5.ilc_func)(self, aSelector, nil, &ilc5, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3693 |
argP[0], argP[1], argP[2], argP[3], argP[4])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3694 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3695 |
case 6: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3696 |
if (aSelector != last6) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3697 |
ilc6.ilc_func = __SEND6ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3698 |
if (ilc6.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3699 |
__flushPolyCache(ilc6.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3700 |
ilc6.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3701 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3702 |
last6 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3703 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3704 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3705 |
ilc6.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3706 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3707 |
RETURN ( (*ilc6.ilc_func)(self, aSelector, nil, &ilc6, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3708 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3709 |
argP[5])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3710 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3711 |
case 7: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3712 |
if (aSelector != last7) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3713 |
ilc7.ilc_func = __SEND7ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3714 |
if (ilc7.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3715 |
__flushPolyCache(ilc7.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3716 |
ilc7.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3717 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3718 |
last7 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3719 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3720 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3721 |
ilc7.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3722 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3723 |
RETURN ( (*ilc7.ilc_func)(self, aSelector, nil, &ilc7, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3724 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3725 |
argP[5], argP[6])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3726 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3727 |
case 8: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3728 |
if (aSelector != last8) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3729 |
ilc8.ilc_func = __SEND8ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3730 |
last8 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3731 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3732 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3733 |
ilc8.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3734 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3735 |
RETURN ( (*ilc8.ilc_func)(self, aSelector, nil, &ilc8, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3736 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3737 |
argP[5], argP[6], argP[7])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3738 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3739 |
case 9: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3740 |
if (aSelector != last9) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3741 |
ilc9.ilc_func = __SEND9ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3742 |
last9 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3743 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3744 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3745 |
ilc9.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3746 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3747 |
RETURN ( (*ilc9.ilc_func)(self, aSelector, nil, &ilc9, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3748 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3749 |
argP[5], argP[6], argP[7], argP[8])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3750 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3751 |
case 10: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3752 |
if (aSelector != last10) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3753 |
ilc10.ilc_func = __SEND10ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3754 |
last10 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3755 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3756 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3757 |
ilc10.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3758 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3759 |
RETURN ( (*ilc10.ilc_func)(self, aSelector, nil, &ilc10, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3760 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3761 |
argP[5], argP[6], argP[7], argP[8], argP[9])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3762 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3763 |
case 11: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3764 |
if (aSelector != last11) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3765 |
ilc11.ilc_func = __SEND11ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3766 |
last11 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3767 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3768 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3769 |
ilc11.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3770 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3771 |
RETURN ( (*ilc11.ilc_func)(self, aSelector, nil, &ilc11, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3772 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3773 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3774 |
argP[10])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3775 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3776 |
case 12: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3777 |
if (aSelector != last12) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3778 |
ilc12.ilc_func = __SEND12ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3779 |
last12 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3780 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3781 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3782 |
ilc12.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3783 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3784 |
RETURN ( (*ilc12.ilc_func)(self, aSelector, nil, &ilc12, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3785 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3786 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3787 |
argP[10], argP[11])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3788 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3789 |
case 13: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3790 |
if (aSelector != last13) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3791 |
ilc13.ilc_func = __SEND13ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3792 |
last13 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3793 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3794 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3795 |
ilc13.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3796 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3797 |
RETURN ( (*ilc13.ilc_func)(self, aSelector, nil, &ilc13, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3798 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3799 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3800 |
argP[10], argP[11], argP[12])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3801 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3802 |
case 14: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3803 |
if (aSelector != last14) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3804 |
ilc14.ilc_func = __SEND14ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3805 |
last14 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3806 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3807 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3808 |
ilc14.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3809 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3810 |
RETURN ( (*ilc14.ilc_func)(self, aSelector, nil, &ilc14, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3811 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3812 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3813 |
argP[10], argP[11], argP[12], argP[13])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3814 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3815 |
case 15: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3816 |
if (aSelector != last15) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3817 |
ilc15.ilc_func = __SEND15ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3818 |
last15 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3819 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3820 |
#ifdef xxTHIS_CONTEXT /* not because this has a context */ |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3821 |
ilc15.ilc_lineNo = __pilc->ilc_lineNo; |
77 | 3822 |
#endif |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
3823 |
RETURN ( (*ilc15.ilc_func)(self, aSelector, nil, &ilc15, |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3824 |
argP[0], argP[1], argP[2], argP[3], argP[4], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3825 |
argP[5], argP[6], argP[7], argP[8], argP[9], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3826 |
argP[10], argP[11], argP[12], argP[13], |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3827 |
argP[14])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3828 |
} |
1 | 3829 |
} |
1626 | 3830 |
%}. |
3831 |
"/ arrive here, if bad number of arguments (too many) |
|
3832 |
"/ ST/X (currently) only allows up to 15 method arguments |
|
3833 |
||
1 | 3834 |
^ self primitiveFailed |
3835 |
! ! |
|
3836 |
||
783 | 3837 |
!Object methodsFor:'misc'! |
3838 |
||
3839 |
-> anObject |
|
3840 |
"return an association with the receiver as key and |
|
3841 |
the argument as value" |
|
3842 |
||
3843 |
^ Association key:self value:anObject |
|
2 | 3844 |
! ! |
3845 |
||
1 | 3846 |
!Object methodsFor:'printing & storing'! |
3847 |
||
3848 |
className |
|
3849 |
"return the classname of the receivers class" |
|
3850 |
||
3851 |
^ self class name |
|
56 | 3852 |
|
293 | 3853 |
" |
3854 |
1 className |
|
3855 |
1 class className 'this may change ...' |
|
3856 |
$a className |
|
3857 |
$a class className 'this may change ...' |
|
3858 |
" |
|
1 | 3859 |
! |
3860 |
||
3861 |
classNameWithArticle |
|
71 | 3862 |
"return a string consisting of classname preceeded by an article. |
3863 |
(dont expect me to write national variants for this ... :-) |
|
3864 |
If you have special preferences, redefine it ..." |
|
1 | 3865 |
|
1391 | 3866 |
|classname cls| |
3867 |
||
3868 |
(cls := self class) == self ifTrue:[ |
|
3869 |
^ 'a funny object' |
|
3870 |
]. |
|
3871 |
classname := cls displayString. |
|
85 | 3872 |
^ classname article , ' ' , classname |
56 | 3873 |
|
293 | 3874 |
" |
3875 |
1 classNameWithArticle |
|
3876 |
(1->2) classNameWithArticle |
|
3877 |
XWorkstation basicNew classNameWithArticle |
|
3878 |
" |
|
1391 | 3879 |
|
3880 |
"Modified: 13.5.1996 / 12:16:14 / cg" |
|
1 | 3881 |
! |
3882 |
||
1445
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3883 |
displayOn:aGc |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3884 |
"ST-80 Compatibility |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3885 |
display the receiver in a graphicsContext at 0@0 |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3886 |
- this method allows for any object to be displayed in some view |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3887 |
(although the fallBack is to display its printString ...)" |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3888 |
|
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3889 |
^ self displayOn:aGc x:0 y:0. |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3890 |
|
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3891 |
"Created: 29.5.1996 / 16:28:58 / cg" |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3892 |
! |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3893 |
|
783 | 3894 |
displayOn:aGc at:aPoint |
3895 |
"ST-80 Compatibility |
|
3896 |
display the receiver in a graphicsContext - this method allows |
|
3897 |
for any object to be displayed in a ListView - for example." |
|
3898 |
||
3899 |
^ self displayOn:aGc x:(aPoint x) y:(aPoint y). |
|
56 | 3900 |
! |
3901 |
||
783 | 3902 |
displayOn:aGc x:x y:y |
3903 |
"display the receiver in a graphicsContext - this method allows |
|
1445
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3904 |
for any object to be displayed in a ListView - for example. |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3905 |
The fallBack here shows the receivers printString." |
783 | 3906 |
|
3907 |
^ aGc displayString:(self displayString) x:x y:y. |
|
1445
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3908 |
|
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3909 |
"Modified: 29.5.1996 / 16:29:38 / cg" |
56 | 3910 |
! |
3911 |
||
783 | 3912 |
displayString |
3913 |
"return a string used when displaying the receiver in a view; |
|
3914 |
for example an Inspector. This is usually the same as printString, |
|
3915 |
but sometimes redefined for a better look." |
|
3916 |
||
3917 |
^ self printString |
|
3918 |
||
3919 |
" |
|
3920 |
#(1 2 3) printString |
|
3921 |
#(1 2 3) displayString |
|
3922 |
#(1 2 3) storeString |
|
3923 |
" |
|
1 | 3924 |
! |
3925 |
||
783 | 3926 |
errorPrint |
3927 |
"print the receiver on the standard error stream." |
|
3928 |
||
1089
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3929 |
Stream streamErrorSignal catch:[ |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3930 |
self printOn:Stderr |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3931 |
] |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3932 |
|
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3933 |
"Modified: 7.3.1996 / 19:11:29 / cg" |
783 | 3934 |
! |
3935 |
||
1425 | 3936 |
errorPrintCR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3937 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3938 |
|
1089
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3939 |
"print the receiver followed by a cr on the standard error stream." |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3940 |
|
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3941 |
Stream streamErrorSignal catch:[ |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3942 |
self printOn:Stderr. |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3943 |
Stderr cr |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3944 |
] |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3945 |
|
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3946 |
"Modified: 7.3.1996 / 19:13:01 / cg" |
1425 | 3947 |
"Created: 20.5.1996 / 10:20:41 / cg" |
3948 |
! |
|
3949 |
||
3950 |
errorPrintNL |
|
3951 |
"{ Pragma: +optSpace }" |
|
3952 |
||
3953 |
"print the receiver followed by a cr on the standard error stream. |
|
3954 |
Please use #errorPrintCR - this method exists for backward compatibility." |
|
3955 |
||
3956 |
^ self errorPrintCR |
|
3957 |
||
3958 |
"Modified: 20.5.1996 / 10:24:45 / cg" |
|
3959 |
! |
|
3960 |
||
3961 |
errorPrintNewline |
|
3962 |
"{ Pragma: +optSpace }" |
|
3963 |
||
3964 |
"print the receiver followed by a cr on the standard error stream. |
|
3965 |
Please use #errorPrintCR - this method exists for backward compatibility." |
|
3966 |
||
3967 |
self errorPrintCR. |
|
3968 |
||
3969 |
"Modified: 20.5.1996 / 10:24:38 / cg" |
|
71 | 3970 |
! |
3971 |
||
356 | 3972 |
infoPrint |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3973 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3974 |
|
356 | 3975 |
"print the receiver on the standard error stream. |
3976 |
This is meant for information messages which are not warnings |
|
3977 |
or fatal messages. |
|
3978 |
These messages can be turned on/off by 'Object infoPrinting:true/false'" |
|
3979 |
||
2114
706cf3f9019a
initialize InfoPrinting flag from VM's setting
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
3980 |
InfoPrinting == true ifTrue:[ |
706cf3f9019a
initialize InfoPrinting flag from VM's setting
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
3981 |
self errorPrint |
356 | 3982 |
] |
3983 |
! |
|
3984 |
||
1425 | 3985 |
infoPrintCR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3986 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3987 |
|
356 | 3988 |
"print the receiver followed by a cr on the standard error stream. |
3989 |
This is meant for information messages which are not warnings |
|
3990 |
or fatal messages. |
|
3991 |
These messages can be turned on/off by 'Object infoPrinting:true/false'" |
|
3992 |
||
2114
706cf3f9019a
initialize InfoPrinting flag from VM's setting
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
3993 |
InfoPrinting == true ifTrue:[ |
1425 | 3994 |
self errorPrintCR |
356 | 3995 |
] |
1425 | 3996 |
|
3997 |
"Created: 20.5.1996 / 10:21:28 / cg" |
|
3998 |
! |
|
3999 |
||
4000 |
infoPrintNL |
|
4001 |
"{ Pragma: +optSpace }" |
|
4002 |
||
4003 |
"print the receiver followed by a cr on the standard error stream. |
|
4004 |
This is meant for information messages which are not warnings |
|
4005 |
or fatal messages. |
|
4006 |
These messages can be turned on/off by 'Object infoPrinting:true/false'. |
|
4007 |
||
4008 |
Please use #infoPrintCR - this method exists for backward compatibility." |
|
4009 |
||
2114
706cf3f9019a
initialize InfoPrinting flag from VM's setting
Claus Gittinger <cg@exept.de>
parents:
2096
diff
changeset
|
4010 |
^ self infoPrintCR |
1425 | 4011 |
|
4012 |
"Modified: 20.5.1996 / 10:25:07 / cg" |
|
356 | 4013 |
! |
4014 |
||
783 | 4015 |
|
1887 | 4016 |
"print the receiver on the standard output stream (which is not the Transcript)" |
783 | 4017 |
|
4018 |
self printOn:Stdout |
|
1887 | 4019 |
|
4020 |
"Modified: 4.11.1996 / 23:36:58 / cg" |
|
783 | 4021 |
! |
4022 |
||
1425 | 4023 |
printCR |
1887 | 4024 |
"print the receiver followed by a cr on the standard output stream (which is not the Transcript)" |
783 | 4025 |
|
4026 |
self printOn:Stdout. |
|
4027 |
Stdout cr |
|
1425 | 4028 |
|
4029 |
"Created: 20.5.1996 / 10:21:37 / cg" |
|
1887 | 4030 |
"Modified: 4.11.1996 / 23:37:06 / cg" |
1425 | 4031 |
! |
4032 |
||
4033 |
printNL |
|
4034 |
"print the receiver followed by a cr on the standard output stream |
|
4035 |
This exists for GNU Smalltalk compatibility - please use #printCR." |
|
4036 |
||
4037 |
^ self printCR |
|
4038 |
||
4039 |
"Modified: 20.5.1996 / 10:25:31 / cg" |
|
4040 |
! |
|
4041 |
||
4042 |
printNewline |
|
4043 |
"print the receiver followed by a cr on the standard output stream. |
|
4044 |
This exists for backward compatibility - please use #printCR." |
|
4045 |
||
4046 |
self printCR |
|
4047 |
||
4048 |
"Modified: 20.5.1996 / 10:25:46 / cg" |
|
783 | 4049 |
! |
4050 |
||
4051 |
printOn:aStream |
|
4052 |
"print the receiver on the argument-stream. |
|
4053 |
The default here is to output the receivers class name. |
|
4054 |
BUT: this method is heavily redefined for objects which |
|
4055 |
can print prettier." |
|
4056 |
||
4057 |
aStream nextPutAll:self classNameWithArticle |
|
4058 |
! |
|
4059 |
||
4060 |
printOn:aStream leftPaddedTo:size |
|
4061 |
"print the receiver on aStream, padding with spaces up to size. |
|
4062 |
padding is done on the left." |
|
4063 |
||
4064 |
self printOn:aStream leftPaddedTo:size with:(Character space) |
|
4065 |
||
4066 |
" |
|
4067 |
123 printOn:Transcript leftPaddedTo:10. Transcript cr |
|
4068 |
123 printOn:Transcript leftPaddedTo:2. Transcript cr |
|
4069 |
" |
|
71 | 4070 |
! |
4071 |
||
783 | 4072 |
printOn:aStream leftPaddedTo:size with:padCharacter |
4073 |
"print the receiver on aStream, padding with padCharacters up to size. |
|
4074 |
padding is done on the left." |
|
4075 |
||
4076 |
aStream nextPutAll:(self printStringLeftPaddedTo:size with:padCharacter) |
|
4077 |
||
4078 |
" |
|
4079 |
123 printOn:Transcript leftPaddedTo:10 with:$_ . Transcript cr |
|
4080 |
123 printOn:Transcript leftPaddedTo:10 with:$. . Transcript cr |
|
4081 |
" |
|
4082 |
! |
|
4083 |
||
4084 |
printOn:aStream paddedTo:size |
|
4085 |
"print the receiver on aStream, padding with spaces up to size." |
|
4086 |
||
4087 |
self printOn:aStream paddedTo:size with:(Character space) |
|
4088 |
||
4089 |
" |
|
4090 |
123.0 printOn:Transcript paddedTo:10. Transcript nextPut:$|. Transcript cr |
|
4091 |
" |
|
71 | 4092 |
! |
4093 |
||
783 | 4094 |
printOn:aStream paddedTo:size with:padCharacter |
4095 |
"print the receiver on aStream, padding with padCharacter up to size" |
|
4096 |
||
4097 |
aStream nextPutAll:(self printStringPaddedTo:size with:padCharacter). |
|
4098 |
||
4099 |
" |
|
4100 |
123 printOn:Transcript paddedTo:10 with:$_ . Transcript cr |
|
4101 |
123 printOn:Transcript paddedTo:10 with:$. . Transcript cr |
|
4102 |
" |
|
4103 |
! |
|
4104 |
||
4105 |
printOn:aStream zeroPaddedTo:size |
|
4106 |
"print the receiver on aStream, padding with zeros up to size. |
|
4107 |
Usually used with float numbers." |
|
4108 |
||
4109 |
self printOn:aStream paddedTo:size with:$0. |
|
4110 |
||
4111 |
" |
|
4112 |
123.0 printOn:Transcript zeroPaddedTo:10 |
|
4113 |
" |
|
4114 |
! |
|
4115 |
||
4116 |
printRightAdjustLen:size |
|
4117 |
"obsolete - just a name confusion. |
|
4118 |
This method will go away ..." |
|
4119 |
||
4120 |
(self printStringLeftPaddedTo:size) printOn:Stdout |
|
71 | 4121 |
! |
4122 |
||
4123 |
printString |
|
4124 |
"return a string for printing the receiver. |
|
4125 |
Since we now use printOn: as the basic print mechanism, |
|
4126 |
we have to create a stream and print into it." |
|
4127 |
||
4128 |
|s| |
|
4129 |
||
4130 |
s := WriteStream on:(String new:30). |
|
4131 |
self printOn:s. |
|
4132 |
^ s contents |
|
4133 |
! |
|
4134 |
||
783 | 4135 |
printStringLeftPaddedTo:size |
4136 |
"return my printString as a right-adjusted string of length size; |
|
4137 |
characters on the left are filled with spaces. |
|
4138 |
If the printString is longer than size, |
|
4139 |
it is returned unchanged (i.e. not truncated)" |
|
4140 |
||
4141 |
^ self printStringLeftPaddedTo:size with:(Character space) |
|
4142 |
||
4143 |
" |
|
4144 |
10 printStringLeftPaddedTo:10 |
|
4145 |
1 printStringLeftPaddedTo:10 |
|
4146 |
" |
|
4147 |
! |
|
4148 |
||
4149 |
printStringLeftPaddedTo:size ifLarger:alternative |
|
4150 |
"return my printString as a right-adjusted string of length size; |
|
4151 |
characters on the left are filled with spaces. |
|
4152 |
If the printString is larger than size, |
|
4153 |
return the result from evaluating alternative." |
|
4154 |
||
4155 |
^ self printStringLeftPaddedTo:size with:(Character space) ifLarger:alternative |
|
4156 |
||
4157 |
" |
|
4158 |
12 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
4159 |
123 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
4160 |
1234 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
4161 |
" |
|
4162 |
! |
|
4163 |
||
4164 |
printStringLeftPaddedTo:size with:padCharacter |
|
4165 |
"return my printString as a right-adjusted string of length size; |
|
4166 |
characters on the left are filled with padCharacter. |
|
4167 |
If the printString is longer than size, |
|
4168 |
it is returned unchanged (i.e. not truncated)" |
|
4169 |
||
4170 |
^ (self printString) leftPaddedTo:size with:padCharacter |
|
4171 |
||
4172 |
" |
|
4173 |
123 printStringLeftPaddedTo:10 with:$. |
|
4174 |
1 printStringLeftPaddedTo:10 with:$. |
|
4175 |
(Float pi) printStringLeftPaddedTo:20 with:$* |
|
4176 |
" |
|
4177 |
! |
|
4178 |
||
4179 |
printStringLeftPaddedTo:size with:padCharacter ifLarger:alternative |
|
4180 |
"return my printString as a right-adjusted string of length size; |
|
4181 |
characters on the left are filled with padCharacter. |
|
4182 |
If the printString is larger than size, |
|
369 | 4183 |
return the result from evaluating alternative." |
4184 |
||
4185 |
|s| |
|
4186 |
||
4187 |
s := self printString. |
|
4188 |
s size > size ifTrue:[^ alternative value]. |
|
783 | 4189 |
^ s leftPaddedTo:size with:padCharacter |
369 | 4190 |
|
4191 |
" |
|
783 | 4192 |
12 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
4193 |
123 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
|
4194 |
1234 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
|
293 | 4195 |
" |
13 | 4196 |
! |
4197 |
||
4198 |
printStringPaddedTo:size |
|
56 | 4199 |
"return a printed representation of the receiver, |
369 | 4200 |
padded with spaces (at the right) up to size. |
293 | 4201 |
If the printString is longer than size, |
4202 |
it is returned unchanged (i.e. not truncated)" |
|
13 | 4203 |
|
4204 |
^ self printStringPaddedTo:size with:(Character space) |
|
4205 |
||
293 | 4206 |
" |
4207 |
123 printStringPaddedTo:10 |
|
4208 |
1234567890123456 printStringPaddedTo:10 |
|
4209 |
'hello' printStringPaddedTo:10 |
|
4210 |
" |
|
2 | 4211 |
! |
4212 |
||
369 | 4213 |
printStringPaddedTo:size ifLarger:alternative |
4214 |
"return a printed representation of the receiver, |
|
4215 |
padded with spaces (at the right) up to size. |
|
4216 |
If the resulting printString is too large, |
|
4217 |
return the result from evaluating alternative." |
|
4218 |
||
4219 |
^ self printStringPaddedTo:size with:(Character space) ifLarger:alternative |
|
4220 |
||
4221 |
" |
|
4222 |
12 printStringPaddedTo:3 ifLarger:['***'] |
|
4223 |
123 printStringPaddedTo:3 ifLarger:['***'] |
|
4224 |
1234 printStringPaddedTo:3 ifLarger:['***'] |
|
4225 |
" |
|
4226 |
! |
|
4227 |
||
783 | 4228 |
printStringPaddedTo:size with:padCharacter |
4229 |
"return a printed representation of the receiver, |
|
4230 |
padded with padCharacter (at the right) up to size. |
|
4231 |
If the printString is longer than size, |
|
4232 |
it is returned unchanged (i.e. not truncated)" |
|
4233 |
||
4234 |
^ (self printString) paddedTo:size with:padCharacter |
|
4235 |
||
4236 |
" |
|
4237 |
123 printStringPaddedTo:10 with:$. |
|
4238 |
123 printStringPaddedTo:10 with:$* |
|
4239 |
123 printStringPaddedTo:3 with:$* |
|
4240 |
1234 printStringPaddedTo:3 with:$* |
|
4241 |
" |
|
4242 |
! |
|
4243 |
||
4244 |
printStringPaddedTo:size with:padCharacter ifLarger:alternative |
|
4245 |
"return a printed representation of the receiver, |
|
4246 |
padded with padCharacter (at the right) up to size. |
|
4247 |
If the resulting printString is too large, |
|
4248 |
return the result from evaluating alternative." |
|
4249 |
||
4250 |
|s| |
|
4251 |
||
4252 |
s := self printString. |
|
4253 |
s size > size ifTrue:[^ alternative value]. |
|
4254 |
^ s paddedTo:size with:padCharacter |
|
4255 |
||
4256 |
" |
|
4257 |
123 printStringPaddedTo:3 with:$. ifLarger:['***'] |
|
4258 |
12345 printStringPaddedTo:3 with:$. ifLarger:['***'] |
|
4259 |
" |
|
4260 |
! |
|
4261 |
||
4262 |
printStringRightAdjustLen:size |
|
4263 |
"obsolete - just a name confusion. |
|
4264 |
This method will go away ..." |
|
4265 |
||
4266 |
^ self printStringLeftPaddedTo:size |
|
4267 |
! |
|
4268 |
||
2 | 4269 |
printStringZeroPaddedTo:size |
71 | 4270 |
"return a printed representation of the receiver, |
369 | 4271 |
padded with zero (at the right) characters up to size. |
13 | 4272 |
Usually used with float numbers." |
2 | 4273 |
|
4274 |
^ self printStringPaddedTo:size with:$0 |
|
13 | 4275 |
|
293 | 4276 |
" |
4277 |
123.0 printStringZeroPaddedTo:10 |
|
4278 |
" |
|
2 | 4279 |
! |
4280 |
||
783 | 4281 |
store |
4282 |
"store the receiver on standard output. |
|
4283 |
this method is useless, but included for compatibility." |
|
4284 |
||
4285 |
self storeOn:Stdout |
|
71 | 4286 |
! |
4287 |
||
1425 | 4288 |
storeCR |
4289 |
"store the receiver on standard output; append a carriage return." |
|
4290 |
||
4291 |
self store. |
|
4292 |
Character cr print |
|
4293 |
||
4294 |
"Created: 20.5.1996 / 10:26:01 / cg" |
|
4295 |
"Modified: 20.5.1996 / 10:26:57 / cg" |
|
4296 |
! |
|
4297 |
||
783 | 4298 |
storeNl |
4299 |
"store the receiver on standard output; append a newline. |
|
1425 | 4300 |
This method is included for backward compatibility- use #storeCR." |
4301 |
||
4302 |
self storeCR. |
|
4303 |
||
4304 |
"Modified: 20.5.1996 / 10:26:49 / cg" |
|
460
7e058858cc3b
New Method: displayOn:aGc at:aPoint (ST80-compatibility).
Stefan Vogel <sv@exept.de>
parents:
446
diff
changeset
|
4305 |
! |
7e058858cc3b
New Method: displayOn:aGc at:aPoint (ST80-compatibility).
Stefan Vogel <sv@exept.de>
parents:
446
diff
changeset
|
4306 |
|
56 | 4307 |
storeOn:aStream |
4308 |
"store the receiver on aStream; i.e. print an expression which will |
|
293 | 4309 |
reconstruct the receiver. |
4310 |
Notice, that no self referencing or cyclic objects can be represented |
|
4311 |
in this format. |
|
4312 |
Use storeBinaryOn:, which handles these cases correctly." |
|
56 | 4313 |
|
4314 |
|myClass hasSemi sz "{ Class: SmallInteger }" | |
|
1 | 4315 |
|
25 | 4316 |
thisContext isRecursive ifTrue:[ |
2287 | 4317 |
('Object [error]: storeString of self referencing object.') errorPrintCR. |
1417 | 4318 |
aStream nextPutAll:'#("recursive")'. |
4319 |
^ self |
|
25 | 4320 |
]. |
56 | 4321 |
|
1 | 4322 |
myClass := self class. |
56 | 4323 |
aStream nextPut:$(. |
4324 |
aStream nextPutAll:self class name. |
|
4325 |
||
1 | 4326 |
hasSemi := false. |
4327 |
myClass isVariable ifTrue:[ |
|
1417 | 4328 |
aStream nextPutAll:' basicNew:'. |
4329 |
self basicSize printOn:aStream |
|
1 | 4330 |
] ifFalse:[ |
1417 | 4331 |
aStream nextPutAll:' basicNew' |
1 | 4332 |
]. |
56 | 4333 |
|
1 | 4334 |
sz := myClass instSize. |
4335 |
1 to:sz do:[:i | |
|
1417 | 4336 |
aStream nextPutAll:' instVarAt:'. |
4337 |
i printOn:aStream. |
|
4338 |
aStream nextPutAll:' put:'. |
|
4339 |
(self instVarAt:i) storeOn:aStream. |
|
4340 |
aStream nextPut:$;. |
|
4341 |
hasSemi := true |
|
1 | 4342 |
]. |
4343 |
myClass isVariable ifTrue:[ |
|
1417 | 4344 |
sz := self basicSize. |
4345 |
1 to:sz do:[:i | |
|
4346 |
aStream nextPutAll:' basicAt:'. |
|
4347 |
i printOn:aStream. |
|
4348 |
aStream nextPutAll:' put:'. |
|
4349 |
(self basicAt:i) storeOn:aStream. |
|
4350 |
aStream nextPut:$;. |
|
4351 |
hasSemi := true |
|
4352 |
] |
|
1 | 4353 |
]. |
4354 |
hasSemi ifTrue:[ |
|
1417 | 4355 |
aStream nextPutAll:' yourself' |
1 | 4356 |
]. |
56 | 4357 |
aStream nextPut:$). |
293 | 4358 |
|
4359 |
" |
|
4360 |
|s| |
|
4361 |
||
4362 |
s := WriteStream on:(String new). |
|
4363 |
('hello' -> 'world') storeOn:s. |
|
4364 |
s := ReadStream on:(s contents). |
|
4365 |
(Object readFrom:s) inspect |
|
4366 |
" |
|
4367 |
" |
|
4368 |
|s| |
|
4369 |
||
4370 |
s := 'data' asFilename writeStream. |
|
4371 |
('hello' -> 'world') storeOn:s. |
|
4372 |
s close. |
|
4373 |
||
4374 |
s := 'data' asFilename readStream. |
|
4375 |
(Object readFrom:s) inspect |
|
4376 |
" |
|
4377 |
||
4378 |
"does not work example:" |
|
4379 |
" |
|
4380 |
|s a| |
|
4381 |
||
4382 |
a := Array new:2. |
|
4383 |
a at:1 put:a. |
|
4384 |
||
4385 |
s := 'data' asFilename writeStream. |
|
4386 |
a storeOn:s. |
|
4387 |
s close. |
|
4388 |
||
4389 |
s := 'data' asFilename readStream. |
|
4390 |
(Object readFrom:s) inspect |
|
4391 |
" |
|
1417 | 4392 |
|
2287 | 4393 |
"Modified: 28.1.1997 / 00:36:12 / cg" |
1 | 4394 |
! |
4395 |
||
56 | 4396 |
storeString |
293 | 4397 |
"return a string representing an expression to reconstruct the receiver. |
4398 |
Notice, that no self referencing or cyclic objects can be represented |
|
4399 |
in this format. |
|
4400 |
Use storeBinaryOn:, which handles these cases correctly." |
|
56 | 4401 |
|
4402 |
|s| |
|
4403 |
||
4404 |
s := WriteStream on:(String new:50). |
|
4405 |
self storeOn:s. |
|
4406 |
^ s contents |
|
783 | 4407 |
! ! |
4408 |
||
4409 |
!Object methodsFor:'queries'! |
|
4410 |
||
4411 |
basicSize |
|
4412 |
"return the number of the receivers indexed instance variables, |
|
4413 |
0 if it has none. |
|
4414 |
||
2148 | 4415 |
This method should NOT be redefined in any subclass (except with great care, for tuning)" |
783 | 4416 |
|
4417 |
%{ /* NOCONTEXT */ |
|
4418 |
||
4419 |
REGISTER int nbytes; |
|
4420 |
REGISTER OBJ myClass; |
|
2209 | 4421 |
REGISTER INT flags; |
783 | 4422 |
|
4423 |
/* |
|
4424 |
* notice the missing test for self being a nonNilObject - |
|
4425 |
* this can be done since basicSize is defined both in UndefinedObject |
|
4426 |
* and SmallInteger |
|
4427 |
*/ |
|
4428 |
myClass = __qClass(self); |
|
4429 |
nbytes = __qSize(self) |
|
2148 | 4430 |
- OHDR_SIZE |
4431 |
- __OBJS2BYTES__(__intVal(__ClassInstPtr(myClass)->c_ninstvars)); |
|
1133 | 4432 |
|
2209 | 4433 |
flags = (INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK); |
783 | 4434 |
/* |
4435 |
* replaced switch by open-if; this is slightly faster since |
|
4436 |
* it avoids the range check and also checks the most common case first |
|
4437 |
*/ |
|
2209 | 4438 |
if (flags == __MASKSMALLINT(POINTERARRAY)) { |
2148 | 4439 |
RETURN ( __MKSMALLINT(__BYTES2OBJS__(nbytes)) ); |
783 | 4440 |
} |
2209 | 4441 |
if (flags == __MASKSMALLINT(BYTEARRAY)) { |
2148 | 4442 |
RETURN ( __MKSMALLINT(nbytes / sizeof(char)) ); |
783 | 4443 |
} |
2209 | 4444 |
if (flags == __MASKSMALLINT(WKPOINTERARRAY)) { |
4445 |
RETURN ( __MKSMALLINT(__BYTES2OBJS__(nbytes)) ); |
|
4446 |
} |
|
4447 |
if (flags == __MASKSMALLINT(FLOATARRAY)) { |
|
2148 | 4448 |
RETURN ( __MKSMALLINT(nbytes / sizeof(float)) ); |
783 | 4449 |
} |
2209 | 4450 |
if (flags == __MASKSMALLINT(DOUBLEARRAY)) { |
783 | 4451 |
#ifdef NEED_DOUBLE_ALIGN |
2148 | 4452 |
/* |
4453 |
* care for filler |
|
4454 |
*/ |
|
4455 |
nbytes -= sizeof(FILLTYPE); |
|
783 | 4456 |
#endif |
2148 | 4457 |
RETURN ( __MKSMALLINT(nbytes / sizeof(double)) ); |
783 | 4458 |
} |
2209 | 4459 |
if ((flags == __MASKSMALLINT(WORDARRAY)) || (flags == __MASKSMALLINT(SWORDARRAY))) { |
2148 | 4460 |
RETURN ( __MKSMALLINT(nbytes / sizeof(short)) ); |
783 | 4461 |
} |
2209 | 4462 |
if ((flags == __MASKSMALLINT(LONGARRAY)) || (flags == __MASKSMALLINT(SLONGARRAY))) { |
2148 | 4463 |
RETURN ( __MKSMALLINT(nbytes / sizeof(long)) ); |
783 | 4464 |
} |
4465 |
%}. |
|
4466 |
^ 0 |
|
1 | 4467 |
! |
4468 |
||
783 | 4469 |
class |
4470 |
"return the receivers class" |
|
4471 |
||
4472 |
%{ /* NOCONTEXT */ |
|
4473 |
||
4474 |
RETURN ( __Class(self) ); |
|
4475 |
%} |
|
4476 |
! |
|
4477 |
||
4478 |
respondsTo:aSelector |
|
4479 |
"return true, if the receiver implements a method with selector equal |
|
4480 |
to aSelector; i.e. if there is a method for aSelector in either the |
|
4481 |
receivers class or one of its superclasses. |
|
4482 |
||
4483 |
Notice, that this does not imply, that such a message can be sent without |
|
4484 |
an error being raised. For example, an implementation could send |
|
4485 |
#shouldNotImplement or #subclassResponsibility." |
|
4486 |
||
4487 |
" |
|
4488 |
should we go via the cache, or search (by class) ? |
|
4489 |
The first is faster, most of the time; while the 2nd fills |
|
4490 |
the cache with useless data if this is sent in a loop over all objects. |
|
4491 |
For now, use the cache ... |
|
4492 |
" |
|
4493 |
%{ /* NOCONTEXT */ |
|
4494 |
||
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
4495 |
if (__lookup(__Class(self), aSelector) == nil) { |
783 | 4496 |
RETURN ( false ); |
4497 |
} |
|
4498 |
RETURN ( true ); |
|
4499 |
%} |
|
4500 |
. |
|
4501 |
" |
|
4502 |
^ self class canUnderstand:aSelector |
|
4503 |
" |
|
4504 |
||
4505 |
"'aString' respondsTo:#+" |
|
4506 |
"'aString' respondsTo:#," |
|
4507 |
"'aString' respondsTo:#collect:" |
|
4508 |
! |
|
4509 |
||
4510 |
respondsToArithmetic |
|
4511 |
"return true, if the receiver responds to arithmetic messages. |
|
4512 |
false is returned here - the method is redefined in ArithmeticValue." |
|
4513 |
||
4514 |
^ false |
|
4515 |
! |
|
4516 |
||
4517 |
size |
|
4518 |
"return the number of the receivers indexed instance variables; |
|
4519 |
this method may be redefined in subclasses" |
|
4520 |
||
4521 |
^ self basicSize |
|
4522 |
! |
|
4523 |
||
4524 |
species |
|
4525 |
"return a class which is similar to (or the same as) the receivers class. |
|
4526 |
This is used to create an appropriate object when creating derived |
|
4527 |
copies in the collection classes (sometimes redefined)." |
|
4528 |
||
4529 |
^ self class |
|
4530 |
! |
|
4531 |
||
4532 |
yourself |
|
4533 |
"return the receiver - used for cascades to return self at the end" |
|
4534 |
||
4535 |
^ self |
|
4536 |
! ! |
|
4537 |
||
4538 |
!Object methodsFor:'secure message sending'! |
|
4539 |
||
4540 |
askFor:aSelector |
|
4541 |
"try to send the receiver the message, aSelector. |
|
4542 |
If it does not understand it, return false. Otherwise |
|
4543 |
the real value returned. |
|
4544 |
Useful to send messages such as: 'isColor' to unknown |
|
4545 |
receivers." |
|
4546 |
||
4547 |
^ self perform:aSelector ifNotUnderstood:[false] |
|
4548 |
||
4549 |
" |
|
4550 |
1 askFor:#isColor |
|
4551 |
" |
|
4552 |
! |
|
4553 |
||
4554 |
perform:aSelector ifNotUnderstood:exceptionBlock |
|
4555 |
"try to send message aSelector to the receiver. |
|
4556 |
If its understood, return the methods returned value, |
|
4557 |
otherwise return the value of the exceptionBlock" |
|
4558 |
||
4559 |
|val| |
|
4560 |
||
4561 |
MessageNotUnderstoodSignal handle:[:ex | |
|
4562 |
^ exceptionBlock value |
|
4563 |
] do:[ |
|
4564 |
val := self perform:aSelector |
|
4565 |
]. |
|
4566 |
^ val |
|
4567 |
||
4568 |
" |
|
4569 |
1.2345 perform:#foo ifNotUnderstood:['sorry'] |
|
4570 |
" |
|
1 | 4571 |
! |
4572 |
||
783 | 4573 |
perform:aSelector with:argument ifNotUnderstood:exceptionBlock |
4574 |
"try to send message aSelector to the receiver. |
|
4575 |
If its understood, return the methods returned value, |
|
4576 |
otherwise return the value of the exceptionBlock" |
|
4577 |
||
4578 |
|val| |
|
4579 |
||
4580 |
MessageNotUnderstoodSignal handle:[:ex | |
|
4581 |
^ exceptionBlock value |
|
4582 |
] do:[ |
|
4583 |
val := self perform:aSelector with:argument |
|
4584 |
]. |
|
4585 |
^ val |
|
4586 |
||
4587 |
" |
|
4588 |
|unknown| |
|
4589 |
||
4590 |
unknown := 1. |
|
4591 |
(unknown perform:#+ with:2 ifNotUnderstood:['sorry']) printNewline. |
|
4592 |
unknown := 'high there'. |
|
4593 |
(unknown perform:#+ with:2 ifNotUnderstood:['sorry']) printNewline. |
|
4594 |
" |
|
4595 |
! ! |
|
4596 |
||
2448 | 4597 |
!Object methodsFor:'signal constants'! |
4598 |
||
4599 |
messageNotUnderstoodSignal |
|
4600 |
^ MessageNotUnderstoodSignal |
|
4601 |
||
4602 |
"Created: 6.3.1997 / 15:46:52 / cg" |
|
4603 |
! ! |
|
4604 |
||
783 | 4605 |
!Object methodsFor:'special queries'! |
4606 |
||
4607 |
allOwners |
|
4608 |
"return a collection of all objects referencing the receiver" |
|
4609 |
||
4610 |
^ ObjectMemory whoReferences:self |
|
4611 |
! |
|
4612 |
||
4613 |
references:anObject |
|
4614 |
"return true, if the receiver refers to the argument, anObject. |
|
4615 |
- for debugging only" |
|
4616 |
||
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4617 |
"/ |myClass |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4618 |
"/ numInst "{ Class: SmallInteger }" | |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4619 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4620 |
%{ /* NOCONTEXT */ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4621 |
OBJ cls, flags; |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4622 |
int nInsts, i; |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4623 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4624 |
if (! __isNonNilObject(self)) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4625 |
RETURN (false); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4626 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4627 |
|
783 | 4628 |
/* |
4629 |
* a little optimization: use the fact that all old objects |
|
4630 |
* refering to a new object are on the remSet; if I am not, |
|
4631 |
* a trivial reject is possible, if anObject is a newbee |
|
4632 |
*/ |
|
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4633 |
if (__isNonNilObject(anObject)) { |
783 | 4634 |
if ((__qSpace(self) <= OLDSPACE) && !__isRemembered(self)) { |
4635 |
int spc; |
|
4636 |
||
4637 |
if (((spc = __qSpace(anObject)) == NEWSPACE) || (spc == SURVSPACE)) { |
|
4638 |
RETURN (false); |
|
4639 |
} |
|
4640 |
} |
|
4641 |
} |
|
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4642 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4643 |
cls = __qClass(self); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4644 |
if (cls == anObject) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4645 |
RETURN (true); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4646 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4647 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4648 |
flags = __ClassInstPtr(cls)->c_flags; |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
4649 |
if (((INT)flags & __MASKSMALLINT(ARRAYMASK)) == __MASKSMALLINT(POINTERARRAY)) { |
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4650 |
nInsts = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4651 |
} else { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4652 |
nInsts = __intVal(__ClassInstPtr(cls)->c_ninstvars); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4653 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4654 |
if (! nInsts) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4655 |
RETURN (false); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4656 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4657 |
for (i=0; i<nInsts; i++) { |
1133 | 4658 |
if (__InstPtr(self)->i_instvars[i] == anObject) { |
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4659 |
RETURN (true); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4660 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4661 |
} |
783 | 4662 |
%}. |
4663 |
||
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4664 |
"/ myClass := self class. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4665 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4666 |
"/ "check the class" |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4667 |
"/ (myClass == anObject) ifTrue:[^ true]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4668 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4669 |
"/ "check the instance variables" |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4670 |
"/ numInst := myClass instSize. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4671 |
"/ 1 to:numInst do:[:i | |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4672 |
"/ ((self instVarAt:i) == anObject) ifTrue:[^ true] |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4673 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4674 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4675 |
"/ "check the indexed variables" |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4676 |
"/ myClass isVariable ifTrue:[ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4677 |
"/ myClass isPointers ifFalse:[ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4678 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4679 |
"/ "/ we could argue about the following unconditional return: |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4680 |
"/ "/ it says that a non pointer array never has a reference to the |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4681 |
"/ "/ corresponding object - not mimicing a reference to a copy of the |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4682 |
"/ "/ integer. However, it avoids useless searches in huge byteArray |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4683 |
"/ "/ like objects when searching for owners. If in doubt, remove it. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4684 |
"/ "/ A consequence of the return below is that #[1 2 3] will say that it |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4685 |
"/ "/ does not refer to the number 2 (think of keeping a copy instead) |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4686 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4687 |
"/ ^ false. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4688 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4689 |
"/ "/ alternative: |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4690 |
"/ "/ anObject isNumber ifFalse:[^ false]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4691 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4692 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4693 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4694 |
"/ "/ because arrays are so common, and those have a highly tuned |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4695 |
"/ "/ idenitytIndex method, use it |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4696 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4697 |
"/ myClass == Array ifTrue:[ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4698 |
"/ ^ (self identityIndexOf:anObject) ~~ 0 |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4699 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4700 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4701 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4702 |
"/ "/ otherwise, do it the slow way |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4703 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4704 |
"/ numInst := self basicSize. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4705 |
"/ 1 to:numInst do:[:i | |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4706 |
"/ ((self basicAt:i) == anObject) ifTrue:[^ true] |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4707 |
"/ ] |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4708 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4709 |
|
783 | 4710 |
^ false |
4711 |
||
4712 |
" |
|
4713 |
|v| |
|
4714 |
||
4715 |
v := View new initialize. |
|
4716 |
v references:Display. |
|
4717 |
" |
|
4718 |
! |
|
4719 |
||
4720 |
referencesDerivedInstanceOf:aClass |
|
4721 |
"return true, if the receiver refers to an instance of |
|
4722 |
the argument, aClass or its subclass. This method exists |
|
4723 |
to support searching for users of a class." |
|
4724 |
||
4725 |
|myClass |
|
4726 |
numInst "{ Class: SmallInteger }" | |
|
4727 |
||
4728 |
myClass := self class. |
|
4729 |
||
4730 |
"check the class" |
|
4731 |
(myClass isKindOf:aClass) ifTrue:[^ true]. |
|
4732 |
||
4733 |
"check the instance variables" |
|
4734 |
numInst := myClass instSize. |
|
4735 |
1 to:numInst do:[:i | |
|
4736 |
((self instVarAt:i) isKindOf:aClass) ifTrue:[^ true] |
|
4737 |
]. |
|
4738 |
||
4739 |
"check the indexed variables" |
|
4740 |
myClass isVariable ifTrue:[ |
|
4741 |
myClass isPointers ifFalse:[ |
|
4742 |
"no need to search in non pointer fields" |
|
4743 |
((aClass == Number) or:[aClass isSubclassOf:Number]) ifFalse:[^ false]. |
|
4744 |
]. |
|
4745 |
numInst := self basicSize. |
|
4746 |
1 to:numInst do:[:i | |
|
4747 |
((self basicAt:i) isKindOf:aClass) ifTrue:[^ true] |
|
4748 |
] |
|
4749 |
]. |
|
4750 |
^ false |
|
4751 |
||
4752 |
" |
|
4753 |
(1 @ 3.4) referencesDerivedInstanceOf:Number |
|
4754 |
(1 @ 3.4) referencesDerivedInstanceOf:Array |
|
4755 |
View new initialize referencesDerivedInstanceOf:DeviceWorkstation |
|
4756 |
" |
|
4757 |
! |
|
4758 |
||
4759 |
referencesInstanceOf:aClass |
|
4760 |
"return true, if the receiver refers to an instance of |
|
4761 |
the argument, aClass.This method exists |
|
4762 |
to support searching for users of a class." |
|
4763 |
||
4764 |
|myClass |
|
4765 |
numInst "{ Class: SmallInteger }" | |
|
4766 |
||
4767 |
myClass := self class. |
|
4768 |
||
4769 |
"check the class" |
|
4770 |
(myClass isMemberOf:aClass) ifTrue:[^ true]. |
|
4771 |
||
4772 |
"check the instance variables" |
|
4773 |
numInst := myClass instSize. |
|
4774 |
1 to:numInst do:[:i | |
|
4775 |
((self instVarAt:i) isMemberOf:aClass) ifTrue:[^ true] |
|
4776 |
]. |
|
4777 |
||
4778 |
"check the indexed variables" |
|
4779 |
myClass isVariable ifTrue:[ |
|
4780 |
myClass isPointers ifFalse:[ |
|
4781 |
"no need to search in non-pointer indexed fields" |
|
4782 |
myClass isLongs ifTrue:[ |
|
4783 |
(aClass == SmallInteger or:[aClass == LargeInteger]) ifFalse:[^ false]. |
|
4784 |
] ifFalse:[ |
|
4785 |
myClass isFloatsOrDoubles ifTrue:[^ aClass == Float]. |
|
4786 |
^ aClass == SmallInteger |
|
4787 |
] |
|
4788 |
]. |
|
4789 |
numInst := self basicSize. |
|
4790 |
1 to:numInst do:[:i | |
|
4791 |
((self basicAt:i) isMemberOf:aClass) ifTrue:[^ true] |
|
4792 |
] |
|
4793 |
]. |
|
4794 |
^ false |
|
4795 |
||
4796 |
" |
|
4797 |
(1 @ 3.4) referencesInstanceOf:Float |
|
4798 |
(1 @ 3.4) referencesInstanceOf:Fraction |
|
4799 |
View new initialize referencesInstanceOf:(Display class) |
|
4800 |
" |
|
1 | 4801 |
! ! |
783 | 4802 |
|
2295 | 4803 |
!Object methodsFor:'synchronized evaluation'! |
4804 |
||
4805 |
freeSynchronizationSemaphore |
|
4806 |
"free synchronizationSemaphore. May be used, to save memory when |
|
4807 |
an object is no longer used synchronized." |
|
4808 |
||
2342 | 4809 |
|sema| |
2295 | 4810 |
|
4811 |
sema := self synchronizationSemaphore. |
|
4812 |
sema notNil ifTrue:[ |
|
4813 |
sema wait. "/ get lock |
|
4814 |
self synchronizationSemaphore:nil. |
|
4815 |
]. |
|
4816 |
||
4817 |
" |
|
4818 |
self synchronized:[]. |
|
4819 |
self synchronizationSemaphore. |
|
4820 |
self freeSynchronizationSemaphore. |
|
4821 |
" |
|
4822 |
||
4823 |
"Created: 28.1.1997 / 19:31:20 / stefan" |
|
4824 |
"Modified: 28.1.1997 / 19:47:55 / stefan" |
|
4825 |
! |
|
4826 |
||
4827 |
synchronizationSemaphore |
|
4828 |
"return the synchronization semaphore for myself. |
|
4829 |
subclasses may redefine" |
|
4830 |
||
4831 |
^ SynchronizationSemaphores at:self ifAbsent:[]. |
|
4832 |
||
4833 |
" |
|
4834 |
self synchronizationSemaphore |
|
4835 |
" |
|
4836 |
||
4837 |
"Modified: 28.1.1997 / 19:47:09 / stefan" |
|
4838 |
! |
|
4839 |
||
4840 |
synchronizationSemaphore:aSemaphore |
|
4841 |
"set the synchronisationSemaphore for myself. |
|
4842 |
subclasses may redefine this method" |
|
4843 |
||
4844 |
aSemaphore isNil ifTrue:[ |
|
4845 |
"/ remove Semaphore |
|
4846 |
SynchronizationSemaphores removeKey:self ifAbsent:[]. |
|
4847 |
] ifFalse:[ |
|
4848 |
SynchronizationSemaphores at:self put:aSemaphore. |
|
4849 |
]. |
|
4850 |
||
4851 |
"Modified: 28.1.1997 / 19:37:48 / stefan" |
|
4852 |
! |
|
4853 |
||
4854 |
synchronized:aBlock |
|
4855 |
"evaluate aBlock synchronized, i.e. use a monitor for this object" |
|
4856 |
||
2412
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4857 |
|sema blocked gotSema| |
2327 | 4858 |
|
4859 |
blocked := OperatingSystem blockInterrupts. |
|
4860 |
||
4861 |
"/ the following avoids creation of an additional |
|
4862 |
"/ block in the common case |
|
2295 | 4863 |
|
4864 |
sema := self synchronizationSemaphore. |
|
4865 |
sema isNil ifTrue:[ |
|
2327 | 4866 |
"get a locked semaphore (with count = 0)" |
4867 |
sema := Semaphore new. |
|
4868 |
self synchronizationSemaphore:sema. |
|
4869 |
blocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
2412
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4870 |
^ aBlock valueNowOrOnUnwindDo:[sema signal]. |
2327 | 4871 |
]. |
4872 |
||
2412
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4873 |
" |
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4874 |
Poll sema (never waits). |
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4875 |
Assuming that this is the common operation, this saves the creation |
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4876 |
of some blocks. |
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4877 |
" |
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4878 |
(sema waitWithTimeout:0) notNil ifTrue:[ |
2295 | 4879 |
blocked ifFalse:[OperatingSystem unblockInterrupts]. |
2412
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4880 |
^ aBlock valueNowOrOnUnwindDo:[sema signal]. |
2295 | 4881 |
]. |
2327 | 4882 |
|
4883 |
[ |
|
2412
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4884 |
gotSema := sema wait. |
2327 | 4885 |
blocked ifFalse:[OperatingSystem unblockInterrupts]. |
4886 |
^ aBlock value. |
|
4887 |
] valueNowOrOnUnwindDo:[ |
|
2412
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4888 |
gotSema notNil ifTrue:[gotSema signal] |
2327 | 4889 |
]. |
2295 | 4890 |
|
4891 |
" |
|
4892 |
[Object synchronized:[Delay waitForSeconds:2. Transcript showCR:'1']] fork. |
|
4893 |
[Object synchronized:[Delay waitForSeconds:2. Transcript showCR:'2']] fork. |
|
4894 |
" |
|
4895 |
||
4896 |
"Created: 28.1.1997 / 17:52:56 / stefan" |
|
2327 | 4897 |
"Modified: 30.1.1997 / 13:38:54 / cg" |
2412
f20a5b10e6ab
Further optim. for #synchronized.
Stefan Vogel <sv@exept.de>
parents:
2359
diff
changeset
|
4898 |
"Modified: 20.2.1997 / 09:43:35 / stefan" |
2295 | 4899 |
! ! |
4900 |
||
783 | 4901 |
!Object methodsFor:'system primitives'! |
4902 |
||
1957 | 4903 |
asOop |
4904 |
"ST-80 compatibility: |
|
4905 |
ST-80 returns an OOP-identity based number here (I guess: its address |
|
4906 |
or index); since ST/X has no such thing, and the objects address cannot |
|
4907 |
be used (since its changing over time), we return the objects identityHash |
|
4908 |
key, which provides (at least) some identity indication. |
|
4909 |
However, notice that (in contrast to ST-80's #asOop), the identityHash |
|
4910 |
key of two non-identical objects may be the same. |
|
4911 |
You'd better not use it - especially do not misuse it." |
|
4912 |
||
4913 |
^ self identityHash |
|
4914 |
||
4915 |
"Created: 9.11.1996 / 19:09:56 / cg" |
|
4916 |
"Modified: 9.11.1996 / 19:16:04 / cg" |
|
4917 |
! |
|
4918 |
||
783 | 4919 |
become:anotherObject |
4920 |
"make all references to the receiver become references to anotherObject |
|
859 | 4921 |
and vice-versa. Notice the vice-versa; see #becomeSameAs: for a one-way become. |
4922 |
This can be a very dangerous operation - be warned. |
|
861 | 4923 |
In general, using #become: should be avoided if possible, since it may |
4924 |
produce many strange effects (think of hashing in Sets, Dictionaries etc.). |
|
4925 |
||
4926 |
This may also be an expensive (i.e. slow) operation, |
|
783 | 4927 |
since in the worst case, the whole memory has to be searched for |
4928 |
references to the two objects (although the primitive tries hard to |
|
4929 |
limit the search, for acceptable performance in most cases). |
|
4930 |
This method fails, if the receiver or the argument is a SmallInteger |
|
4931 |
or nil, or is a context of a living method (i.e. one that has not already |
|
4932 |
returned). |
|
859 | 4933 |
(notice that #become: is not used heavily by the system |
783 | 4934 |
- the Collection-classes have been rewritten to not use it.)" |
4935 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
4936 |
if (__primBecome(self, anotherObject)) { |
783 | 4937 |
RETURN ( self ); |
859 | 4938 |
} |
4939 |
%}. |
|
783 | 4940 |
self primitiveFailed |
4941 |
! |
|
4942 |
||
4943 |
becomeNil |
|
4944 |
"make all references to the receiver become nil - effectively getting |
|
859 | 4945 |
rid of the receiver. |
4946 |
This can be a very dangerous operation - be warned. |
|
4947 |
||
4948 |
This may be an expensive (i.e. slow) operation. |
|
783 | 4949 |
The receiver may not be a SmallInteger or a context of a living method." |
4950 |
||
4951 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
4952 |
if (__primBecomeNil(self)) { |
783 | 4953 |
RETURN ( nil ); |
859 | 4954 |
} |
4955 |
%}. |
|
4956 |
self primitiveFailed |
|
4957 |
! |
|
4958 |
||
4959 |
becomeSameAs:anotherObject |
|
4960 |
"make all references to the receiver become references to anotherObject |
|
861 | 4961 |
but NOT vice versa (as done in #become:). |
859 | 4962 |
This can be a very dangerous operation - be warned. |
861 | 4963 |
In general, using #become: should be avoided if possible, since it may |
4964 |
produce many strange effects (think of hashing in Sets, Dictionaries etc.). |
|
4965 |
||
4966 |
This may also be an expensive (i.e. slow) operation, |
|
859 | 4967 |
since in the worst case, the whole memory has to be searched for |
4968 |
references to the two objects (although the primitive tries hard to |
|
4969 |
limit the search, for acceptable performance in most cases). |
|
4970 |
This method fails, if the receiver or the argument is a SmallInteger |
|
4971 |
or nil, or is a context of a living method (i.e. one that has not already returned)." |
|
4972 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1685
diff
changeset
|
4973 |
if (__primBecomeSameAs(self, anotherObject)) { |
859 | 4974 |
RETURN ( self ); |
4975 |
} |
|
4976 |
%}. |
|
783 | 4977 |
self primitiveFailed |
4978 |
! |
|
4979 |
||
4980 |
changeClassTo:otherClass |
|
4981 |
"changes the class of the receiver to the argument, otherClass. |
|
4982 |
This is only allowed (possible), if the receivers class and the argument |
|
4983 |
have the same structure (i.e. number of named instance variables and |
|
4984 |
type of indexed instance variables). |
|
4985 |
If the structures do not match, or any of the original class or new class |
|
4986 |
is UndefinedObject or a Smallinteger, a primitive error is triggered." |
|
4987 |
||
4988 |
|myClass ok| |
|
4989 |
||
4990 |
"check for UndefinedObject/SmallInteger receiver or newClass" |
|
4991 |
%{ |
|
1133 | 4992 |
{ |
4993 |
OBJ other = otherClass; |
|
4994 |
||
4995 |
if (__isNonNilObject(self) |
|
4996 |
&& __isNonNilObject(other) |
|
4997 |
&& (other != UndefinedObject) |
|
4998 |
&& (other != SmallInteger)) { |
|
4999 |
ok = true; |
|
5000 |
} else { |
|
5001 |
ok = false; |
|
5002 |
} |
|
783 | 5003 |
} |
5004 |
%}. |
|
5005 |
ok ifTrue:[ |
|
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5006 |
ok := false. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5007 |
myClass := self class. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5008 |
myClass flags == otherClass flags ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5009 |
myClass instSize == otherClass instSize ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5010 |
"same instance layout and types: its ok to do it" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5011 |
ok := true. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5012 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5013 |
myClass isPointers ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5014 |
myClass isVariable ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5015 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5016 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5017 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5018 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5019 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5020 |
myClass isPointers ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5021 |
"if newClass is a variable class, with instSize <= my instsize, |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5022 |
we can do it (effectively mapping additional instvars into the |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5023 |
variable part) - usefulness is questionable, though" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5024 |
|
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5025 |
otherClass isPointers ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5026 |
otherClass isVariable ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5027 |
otherClass instSize <= (myClass instSize + self basicSize) |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5028 |
ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5029 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5030 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5031 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5032 |
otherClass instSize == (myClass instSize + self basicSize) |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5033 |
ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5034 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5035 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5036 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5037 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5038 |
"it does not make sense to convert pointers to bytes ..." |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5039 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5040 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5041 |
"does it make sense, to convert bits ?" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5042 |
"could allow byteArray->wordArray->longArray->floatArray->doubleArray here ..." |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5043 |
(myClass isBits and:[otherClass isBits]) ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5044 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5045 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5046 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5047 |
] |
783 | 5048 |
]. |
5049 |
ok ifTrue:[ |
|
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5050 |
"now, change the receivers class ..." |
783 | 5051 |
%{ |
1133 | 5052 |
{ |
5053 |
OBJ me = self; |
|
5054 |
||
5055 |
__qClass(me) = otherClass; |
|
5056 |
__STORE(me, otherClass); |
|
5057 |
RETURN (me); |
|
5058 |
} |
|
783 | 5059 |
%}. |
5060 |
]. |
|
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5061 |
|
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5062 |
" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5063 |
the receiver cannot be represented as a instance of |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5064 |
the desired class. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5065 |
For example, you cannot change a bitInstance (byteArray etc.) |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5066 |
into a pointer object and vice versa. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5067 |
" |
783 | 5068 |
self primitiveFailed |
5069 |
! |
|
5070 |
||
5071 |
changeClassToThatOf:anObject |
|
5072 |
"changes the class of the receiver to that of the argument, anObject. |
|
5073 |
This is only allowed (possible), if the receivers class and the arguments |
|
5074 |
class have the same structure (i.e. number of named instance variables and |
|
5075 |
type of indexed instance variables). If the structures do not match, or any |
|
5076 |
of the objects is nil or a Smallinteger, a primitive error is triggered." |
|
5077 |
||
5078 |
self changeClassTo:(anObject class) |
|
5079 |
! ! |
|
5080 |
||
1867 | 5081 |
!Object methodsFor:'testing'! |
5082 |
||
5083 |
? defaultValue |
|
5084 |
"if the receiver is nil, return the defaultValue; |
|
5085 |
otherwise, return the receiver. |
|
5086 |
This method is only redefined in UndefinedObject - therefore, |
|
5087 |
the recevier is retuned here. |
|
5088 |
||
1958 | 5089 |
Thus, if foo and bar are simple variables or constants, |
5090 |
foo ? bar |
|
5091 |
is the same as: |
|
5092 |
(foo isNil ifTrue:[bar] ifFalse:[foo]) |
|
5093 |
||
5094 |
if they are message sends, the equivalent code is: |
|
5095 |
[ |
|
5096 |
|t1 t2| |
|
5097 |
||
5098 |
t1 := foo. |
|
5099 |
t2 := bar. |
|
5100 |
t1 isNil ifTrue:[t2] ifFalse:[t1] |
|
5101 |
] value |
|
5102 |
||
1867 | 5103 |
Can be used to provide defaultValues to variables, |
5104 |
as in: |
|
1958 | 5105 |
foo := arg ? #defaultValue |
2147 | 5106 |
|
2148 | 5107 |
Note: this method should never be redefined in classes other than UndefinedObject. |
1867 | 5108 |
" |
5109 |
||
5110 |
^ self |
|
5111 |
||
5112 |
" |
|
5113 |
1 ? #default |
|
5114 |
nil ? #default |
|
5115 |
" |
|
5116 |
||
5117 |
"Created: 4.11.1996 / 20:36:19 / cg" |
|
2148 | 5118 |
"Modified: 11.1.1997 / 14:56:47 / cg" |
1867 | 5119 |
! |
5120 |
||
5121 |
isArray |
|
5122 |
"return true, if the receiver is some kind of array (or weakArray etc); |
|
5123 |
false is returned here - the method is only redefined in Array." |
|
5124 |
||
5125 |
^ false |
|
5126 |
! |
|
5127 |
||
5128 |
isAssociation |
|
5129 |
"return true, if the receiver is some kind of association; |
|
5130 |
false is returned here - the method is only redefined in Association." |
|
5131 |
||
5132 |
^ false |
|
5133 |
||
5134 |
"Created: 14.5.1996 / 17:03:45 / cg" |
|
5135 |
! |
|
5136 |
||
5137 |
isBehavior |
|
5138 |
"return true, if the receiver is some kind of class (i.e. behavior); |
|
5139 |
false is returned here - the method is only redefined in Behavior." |
|
5140 |
||
5141 |
^ false |
|
5142 |
! |
|
5143 |
||
5144 |
isBlock |
|
5145 |
"return true, if the receiver is some kind of block; |
|
5146 |
false returned here - the method is only redefined in Block." |
|
5147 |
||
5148 |
^ false |
|
5149 |
! |
|
5150 |
||
5151 |
isCharacter |
|
5152 |
"return true, if the receiver is some kind of character; |
|
5153 |
false is returned here - the method is only redefined in Character." |
|
5154 |
||
5155 |
^ false |
|
5156 |
! |
|
5157 |
||
5158 |
isClass |
|
5159 |
"return true, if the receiver is some kind of class (real class, |
|
5160 |
not just behavior); |
|
5161 |
false is returned here - the method is only redefined in Class." |
|
5162 |
||
5163 |
^ false |
|
5164 |
! |
|
5165 |
||
5166 |
isCollection |
|
5167 |
"return true, if the receiver is some kind of collection; |
|
5168 |
false is returned here - the method is only redefined in Collection." |
|
5169 |
||
5170 |
^ false |
|
5171 |
! |
|
5172 |
||
5173 |
isColor |
|
5174 |
"return true, if the receiver is some kind of color; |
|
5175 |
false is returned here - the method is only redefined in Color." |
|
5176 |
||
5177 |
^ false |
|
5178 |
! |
|
5179 |
||
5180 |
isContext |
|
5181 |
"return true, if the receiver is some kind of context; |
|
5182 |
false returned here - the method is only redefined in Context." |
|
5183 |
||
5184 |
^ false |
|
5185 |
! |
|
5186 |
||
5187 |
isExternalStream |
|
5188 |
"return true, if the receiver is some kind of externalStream; |
|
5189 |
false is returned here - the method is only redefined in ExternalStream." |
|
5190 |
||
5191 |
^false |
|
5192 |
! |
|
5193 |
||
5194 |
isFileStream |
|
5195 |
"return true, if the receiver is some kind of fileStream; |
|
5196 |
false is returned here - the method is only redefined in FileStream." |
|
5197 |
||
5198 |
^false |
|
5199 |
! |
|
5200 |
||
1887 | 5201 |
isFixedPoint |
5202 |
"return true, if the receiver is some kind of fixedPoint number; |
|
5203 |
false is returned here - the method is only redefined in FixedPoint." |
|
5204 |
||
5205 |
^ false |
|
5206 |
||
5207 |
"Created: 5.11.1996 / 19:23:04 / cg" |
|
5208 |
! |
|
5209 |
||
1867 | 5210 |
isFixedSize |
5211 |
"return true if the receiver cannot grow easily |
|
5212 |
(i.e. a grow may be expensive, since it involves a become:)" |
|
5213 |
||
5214 |
^ true |
|
5215 |
! |
|
5216 |
||
5217 |
isForm |
|
5218 |
"return true, if the receiver is some kind of form; |
|
5219 |
false is returned here - the method is only redefined in Form." |
|
5220 |
||
5221 |
^ false |
|
5222 |
! |
|
5223 |
||
5224 |
isFraction |
|
5225 |
"return true, if the receiver is some kind of fraction; |
|
5226 |
false is returned here - the method is only redefined in Fraction." |
|
5227 |
||
5228 |
^ false |
|
5229 |
! |
|
5230 |
||
5231 |
isImage |
|
5232 |
"return true, if the receiver is some kind of image; |
|
5233 |
false is returned here - the method is only redefined in Image." |
|
5234 |
||
5235 |
^ false |
|
5236 |
! |
|
5237 |
||
5238 |
isImageOrForm |
|
5239 |
"return true, if the receiver is some kind of image or form; |
|
5240 |
false is returned here - the method is only redefined in Image and Form." |
|
5241 |
||
5242 |
^ false |
|
5243 |
! |
|
5244 |
||
5245 |
isInteger |
|
5246 |
"return true, if the receiver is some kind of integer number; |
|
5247 |
false is returned here - the method is only redefined in Integer." |
|
5248 |
||
5249 |
^ false |
|
5250 |
! |
|
5251 |
||
2502
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5252 |
isJavaClass |
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5253 |
^ false |
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5254 |
|
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5255 |
"Created: 26.3.1997 / 13:34:54 / cg" |
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5256 |
! |
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5257 |
|
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5258 |
isJavaObject |
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5259 |
^ false |
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5260 |
|
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5261 |
"Created: 26.3.1997 / 13:34:48 / cg" |
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5262 |
! |
8f3bf6043968
added #isJavaObject & #isJavaClass
Claus Gittinger <cg@exept.de>
parents:
2480
diff
changeset
|
5263 |
|
1867 | 5264 |
isKindOf:aClass |
5265 |
"return true, if the receiver is an instance of aClass or one of its |
|
5266 |
subclasses, false otherwise. |
|
5267 |
Advice: |
|
5268 |
use of this to check objects for certain attributes/protocoll should |
|
5269 |
be avoided; it limits the reusability of your classes by limiting use |
|
5270 |
to instances of certain classes and fences you into a specific inheritance |
|
5271 |
hierarchy. |
|
5272 |
Use check-methods to check an object for a certain attributes/protocol |
|
5273 |
(such as #isXXXX, #respondsTo: or #isNumber). |
|
5274 |
||
5275 |
Using #isKindOf: is considered BAD STYLE. |
|
5276 |
||
5277 |
Advice2: |
|
5278 |
Be aware, that using an #isXXX method is usually much faster than |
|
5279 |
using #isKindOf:; because isKindOf: has to walk up all the superclass |
|
5280 |
hierarchy, comparing every class on the way. |
|
5281 |
Due to caching in the VM, a call to #isXXX is normally reached via |
|
5282 |
a single function call. |
|
5283 |
" |
|
5284 |
||
5285 |
%{ /* NOCONTEXT */ |
|
5286 |
register OBJ thisClass; |
|
5287 |
||
5288 |
thisClass = __Class(self); |
|
5289 |
while (thisClass != nil) { |
|
5290 |
if (thisClass == aClass) { |
|
5291 |
RETURN ( true ); |
|
5292 |
} |
|
5293 |
thisClass = __ClassInstPtr(thisClass)->c_superclass; |
|
5294 |
} |
|
5295 |
%} |
|
5296 |
. |
|
5297 |
"/ |
|
5298 |
"/ the above code is equivalent to: |
|
5299 |
"/ |
|
5300 |
"/ thisClass := self class. |
|
5301 |
"/ [thisClass notNil] whileTrue:[ |
|
5302 |
"/ thisClass == aClass ifTrue:[^ true]. |
|
5303 |
"/ thisClass := thisClass superclass |
|
5304 |
"/ ] |
|
5305 |
"/ |
|
5306 |
^ false |
|
5307 |
! |
|
5308 |
||
5309 |
isLayout |
|
5310 |
"return true, if the receiver is some kind of layout; |
|
5311 |
false is returned here - the method is only redefined in Layout." |
|
5312 |
||
5313 |
^ false |
|
5314 |
! |
|
5315 |
||
5316 |
isLiteral |
|
5317 |
"return true, if the receiver can be represented as a constant in ST syntax; |
|
5318 |
false is returned here - the method is redefined in some classes." |
|
5319 |
||
5320 |
^ false |
|
5321 |
! |
|
5322 |
||
5323 |
isMemberOf:aClass |
|
5324 |
"return true, if the receiver is an instance of aClass, false otherwise. |
|
5325 |
Advice: |
|
5326 |
use of this to check objects for certain attributes/protocoll should |
|
5327 |
be avoided; it limits the reusability of your classes by limiting use |
|
5328 |
to instances of a certain class. |
|
5329 |
Use check-methods to check an object for a certain attributes/protocol |
|
5330 |
(such as #isXXX, #respondsTo: or #isNumber); |
|
5331 |
||
5332 |
Using #isMemberOf: is considered BAD STYLE." |
|
5333 |
||
5334 |
^ (self class) == aClass |
|
5335 |
! |
|
5336 |
||
5337 |
isMeta |
|
5338 |
"return true, if the receiver is some kind of metaclass; |
|
5339 |
false is returned here - the method is only redefined in Metaclass." |
|
5340 |
||
5341 |
^ false |
|
5342 |
! |
|
5343 |
||
5344 |
isMethod |
|
5345 |
"return true, if the receiver is some kind of method; |
|
5346 |
false returned here - the method is only redefined in Method." |
|
5347 |
||
5348 |
^ false |
|
5349 |
! |
|
5350 |
||
5351 |
isNamespace |
|
5352 |
^ false |
|
5353 |
||
5354 |
"Created: 11.10.1996 / 18:08:56 / cg" |
|
5355 |
! |
|
5356 |
||
5357 |
isNumber |
|
5358 |
"return true, if the receiver is some kind of number; |
|
5359 |
false is returned here - the method is only redefined in Number." |
|
5360 |
||
5361 |
^ false |
|
5362 |
! |
|
5363 |
||
5364 |
isPoint |
|
5365 |
"return true, if the receiver is some kind of point; |
|
5366 |
false is returned here - the method is only redefined in Point." |
|
5367 |
||
5368 |
^ false |
|
5369 |
! |
|
5370 |
||
5371 |
isReal |
|
5372 |
"return true, if the receiver is some kind of real number; |
|
5373 |
false is returned here - the method is only redefined in LimitedPrecisionReal." |
|
5374 |
||
5375 |
^ false |
|
5376 |
! |
|
5377 |
||
5378 |
isRectangle |
|
5379 |
"return true, if the receiver is some kind of rectangle; |
|
5380 |
false is returned here - the method is only redefined in Rectangle." |
|
5381 |
||
5382 |
^ false |
|
5383 |
! |
|
5384 |
||
5385 |
isRemoteObject |
|
5386 |
"return true, if the receiver is some kind of remoteObject, |
|
5387 |
false if its local - the method is only redefined in RemoteObject." |
|
5388 |
||
5389 |
^ false |
|
5390 |
||
5391 |
"Created: 28.10.1996 / 15:18:45 / cg" |
|
5392 |
"Modified: 28.10.1996 / 15:20:57 / cg" |
|
5393 |
! |
|
5394 |
||
5395 |
isSequenceable |
|
5396 |
"return true, if the receiver is some kind of sequenceable collection; |
|
5397 |
false is returned here - the method is only redefined in SequenceableCollection." |
|
5398 |
||
5399 |
^ false |
|
5400 |
! |
|
5401 |
||
5402 |
isSequenceableCollection |
|
5403 |
"OBSOLETE: use isSequenceable for ST-80 compatibility. |
|
5404 |
This method is a historic leftover and will be removed soon ..." |
|
5405 |
||
5406 |
self obsoleteMethodWarning:'use #isSequenceable'. |
|
5407 |
^ false |
|
5408 |
! |
|
5409 |
||
5410 |
isSignal |
|
5411 |
"return true, if the receiver is some kind of signal; |
|
5412 |
false returned here - the method is only redefined in Signal." |
|
5413 |
||
5414 |
^ false |
|
5415 |
! |
|
5416 |
||
5417 |
isStream |
|
5418 |
"return true, if the receiver is some kind of stream; |
|
5419 |
false is returned here - the method is only redefined in Stream." |
|
5420 |
||
5421 |
^ false |
|
5422 |
! |
|
5423 |
||
5424 |
isString |
|
5425 |
"return true, if the receiver is some kind of string; |
|
5426 |
false is returned here - the method is only redefined in String." |
|
5427 |
||
5428 |
^ false |
|
5429 |
! |
|
5430 |
||
5431 |
isSymbol |
|
5432 |
"return true, if the receiver is some kind of symbol; |
|
5433 |
false is returned here - the method is only redefined in Symbol." |
|
5434 |
||
5435 |
^ false |
|
5436 |
! |
|
5437 |
||
5438 |
isText |
|
5439 |
"return true, if the receiver is some kind of text object; |
|
5440 |
false is returned here - the method is only redefined in Text." |
|
5441 |
||
5442 |
^ false |
|
5443 |
||
5444 |
"Created: 12.5.1996 / 10:56:50 / cg" |
|
5445 |
! |
|
5446 |
||
5447 |
isVariable |
|
5448 |
"return true if the receiver has indexed instance variables, |
|
5449 |
false otherwise." |
|
5450 |
||
5451 |
^ self class isVariable |
|
5452 |
! |
|
5453 |
||
5454 |
isView |
|
5455 |
"return true, if the receiver is some kind of view; |
|
5456 |
false is returned here - the method is only redefined in View." |
|
5457 |
||
5458 |
^ false |
|
5459 |
! ! |
|
5460 |
||
783 | 5461 |
!Object methodsFor:'user interaction & notifications'! |
5462 |
||
5463 |
activityNotification:aString |
|
5464 |
"this can be sent from deeply nested methods, which are going to perform |
|
5465 |
some long-time activity. |
|
5466 |
If there is a handler for the ActivityNotificationSignal signal, that one is raised, |
|
5467 |
passing the argument. The handler should show this message whereever it likes, |
|
5468 |
and proceed. If there is no handler, this is simply ignored. |
|
5469 |
||
5470 |
This is very useful to pass busy messages up to some higher level (typically a view) |
|
5471 |
which likes to display that message in its label or a busy-box. |
|
5472 |
It could also be put into some logfile or printed on the standard output/error." |
|
5473 |
||
5474 |
ActivityNotificationSignal isHandled ifTrue:[ |
|
861 | 5475 |
^ ActivityNotificationSignal raiseRequestWith:self errorString:aString |
783 | 5476 |
]. |
5477 |
||
5478 |
" |
|
5479 |
nil activityNotification:'hello there' |
|
5480 |
self activityNotification:'hello there' |
|
5481 |
" |
|
5482 |
||
5483 |
" |
|
5484 |
ActivityNotificationSignal handle:[:ex | |
|
861 | 5485 |
ex errorString printNL. |
5486 |
ex proceed. |
|
783 | 5487 |
] do:[ |
861 | 5488 |
'hello' printNL. |
5489 |
self activityNotification:'doing some long time computation'. |
|
5490 |
'world' printNL. |
|
783 | 5491 |
] |
5492 |
" |
|
5493 |
||
5494 |
"Modified: 16.12.1995 / 18:23:42 / cg" |
|
5495 |
! |
|
5496 |
||
5497 |
confirm:aString |
|
5498 |
"launch a confirmer, which allows user to enter yes or no. |
|
5499 |
return true for yes, false for no" |
|
5500 |
||
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5501 |
" |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5502 |
on systems without GUI, or during startup, output a message |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5503 |
and return true (as if yes was answered) |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5504 |
Q: should we ask user by reading Stdin ? |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5505 |
" |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5506 |
Smalltalk isInitialized ifFalse:[ |
1905 | 5507 |
'*** confirmation requested during initialization:' printCR. |
5508 |
aString printCR. |
|
5509 |
'*** I''ll continue, assuming <yes> ...' printCR. |
|
1417 | 5510 |
^ true |
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5511 |
]. |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5512 |
|
783 | 5513 |
Dialog isNil ifTrue:[ |
1417 | 5514 |
Transcript showCR:aString. |
5515 |
Transcript showCR:'continue, assuming <yes>'. |
|
5516 |
^ true |
|
783 | 5517 |
]. |
5518 |
Dialog autoload. "in case its autoloaded" |
|
5519 |
^ Dialog confirm:aString |
|
5520 |
||
5521 |
" |
|
5522 |
nil confirm:'hello' |
|
5523 |
self confirm:'hello' |
|
5524 |
" |
|
1417 | 5525 |
|
1425 | 5526 |
"Modified: 20.5.1996 / 10:28:40 / cg" |
783 | 5527 |
! |
5528 |
||
5529 |
errorNotify:aString |
|
5530 |
"launch a Notifier, showing top stack, telling user something |
|
2150 | 5531 |
and give user a chance to enter debugger." |
5532 |
||
5533 |
^ self |
|
5534 |
errorNotify:aString |
|
5535 |
from:thisContext sender |
|
5536 |
||
5537 |
" |
|
5538 |
nil errorNotify:'hello there' |
|
5539 |
self errorNotify:'hello there' |
|
5540 |
" |
|
5541 |
||
5542 |
"Modified: 11.1.1997 / 18:39:20 / cg" |
|
5543 |
! |
|
5544 |
||
5545 |
errorNotify:aString from:aContext |
|
5546 |
"launch a Notifier, showing top stack (above aContext), |
|
5547 |
telling user something and give user a chance to enter debugger." |
|
783 | 5548 |
|
2082 | 5549 |
|info con sender action| |
783 | 5550 |
|
891 | 5551 |
Smalltalk isInitialized ifFalse:[ |
1425 | 5552 |
'errorNotification: ' print. aString printCR. |
1417 | 5553 |
^ self |
891 | 5554 |
]. |
5555 |
||
783 | 5556 |
Dialog isNil ifTrue:[ |
1417 | 5557 |
" |
5558 |
on systems without GUI, simply show |
|
2203
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5559 |
the message on the Transcript and abort. |
1417 | 5560 |
" |
5561 |
Transcript showCR:aString. |
|
2203
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5562 |
AbortSignal raise. |
1417 | 5563 |
^ self |
783 | 5564 |
]. |
2203
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5565 |
|
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5566 |
Processor activeProcessIsSystemProcess ifTrue:[ |
2192
ab86d9481b32
handle errors while showing errorNotifier.
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
5567 |
action := #debug. |
2296
97eb35d5ce43
dont pass nil as context, when opening a modalDebugger
Claus Gittinger <cg@exept.de>
parents:
2295
diff
changeset
|
5568 |
sender := aContext. |
2203
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5569 |
] ifFalse:[ |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5570 |
Dialog autoload. "in case its autoloaded" |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5571 |
|
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5572 |
ErrorSignal handle:[:ex | |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5573 |
|
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5574 |
"/ a recursive error - quickly enter debugger |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5575 |
"/ this happened, when I corrupted the Dialog class ... |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5576 |
|
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5577 |
('Object [error]: ' , ex errorString , ' cought in errorNotification') errorPrintCR. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5578 |
action := #debug. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5579 |
ex return. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5580 |
] do:[ |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5581 |
sender := aContext. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5582 |
sender isNil ifTrue:[ |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5583 |
sender := thisContext sender. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5584 |
"/ |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5585 |
"/ for your convenience: skip the emergencyHandler block |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5586 |
"/ sender isBlockContext ifTrue:[ |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5587 |
"/ sender := sender sender |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5588 |
"/ ]. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5589 |
]. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5590 |
|
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5591 |
"/ skip intermediate (signal & exception) contexts |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5592 |
|
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5593 |
DebugView notNil ifTrue:[ |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5594 |
sender := DebugView interestingContextFrom:sender |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5595 |
]. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5596 |
|
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5597 |
"/ show the first 5 contexts |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5598 |
|
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5599 |
con := sender. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5600 |
info := aString , Character cr asString , Character cr asString. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5601 |
1 to:5 do:[:n | |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5602 |
con notNil ifTrue:[ |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5603 |
info := info , con printString , Character cr asString. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5604 |
con := con sender |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5605 |
] |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5606 |
]. |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5607 |
|
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5608 |
action := Dialog |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5609 |
choose:info |
2359
fdc5d828bb5e
add process name to exception notifyer boxes window-title
Claus Gittinger <cg@exept.de>
parents:
2342
diff
changeset
|
5610 |
label:('Exception [' , Processor activeProcess nameOrId , ']') |
2203
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5611 |
labels:#('proceed' 'abort' 'debug') |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5612 |
values:#(#proceed #abort #debug) |
5899dbf1b69c
go directly into the debugger if an error occurs
Claus Gittinger <cg@exept.de>
parents:
2194
diff
changeset
|
5613 |
default:#debug. |
2192
ab86d9481b32
handle errors while showing errorNotifier.
Claus Gittinger <cg@exept.de>
parents:
2150
diff
changeset
|
5614 |
]. |
2082 | 5615 |
]. |
5616 |
||
5617 |
action == #debug ifTrue:[ |
|
1417 | 5618 |
Debugger enter:sender withMessage:aString |
2082 | 5619 |
] ifFalse:[ |
5620 |
action == #abort ifTrue:[ |
|
5621 |
AbortSignal raise |
|
5622 |
] |
|
783 | 5623 |
] |
5624 |
||
5625 |
" |
|
5626 |
nil errorNotify:'hello there' |
|
5627 |
self errorNotify:'hello there' |
|
5628 |
" |
|
1417 | 5629 |
|
2150 | 5630 |
"Created: 11.1.1997 / 17:53:09 / cg" |
2359
fdc5d828bb5e
add process name to exception notifyer boxes window-title
Claus Gittinger <cg@exept.de>
parents:
2342
diff
changeset
|
5631 |
"Modified: 8.2.1997 / 12:47:41 / cg" |
783 | 5632 |
! |
5633 |
||
5634 |
information:aString |
|
5635 |
"launch an InfoBox, telling user something. |
|
5636 |
These info-boxes can be suppressed by handling the |
|
5637 |
UserNotification- or InformationSignal and proceeding in the handler." |
|
5638 |
||
5639 |
InformationSignal isHandled ifTrue:[ |
|
5640 |
^ InformationSignal raiseRequestWith:self errorString:aString |
|
5641 |
]. |
|
5642 |
self notify:aString |
|
5643 |
||
5644 |
" |
|
5645 |
nil information:'hello there' |
|
5646 |
self information:'hello there' |
|
5647 |
" |
|
5648 |
||
5649 |
" |
|
5650 |
InformationSignal handle:[:ex | |
|
5651 |
'no box popped' printNL. |
|
5652 |
ex proceed. |
|
5653 |
] do:[ |
|
5654 |
'hello' printNL. |
|
5655 |
self information:'some info'. |
|
5656 |
'world' printNL. |
|
5657 |
] |
|
5658 |
" |
|
5659 |
||
5660 |
"Modified: 24.11.1995 / 22:29:49 / cg" |
|
5661 |
! |
|
5662 |
||
5663 |
notify:aString |
|
5664 |
"launch a Notifier, telling user something. |
|
5665 |
Use #information: for ignorable messages." |
|
5666 |
||
891 | 5667 |
Smalltalk isInitialized ifFalse:[ |
1425 | 5668 |
'information: ' print. aString printCR. |
1417 | 5669 |
^ self |
891 | 5670 |
]. |
5671 |
||
783 | 5672 |
Dialog isNil ifTrue:[ |
1417 | 5673 |
" |
5674 |
on systems without GUI, simply show |
|
5675 |
the message on the Transcript. |
|
5676 |
" |
|
5677 |
Transcript showCR:aString. |
|
5678 |
^ self |
|
783 | 5679 |
]. |
5680 |
Dialog autoload. "in case its autoloaded" |
|
5681 |
Dialog information:aString |
|
5682 |
||
5683 |
" |
|
5684 |
nil notify:'hello there' |
|
5685 |
self notify:'hello there' |
|
5686 |
" |
|
1417 | 5687 |
|
1425 | 5688 |
"Modified: 20.5.1996 / 10:28:48 / cg" |
783 | 5689 |
! |
5690 |
||
5691 |
warn:aString |
|
5692 |
"launch a WarningBox, telling user something. |
|
5693 |
These warn-boxes can be suppressed by handling the |
|
5694 |
UserNotification- or WarningSignal and proceeding in the handler." |
|
5695 |
||
5696 |
WarningSignal isHandled ifTrue:[ |
|
1417 | 5697 |
^ WarningSignal raiseRequestWith:self errorString:aString |
783 | 5698 |
]. |
5699 |
||
891 | 5700 |
Smalltalk isInitialized ifFalse:[ |
1425 | 5701 |
'warning: ' print. aString printCR. |
1417 | 5702 |
^ self |
891 | 5703 |
]. |
5704 |
||
783 | 5705 |
Dialog isNil ifTrue:[ |
1417 | 5706 |
" |
5707 |
on systems without GUI, simply show |
|
5708 |
the message on the Transcript. |
|
5709 |
" |
|
5710 |
Transcript showCR:aString. |
|
5711 |
^ self |
|
783 | 5712 |
]. |
5713 |
Dialog autoload. "in case its autoloaded" |
|
5714 |
Dialog warn:aString |
|
5715 |
||
5716 |
" |
|
5717 |
nil warn:'hello there' |
|
5718 |
self warn:'hello there' |
|
5719 |
" |
|
5720 |
||
5721 |
" |
|
5722 |
WarningSignal handle:[:ex | |
|
1417 | 5723 |
ex proceed. |
783 | 5724 |
] do:[ |
1417 | 5725 |
'hello' printNL. |
5726 |
self warn:'some info'. |
|
5727 |
'world' printNL. |
|
783 | 5728 |
] |
5729 |
" |
|
1417 | 5730 |
|
1425 | 5731 |
"Modified: 20.5.1996 / 10:28:53 / cg" |
783 | 5732 |
! ! |
5733 |
||
1788 | 5734 |
!Object class methodsFor:'documentation'! |
783 | 5735 |
|
5736 |
version |
|
2505 | 5737 |
^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.186 1997-03-27 12:43:15 cg Exp $' |
783 | 5738 |
! ! |
5739 |
Object initialize! |