author | Claus Gittinger <cg@exept.de> |
Tue, 24 Sep 1996 18:47:33 +0200 | |
changeset 1684 | 98ce4d199c9b |
parent 1678 | 1c0fc4e322d0 |
child 1685 | 5f867e93af8e |
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 |
||
1678
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
13 |
'From Smalltalk/X, Version:2.10.9 on 23-sep-1996 at 14:00:08' ! |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
14 |
|
783 | 15 |
nil subclass:#Object |
16 |
instanceVariableNames:'' |
|
17 |
classVariableNames:'ErrorSignal HaltSignal MessageNotUnderstoodSignal |
|
18 |
UserInterruptSignal RecursionInterruptSignal |
|
19 |
ExceptionInterruptSignal SubscriptOutOfBoundsSignal |
|
20 |
NonIntegerIndexSignal NotFoundSignal KeyNotFoundSignal |
|
21 |
ElementOutOfBoundsSignal UserNotificationSignal InformationSignal |
|
22 |
WarningSignal PrimitiveFailureSignal DeepCopyErrorSignal |
|
23 |
AbortSignal ErrorRecursion Dependencies InfoPrinting |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
24 |
ActivityNotificationSignal NonWeakDependencies' |
783 | 25 |
poolDictionaries:'' |
26 |
category:'Kernel-Objects' |
|
1 | 27 |
! |
28 |
||
1528
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
29 |
!Object class methodsFor:'documentation'! |
71 | 30 |
|
88 | 31 |
copyright |
32 |
" |
|
33 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 34 |
All Rights Reserved |
88 | 35 |
|
36 |
This software is furnished under a license and may be used |
|
37 |
only in accordance with the terms of that license and with the |
|
38 |
inclusion of the above copyright notice. This software may not |
|
39 |
be provided or otherwise made available to, or used by, any |
|
40 |
other person. No title to or ownership of the software is |
|
41 |
hereby transferred. |
|
42 |
" |
|
43 |
! |
|
44 |
||
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
45 |
dependencies |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
46 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
47 |
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
|
48 |
(we think they are better ;-). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
49 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
50 |
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
|
51 |
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
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
to dependent or the dependee. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
56 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
57 |
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
|
58 |
prevent memory leaks. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
59 |
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
|
60 |
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
|
61 |
need to care about dependencies. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
62 |
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
|
63 |
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
|
64 |
(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
|
65 |
that behavior) |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
66 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
73 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
references exist to the dependent. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
78 |
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
|
79 |
(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
|
80 |
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
|
81 |
(see #addNonWeakDependent / #removeNonWeakDependent). |
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 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
84 |
Caveat: |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
85 |
since interrests are implemented using InterrestConverter (which are simply |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
86 |
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
|
87 |
automatically). |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
88 |
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
|
89 |
and those would be reclaimed if stored in a weakDictionary. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
90 |
This means, that those interrests MUST be removed with #retractInterrest |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
91 |
(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
|
92 |
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
|
93 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
94 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
95 |
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
|
96 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
97 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
98 |
|
71 | 99 |
documentation |
100 |
" |
|
1294 | 101 |
Object is the superclass of most other classes. |
102 |
(except for nil-subclasses, which inherit nothing, |
|
103 |
to catch any message into their #doesNotUnderstand: method) |
|
104 |
||
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
105 |
Protocol which is common to every object is defined here. |
71 | 106 |
Also some utility stuff (like notify) and error handling is implemented here. |
107 |
||
108 |
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
|
109 |
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
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
(and also rewritten in some places). |
71 | 115 |
|
1294 | 116 |
[Class variables:] |
71 | 117 |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
118 |
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
|
119 |
also, parent of all other signals. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
120 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
121 |
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
|
122 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
123 |
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
|
124 |
UserInterruptSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
125 |
RecursionInterruptSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
126 |
ExceptionInterruptSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
127 |
SubscriptOutOfBoundsSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
128 |
NonIntegerIndexSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
129 |
NotFoundSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
130 |
KeyNotFoundSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
131 |
ElementOutOfBoundsSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
132 |
InformationSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
133 |
WarningSignal |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
134 |
DeepCopyErrorSignal |
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 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
145 |
Dependencies <Dictionary> keeps track of object dependencies |
1294 | 146 |
|
147 |
[author:] |
|
148 |
Claus Gittinger |
|
149 |
||
71 | 150 |
" |
151 |
! ! |
|
1 | 152 |
|
1528
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
153 |
!Object class methodsFor:'initialization'! |
1 | 154 |
|
155 |
initialize |
|
156 |
"called only once - initialize signals" |
|
157 |
||
158 |
ErrorSignal isNil ifTrue:[ |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
159 |
ErrorSignal := (Signal new) mayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
160 |
ErrorSignal nameClass:self message:#errorSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
161 |
ErrorSignal notifierString:'error encountered'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
162 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
163 |
HaltSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
164 |
HaltSignal nameClass:self message:#haltSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
165 |
HaltSignal notifierString:'halt encountered'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
166 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
167 |
MessageNotUnderstoodSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
168 |
MessageNotUnderstoodSignal nameClass:self message:#messageNotUnderstoodSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
169 |
MessageNotUnderstoodSignal notifierString:'message not understood'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
170 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
171 |
PrimitiveFailureSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
172 |
PrimitiveFailureSignal nameClass:self message:#primitiveFailureSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
173 |
PrimitiveFailureSignal notifierString:'primitive failed'. |
159 | 174 |
|
362 | 175 |
"/ UserInterruptSignal := ErrorSignal newSignalMayProceed:true. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
176 |
UserInterruptSignal := (Signal new) newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
177 |
UserInterruptSignal nameClass:self message:#userInterruptSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
178 |
UserInterruptSignal notifierString:'user Interrupt'. |
159 | 179 |
|
362 | 180 |
"/ RecursionInterruptSignal := ErrorSignal newSignalMayProceed:false. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
181 |
RecursionInterruptSignal := (Signal new) mayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
182 |
RecursionInterruptSignal nameClass:self message:#recursionInterruptSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
183 |
RecursionInterruptSignal notifierString:'recursion limit reached'. |
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 |
ExceptionInterruptSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
186 |
ExceptionInterruptSignal nameClass:self message:#exceptionInterruptSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
187 |
ExceptionInterruptSignal notifierString:'exception Interrupt'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
188 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
189 |
SubscriptOutOfBoundsSignal := ErrorSignal newSignalMayProceed:false. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
190 |
SubscriptOutOfBoundsSignal nameClass:self message:#subscriptOutOfBoundsSignal. |
1377 | 191 |
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
|
192 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
193 |
ElementOutOfBoundsSignal := ErrorSignal newSignalMayProceed:false. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
194 |
ElementOutOfBoundsSignal nameClass:self message:#elementOutOfBoundsSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
195 |
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
|
196 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
197 |
NotFoundSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
198 |
NotFoundSignal nameClass:self message:#notFoundSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
199 |
NotFoundSignal notifierString:'no such element'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
200 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
201 |
KeyNotFoundSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
202 |
KeyNotFoundSignal nameClass:self message:#keyNotFoundSignal. |
1377 | 203 |
KeyNotFoundSignal notifierString:'no such key: '. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
204 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
205 |
NonIntegerIndexSignal := ErrorSignal newSignalMayProceed:false. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
206 |
NonIntegerIndexSignal nameClass:self message:#nonIntegerIndexSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
207 |
NonIntegerIndexSignal notifierString:'index must be integer'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
208 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
209 |
UserNotificationSignal := QuerySignal new newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
210 |
UserNotificationSignal nameClass:self message:#userNotificationSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
211 |
UserNotificationSignal notifierString:'user notifiaction'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
212 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
213 |
InformationSignal := UserNotificationSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
214 |
InformationSignal nameClass:self message:#informationSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
215 |
InformationSignal notifierString:'information'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
216 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
217 |
WarningSignal := UserNotificationSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
218 |
WarningSignal nameClass:self message:#warnungSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
219 |
WarningSignal notifierString:'warning'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
220 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
221 |
ActivityNotificationSignal := UserNotificationSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
222 |
ActivityNotificationSignal nameClass:self message:#activityNotificationSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
223 |
ActivityNotificationSignal notifierString:'activity'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
224 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
225 |
DeepCopyErrorSignal := ErrorSignal newSignalMayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
226 |
DeepCopyErrorSignal nameClass:self message:#deepCopyErrorSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
227 |
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
|
228 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
229 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
230 |
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
|
231 |
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
|
232 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
233 |
AbortSignal := Signal new mayProceed:true. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
234 |
AbortSignal nameClass:self message:#abortSignal. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
235 |
AbortSignal notifierString:'unhandled abort signal'. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
236 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
237 |
Dependencies isNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
238 |
Dependencies := WeakIdentityDictionary new. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
239 |
]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
240 |
NonWeakDependencies isNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
241 |
NonWeakDependencies := IdentityDictionary new. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
242 |
] |
356 | 243 |
]. |
244 |
InfoPrinting := true |
|
1 | 245 |
|
246 |
"Object initialize" |
|
812
00db9c0646fe
notificationsignals are no longer children of ErrorSignal
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
247 |
|
1377 | 248 |
"Modified: 12.5.1996 / 14:10:40 / cg" |
1 | 249 |
! ! |
250 |
||
1528
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
251 |
!Object class methodsFor:'Signal constants'! |
1 | 252 |
|
783 | 253 |
abortSignal |
254 |
"return the signal used to abort user actions. This signal is only |
|
255 |
raised if cought (by the debugger), and will lead way out of the |
|
256 |
currently active doIt/printIt or inspectIt. (also some others use |
|
257 |
this for a save abort)" |
|
258 |
||
259 |
^ AbortSignal |
|
579
2d26193415b5
allow catching of information: and warn: boxes
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
260 |
! |
2d26193415b5
allow catching of information: and warn: boxes
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
261 |
|
782 | 262 |
activityNotificationSignal |
263 |
"return the signal used for activity notifications. |
|
264 |
A handler for this signal gets all #activityNotification: sends" |
|
265 |
||
266 |
^ ActivityNotificationSignal |
|
267 |
! |
|
268 |
||
159 | 269 |
deepCopyErrorSignal |
270 |
"return the signal raised when a deepcopy is asked for |
|
271 |
an object which cannot do this (for example, BlockClosures |
|
272 |
or Contexts)." |
|
273 |
||
274 |
^ DeepCopyErrorSignal |
|
275 |
! |
|
276 |
||
783 | 277 |
elementOutOfBoundsSignal |
278 |
"return the signal used for element error reporting |
|
279 |
(this signal is used for example when a value not in 0..255 is to |
|
280 |
be put into a bytearray)" |
|
281 |
||
282 |
^ ElementOutOfBoundsSignal |
|
283 |
! |
|
284 |
||
285 |
errorSignal |
|
286 |
"return the signal used for error/error: - handling" |
|
287 |
||
288 |
^ ErrorSignal |
|
289 |
! |
|
290 |
||
291 |
exceptionInterruptSignal |
|
292 |
"return the signal used for exception (display errors) error handling" |
|
293 |
||
294 |
^ ExceptionInterruptSignal |
|
295 |
! |
|
296 |
||
297 |
haltSignal |
|
298 |
"return the signal used for halt/halt: - handling" |
|
299 |
||
300 |
^ HaltSignal |
|
301 |
! |
|
302 |
||
303 |
informationSignal |
|
304 |
"return the signal used for informations. |
|
305 |
A handler for this signal gets all #information: sends" |
|
306 |
||
307 |
^ InformationSignal |
|
308 |
! |
|
309 |
||
310 |
keyNotFoundSignal |
|
311 |
"return the signal used for no such key error reporting" |
|
312 |
||
313 |
^ KeyNotFoundSignal |
|
314 |
! |
|
315 |
||
316 |
messageNotUnderstoodSignal |
|
317 |
"return the signal used for doesNotUnderstand: - error handling" |
|
318 |
||
319 |
^ MessageNotUnderstoodSignal |
|
320 |
! |
|
321 |
||
322 |
nonIntegerIndexSignal |
|
323 |
"return the signal used for bad subscript error reporting" |
|
324 |
||
325 |
^ NonIntegerIndexSignal |
|
326 |
! |
|
327 |
||
328 |
notFoundSignal |
|
329 |
"return the signal used for no element found error reporting" |
|
330 |
||
331 |
^ NotFoundSignal |
|
332 |
! |
|
333 |
||
334 |
primitiveFailureSignal |
|
335 |
"return the signal used for primitiveFailed - error handling" |
|
336 |
||
337 |
^ PrimitiveFailureSignal |
|
338 |
! |
|
339 |
||
340 |
privateMethodSignal |
|
341 |
"return the signal used for privateMethod - error handling" |
|
342 |
||
343 |
^ MessageNotUnderstoodSignal |
|
344 |
! |
|
345 |
||
346 |
recursionInterruptSignal |
|
347 |
"return the signal used for recursion overflow error handling" |
|
348 |
||
349 |
^ RecursionInterruptSignal |
|
350 |
! |
|
351 |
||
352 |
subscriptOutOfBoundsSignal |
|
353 |
"return the signal used for subscript error reporting. |
|
354 |
(this signal is used for example when an array is accessed with an |
|
355 |
index less than 1 or greater than the array size)" |
|
356 |
||
357 |
^ SubscriptOutOfBoundsSignal |
|
358 |
! |
|
359 |
||
360 |
userInterruptSignal |
|
361 |
"return the signal used for ^C interrupts handling" |
|
362 |
||
363 |
^ UserInterruptSignal |
|
364 |
! |
|
365 |
||
366 |
userNotificationSignal |
|
367 |
"the parent signal used with information and warnings. |
|
368 |
Handling this allows handling of both information- and warning notifications." |
|
369 |
||
370 |
^ UserNotificationSignal |
|
371 |
! |
|
372 |
||
373 |
warningSignal |
|
374 |
"return the signal used for warnings. |
|
375 |
A handler for this signal gets all #warn: sends" |
|
376 |
||
377 |
^ WarningSignal |
|
1 | 378 |
! ! |
379 |
||
1528
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
380 |
!Object class methodsFor:'info messages'! |
356 | 381 |
|
783 | 382 |
infoPrinting |
383 |
"return the flag which controls information messages." |
|
384 |
||
385 |
^ InfoPrinting |
|
386 |
! |
|
387 |
||
356 | 388 |
infoPrinting:aBoolean |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
389 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
390 |
|
356 | 391 |
"turn on/off printing of information messages. |
392 |
If the argument, aBoolean is false, infoPrint will not output |
|
393 |
messages. The default is true." |
|
394 |
||
395 |
InfoPrinting := aBoolean |
|
396 |
! ! |
|
397 |
||
1528
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
398 |
!Object class methodsFor:'queries'! |
3 | 399 |
|
400 |
isBuiltInClass |
|
49 | 401 |
"return true, if this class is known by the run-time-system, |
402 |
i.e. you cannot add/remove instance variables without recompiling |
|
1266 | 403 |
the VM. |
404 |
Here, true is returned for myself, false for subclasses." |
|
3 | 405 |
|
406 |
^ self == Object |
|
1266 | 407 |
|
408 |
"Modified: 23.4.1996 / 16:00:07 / cg" |
|
3 | 409 |
! ! |
410 |
||
1 | 411 |
!Object methodsFor:'accessing'! |
412 |
||
413 |
at:index |
|
414 |
"return the indexed instance variable with index, anInteger; |
|
415 |
this method can be redefined in subclasses." |
|
416 |
||
417 |
^ self basicAt:index |
|
418 |
! |
|
419 |
||
783 | 420 |
at:index put:anObject |
421 |
"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
|
422 |
this method can be redefined in subclasses. Returns anObject (sigh)" |
783 | 423 |
|
424 |
^ self basicAt:index put:anObject |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
425 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
426 |
"Modified: 19.4.1996 / 11:13:29 / cg" |
783 | 427 |
! |
428 |
||
1 | 429 |
basicAt:index |
430 |
"return the indexed instance variable with index, anInteger. |
|
431 |
Trigger an error if the receiver has no indexed instance variables. |
|
432 |
This method should NOT be redefined in any subclass" |
|
433 |
||
434 |
%{ /* NOCONTEXT */ |
|
435 |
||
329 | 436 |
REGISTER int nbytes, indx; |
1 | 437 |
OBJ myClass; |
329 | 438 |
REGISTER char *pFirst; |
1 | 439 |
unsigned char *cp; |
440 |
unsigned short *sp; |
|
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
441 |
short *ssp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
442 |
unsigned long *lp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
443 |
long *slp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
444 |
unsigned long ul; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
445 |
long l; |
1 | 446 |
OBJ *op; |
329 | 447 |
/* int nInstBytes, nInstVars, flags; */ |
448 |
REGISTER int n; |
|
1 | 449 |
|
450 |
||
451 |
/* |
|
56 | 452 |
* notice the missing test for self being a nonNilObject - |
1 | 453 |
* this can be done since basicAt: is defined both in UndefinedObject |
454 |
* and SmallInteger |
|
455 |
*/ |
|
253 | 456 |
if (__isSmallInteger(index)) { |
329 | 457 |
myClass = __qClass(self); |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
458 |
indx = __intVal(index) - 1; |
1133 | 459 |
n /* nInstVars */ = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
329 | 460 |
n /* nInstBytes */ = OHDR_SIZE + __OBJS2BYTES__(n /* nInstVars */); |
461 |
nbytes = __qSize(self) - n /* nInstBytes */; |
|
1133 | 462 |
pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */; |
329 | 463 |
|
464 |
/* |
|
465 |
* replaced switch by open-coded if; this is slightly faster |
|
466 |
* since it avoids the range check and also handles the most common case first |
|
467 |
*/ |
|
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
468 |
n = (INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK); |
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
469 |
|
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
470 |
if ((n == __MASKSMALLINT(POINTERARRAY)) |
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
471 |
|| (n == __MASKSMALLINT(WKPOINTERARRAY))) { |
329 | 472 |
if ((indx >= 0) && (indx < (__BYTES2OBJS__(nbytes)))) { |
473 |
op = (OBJ *)pFirst + indx; |
|
474 |
RETURN ( *op ); |
|
475 |
} |
|
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
476 |
} else if (n == __MASKSMALLINT(BYTEARRAY)) { |
329 | 477 |
if ((indx >= 0) && (indx < (nbytes / sizeof(char)))) { |
478 |
cp = (unsigned char *)pFirst + indx; |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
479 |
RETURN ( __MKSMALLINT(*cp & 0xFF) ); |
329 | 480 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
481 |
} else if (n == __MASKSMALLINT(FLOATARRAY)) { |
329 | 482 |
if ((indx >= 0) && (indx < (nbytes / sizeof(float)))) { |
483 |
float *fp; |
|
484 |
||
485 |
fp = (float *)pFirst + indx; |
|
1133 | 486 |
RETURN ( __MKFLOAT((double)(*fp)) COMMA_CON ); |
329 | 487 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
488 |
} else if (n == __MASKSMALLINT(DOUBLEARRAY)) { |
329 | 489 |
if ((indx >= 0) && (indx < (nbytes / sizeof(double)))) { |
490 |
double *dp; |
|
1 | 491 |
|
56 | 492 |
#ifdef NEED_DOUBLE_ALIGN |
329 | 493 |
/* |
494 |
* care for filler |
|
495 |
*/ |
|
496 |
pFirst += sizeof(FILLTYPE); |
|
56 | 497 |
#endif |
329 | 498 |
dp = (double *)pFirst + indx; |
1133 | 499 |
RETURN ( __MKFLOAT(*dp) COMMA_CON ); |
329 | 500 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
501 |
} else if (n == __MASKSMALLINT(WORDARRAY)) { |
329 | 502 |
if ((indx >= 0) && (indx < (nbytes / sizeof(short)))) { |
503 |
sp = (unsigned short *)pFirst + indx; |
|
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
504 |
RETURN ( __MKSMALLINT(*sp & 0xFFFF) ); |
329 | 505 |
} |
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
506 |
} else if (n == __MASKSMALLINT(SWORDARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
507 |
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
|
508 |
ssp = (short *)pFirst + indx; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
509 |
RETURN ( __MKSMALLINT(*ssp) ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
510 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
511 |
} else if (n == __MASKSMALLINT(LONGARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
512 |
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
|
513 |
lp = (unsigned long *)pFirst + indx; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
514 |
ul = *lp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
515 |
if (ul <= _MAX_INT) |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
516 |
RETURN ( __MKSMALLINT(ul) ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
517 |
RETURN ( __MKULARGEINT(ul) ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
518 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
519 |
} else if (n == __MASKSMALLINT(SLONGARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
520 |
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
|
521 |
slp = (long *)pFirst + indx; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
522 |
l = *slp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
523 |
if ((l >= _MIN_INT) && (l <= _MAX_INT)) |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
524 |
RETURN ( __MKSMALLINT(l) ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
525 |
RETURN ( __MKLARGEINT(l) ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
526 |
} |
159 | 527 |
} |
1 | 528 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
529 |
%}. |
10 | 530 |
index isInteger ifFalse:[ |
159 | 531 |
^ self indexNotInteger |
1 | 532 |
]. |
159 | 533 |
^ self subscriptBoundsError:index |
1 | 534 |
! |
535 |
||
536 |
basicAt:index put:anObject |
|
537 |
"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
|
538 |
Returns anObject (sigh). |
1 | 539 |
Trigger an error if the receiver has no indexed instance variables. |
540 |
This method should NOT be redefined in any subclass" |
|
541 |
||
542 |
%{ /* NOCONTEXT */ |
|
543 |
||
544 |
register int nbytes, indx; |
|
545 |
OBJ myClass; |
|
546 |
register char *pFirst; |
|
547 |
char *cp; |
|
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
548 |
unsigned short *sp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
549 |
short *ssp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
550 |
unsigned long *lp; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
551 |
long *slp; |
1 | 552 |
OBJ *op; |
329 | 553 |
/* int nInstBytes, ninstvars, flags; */ |
554 |
REGISTER int n; |
|
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
555 |
unsigned int u; |
1 | 556 |
int val; |
557 |
||
56 | 558 |
/* notice the missing test for self being a nonNilObject - |
77 | 559 |
this can be done since basicAt: is defined both in UndefinedObject |
1 | 560 |
and SmallInteger */ |
561 |
||
253 | 562 |
if (__isSmallInteger(index)) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
563 |
indx = __intVal(index) - 1; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
564 |
myClass = __qClass(self); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
565 |
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
|
566 |
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
|
567 |
nbytes = __qSize(self) - n /* nInstBytes */; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
568 |
pFirst = (char *)(__InstPtr(self)) + n /* nInstBytes */; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
569 |
|
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
570 |
n = (INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(ARRAYMASK); |
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
571 |
|
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
572 |
/* |
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
573 |
* replaced switch by open-coded if; this is slightly faster |
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
574 |
* since it avoids the range check and also handles the most common case first |
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
575 |
*/ |
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
576 |
if ((n == __MASKSMALLINT(POINTERARRAY)) |
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
577 |
|| (n == __MASKSMALLINT(WKPOINTERARRAY))) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
578 |
if ((indx >= 0) && (indx < (__BYTES2OBJS__(nbytes)))) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
579 |
op = (OBJ *)pFirst + indx; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
580 |
*op = anObject; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
581 |
__STORE(self, anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
582 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
583 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
584 |
} else if (n == __MASKSMALLINT(BYTEARRAY)) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
585 |
if (__isSmallInteger(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
586 |
val = __intVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
587 |
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
|
588 |
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
|
589 |
cp = pFirst + indx; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
590 |
*cp = val; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
591 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
592 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
593 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
594 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
595 |
} else if (n == __MASKSMALLINT(FLOATARRAY)) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
596 |
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
|
597 |
float *fp; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
598 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
599 |
fp = (float *)pFirst + indx; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
600 |
if (__isFloatLike(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
601 |
*fp = _floatVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
602 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
603 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
604 |
if (__isSmallInteger(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
605 |
*fp = (float) __intVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
606 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
607 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
608 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
609 |
} else if (n == __MASKSMALLINT(DOUBLEARRAY)) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
610 |
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
|
611 |
double *dp; |
13 | 612 |
|
56 | 613 |
#ifdef NEED_DOUBLE_ALIGN |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
614 |
/* |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
615 |
* care for filler |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
616 |
*/ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
617 |
pFirst += sizeof(FILLTYPE); |
56 | 618 |
#endif |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
619 |
dp = (double *)pFirst + indx; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
620 |
if (__isFloatLike(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
621 |
*dp = _floatVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
622 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
623 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
624 |
if (__isSmallInteger(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
625 |
*dp = (double) __intVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
626 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
627 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
628 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
629 |
} else if (n == __MASKSMALLINT(WORDARRAY)) { |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
630 |
if (__isSmallInteger(anObject)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
631 |
val = __intVal(anObject); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
632 |
if ((val >= 0) && (val <= 0xFFFF)) { |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
633 |
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
|
634 |
sp = (unsigned short *)pFirst + indx; |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
635 |
*sp = val; |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
636 |
RETURN ( anObject ); |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
637 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
638 |
} |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
639 |
} |
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
640 |
} else if (n == __MASKSMALLINT(SWORDARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
641 |
if (__isSmallInteger(anObject)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
642 |
val = __intVal(anObject); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
643 |
if ((val >= -32768) && (val < 32768)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
644 |
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
|
645 |
ssp = (short *)pFirst + indx; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
646 |
*ssp = val; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
647 |
RETURN ( anObject ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
648 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
649 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
650 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
651 |
} else if (n == __MASKSMALLINT(SLONGARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
652 |
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
|
653 |
slp = (long *)pFirst + indx; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
654 |
if (__isSmallInteger(anObject)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
655 |
*slp = __intVal(anObject); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
656 |
RETURN ( anObject ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
657 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
658 |
n = __signedLongIntVal(anObject); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
659 |
/* zero means failure for an int larger than 4 bytes ... (would be a smallInteger) */ |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
660 |
if (n) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
661 |
*slp = n; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
662 |
RETURN ( anObject ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
663 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
664 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
665 |
} else if (n == __MASKSMALLINT(LONGARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
666 |
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
|
667 |
lp = (unsigned long *)pFirst + indx; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
668 |
if (anObject == __MKSMALLINT(0)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
669 |
*lp = 0; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
670 |
RETURN ( anObject ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
671 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
672 |
u = __longIntVal(anObject); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
673 |
/* zero means failure for an int larger than 4 bytes ... (would be a smallInteger) */ |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
674 |
if (u) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
675 |
*lp = u; |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
676 |
RETURN ( anObject ); |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
677 |
} |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
678 |
} |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
679 |
} |
1 | 680 |
} |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
681 |
%}. |
10 | 682 |
index isInteger ifFalse:[ |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
683 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
684 |
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
|
685 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
686 |
^ self indexNotInteger |
1 | 687 |
]. |
688 |
(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
|
689 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
690 |
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
|
691 |
receiver collection |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
692 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
693 |
^ self subscriptBoundsError:index |
1 | 694 |
]. |
643 | 695 |
(self class isFloatsOrDoubles) ifTrue:[ |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
696 |
anObject isNumber ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
697 |
^ self basicAt:index put:(anObject asFloat) |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
698 |
] |
13 | 699 |
]. |
10 | 700 |
anObject isInteger ifFalse:[ |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
701 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
702 |
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
|
703 |
should be an integer number |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
704 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
705 |
^ self elementNotInteger |
2 | 706 |
]. |
159 | 707 |
" |
213 | 708 |
the object to put into the receiver collection |
362 | 709 |
is not an instance of the expected element class, |
710 |
or the value is not within the elements valid range. |
|
159 | 711 |
" |
2 | 712 |
^ self elementBoundsError |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
713 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
714 |
"Modified: 19.4.1996 / 11:14:10 / cg" |
1 | 715 |
! |
716 |
||
717 |
instVarAt:index |
|
718 |
"return a non-indexed instance variable; |
|
13 | 719 |
peeking into an object this way is not very object oriented |
720 |
- use with care (needed for copy, inspector etc.)" |
|
1 | 721 |
|
722 |
%{ /* NOCONTEXT */ |
|
723 |
||
724 |
OBJ myClass; |
|
725 |
int idx, ninstvars; |
|
726 |
||
253 | 727 |
if (__isSmallInteger(index)) { |
329 | 728 |
myClass = __Class(self); |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
729 |
idx = __intVal(index) - 1; |
357 | 730 |
/* |
731 |
* do not allow return of non-object fields. |
|
732 |
* if subclass did not make privisions for that, |
|
733 |
* we wont do so here ... |
|
734 |
*/ |
|
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
735 |
if (((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(NONOBJECT_INSTS))) { |
357 | 736 |
if (idx == 0) { |
737 |
RETURN ( nil ) |
|
738 |
} |
|
739 |
} |
|
1133 | 740 |
ninstvars = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
159 | 741 |
if ((idx >= 0) && (idx < ninstvars)) { |
1133 | 742 |
RETURN ( __InstPtr(self)->i_instvars[idx] ); |
159 | 743 |
} |
1 | 744 |
} |
745 |
%} |
|
746 |
. |
|
747 |
index isInteger ifFalse:[ |
|
159 | 748 |
^ self indexNotInteger |
1 | 749 |
]. |
159 | 750 |
^ self subscriptBoundsError:index |
1 | 751 |
! |
752 |
||
753 |
instVarAt:index put:value |
|
754 |
"change a non-indexed instance variable; |
|
13 | 755 |
peeking into an object this way is not very object oriented |
756 |
- use with care (needed for copy, inspector etc.)" |
|
1 | 757 |
|
758 |
%{ /* NOCONTEXT */ |
|
759 |
||
760 |
OBJ myClass; |
|
761 |
int idx, ninstvars; |
|
762 |
||
253 | 763 |
if (__isSmallInteger(index)) { |
329 | 764 |
myClass = __Class(self); |
755
eaab1d1dacbd
_-macros replcaed by __-macros (needed especially for MKLARGINT)
Claus Gittinger <cg@exept.de>
parents:
751
diff
changeset
|
765 |
idx = __intVal(index) - 1; |
1133 | 766 |
ninstvars = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
357 | 767 |
/* |
768 |
* do not allow setting of non-object fields. |
|
769 |
* if subclass did not make privisions for that, |
|
770 |
* we wont do so here ... |
|
771 |
*/ |
|
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
772 |
if (((INT)(__ClassInstPtr(myClass)->c_flags) & __MASKSMALLINT(NONOBJECT_INSTS))) { |
357 | 773 |
if (idx == 0) { |
774 |
RETURN ( nil ) |
|
775 |
} |
|
776 |
} |
|
159 | 777 |
if ((idx >= 0) && (idx < ninstvars)) { |
1133 | 778 |
__InstPtr(self)->i_instvars[idx] = value; |
159 | 779 |
__STORE(self, value); |
780 |
RETURN ( value ); |
|
781 |
} |
|
1 | 782 |
} |
783 |
%} |
|
784 |
. |
|
785 |
index isInteger ifFalse:[ |
|
159 | 786 |
^ self indexNotInteger |
1 | 787 |
]. |
159 | 788 |
^ self subscriptBoundsError:index |
359 | 789 |
! |
790 |
||
791 |
instVarNamed:name |
|
792 |
"return a non-indexed instance variables value by name; |
|
793 |
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
|
794 |
- 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
|
795 |
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
|
796 |
parsed ad runtime)" |
359 | 797 |
|
798 |
^ 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
|
799 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
800 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
801 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
802 |
|p| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
803 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
804 |
p := Point x:10 y:20. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
805 |
p instVarNamed:'x' |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
806 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
807 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
808 |
"Modified: 19.4.1996 / 11:12:39 / cg" |
359 | 809 |
! |
810 |
||
1528
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
811 |
instVarNamed:name ifAbsent:exceptionBlock |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
812 |
"return a non-indexed instance variables value by name, |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
813 |
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
|
814 |
peeking into an object this way is not very object oriented |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
815 |
- 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
|
816 |
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
|
817 |
parsed ad runtime)" |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
818 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
819 |
|idx| |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
820 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
821 |
idx := self class instVarOffsetOf:name. |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
822 |
idx isNil ifTrue:[^ exceptionBlock value]. |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
823 |
^ self instVarAt:idx |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
824 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
825 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
826 |
" |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
827 |
|p| |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
828 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
829 |
p := Point x:10 y:20. |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
830 |
p instVarNamed:'x' |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
831 |
" |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
832 |
|
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
833 |
"Created: 6.7.1996 / 23:02:49 / cg" |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
834 |
"Modified: 6.7.1996 / 23:03:41 / cg" |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
835 |
! |
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
836 |
|
359 | 837 |
instVarNamed:name put:value |
838 |
"set a non-indexed instance variable by name; |
|
839 |
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
|
840 |
- 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
|
841 |
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
|
842 |
parsed ad runtime)" |
359 | 843 |
|
844 |
^ 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
|
845 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
846 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
847 |
|p| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
848 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
849 |
p := Point x:10 y:20. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
850 |
p instVarNamed:'x' put:30. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
851 |
p |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
852 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
853 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
854 |
"Modified: 19.4.1996 / 11:12:49 / cg" |
1 | 855 |
! ! |
856 |
||
783 | 857 |
!Object methodsFor:'binary storage'! |
858 |
||
859 |
hasSpecialBinaryRepresentation |
|
860 |
"return true, if the receiver has a special binary representation; |
|
861 |
default here is false, but can be redefined in class which provide |
|
862 |
their own storeBinary/readBinary methods. |
|
863 |
||
864 |
Normal user classes should not use this, it is meant as a hook for |
|
865 |
special classes such as True, False, UndefinedObject or SmallInteger. |
|
866 |
||
867 |
If your instances should be stored in a special way, see |
|
868 |
#representBinaryOn: and #readBinaryContentsFromdata:manager:." |
|
869 |
||
870 |
^ false |
|
1 | 871 |
! |
872 |
||
783 | 873 |
readBinaryContentsFrom:stream manager:manager |
874 |
"reconstruct the receivers instance variables by reading a binary |
|
875 |
binary representation from stream. |
|
876 |
This is a general implementation, walking over instances |
|
877 |
and loading each recursively using manager. |
|
878 |
Redefined by some classes to read a more compact representations |
|
879 |
(see String, SmallInteger etc). |
|
880 |
||
881 |
Notice, that the object is already recreated as an empty corps |
|
882 |
with instance variables all nil and bit-instances (bytes, words etc.) |
|
883 |
already read and restored. |
|
884 |
||
885 |
Also notice: this method is not called for if a private representation |
|
886 |
has been stored (see representBinaryOn:). |
|
887 |
In that case, #readBinaryContentsFromData:manager: is called, which |
|
888 |
has to be reimplemented in the objects class." |
|
889 |
||
890 |
|size "{ Class: SmallInteger }" |
|
891 |
instvarArray| |
|
892 |
||
893 |
stream next == 1 ifTrue:[ |
|
894 |
"/ |
|
895 |
"/ special representation ... |
|
896 |
"/ |
|
897 |
instvarArray := Array new:(size := stream nextNumber:3). |
|
898 |
1 to:size do:[:i | |
|
899 |
instvarArray basicAt:i put:(manager nextObject) |
|
900 |
]. |
|
901 |
self readBinaryContentsFromData:instvarArray manager:manager. |
|
902 |
^ self |
|
903 |
]. |
|
904 |
||
905 |
"/ |
|
906 |
"/ standard representation |
|
907 |
"/ |
|
908 |
size := self basicSize. |
|
909 |
size ~~ 0 ifTrue:[ |
|
910 |
self class isPointers ifTrue:[ |
|
911 |
1 to:size do:[:i | |
|
912 |
self basicAt:i put:(manager nextObject) |
|
913 |
] |
|
914 |
] |
|
915 |
]. |
|
916 |
size := self class instSize. |
|
917 |
1 to:size do:[:i | |
|
918 |
self instVarAt:i put:(manager nextObject) |
|
919 |
]. |
|
920 |
! |
|
921 |
||
922 |
readBinaryContentsFromData:instvarArray manager:manager |
|
923 |
"reconstruct the receivers instance variables by filling instance |
|
924 |
variables with values from instvarArray. This array contains the instvars |
|
925 |
as specified in #representBinaryOn: when the object was stored. |
|
926 |
It is the receivers responsibility to set its instance variables in the |
|
927 |
same order from that array." |
|
928 |
||
929 |
^ self subclassResponsibility |
|
930 |
||
931 |
"typical implementation (see also comment in #representBinaryOn:) |
|
932 |
(for an object with foo, bar and baz as instance variables, |
|
933 |
which did not store baz and wants baz to be reinitialized to |
|
934 |
some constant string) |
|
935 |
||
936 |
foo := instvarArray at:1. |
|
937 |
bar := instvarArray at:2. |
|
938 |
baz := 'aConstant'. |
|
939 |
" |
|
940 |
! |
|
941 |
||
942 |
representBinaryOn:manager |
|
943 |
"this method is called by the storage manager to ask objects |
|
944 |
if they wish to provide their own binary representation. |
|
945 |
||
946 |
If they want to do so, they should return an array containing all |
|
947 |
instance variables (named & indexed pointer) to be stored. |
|
948 |
If not redefined, this method returns nil which means that all |
|
949 |
instance variables are to be stored. |
|
950 |
||
951 |
It should be redefined in objects which do not want all instance variables |
|
952 |
to be stored (for example: objects which keep references to a view etc.). |
|
953 |
||
954 |
If this is redefined returning non-nil, the corresponding class needs |
|
955 |
a redefined instance method named #readBinaryContentsFromData:manager: |
|
956 |
which has to fill the receivers named (and optionally indexed pointer) |
|
957 |
instance variables with corresponding values from a data array." |
|
958 |
||
959 |
^ nil |
|
960 |
||
961 |
"typical implementation: |
|
962 |
(see also comment in #readBinaryContentsFromData:manager:) |
|
963 |
for an object with foo, bar and baz as instance variables, |
|
964 |
which does not want to store baz: |
|
965 |
||
966 |
representBinaryOn:manager |
|
967 |
|data| |
|
968 |
||
969 |
data := Array new:2. |
|
970 |
data at:1 put:foo. |
|
971 |
data at:2 put:bar. |
|
972 |
^ data |
|
973 |
" |
|
159 | 974 |
! |
975 |
||
783 | 976 |
storeBinaryContentsFromData:instvarArray on:stream manager:manager |
977 |
"store the instvars (both named & indexed pointer) |
|
978 |
as returned by #representBinaryOn:." |
|
979 |
||
980 |
|size "{ Class: SmallInteger }"| |
|
981 |
||
982 |
size := instvarArray size. |
|
983 |
1 to:size do:[:i | |
|
984 |
manager putIdOf:(instvarArray at:i) on:stream |
|
985 |
]. |
|
986 |
! |
|
987 |
||
988 |
storeBinaryContentsOn:stream manager:manager |
|
989 |
"store the receivers instance variables in a binary representation |
|
990 |
on a stream using manager. |
|
991 |
This is a general implementation, walking over instances |
|
992 |
and storing each recursively using manager. |
|
993 |
||
994 |
Notice, that the objects definition and bit-instances (bytes, words etc.) |
|
995 |
are already stored. |
|
996 |
Here, we only have to deal with indexed-pointer and named instance variables. |
|
997 |
||
998 |
Also notice: this method is not called for if a private representation |
|
999 |
has been stored (see representBinaryOn:). |
|
1000 |
In that case, #storeBinaryContentsFromData:manager: is called." |
|
1001 |
||
1002 |
|size "{ Class: SmallInteger }"| |
|
1003 |
||
1004 |
size := self basicSize. |
|
1005 |
size ~~ 0 ifTrue:[ |
|
1006 |
self class isPointers ifTrue:[ |
|
1007 |
1 to:size do:[:i | |
|
1008 |
manager putIdOf:(self basicAt:i) on:stream |
|
1009 |
]. |
|
1010 |
]. |
|
1011 |
]. |
|
1012 |
size := self class instSize. |
|
1013 |
1 to:size do:[:i | |
|
1014 |
manager putIdOf:(self instVarAt:i) on:stream |
|
1015 |
]. |
|
1 | 1016 |
! |
1017 |
||
783 | 1018 |
storeBinaryDefinitionBodyOn:stream manager:manager |
1019 |
"append a binary representation of the receivers body onto stream. |
|
1020 |
This is a general implementation walking over instances storing |
|
1021 |
each recursively as an ID using manager. |
|
1022 |
Can be redefined in subclasses." |
|
1023 |
||
1024 |
|basicSize "{ Class: SmallInteger }" |
|
1025 |
instSize "{ Class: SmallInteger }" |
|
1026 |
myClass specialRep pointers| |
|
1027 |
||
1028 |
myClass := self class. |
|
1029 |
instSize := myClass instSize. |
|
1030 |
||
1031 |
(pointers := myClass isPointers) ifTrue:[ |
|
1032 |
"/ |
|
1033 |
"/ inst size not needed - if you uncomment the line below, |
|
1034 |
"/ also uncomment the corresponding line in |
|
1035 |
"/ Object>>binaryDefinitionFrom:manager: |
|
1036 |
"/ |
|
1037 |
"/ stream nextPut:instSize. "mhmh this limits us to 255 named instvars" |
|
1038 |
||
1039 |
myClass isVariable ifTrue:[ |
|
1040 |
stream nextNumber:3 put:(basicSize := self basicSize) |
|
1041 |
] ifFalse:[ |
|
1042 |
basicSize := 0 |
|
1043 |
]. |
|
1044 |
] ifFalse: [ |
|
1045 |
stream nextNumber:4 put:(basicSize := self basicSize). |
|
1046 |
myClass isBytes ifTrue:[ |
|
1047 |
1 to:basicSize do:[:i | |
|
1048 |
stream nextPut:(self basicAt:i) |
|
1049 |
] |
|
1050 |
] ifFalse:[ |
|
1051 |
myClass isWords ifTrue:[ |
|
1052 |
1 to:basicSize do:[:i | |
|
1053 |
stream nextNumber:2 put:(self basicAt: i) |
|
1054 |
] |
|
1055 |
] ifFalse:[ |
|
1056 |
myClass isLongs ifTrue:[ |
|
1057 |
1 to:basicSize do:[:i | |
|
1058 |
stream nextNumber:4 put:(self basicAt: i) |
|
1059 |
] |
|
1060 |
] ifFalse:[ |
|
1061 |
myClass isFloats ifTrue:[ |
|
1062 |
"could do it in one big write on machines which use IEEE floats ..." |
|
1063 |
1 to:basicSize do:[:i | |
|
1064 |
Float storeBinaryIEEESingle:(self basicAt:i) on:stream |
|
1065 |
] |
|
1066 |
] ifFalse:[ |
|
1067 |
myClass isDoubles ifTrue:[ |
|
1068 |
"could do it in one big write on machines which use IEEE doubles ..." |
|
1069 |
1 to:basicSize do:[:i | |
|
1070 |
Float storeBinaryIEEEDouble:(self basicAt:i) on:stream |
|
1071 |
] |
|
1072 |
] ifFalse:[ |
|
1073 |
"/ should never be reached ... |
|
1074 |
1 to:basicSize do:[:i | |
|
1075 |
manager putIdOf:(self basicAt:i) on:stream |
|
1076 |
] |
|
1077 |
] |
|
1078 |
] |
|
1079 |
] |
|
1080 |
] |
|
1081 |
]. |
|
1082 |
]. |
|
1083 |
||
1084 |
(pointers or:[instSize ~~ 0]) ifTrue:[ |
|
1085 |
specialRep := self representBinaryOn:manager. |
|
1086 |
specialRep notNil ifTrue:[ |
|
1087 |
stream nextPut:1. "/ means: private representation follows |
|
1088 |
stream nextNumber:3 put:(specialRep basicSize). |
|
1089 |
self storeBinaryContentsFromData:specialRep on:stream manager:manager |
|
1090 |
] ifFalse:[ |
|
1091 |
stream nextPut:0. "/ means: full representation follows |
|
1092 |
self storeBinaryContentsOn:stream manager:manager |
|
159 | 1093 |
] |
1 | 1094 |
] |
783 | 1095 |
|
1096 |
"Modified: 25.10.1995 / 14:00:51 / cg" |
|
1 | 1097 |
! |
1098 |
||
783 | 1099 |
storeBinaryDefinitionOn:stream manager:manager |
1100 |
"append a binary representation of the receiver onto stream. |
|
1260 | 1101 |
This is an internal interface for binary storage mechanism. |
783 | 1102 |
This method first stores the class, then the body, which is done |
1103 |
in a separate method to allow redefinition of the bodies format. |
|
1104 |
Can be redefined in subclasses to write more compact representations |
|
1105 |
(see String, SmallInteger etc)." |
|
1106 |
||
1107 |
manager putIdOfClass:(self class) on:stream. |
|
1108 |
self storeBinaryDefinitionBodyOn:stream manager:manager |
|
1260 | 1109 |
|
1110 |
"Modified: 23.4.1996 / 09:31:12 / cg" |
|
783 | 1111 |
! |
1112 |
||
1113 |
storeBinaryOn:aStream |
|
1114 |
"Writes a description of the receiver onto aStream, in a way that allows |
|
1115 |
the object's structure to be reconstructed from the stream's contents" |
|
1116 |
||
1117 |
BinaryOutputManager store:self on:aStream |
|
899 | 1118 |
|
1119 |
" |
|
1120 |
|a s1 s2| |
|
1121 |
||
1122 |
s1 := 'hello'. |
|
1123 |
s2 := 'world'. |
|
1124 |
a := Array new:5. |
|
1125 |
a at:1 put:s1. |
|
1126 |
a at:2 put:s2. |
|
1127 |
a at:3 put:s1. |
|
1128 |
a at:4 put:s2. |
|
1129 |
a storeBinaryOn:'test.boss' |
|
1130 |
" |
|
1131 |
||
1132 |
" |
|
1133 |
(BinaryObjectStorage onOld:'test.boss' asFilename readStream) |
|
1134 |
next |
|
1135 |
inspect |
|
1136 |
" |
|
783 | 1137 |
! |
1138 |
||
1139 |
storeBinaryOn:stream manager:manager |
|
1140 |
"append a binary representation of the receiver onto stream." |
|
1141 |
||
1142 |
manager putIdOf:self on:stream |
|
1 | 1143 |
! ! |
1144 |
||
1145 |
!Object methodsFor:'change and update'! |
|
1146 |
||
783 | 1147 |
broadcast:aSelectorSymbol |
1148 |
"send a message with selector aSelectorSymbol to all my dependents" |
|
1149 |
||
1150 |
self dependentsDo:[:dependent | |
|
1151 |
dependent perform:aSelectorSymbol |
|
1152 |
] |
|
1153 |
! |
|
1154 |
||
1155 |
broadcast:aSelectorSymbol with:anArgument |
|
1156 |
"send a message with selector aSelectorSymbol with an additional |
|
1157 |
argument anArgument to all my dependents." |
|
1158 |
||
1159 |
self dependentsDo:[:dependent | |
|
1160 |
dependent perform:aSelectorSymbol with:anArgument |
|
1161 |
] |
|
1162 |
! |
|
1163 |
||
159 | 1164 |
changeRequest |
1165 |
"the receiver wants to change - check if all dependents |
|
1166 |
grant the request, and return true if so" |
|
1167 |
||
1168 |
self dependentsDo:[:dependent | |
|
1169 |
dependent updateRequest ifFalse:[^ false]. |
|
1170 |
]. |
|
1171 |
^ true |
|
1172 |
! |
|
1173 |
||
1174 |
changeRequest:aParameter |
|
1175 |
"the receiver wants to change - check if all dependents |
|
1176 |
grant the request, and return true if so" |
|
1177 |
||
1178 |
self dependentsDo:[:dependent | |
|
1179 |
(dependent updateRequest:aParameter) ifFalse:[^ false]. |
|
1180 |
]. |
|
1181 |
^ true |
|
1182 |
! |
|
1183 |
||
783 | 1184 |
changeRequest:aParameter from:anObject |
1185 |
"the receiver wants to change - check if all dependents |
|
1186 |
except anObject grant the request, and return true if so. |
|
1187 |
The argument anObject is typically going to be the one who is |
|
1188 |
about to send the change request." |
|
1189 |
||
1190 |
self dependentsDo:[:dependent | |
|
1191 |
dependent == anObject ifFalse:[ |
|
1192 |
(dependent updateRequest:aParameter) ifFalse:[^ false]. |
|
1193 |
] |
|
1194 |
]. |
|
1195 |
^ true |
|
1196 |
! |
|
1197 |
||
159 | 1198 |
changeRequestFrom:anObject |
1199 |
"the receiver wants to change - check if all dependents |
|
202 | 1200 |
except anObject grant the request, and return true if so. |
1201 |
The argument anObject is typically going to be the one who is |
|
1202 |
about to send the change request." |
|
159 | 1203 |
|
1204 |
self dependentsDo:[:dependent | |
|
1205 |
dependent == anObject ifFalse:[ |
|
1206 |
(dependent updateRequest) ifFalse:[^ false]. |
|
1207 |
] |
|
1208 |
]. |
|
1209 |
^ true |
|
1210 |
! |
|
1211 |
||
1 | 1212 |
changed |
1213 |
"notify all dependents that the receiver has changed. |
|
71 | 1214 |
Each dependent gets a '#update:'-message with the original |
1215 |
receiver as argument." |
|
1 | 1216 |
|
159 | 1217 |
self changed:nil |
1 | 1218 |
! |
1219 |
||
1220 |
changed:aParameter |
|
1221 |
"notify all dependents that the receiver has changed somehow. |
|
71 | 1222 |
Each dependent gets a '#update:'-message with aParameter |
1223 |
as argument." |
|
1 | 1224 |
|
159 | 1225 |
self changed:aParameter with:nil |
1 | 1226 |
! |
1227 |
||
71 | 1228 |
changed:aParameter with:anArgument |
1 | 1229 |
"notify all dependents that the receiver has changed somehow. |
159 | 1230 |
Each dependent gets a '#update:with:from:'-message, with aParameter |
71 | 1231 |
and anArgument as arguments." |
1 | 1232 |
|
159 | 1233 |
self dependentsDo:[:dependent | |
1234 |
dependent update:aParameter with:anArgument from:self |
|
1 | 1235 |
] |
1236 |
! |
|
1237 |
||
1238 |
update:aParameter |
|
71 | 1239 |
"the message is sent to a dependent, when one of the objects |
1240 |
on whom the receiver depends, has changed. The argument aParameter |
|
1241 |
is either the changed object or the argument to the #changed: message. |
|
1242 |
||
1243 |
Default behavior here is to do nothing" |
|
1 | 1244 |
|
1245 |
^ self |
|
1246 |
! |
|
1247 |
||
1248 |
update:aParameter with:anArgument |
|
1249 |
"dependent is notified of some change - |
|
159 | 1250 |
Default is to try update:" |
1 | 1251 |
|
1252 |
^ self update:aParameter |
|
1253 |
! |
|
1254 |
||
1255 |
update:aParameter with:anArgument from:sender |
|
1256 |
"dependent is notified of some change - |
|
159 | 1257 |
Default is to try update:with:" |
1 | 1258 |
|
1259 |
^ self update:aParameter with:anArgument |
|
159 | 1260 |
! |
1261 |
||
1262 |
updateRequest |
|
1263 |
"return true, if an update request is granted. |
|
1264 |
Default here is to grant updates - may be used |
|
1265 |
to lock updates if someone is making other changes |
|
202 | 1266 |
from within an update. Or if someone has locked its |
1267 |
state and does not want others to change things. |
|
1268 |
However, these dependents must all honor the |
|
1269 |
changeRequest - ifTrue - change protocol. I.e. they |
|
1270 |
must first ask all others via changeRequest, and only do the change |
|
1271 |
it returns true. The others must decide in updateRequest and |
|
1272 |
return true if they think a change is ok." |
|
159 | 1273 |
|
1274 |
^ true |
|
1275 |
! |
|
1276 |
||
1277 |
updateRequest:aSymbol |
|
1278 |
"return true, if an update request is granted. |
|
1279 |
Default here a simple updateRequest" |
|
1280 |
||
1281 |
^ self updateRequest |
|
1 | 1282 |
! ! |
1283 |
||
783 | 1284 |
!Object methodsFor:'cleanup'! |
1285 |
||
1286 |
lowSpaceCleanup |
|
1287 |
"ignored here - redefined in some classes to |
|
1288 |
cleanup in low-memory situations" |
|
1289 |
||
1290 |
^ self |
|
1291 |
! ! |
|
1292 |
||
1293 |
!Object methodsFor:'comparing'! |
|
1294 |
||
1295 |
= anObject |
|
1296 |
"return true, if the receiver and the arg have the same structure" |
|
1297 |
||
1298 |
^ self == anObject |
|
1299 |
! |
|
1300 |
||
1301 |
== anObject |
|
1302 |
"return true, if the receiver and the arg are the same object" |
|
1303 |
||
1304 |
%{ /* NOCONTEXT */ |
|
1305 |
||
1306 |
RETURN ( (self == anObject) ? true : false ); |
|
1307 |
%} |
|
1308 |
! |
|
1309 |
||
1310 |
hash |
|
1311 |
"return an Integer useful as a hash key for the receiver. |
|
1312 |
This hash should return same values for objects with same |
|
1313 |
contents (i.e. use this to hash on structure)" |
|
1314 |
||
1315 |
^ self identityHash |
|
1316 |
! |
|
1317 |
||
1318 |
identityHash |
|
1319 |
"return an Integer useful as a hash key for the receiver. |
|
1320 |
This hash should return same values for the same object (i.e. use |
|
1321 |
this to hash on identity of objects). |
|
1322 |
||
1323 |
We cannot use the Objects address (as other smalltalks do) since |
|
1324 |
no object-table exists and the hashval must not change when objects |
|
1325 |
are moved by the collector. Therefore we assign each object a unique |
|
1326 |
Id in the object header itself as its hashed upon. |
|
1327 |
(luckily we have 11 bits spare to do this - unluckily its only 11 bits). |
|
1328 |
Time will show, if 11 bits are enough; if not, another entry in the |
|
1329 |
object header will be needed, adding 4 bytes to every object. Alternatively, |
|
1330 |
hashed-upon objects could add an instvar containing the hash value." |
|
1331 |
||
1332 |
%{ /* NOCONTEXT */ |
|
1333 |
||
1334 |
REGISTER unsigned hash; |
|
1335 |
static unsigned nextHash = 0; |
|
1336 |
OBJ cls; |
|
1337 |
||
1338 |
if (__isNonNilObject(self)) { |
|
1339 |
hash = __GET_HASH(self); |
|
1340 |
if (hash == 0) { |
|
1341 |
hash = nextHash++; |
|
1342 |
__SET_HASH(self, hash); |
|
1343 |
hash = __GET_HASH(self); |
|
1344 |
if (hash == 0) { |
|
1345 |
hash = nextHash++; |
|
1346 |
__SET_HASH(self, hash); |
|
1347 |
hash = __GET_HASH(self); |
|
1348 |
} |
|
1349 |
} |
|
1350 |
||
1351 |
/* |
|
1352 |
* now, we got 11 bits for hashing; |
|
1353 |
* make it as large as possible; since most hashers use the returned |
|
1354 |
* key and take it modulu some prime number, this will allow for |
|
1355 |
* better distribution (i.e. bigger empty spaces) in hashed collection. |
|
1356 |
* we could shift it up to the 30 bit limit - not making it negative. |
|
1357 |
*/ |
|
1358 |
RETURN ( __MKSMALLINT(hash << __HASH_SHIFT__) ); |
|
1359 |
} |
|
1360 |
%}. |
|
1361 |
^ 0 "never reached, since redefined in UndefinedObject and SmallInteger" |
|
1362 |
! |
|
1363 |
||
1364 |
isNil |
|
1365 |
"return true, if the receiver is nil" |
|
1366 |
||
1367 |
^ false |
|
1368 |
! |
|
1369 |
||
1370 |
notNil |
|
1371 |
"return true, if the receiver is not nil" |
|
1372 |
||
1373 |
^ true |
|
1374 |
! |
|
1375 |
||
1376 |
~= anObject |
|
1377 |
"return true, if the receiver and the arg do not have the same structure" |
|
1378 |
||
1379 |
^ (self = anObject) not |
|
1380 |
! |
|
1381 |
||
1382 |
~~ anObject |
|
1383 |
"return true, if the receiver and the arg are not the same object" |
|
1384 |
||
1385 |
%{ /* NOCONTEXT */ |
|
1386 |
||
1387 |
RETURN ( (self == anObject) ? false : true ); |
|
1388 |
%} |
|
1389 |
! ! |
|
1390 |
||
1391 |
!Object methodsFor:'converting'! |
|
1392 |
||
1393 |
asValue |
|
1394 |
"return a valueHolder for for the receiver" |
|
1395 |
||
1396 |
^ ValueHolder with:self |
|
1397 |
! ! |
|
1398 |
||
1399 |
!Object methodsFor:'copying'! |
|
1400 |
||
1401 |
copy |
|
1402 |
"return a copy of the receiver - defaults to shallowcopy here. |
|
1403 |
Notice, that copy does not copy dependents." |
|
1404 |
||
1405 |
^ self shallowCopy postCopy |
|
1406 |
! |
|
1407 |
||
1408 |
deepCopy |
|
1409 |
"return a copy of the object with all subobjects also copied. |
|
1410 |
This method DOES handle cycles/self-refs; however the receivers |
|
1411 |
class is not copied (to avoid the 'total' copy). |
|
1412 |
This deepCopy is a bit slower than the old (unsecure) one, since it |
|
1413 |
keeps track of already copied objects. If you are sure, that your |
|
1129 | 1414 |
copied object does not include duplicates (or you do not care) and |
783 | 1415 |
no cycles, you can use the old simpleDeepCopy, which avoids this overhead, |
1416 |
but may run into trouble. |
|
1417 |
Notice, that copy does not copy dependents." |
|
1418 |
||
1419 |
^ self deepCopyUsing:(IdentityDictionary new) |
|
1420 |
||
1421 |
"an example which is not handled by the old deepCopy: |
|
1422 |
||
1423 |
|a| |
|
1424 |
a := Array new:3. |
|
1425 |
a at:3 put:a. |
|
1426 |
a deepCopy inspect |
|
1427 |
" |
|
1129 | 1428 |
|
1429 |
"Modified: 27.3.1996 / 16:31:20 / stefan" |
|
783 | 1430 |
! |
1431 |
||
1432 |
deepCopyError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1433 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1434 |
|
783 | 1435 |
"raise a signal, that deepCopy is not allowed for this object" |
1436 |
||
1437 |
^ DeepCopyErrorSignal raise |
|
1438 |
! |
|
1439 |
||
1440 |
deepCopyUsing:aDictionary |
|
1441 |
"a helper for deepCopy; return a copy of the object with |
|
1442 |
all subobjects also copied. If the to-be-copied object is in the dictionary, |
|
1443 |
use the value found there. The class of the receiver is not copied. |
|
1444 |
This method DOES handle cycles/self references." |
|
1445 |
||
1446 |
|myClass aCopy |
|
1447 |
sz "{ Class: SmallInteger }" |
|
1448 |
iOrig iCopy| |
|
1449 |
||
1450 |
myClass := self class. |
|
1451 |
myClass isVariable ifTrue:[ |
|
1452 |
sz := self basicSize. |
|
1453 |
aCopy := myClass basicNew:sz. |
|
1454 |
] ifFalse:[ |
|
1455 |
sz := 0. |
|
1456 |
aCopy := myClass basicNew |
|
1457 |
]. |
|
1458 |
aCopy setHashFrom:self. |
|
1459 |
||
1460 |
aDictionary at:self put:aCopy. |
|
143 | 1461 |
|
1462 |
" |
|
783 | 1463 |
copy indexed instvars - if any |
1464 |
" |
|
1465 |
sz ~~ 0 ifTrue:[ |
|
1466 |
myClass isBits ifTrue:[ |
|
1467 |
"block-copy indexed instvars" |
|
1468 |
aCopy replaceFrom:1 to:sz with:self startingAt:1 |
|
1469 |
] ifFalse:[ |
|
1470 |
"individual deep copy the indexed variables" |
|
1471 |
1 to:sz do:[:i | |
|
1472 |
iOrig := self basicAt:i. |
|
1473 |
iOrig notNil ifTrue:[ |
|
1474 |
(aDictionary includesKey:iOrig) ifTrue:[ |
|
1475 |
iCopy := aDictionary at:iOrig |
|
1476 |
] ifFalse:[ |
|
1477 |
iCopy := iOrig deepCopyUsing:aDictionary. |
|
1478 |
]. |
|
1479 |
aCopy basicAt:i put:iCopy |
|
1480 |
] |
|
1481 |
] |
|
1482 |
] |
|
1483 |
]. |
|
1484 |
||
1485 |
" |
|
1486 |
copy the instance variables |
|
1487 |
" |
|
1488 |
sz := myClass instSize. |
|
1489 |
sz ~~ 0 ifTrue:[ |
|
1490 |
1 to:sz do:[:i | |
|
1491 |
iOrig := self instVarAt:i. |
|
1492 |
iOrig notNil ifTrue:[ |
|
1493 |
(aDictionary includesKey:iOrig) ifTrue:[ |
|
1494 |
iCopy := aDictionary at:iOrig |
|
1495 |
] ifFalse:[ |
|
1496 |
iCopy := iOrig deepCopyUsing:aDictionary. |
|
1497 |
]. |
|
1498 |
aCopy instVarAt:i put:iCopy |
|
1499 |
] |
|
1500 |
]. |
|
1501 |
]. |
|
1502 |
||
1503 |
^ aCopy |
|
1504 |
! |
|
1505 |
||
1506 |
postCopy |
|
1507 |
"this is for compatibility with ST-80 code, which uses postCopy for |
|
1508 |
cleanup after copying, while ST/X passes the original in postCopyFrom: |
|
1509 |
(see there)" |
|
1510 |
||
1511 |
^ self |
|
1512 |
! |
|
1513 |
||
1514 |
postCopyFrom:original |
|
1515 |
"sent to a freshly deep-copied object to give it a chance to adjust things. |
|
1516 |
(a font could flush its device-handle for example). |
|
1517 |
Notice, that for Sets/Dicts etc. a rehash is not needed, since the deepCopy |
|
1518 |
will have the same hash key as the receiver (as long as ST/X provides the |
|
1519 |
setHash: functionality)." |
|
1520 |
||
1521 |
"for ST-80 compatibility, we try postCopy here ..." |
|
1522 |
^ self postCopy |
|
1523 |
! |
|
1524 |
||
1525 |
setHashFrom:anObject |
|
1526 |
"set my identity-hash key to be the same as anObjects hash key. |
|
1527 |
This is an ST/X speciality, which is NOT available in other (especially OT based) |
|
1528 |
Smalltalks, and may not be available in future ST/X versions. |
|
1529 |
DO NEVER use this for normal application code." |
|
1530 |
||
1531 |
%{ /* NOCONTEXT */ |
|
1532 |
||
1533 |
REGISTER unsigned h; |
|
1534 |
||
1535 |
if (__isNonNilObject(self) && __isNonNilObject(anObject)) { |
|
1536 |
h = __GET_HASH(anObject); |
|
1537 |
__SET_HASH(self, h); |
|
1538 |
RETURN (self); |
|
1539 |
} |
|
1540 |
%} |
|
1541 |
. |
|
1542 |
self primitiveFailed "neither receiver not arg may be nil or SmallInteger" |
|
1543 |
! |
|
1544 |
||
1545 |
shallowCopy |
|
1546 |
"return a copy of the object with shared subobjects (a shallow copy) |
|
1547 |
i.e. the copy shares referenced instvars with its original." |
|
1548 |
||
1549 |
|myClass aCopy |
|
1550 |
sz "{ Class: SmallInteger }" | |
|
1551 |
||
1552 |
myClass := self class. |
|
1553 |
myClass isVariable ifTrue:[ |
|
1554 |
sz := self basicSize. |
|
1555 |
aCopy := myClass basicNew:sz. |
|
1556 |
||
1557 |
"copy the indexed variables" |
|
1558 |
1 to:sz do:[:i | |
|
1559 |
aCopy basicAt:i put:(self basicAt:i) |
|
1560 |
] |
|
1561 |
] ifFalse:[ |
|
1562 |
aCopy := myClass basicNew |
|
1563 |
]. |
|
1564 |
||
1565 |
"copy the instance variables" |
|
1566 |
sz := myClass instSize. |
|
1567 |
1 to:sz do:[:i | |
|
1568 |
aCopy instVarAt:i put:(self instVarAt:i) |
|
1569 |
]. |
|
1570 |
||
1571 |
^ aCopy |
|
1572 |
! |
|
1573 |
||
1574 |
shallowCopyForFinalization |
|
1575 |
"this is used to aquire a copy to be used for finalization - |
|
1576 |
(the copy will get a dispose-notification; see the documentation in the Registry class) |
|
1577 |
This method can be redefined for more efficient copying - especially for large objects." |
|
1578 |
||
1579 |
^ self shallowCopy |
|
1580 |
! |
|
1581 |
||
1582 |
simpleDeepCopy |
|
1583 |
"return a copy of the object with all subobjects also copied. |
|
1584 |
This method does NOT handle cycles - but is included to allow this |
|
1585 |
slightly faster copy in situations where it is known that |
|
1586 |
no recursive references occur (LargeIntegers for example). |
|
1587 |
NOTICE: you will run into trouble, when trying this with recursive |
|
1588 |
objects (usually recursionInterrupt or memory-alert). |
|
1589 |
This method corresponds to the 'traditional' deepCopy found in |
|
1590 |
the Blue book." |
|
1591 |
||
1592 |
|myClass aCopy |
|
1593 |
sz "{ Class: SmallInteger }" | |
|
1594 |
||
1595 |
myClass := self class. |
|
1596 |
myClass isVariable ifTrue:[ |
|
1597 |
sz := self basicSize. |
|
1598 |
aCopy := myClass basicNew:sz. |
|
1599 |
||
1600 |
"copy the indexed variables" |
|
1601 |
1 to:sz do:[:i | |
|
1602 |
aCopy basicAt:i put:((self basicAt:i) simpleDeepCopy) |
|
1603 |
] |
|
1604 |
] ifFalse:[ |
|
1605 |
aCopy := myClass basicNew |
|
1606 |
]. |
|
1607 |
||
1608 |
"copy the instance variables" |
|
1609 |
sz := myClass instSize. |
|
1610 |
1 to:sz do:[:i | |
|
1611 |
aCopy instVarAt:i put:((self instVarAt:i) simpleDeepCopy) |
|
1612 |
]. |
|
1613 |
||
1614 |
^ aCopy |
|
1615 |
||
1616 |
"a bad example (but ST/X should survive ...)" |
|
1617 |
" |
|
1618 |
|a| |
|
1619 |
a := Array new:3. |
|
1620 |
a at:3 put:a. |
|
1621 |
a simpleDeepCopy |
|
1622 |
" |
|
1623 |
! ! |
|
1624 |
||
1625 |
!Object methodsFor:'debugging'! |
|
1626 |
||
1627 |
basicInspect |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1628 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1629 |
|
783 | 1630 |
"launch an inspector on the receiver. |
1631 |
this method should NOT be redefined in subclasses." |
|
1632 |
||
1633 |
Inspector isNil ifTrue:[ |
|
1417 | 1634 |
" |
1635 |
for systems without GUI |
|
1636 |
" |
|
1637 |
Transcript showCR:'no Inspector' |
|
783 | 1638 |
] ifFalse:[ |
1417 | 1639 |
Inspector openOn:self |
783 | 1640 |
] |
1417 | 1641 |
|
1642 |
"Modified: 18.5.1996 / 15:43:25 / cg" |
|
783 | 1643 |
! |
1644 |
||
1645 |
inspect |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1646 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1647 |
|
783 | 1648 |
"launch an inspector on the receiver. |
1649 |
this method (or better: inspectorClass) can be redefined in subclasses |
|
1650 |
to start special inspectors." |
|
1651 |
||
1652 |
|cls| |
|
1653 |
||
1654 |
cls := self inspectorClass. |
|
1655 |
cls isNil ifTrue:[ |
|
1656 |
^ self basicInspect |
|
1657 |
]. |
|
1658 |
cls openOn:self |
|
1659 |
||
1660 |
" |
|
1661 |
Object new inspect |
|
1662 |
(1 @ 2) inspect |
|
1663 |
Smalltalk inspect |
|
1664 |
#(1 2 3) asOrderedCollection inspect |
|
1665 |
(Color red) inspect |
|
1666 |
(Image fromFile:'bitmaps/garfield.gif') inspect |
|
143 | 1667 |
" |
71 | 1668 |
! |
1669 |
||
783 | 1670 |
inspectorClass |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1671 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1672 |
|
783 | 1673 |
"return the class to use for inspect. |
1674 |
Can (should) be redefined in classes for which a better inspector is available" |
|
1675 |
||
1676 |
^ Inspector |
|
1677 |
! |
|
1678 |
||
1679 |
mustBeKindOf:aClass |
|
1680 |
"for compatibility & debugging support: |
|
1681 |
check if the receiver isKindOf:aClass and raise an error if not. |
|
1682 |
Notice: |
|
1683 |
it is VERY questionable, if it makes sense to add manual |
|
1684 |
type checks to a dynamically typed language like smalltalk. |
|
1685 |
It will, at least, slow down performance, |
|
1686 |
make your code less reusable and clutter your code with stupid sends |
|
1687 |
of this selector. Also, read the comment in isKindOf:, regarding the |
|
1688 |
use of isXXX check methods. |
|
1689 |
You see: The author does not like this at all ..." |
|
1690 |
||
1691 |
(self isKindOf:aClass) ifFalse:[ |
|
1692 |
self error:'argument is not of expected type' |
|
1693 |
] |
|
1694 |
! |
|
1695 |
||
1696 |
obsoleteMethodWarning |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1697 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1698 |
|
783 | 1699 |
"in methods which are going to be obsoleted, a self send to |
1700 |
this method is used to tell programmers that a method is |
|
1701 |
used which is going to be removed in later ST/X versions. |
|
1702 |
Find all methods which will be obsolete soon by looking at senders |
|
1703 |
of this message. |
|
1704 |
Hopefully, this warning message is annoying enough for you to |
|
1705 |
change the code ... ;-)" |
|
1706 |
||
1707 |
self obsoleteMethodWarning:nil from:thisContext sender |
|
1708 |
! |
|
1709 |
||
1710 |
obsoleteMethodWarning:message |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1711 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1712 |
|
783 | 1713 |
"in methods which are going to be obsoleted, a self send to |
1714 |
this method is used to tell programmers that a method is |
|
1715 |
used which is going to be removed in later ST/X versions. |
|
1716 |
Find all methods which will be obsolete soon by looking at senders |
|
1717 |
of this message. |
|
1718 |
Hopefully, this warning message is annoying enough for you to |
|
1719 |
change the code ... ;-)" |
|
1720 |
||
1721 |
self obsoleteMethodWarning:message from:thisContext sender |
|
1722 |
! |
|
1723 |
||
1724 |
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
|
1725 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
1726 |
|
783 | 1727 |
"in methods which are going to be obsoleted, a self-send to |
1728 |
this method is used to tell programmers that a method is |
|
1729 |
used which is going to be removed in later ST/X versions. |
|
1730 |
Find all methods which will be obsolete soon by looking at senders |
|
1731 |
of this message. |
|
1732 |
Hopefully, this warning message is annoying enough for you to |
|
1733 |
change the code ... ;-)" |
|
1734 |
||
1735 |
|spec| |
|
1736 |
||
1737 |
spec := aContext methodPrintString. |
|
1738 |
('WARNING: the ''' , spec , ''' method is obsolete.') errorPrintNL. |
|
1739 |
(' And may not be present in future ST/X versions.') errorPrintNL. |
|
1740 |
(' called from ' , aContext sender printString) errorPrintNL. |
|
1741 |
message notNil ifTrue:[ |
|
1742 |
'------> ' errorPrint. message errorPrintNL |
|
1743 |
] |
|
1744 |
||
1745 |
" |
|
1746 |
Object obsoleteMethodWarning:'foo' from:thisContext sender sender |
|
1747 |
" |
|
1748 |
! ! |
|
1749 |
||
1750 |
!Object methodsFor:'dependents access'! |
|
1751 |
||
1752 |
addDependent:anObject |
|
1753 |
"make the argument, anObject be a dependent of the receiver" |
|
1754 |
||
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1755 |
|wasBlocked| |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1756 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1757 |
"/ 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
|
1758 |
"/ is possibly accessed from multiple threads. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1759 |
"/ 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
|
1760 |
"/ faster execution. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1761 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1762 |
wasBlocked := OperatingSystem blockInterrupts. |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1763 |
[ |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1764 |
|deps dep| |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1765 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1766 |
deps := self dependents. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1767 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1768 |
"/ 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
|
1769 |
"/ 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
|
1770 |
"/ 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
|
1771 |
"/ added. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1772 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1773 |
deps isNil ifTrue:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1774 |
self dependents:(WeakArray with:anObject) |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1775 |
] ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1776 |
deps class == WeakArray ifTrue:[ |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1777 |
dep := deps at:1. |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1778 |
dep ~~ anObject ifTrue:[ |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1779 |
self dependents:(WeakIdentitySet with:dep with:anObject) |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1780 |
] |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1781 |
] ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1782 |
deps add:anObject |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1783 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1784 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1785 |
] valueNowOrOnUnwindDo:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1786 |
wasBlocked ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1787 |
OperatingSystem unblockInterrupts |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1788 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1789 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1790 |
|
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1791 |
"Modified: 1.8.1996 / 14:21:20 / cg" |
783 | 1792 |
! |
1793 |
||
1794 |
dependents |
|
1795 |
"return a Collection of dependents - nil if there is none. |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1796 |
The default implementation here uses a global WeakDictionary to store |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1797 |
dependents |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1798 |
This may be too slow for high frequency change&update, |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1799 |
therefore, some classes (Model) redefine this for better performance. |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1800 |
Notice the mentioning of a WeakDictionary - read the classes documentation." |
783 | 1801 |
|
1802 |
^ Dependencies at:self ifAbsent:[nil] |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1803 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1804 |
"Modified: 19.4.1996 / 12:36:46 / cg" |
783 | 1805 |
! |
1806 |
||
1807 |
dependents:aCollection |
|
1808 |
"set the collection of dependents. |
|
1809 |
The default implementation here uses a global Dictionary to store |
|
1810 |
dependents which may be too slow for high frequency change&update. |
|
1811 |
Therefore, some classes (Model) redefine this for better performance." |
|
1812 |
||
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1813 |
|wasBlocked| |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1814 |
|
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1815 |
"/ 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
|
1816 |
"/ 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
|
1817 |
"/ Used to use #valueUninterruptably here; inlined that code for slightly |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1818 |
"/ faster execution. |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1819 |
|
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1820 |
wasBlocked := OperatingSystem blockInterrupts. |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1821 |
[ |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1822 |
(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
|
1823 |
Dependencies removeKey:self ifAbsent:[] |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1824 |
] ifFalse:[ |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1825 |
Dependencies at:self put:aCollection |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1826 |
] |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1827 |
] valueNowOrOnUnwindDo:[ |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1828 |
wasBlocked ifFalse:[ |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1829 |
OperatingSystem unblockInterrupts |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1830 |
] |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1831 |
] |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1832 |
|
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1833 |
"Modified: 1.8.1996 / 14:16:41 / cg" |
783 | 1834 |
! |
1835 |
||
1836 |
dependentsDo:aBlock |
|
1837 |
"evaluate aBlock for all of my dependents" |
|
1838 |
||
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1839 |
|deps nwDeps| |
783 | 1840 |
|
1841 |
deps := self dependents. |
|
1842 |
deps notNil ifTrue:[ |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1843 |
deps do:aBlock |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1844 |
]. |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1845 |
nwDeps := self nonWeakDependents. |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1846 |
(nwDeps notNil and:[nwDeps ~~ deps]) ifTrue:[ |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1847 |
nwDeps do:aBlock |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1848 |
]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1849 |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1850 |
"Modified: 19.4.1996 / 12:35:54 / cg" |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1851 |
! |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
1852 |
|
783 | 1853 |
release |
1854 |
"remove all dependencies from the receiver" |
|
1855 |
||
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1856 |
self dependents:nil. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1857 |
self nonWeakDependents:nil |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1858 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1859 |
"Modified: 19.4.1996 / 10:55:36 / cg" |
783 | 1860 |
! |
1861 |
||
1862 |
removeDependent:anObject |
|
1863 |
"make the argument, anObject be independent of the receiver" |
|
1864 |
||
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1865 |
|wasBlocked| |
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 |
"/ 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
|
1868 |
"/ is possibly accessed from multiple threads. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1869 |
"/ 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
|
1870 |
"/ faster execution. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1871 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1872 |
wasBlocked := OperatingSystem blockInterrupts. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1873 |
[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1874 |
|deps n| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1875 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1876 |
deps := self dependents. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1877 |
deps notNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1878 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1879 |
"/ 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
|
1880 |
"/ 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
|
1881 |
"/ 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
|
1882 |
"/ 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
|
1883 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1884 |
deps class == WeakArray ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1885 |
(deps at:1) == anObject ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1886 |
self dependents:nil |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1887 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1888 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1889 |
deps remove:anObject ifAbsent:[]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1890 |
(n := deps size) == 0 ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1891 |
self dependents:nil |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1892 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1893 |
n == 1 ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1894 |
self dependents:(WeakArray with:(deps first)) |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1895 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1896 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1897 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1898 |
] |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1899 |
] valueNowOrOnUnwindDo:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1900 |
wasBlocked ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1901 |
OperatingSystem unblockInterrupts |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1902 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1903 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1904 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1905 |
"Modified: 19.7.1996 / 12:40:23 / cg" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1906 |
! ! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1907 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1908 |
!Object methodsFor:'dependents access (nonWeak)'! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1909 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1910 |
addNonWeakDependent:anObject |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1911 |
"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
|
1912 |
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
|
1913 |
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
|
1914 |
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
|
1915 |
|
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1916 |
|wasBlocked| |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1917 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1918 |
"/ 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
|
1919 |
"/ is possibly accessed from multiple threads. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1920 |
"/ 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
|
1921 |
"/ faster execution. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1922 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1923 |
wasBlocked := OperatingSystem blockInterrupts. |
863
2c83fe958ca7
change dependencies uninterruptably
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1924 |
[ |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1925 |
|deps dep| |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1926 |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1927 |
deps := self nonWeakDependents. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1928 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1929 |
"/ 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
|
1930 |
"/ 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
|
1931 |
"/ 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
|
1932 |
"/ added. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1933 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1934 |
deps isNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1935 |
self nonWeakDependents:(Array with:anObject) |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1936 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1937 |
deps class == Array ifTrue:[ |
1624
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1938 |
dep := deps at:1. |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1939 |
dep ~~ anObject ifTrue:[ |
50c5849dc9d4
mhmh - care for dependent being already in the array,
Claus Gittinger <cg@exept.de>
parents:
1611
diff
changeset
|
1940 |
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
|
1941 |
] |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1942 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1943 |
deps add:anObject |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1944 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1945 |
] |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1946 |
] valueNowOrOnUnwindDo:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1947 |
wasBlocked ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1948 |
OperatingSystem unblockInterrupts |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1949 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1950 |
] |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1951 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1952 |
"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
|
1953 |
"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
|
1954 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1955 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1956 |
nonWeakDependents |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1957 |
"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
|
1958 |
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
|
1959 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1960 |
NonWeakDependencies isNil ifTrue:[^nil]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1961 |
^ NonWeakDependencies at:self ifAbsent:[nil] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1962 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1963 |
"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
|
1964 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1965 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1966 |
nonWeakDependents:aCollection |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1967 |
"set the collection of nonWeak dependents. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1968 |
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
|
1969 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1970 |
[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1971 |
(aCollection isNil or:[aCollection isEmpty]) ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1972 |
NonWeakDependencies removeKey:self ifAbsent:[] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1973 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1974 |
NonWeakDependencies at:self put:aCollection |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1975 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1976 |
] valueUninterruptably |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1977 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1978 |
"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
|
1979 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1980 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1981 |
removeNonWeakDependent:anObject |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1982 |
"remove a nonWeak dependency from the receiver to the argument, anObject. |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
1983 |
(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
|
1984 |
|
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1985 |
|wasBlocked| |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1986 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1987 |
"/ 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
|
1988 |
"/ is possibly accessed from multiple threads. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1989 |
"/ 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
|
1990 |
"/ faster execution. |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1991 |
|
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
1992 |
wasBlocked := OperatingSystem blockInterrupts. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1993 |
[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1994 |
|deps n| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1995 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1996 |
deps := self nonWeakDependents. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1997 |
deps notNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1998 |
deps class == Array ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1999 |
(deps at:1) == anObject ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2000 |
self nonWeakDependents:nil |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2001 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2002 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2003 |
deps remove:anObject ifAbsent:[]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2004 |
(n := deps size) == 0 ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2005 |
self nonWeakDependents:nil |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2006 |
] ifFalse:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2007 |
n == 1 ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2008 |
self nonWeakDependents:(Array with:(deps first)) |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2009 |
] |
1098
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
2010 |
] |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
2011 |
] |
e8543399e2a0
support aspect-specific interests
Claus Gittinger <cg@exept.de>
parents:
1097
diff
changeset
|
2012 |
] |
1585
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2013 |
] valueNowOrOnUnwindDo:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2014 |
wasBlocked ifFalse:[ |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2015 |
OperatingSystem unblockInterrupts |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2016 |
] |
5cfa7f2586ad
use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
2017 |
] |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2018 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2019 |
"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
|
2020 |
"Modified: 19.7.1996 / 12:42:08 / cg" |
783 | 2021 |
! ! |
2022 |
||
2023 |
!Object methodsFor:'error handling'! |
|
2024 |
||
2025 |
appropriateDebugger:aSelector |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2026 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2027 |
|
783 | 2028 |
"return an appropriate debugger to use. |
2029 |
If there is already a debugger active on the stack, and it is |
|
2030 |
the DebugView, return MiniDebugger (as a last chance) otherwise abort." |
|
2031 |
||
2032 |
|context| |
|
2033 |
||
1678
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2034 |
"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
|
2035 |
|
1684 | 2036 |
[Processor isNil |
2037 |
or:[Processor activeProcessIsSystemProcess]) ifTrue:[ |
|
1678
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2038 |
^ MiniDebugger |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2039 |
]. |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2040 |
|
783 | 2041 |
context := thisContext. |
2042 |
context := context sender. |
|
2043 |
[context notNil] whileTrue:[ |
|
1678
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2044 |
((context receiver class == Debugger) |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2045 |
and:[context selector == aSelector]) ifTrue:[ |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2046 |
"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
|
2047 |
(Debugger == MiniDebugger) ifTrue:[ |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2048 |
"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
|
2049 |
ErrorRecursion ifFalse:[ |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2050 |
Smalltalk fatalAbort:'recursive error ...' |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2051 |
] |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2052 |
]. |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2053 |
MiniDebugger isNil ifTrue:[ |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2054 |
Smalltalk fatalAbort:'no debugger' |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2055 |
]. |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2056 |
|
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2057 |
"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
|
2058 |
lets try MiniDebugger" |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2059 |
^ MiniDebugger |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2060 |
]. |
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2061 |
context := context sender |
71 | 2062 |
]. |
783 | 2063 |
"not within Debugger - no problem" |
2064 |
^ Debugger |
|
1678
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2065 |
|
1c0fc4e322d0
Change #appropriateDebugger: to call Minidebugger when being called by
Stefan Vogel <sv@exept.de>
parents:
1674
diff
changeset
|
2066 |
"Modified: 23.9.1996 / 12:14:52 / stefan" |
783 | 2067 |
! |
2068 |
||
2069 |
doesNotUnderstand:aMessage |
|
2070 |
"this message is sent by the runtime system (VM) when |
|
2071 |
a message is not understood by some object (i.e. there |
|
2072 |
is no method for that selector). The original message has |
|
2073 |
been packed into aMessage (i.e. the receiver, selector and |
|
2074 |
any arguments) and the original receiver is then sent the |
|
2075 |
#doesNotUnderstand: message. |
|
2076 |
Here, we raise another signal which usually enters the debugger. |
|
2077 |
You can of course redefine #doesNotUnderstand: in your classes |
|
1327 | 2078 |
to implement message delegation, |
2079 |
or handle the MessageNotUnderstoodSignal gracefully." |
|
783 | 2080 |
|
2081 |
|sel errorString cls sender| |
|
2082 |
||
2083 |
"/ handle the case of an error during early startup |
|
2084 |
"/ (output streams not yet initialized) |
|
2085 |
"/ |
|
2086 |
Stdout isNil ifTrue:[ |
|
1327 | 2087 |
Smalltalk fatalAbort:'error during init: ' , aMessage selector , ' not understood'. |
783 | 2088 |
]. |
2089 |
||
2090 |
(sel := aMessage selector) isNil ifTrue:[ |
|
1327 | 2091 |
"/ |
2092 |
"/ happens when things go mad, or a method has been |
|
2093 |
"/ called by valueWithReceiver: with a wrong receiver. |
|
2094 |
"/ To avoid later trouble (when concatenating strings), |
|
2095 |
"/ replace the selector by some (nonNil) string |
|
2096 |
"/ |
|
2097 |
sel := '(nil)' |
|
783 | 2098 |
]. |
2099 |
||
2100 |
"/ |
|
2101 |
"/ extract the class that should have implemented the message. |
|
2102 |
"/ (in case of a super-send, this is not the receivers class) |
|
2103 |
"/ |
|
2104 |
sender := thisContext sender. |
|
2105 |
cls := sender searchClass. |
|
2106 |
cls isNil ifTrue:[ |
|
1327 | 2107 |
"it was NOT a super or directed send ..." |
2108 |
cls := self class |
|
783 | 2109 |
]. |
2110 |
||
2111 |
cls notNil ifTrue:[ |
|
1327 | 2112 |
"/ |
2113 |
"/ displayString is better than 'cls name', |
|
2114 |
"/ since it appends (obsolete) for outdated classes. |
|
2115 |
"/ (this happens if you send messages to old instances |
|
2116 |
"/ after changing a classes definition) |
|
2117 |
"/ |
|
2118 |
errorString := cls displayString. |
|
783 | 2119 |
] ifFalse:[ |
1327 | 2120 |
errorString := '(** nil-class **)' |
783 | 2121 |
]. |
2122 |
errorString := errorString , ' does not understand: ' , sel. |
|
2123 |
||
2124 |
"/ |
|
2125 |
"/ this only happens, when YOU play around with my classvars ... |
|
1327 | 2126 |
"/ (or an error occurs during very early startup, when signals are not yet set) |
783 | 2127 |
"/ |
2128 |
MessageNotUnderstoodSignal isNil ifTrue:[ |
|
1674 | 2129 |
^ self |
2130 |
enterDebuggerWithMessage:'oops - MessageNotUnderstoodSignal is gone' |
|
2131 |
on:thisContext. |
|
783 | 2132 |
]. |
2133 |
||
2134 |
"/ |
|
2135 |
"/ thats where we end up normally - raise a signal which (if unhandled) opens a debugger |
|
2136 |
"/ |
|
2137 |
^ MessageNotUnderstoodSignal |
|
1327 | 2138 |
raiseRequestWith:aMessage |
2139 |
errorString:errorString |
|
2140 |
in:sender |
|
2141 |
||
2142 |
"Modified: 3.5.1996 / 11:51:45 / cg" |
|
783 | 2143 |
! |
2144 |
||
2145 |
elementBoundsError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2146 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2147 |
|
1345 | 2148 |
"report an error that badElement is out of bounds |
2149 |
(i.e. cannot be put into that collection). |
|
2150 |
The error is reported by raising the ElementOutOfBoundsSignal exception." |
|
783 | 2151 |
|
2152 |
^ ElementOutOfBoundsSignal raiseIn:thisContext sender |
|
1345 | 2153 |
|
2154 |
"Modified: 8.5.1996 / 09:12:45 / cg" |
|
783 | 2155 |
! |
2156 |
||
2157 |
elementNotCharacter |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2158 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2159 |
|
1345 | 2160 |
"report an error that object to be stored is no Character. |
2161 |
(usually when storing into Strings). |
|
2162 |
The error is reported by raising the ElementOutOfBoundsSignal exception." |
|
783 | 2163 |
|
2164 |
^ ElementOutOfBoundsSignal raiseIn:thisContext sender |
|
1345 | 2165 |
|
2166 |
"Modified: 8.5.1996 / 09:12:49 / cg" |
|
783 | 2167 |
! |
2168 |
||
2169 |
elementNotInteger |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2170 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2171 |
|
1345 | 2172 |
"report an error that object to be stored is not Integer. |
2173 |
(in collections that store integers only). |
|
2174 |
The error is reported by raising the ElementOutOfBoundsSignal exception." |
|
783 | 2175 |
|
2176 |
^ ElementOutOfBoundsSignal raiseIn:thisContext sender |
|
1345 | 2177 |
|
2178 |
"Modified: 8.5.1996 / 09:12:51 / cg" |
|
783 | 2179 |
! |
2180 |
||
2181 |
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
|
2182 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2183 |
|
783 | 2184 |
"enter the debugger with error-message aString" |
2185 |
||
1674 | 2186 |
^ self |
2187 |
enterDebuggerWithMessage:aString |
|
2188 |
on:anException suspendedContext |
|
2189 |
! |
|
2190 |
||
2191 |
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
|
2192 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2193 |
|
783 | 2194 |
"enter the debugger with error-message aString. |
2195 |
The first visible context shown there is aContext |
|
2196 |
(this allows intermediate helpers to hide themselfes from what is |
|
2197 |
presented to the user)" |
|
2198 |
||
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2199 |
|debugger msg| |
71 | 2200 |
|
2201 |
" |
|
783 | 2202 |
if there is no debugger, exit smalltalk |
2203 |
" |
|
2204 |
Debugger isNil ifTrue:[ |
|
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2205 |
msg := 'error: ' , aString. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2206 |
|
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2207 |
Smalltalk isStandAloneApp ifTrue:[ |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2208 |
Dialog notNil ifTrue:[ |
1097 | 2209 |
(Dialog |
2210 |
confirm:msg title:(Smalltalk commandName) |
|
2211 |
yesLabel:'ignore' noLabel:'exit' |
|
2212 |
) ifTrue:[ |
|
1095 | 2213 |
^ AbortSignal raise |
1094
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2214 |
] |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2215 |
]. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2216 |
msg errorPrintNL. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2217 |
OperatingSystem exit:1 |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2218 |
]. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2219 |
msg errorPrintNL. |
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2220 |
Smalltalk fatalAbort:'no Debugger defined' |
783 | 2221 |
]. |
983 | 2222 |
|
783 | 2223 |
" |
2224 |
find an appropriate debugger to use |
|
71 | 2225 |
" |
783 | 2226 |
debugger := self appropriateDebugger:#'enter:withMessage:'. |
2227 |
^ 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
|
2228 |
|
af10927dc0f2
standAlone graphical app gives user a chance to ignore errors
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
2229 |
"Modified: 8.3.1996 / 20:40:48 / cg" |
783 | 2230 |
! |
2231 |
||
2232 |
error |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2233 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2234 |
|
1345 | 2235 |
"report error that an error occured. |
2236 |
The error is reported by raising the ErrorSignal exception." |
|
2237 |
||
2238 |
^ ErrorSignal raiseIn:thisContext sender |
|
2239 |
||
2240 |
"Modified: 8.5.1996 / 09:13:01 / cg" |
|
783 | 2241 |
! |
2242 |
||
2243 |
error:aString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2244 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2245 |
|
1345 | 2246 |
"enter debugger with error-message aString. |
2247 |
The error is reported by raising the ErrorSignal exception." |
|
783 | 2248 |
|
2249 |
^ ErrorSignal raiseRequestWith:#error: |
|
1345 | 2250 |
errorString:aString |
2251 |
in:thisContext sender |
|
2252 |
||
2253 |
"Modified: 8.5.1996 / 09:13:04 / cg" |
|
2254 |
! |
|
2255 |
||
2256 |
error:aString in:aContext |
|
2257 |
"{ Pragma: +optSpace }" |
|
2258 |
||
2259 |
"enter debugger with error-message aString. |
|
2260 |
The error is reported by raising the ErrorSignal exception." |
|
2261 |
||
2262 |
^ ErrorSignal raiseRequestWith:#error: |
|
2263 |
errorString:aString |
|
2264 |
in:aContext |
|
2265 |
||
2266 |
"Created: 8.5.1996 / 09:07:59 / cg" |
|
2267 |
"Modified: 8.5.1996 / 09:13:06 / cg" |
|
783 | 2268 |
! |
2269 |
||
2270 |
errorKeyNotFound:aKey |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2271 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2272 |
|
1345 | 2273 |
"report an error that a key was not found in a collection. |
2274 |
The error is reported by raising the KeyNotFoundSignal exception." |
|
783 | 2275 |
|
2276 |
^ KeyNotFoundSignal raiseRequestWith:aKey in:thisContext sender |
|
1345 | 2277 |
|
2278 |
"Modified: 8.5.1996 / 09:13:08 / cg" |
|
783 | 2279 |
! |
2280 |
||
2281 |
errorNotFound |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2282 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2283 |
|
1345 | 2284 |
"report an error that no element was found in a collection. |
2285 |
The error is reported by raising the NotFoundSignal exception." |
|
783 | 2286 |
|
2287 |
^ NotFoundSignal raiseIn:thisContext sender |
|
1345 | 2288 |
|
2289 |
"Modified: 8.5.1996 / 09:13:11 / cg" |
|
783 | 2290 |
! |
2291 |
||
2292 |
halt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2293 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2294 |
|
1345 | 2295 |
"enter debugger with halt-message. |
2296 |
The error is reported by raising the HaltSignal exception." |
|
783 | 2297 |
|
2298 |
^ HaltSignal raiseIn:thisContext sender. |
|
1345 | 2299 |
|
2300 |
"Modified: 8.5.1996 / 09:12:38 / cg" |
|
783 | 2301 |
! |
2302 |
||
2303 |
halt:aString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2304 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2305 |
|
1345 | 2306 |
"enter debugger with halt-message. |
2307 |
The error is reported by raising the HaltSignal exception." |
|
783 | 2308 |
|
2309 |
^ HaltSignal raiseRequestWith:#halt: |
|
1345 | 2310 |
errorString:aString |
2311 |
in:thisContext sender |
|
2312 |
||
2313 |
"Modified: 8.5.1996 / 09:13:23 / cg" |
|
783 | 2314 |
! |
2315 |
||
2316 |
implementedBySubclass |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2317 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2318 |
|
783 | 2319 |
"this is sent by ST/V code - its the same as #subclassResponsibility" |
2320 |
||
2321 |
^ self subclassResponsibility |
|
2322 |
! |
|
2323 |
||
2324 |
indexNotInteger |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2325 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2326 |
|
1345 | 2327 |
"report an error that index is not an Integer. |
2328 |
(when accessing collections indexed by an integer key). |
|
2329 |
The error is reported by raising the NonIntegerIndexSignal exception." |
|
783 | 2330 |
|
2331 |
^ NonIntegerIndexSignal raiseIn:thisContext sender |
|
1345 | 2332 |
|
2333 |
"Modified: 8.5.1996 / 09:13:37 / cg" |
|
783 | 2334 |
! |
2335 |
||
2336 |
integerCheckError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2337 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2338 |
|
783 | 2339 |
"generated when a variable declared with an integer type gets a bad |
2340 |
value assigned" |
|
2341 |
||
2342 |
^ self error:'bad assign of ' , self printString , |
|
2343 |
' (' , self class name , ') to integer-typed variable' |
|
71 | 2344 |
! |
2345 |
||
783 | 2346 |
invalidMessage |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2347 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2348 |
|
783 | 2349 |
"this is sent by ST/V code - its the same as #shouldNotImplement" |
2350 |
||
2351 |
^ self shouldNotImplement |
|
2352 |
! |
|
2353 |
||
2354 |
mustBeRectangle |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2355 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2356 |
|
783 | 2357 |
"report an argument-not-rectangle-error" |
2358 |
||
2359 |
^ self error:'argument must be a Rectangle' |
|
2360 |
! |
|
2361 |
||
2362 |
mustBeString |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2363 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2364 |
|
783 | 2365 |
"report an argument-not-string-error" |
2366 |
||
2367 |
^ self error:'argument must be a String' |
|
2368 |
! |
|
2369 |
||
2370 |
notIndexed |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2371 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2372 |
|
1611
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2373 |
"report an error that receiver has no indexed instance variables. |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2374 |
The error is reported by raising the SubscriptOutOfBoundsSignal exception." |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2375 |
|
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2376 |
^ SubscriptOutOfBoundsSignal |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2377 |
raiseErrorString:'receiver has no indexed variables' |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2378 |
in:thisContext sender |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2379 |
|
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2380 |
"Modified: 26.7.1996 / 16:43:13 / cg" |
783 | 2381 |
! |
2382 |
||
2383 |
primitiveFailed |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2384 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2385 |
|
1345 | 2386 |
"report an error that some primitive code failed. |
2387 |
The error is reported by raising the PrimitiveFailureSignal exception." |
|
783 | 2388 |
|
2389 |
^ PrimitiveFailureSignal raiseIn:(thisContext sender) |
|
1345 | 2390 |
|
2391 |
"Modified: 8.5.1996 / 09:14:07 / cg" |
|
783 | 2392 |
! |
2393 |
||
2394 |
shouldNotImplement |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2395 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2396 |
|
1345 | 2397 |
"report an error that this message should not be implemented" |
783 | 2398 |
|
2399 |
^ self error:'method not appropriate for this class' |
|
1345 | 2400 |
|
2401 |
"Modified: 8.5.1996 / 09:09:44 / cg" |
|
783 | 2402 |
! |
2403 |
||
2404 |
subclassResponsibility |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2405 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2406 |
|
1345 | 2407 |
"report an error that this message should have been reimplemented in a |
783 | 2408 |
subclass" |
2409 |
||
1345 | 2410 |
^ self error:'method must be reimplemented in subclass' in:thisContext sender |
2411 |
||
2412 |
"Modified: 8.5.1996 / 09:09:26 / cg" |
|
783 | 2413 |
! |
2414 |
||
2415 |
subscriptBoundsError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2416 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2417 |
|
1345 | 2418 |
"report an error that some index is out of bounds. |
2419 |
(when accessing indexable collections). |
|
2420 |
The error is reported by raising the SubscriptOutOfBoundsSignal exception." |
|
783 | 2421 |
|
1611
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2422 |
^ SubscriptOutOfBoundsSignal |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2423 |
raiseIn:thisContext sender |
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2424 |
|
f8c9a3ab9929
notIndexedError now uses SubscriptBoundsErrorSignal
Claus Gittinger <cg@exept.de>
parents:
1585
diff
changeset
|
2425 |
"Modified: 26.7.1996 / 16:45:42 / cg" |
783 | 2426 |
! |
2427 |
||
2428 |
subscriptBoundsError:anIndex |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2429 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2430 |
|
1345 | 2431 |
"report an error that anIndex is out of bounds. |
2432 |
(when accessing indexable collections). |
|
2433 |
The error is reported by raising the SubscriptOutOfBoundsSignal exception." |
|
783 | 2434 |
|
1021
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2435 |
^ SubscriptOutOfBoundsSignal |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2436 |
raiseRequestWith:anIndex |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2437 |
errorString:('subscript (' , anIndex printString , ') out of bounds') |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2438 |
in:thisContext sender |
b0c7f4a235fb
show bad index in subscriptBoundsError
Claus Gittinger <cg@exept.de>
parents:
985
diff
changeset
|
2439 |
|
1345 | 2440 |
"Modified: 8.5.1996 / 09:14:34 / cg" |
783 | 2441 |
! |
2442 |
||
2443 |
typeCheckError |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2444 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2445 |
|
783 | 2446 |
"generated when a variable declared with a type hint gets a bad |
2447 |
value assigned" |
|
2448 |
||
2449 |
^ self error:'bad assign of ' , self printString , |
|
2450 |
' (' , self class name , ') to typed variable' |
|
2451 |
! ! |
|
2452 |
||
2453 |
!Object methodsFor:'evaluation'! |
|
2454 |
||
2455 |
value |
|
1327 | 2456 |
"return the receiver itself. |
2457 |
This allows every object to be used where blocks or valueHolders |
|
2458 |
are typically used, and allows for valueHolders and blocks to be |
|
2459 |
used interchangably in some situations. |
|
2460 |
||
783 | 2461 |
Time will show, if this is a good idea or leads to sloppy programming |
2462 |
style ... (the idea was borrowed from the Self language). |
|
1327 | 2463 |
|
2464 |
WARNING: dont 'optimize' away ifXXX: blocks |
|
2465 |
(i.e. do NOT replace |
|
2466 |
foo ifTrue:[var1] ifFalse:[var2] |
|
2467 |
by: |
|
2468 |
foo ifTrue:var1 ifFalse:var2 |
|
2469 |
) |
|
2470 |
- the compilers will only generate inline code for the if, |
|
2471 |
iff the argument(s) are blocks - otherwise, a true send is |
|
2472 |
generated. |
|
2473 |
This 'oprimization' will work semantically correct, |
|
2474 |
but execute SLOWER instead." |
|
783 | 2475 |
|
2476 |
^ self |
|
71 | 2477 |
|
2478 |
" |
|
1327 | 2479 |
#(1 2 3 4) indexOf:5 ifAbsent:0 |
2480 |
#(1 2 3 4) indexOf:5 ifAbsent:[0] |
|
2481 |
1 > 2 ifTrue:['yes'] ifFalse:['no'] |
|
2482 |
1 > 2 ifTrue:'yes' ifFalse:'no' |
|
783 | 2483 |
" |
2484 |
||
2485 |
"DO NOT DO THIS (its slower) |
|
2486 |
(1 > 4) ifTrue:'oops' ifFalse:'ok' |
|
2487 |
||
2488 |
USE (the compiler optimizes blocks in if/while): |
|
2489 |
(1 > 4) ifTrue:['oops'] ifFalse:['ok'] |
|
2490 |
" |
|
1327 | 2491 |
|
2492 |
"Modified: 3.5.1996 / 11:57:08 / cg" |
|
783 | 2493 |
! ! |
2494 |
||
2495 |
!Object methodsFor:'initialization'! |
|
2496 |
||
2497 |
initialize |
|
2498 |
"just to ignore initialize to objects which do not need it" |
|
2499 |
||
2500 |
^ self |
|
2501 |
! ! |
|
2502 |
||
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2503 |
!Object methodsFor:'interrest'! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2504 |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2505 |
addInterrest:anInterrest |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2506 |
"install an interrest forwarder. |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2507 |
Here, we use the nonWeakDependencies." |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2508 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2509 |
self addNonWeakDependent:anInterrest |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2510 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2511 |
"Created: 19.4.1996 / 12:33:47 / cg" |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2512 |
! |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2513 |
|
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2514 |
expressInterestIn:aspect for:anObject sendBack:aSelector |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2515 |
"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
|
2516 |
changes aspect." |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2517 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2518 |
"/ 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
|
2519 |
"/ 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
|
2520 |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2521 |
self addInterrest:(InterestConverter |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2522 |
destination:anObject |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2523 |
selector:aSelector |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2524 |
aspect:aspect) |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2525 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2526 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2527 |
|p b| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2528 |
|
1422 | 2529 |
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
|
2530 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2531 |
p := Point new. |
1422 | 2532 |
Transcript showCR:'interest in #foo:'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2533 |
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
|
2534 |
p x:1. |
1422 | 2535 |
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
|
2536 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2537 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2538 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2539 |
Delay waitForSeconds:1. |
1422 | 2540 |
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
|
2541 |
p changed:#foo. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2542 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2543 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2544 |
Delay waitForSeconds:1. |
1422 | 2545 |
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
|
2546 |
p retractInterestIn:#foo for:b. |
1422 | 2547 |
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
|
2548 |
p changed:#foo. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2549 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2550 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2551 |
Delay waitForSeconds:1. |
1422 | 2552 |
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
|
2553 |
p expressInterestIn:#bar for:b sendBack:#value. |
1422 | 2554 |
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
|
2555 |
p changed:#foo. |
1422 | 2556 |
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
|
2557 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2558 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2559 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2560 |
Delay waitForSeconds:1. |
1422 | 2561 |
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
|
2562 |
p expressInterestIn:#foo for:b sendBack:#value. |
1422 | 2563 |
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
|
2564 |
p changed:#foo. |
1422 | 2565 |
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
|
2566 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2567 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2568 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2569 |
Delay waitForSeconds:1. |
1422 | 2570 |
Transcript showCR:'no more interests:'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2571 |
p retractInterestsFor:b. |
1422 | 2572 |
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
|
2573 |
p changed:#foo. |
1422 | 2574 |
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
|
2575 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2576 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2577 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2578 |
p release. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2579 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2580 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2581 |
"Created: 19.4.1996 / 10:26:22 / cg" |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2582 |
"Modified: 19.4.1996 / 12:34:08 / cg" |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2583 |
! |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2584 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2585 |
interrests |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2586 |
"return a Collection of interrests - nil if there is none. |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2587 |
Here, we use the nonWeakDependents for interrests." |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2588 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2589 |
^ self nonWeakDependents |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2590 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2591 |
"Created: 19.4.1996 / 12:27:56 / cg" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2592 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2593 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2594 |
onChangeSend:aSelector to:anObject |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2595 |
"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
|
2596 |
changes." |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2597 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2598 |
"/ 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
|
2599 |
"/ 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
|
2600 |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2601 |
self addInterrest:(InterestConverter |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2602 |
destination:anObject |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2603 |
selector:aSelector) |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2604 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2605 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2606 |
|p b| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2607 |
|
1422 | 2608 |
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
|
2609 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2610 |
p := Point new. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2611 |
p onChangeSend:#value to:b. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2612 |
p x:1. |
1422 | 2613 |
Transcript showCR:'now changing'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2614 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2615 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2616 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2617 |
Delay waitForSeconds:1. |
1422 | 2618 |
Transcript showCR:'now changing'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2619 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2620 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2621 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2622 |
Delay waitForSeconds:1. |
1422 | 2623 |
Transcript showCR:'no more interest'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2624 |
p retractInterestsFor:b. |
1422 | 2625 |
Transcript showCR:'now changing again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2626 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2627 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2628 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2629 |
Delay waitForSeconds:1. |
1422 | 2630 |
Transcript showCR:'interest again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2631 |
p onChangeSend:#value to:b. |
1422 | 2632 |
Transcript showCR:'now changing again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2633 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2634 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2635 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2636 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2637 |
"Created: 19.4.1996 / 10:26:38 / cg" |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2638 |
"Modified: 19.4.1996 / 12:34:26 / cg" |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2639 |
! |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2640 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2641 |
removeInterrest:anInterrest |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2642 |
"remove an interrest forwarder. |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2643 |
Here, we use the nonWeakDependencies." |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2644 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2645 |
self removeNonWeakDependent:anInterrest |
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2646 |
|
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2647 |
"Created: 19.4.1996 / 12:35:01 / cg" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2648 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2649 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2650 |
retractInterestIn:aspect for:someOne |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2651 |
"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
|
2652 |
(as installed with #expressInterestIn:for:sendBack:)." |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2653 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2654 |
"/ for now, remove the interestConverter. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2655 |
"/ 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
|
2656 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2657 |
|deps| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2658 |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2659 |
deps := self interrests. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2660 |
deps notNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2661 |
deps do:[:dep | |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2662 |
(dep isMemberOf:InterestConverter) ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2663 |
dep destination == someOne ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2664 |
dep aspect == aspect ifTrue:[ |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2665 |
self removeInterrest:dep. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2666 |
^ self |
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 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2669 |
] |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2670 |
] |
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 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2673 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2674 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2675 |
|p b| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2676 |
|
1422 | 2677 |
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
|
2678 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2679 |
p := Point new. |
1422 | 2680 |
Transcript showCR:'interest in #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2681 |
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
|
2682 |
p x:1. |
1422 | 2683 |
Transcript showCR:'now changing #bar'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2684 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2685 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2686 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2687 |
Delay waitForSeconds:1. |
1422 | 2688 |
Transcript showCR:'now changing #foo'. |
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:'no more interest in #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2694 |
p retractInterestIn:#foo for:b. |
1422 | 2695 |
Transcript showCR:'now changing #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2696 |
p changed:#foo. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2697 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2698 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2699 |
Delay waitForSeconds:1. |
1422 | 2700 |
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
|
2701 |
p expressInterestIn:#bar for:b sendBack:#value. |
1422 | 2702 |
Transcript showCR:'now changing #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2703 |
p changed:#foo. |
1422 | 2704 |
Transcript showCR:'now changing #bar'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2705 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2706 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2707 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2708 |
Delay waitForSeconds:1. |
1422 | 2709 |
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
|
2710 |
p expressInterestIn:#foo for:b sendBack:#value. |
1422 | 2711 |
Transcript showCR:'now changing #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2712 |
p changed:#foo. |
1422 | 2713 |
Transcript showCR:'now changing #bar'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2714 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2715 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2716 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2717 |
Delay waitForSeconds:1. |
1422 | 2718 |
Transcript showCR:'no more interests'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2719 |
p retractInterestsFor:b. |
1422 | 2720 |
Transcript showCR:'now changing #foo'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2721 |
p changed:#foo. |
1422 | 2722 |
Transcript showCR:'now changing #bar'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2723 |
p changed:#bar. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2724 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2725 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2726 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2727 |
"Created: 19.4.1996 / 10:27:11 / cg" |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2728 |
"Modified: 19.4.1996 / 12:29:52 / cg" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2729 |
! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2730 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2731 |
retractInterestsFor:someOne |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2732 |
"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
|
2733 |
(as installed with #onChangeSend:to:)." |
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 |
"/ for now, remove the interestConverter. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2736 |
"/ 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
|
2737 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2738 |
|coll deps| |
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 |
"/ 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
|
2741 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2742 |
coll := IdentitySet new. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2743 |
|
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2744 |
deps := self interrests. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2745 |
deps notNil ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2746 |
deps do:[:dep | |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2747 |
(dep isMemberOf:InterestConverter) ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2748 |
dep destination == someOne ifTrue:[ |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2749 |
coll add:dep. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2750 |
] |
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 |
]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2753 |
]. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2754 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2755 |
coll do:[:dep | |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2756 |
self removeInterrest:dep. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2757 |
]. |
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 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2760 |
" |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2761 |
|p b| |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2762 |
|
1422 | 2763 |
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
|
2764 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2765 |
p := Point new. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2766 |
p onChangeSend:#value to:b. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2767 |
p x:1. |
1422 | 2768 |
Transcript showCR:'now changing'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2769 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2770 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2771 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2772 |
Delay waitForSeconds:1. |
1422 | 2773 |
Transcript showCR:'now changing'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2774 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2775 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2776 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2777 |
Delay waitForSeconds:1. |
1422 | 2778 |
Transcript showCR:'no more interest'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2779 |
p retractInterestsFor:b. |
1422 | 2780 |
Transcript showCR:'now changing again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2781 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2782 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2783 |
|
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2784 |
Delay waitForSeconds:1. |
1422 | 2785 |
Transcript showCR:'interest again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2786 |
p onChangeSend:#value to:b. |
1422 | 2787 |
Transcript showCR:'now changing again'. |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2788 |
p changed. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2789 |
Transcript cr. |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2790 |
" |
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 |
"Created: 19.4.1996 / 10:23:46 / cg" |
1231
4f457f654e57
interrests slightly rewritten
Claus Gittinger <cg@exept.de>
parents:
1217
diff
changeset
|
2793 |
"Modified: 19.4.1996 / 12:30:03 / cg" |
1217
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2794 |
! ! |
4f7099eb007c
separated dependencies into weak-ones and nonWeak ones
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2795 |
|
783 | 2796 |
!Object methodsFor:'interrupt handling'! |
2797 |
||
2798 |
childSignalInterrupt |
|
2799 |
"death of a child process (unix process) - do nothing" |
|
2800 |
||
2801 |
^ self |
|
2802 |
! |
|
2803 |
||
2804 |
customInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2805 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2806 |
|
783 | 2807 |
"a custom interrupt" |
2808 |
||
2809 |
^ self error:'custom interrupt' |
|
2810 |
! |
|
2811 |
||
2812 |
errorInterrupt:errorID with:aParameter |
|
2813 |
"subsystem error. The arguments errorID and aParameter are the values passed |
|
2814 |
to the 'errorInterruptWithIDAndParameter(id, param)' function, |
|
2815 |
which can be called from C subsystems to raise an (asynchronous) |
|
2816 |
error exception. |
|
2817 |
||
2818 |
Currently, this is used to map XErrors to smalltalk errors, but can be |
|
2819 |
used from other C subsystems too, to upcast errors. |
|
2820 |
Especially, for subsystems which call errorHandler functions asynchronously. |
|
2821 |
IDs (currently) used: |
|
2822 |
#DisplayError ..... x-error interrupt |
|
2823 |
#XtError ..... xt-error interrupt (Xt interface is not yet published) |
|
71 | 2824 |
" |
783 | 2825 |
|
2826 |
|handler| |
|
2827 |
||
2828 |
handler := ObjectMemory registeredErrorInterruptHandlers at:errorID ifAbsent:nil. |
|
2829 |
handler notNil ifTrue:[ |
|
2830 |
"/ |
|
2831 |
"/ handler found; let it do whatever it wants ... |
|
2832 |
"/ |
|
2833 |
handler errorInterrupt:errorID with:aParameter. |
|
2834 |
^ self |
|
2835 |
]. |
|
2836 |
||
2837 |
"/ |
|
2838 |
"/ no handler - raise errorSignal passing the errorId as parameter |
|
2839 |
"/ |
|
2840 |
^ ErrorSignal |
|
2841 |
raiseRequestWith:errorID |
|
2842 |
errorString:('Subsystem error. ErrorID = ' , errorID printString) |
|
2843 |
! |
|
2844 |
||
2845 |
exceptionInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2846 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2847 |
|
783 | 2848 |
"exception interrupt - enter debugger" |
2849 |
||
2850 |
self error:'exception Interrupt' |
|
2851 |
! |
|
2852 |
||
2853 |
fpExceptionInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2854 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2855 |
|
783 | 2856 |
"a floating point exception occured - this one |
2857 |
has to be handled differently since it comes asynchronous |
|
2858 |
on some machines (for example, on machines with a separate FPU |
|
2859 |
or superscalar architectures. Also, errors from within primitive code |
|
2860 |
(or library functions such as GL) are sent via the Unix-signal |
|
2861 |
mechanism this way." |
|
2862 |
||
2863 |
^ Float domainErrorSignal raise |
|
2864 |
! |
|
2865 |
||
2866 |
internalError:msg |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2867 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2868 |
|
783 | 2869 |
"this is triggered, when system hits some bad error, |
2870 |
such as corrupted class, corrupted method/selector array |
|
2871 |
etc. The argument string gives some more information on what happened. |
|
2872 |
(for example, if you set an objects class to a smallInteger, nil etc). |
|
2873 |
Its not guaranteed, that the system is in a working condition once |
|
2874 |
this error occurred ...." |
|
2875 |
||
2876 |
^ self error:msg |
|
2877 |
! |
|
2878 |
||
2879 |
ioInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2880 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2881 |
|
783 | 2882 |
"I/O (SIGIO/SIGPOLL) interrupt (supposed to be sent to Processor). |
2883 |
If we arrive here, there is either no handler (ObjMem>>ioInterruptHandler) |
|
2884 |
or it does not understand the ioInterrupt message. |
|
2885 |
In any case, this is a sign of some big trouble. Enter debugger." |
|
2886 |
||
2887 |
self error:'I/O Interrupt - but no handler' |
|
2888 |
! |
|
2889 |
||
2890 |
memoryInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2891 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2892 |
|
783 | 2893 |
"out-of-memory interrupt and no handler - enter debugger" |
2894 |
||
2895 |
^ self error:'almost out of memory' |
|
2896 |
! |
|
2897 |
||
2898 |
recursionInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2899 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2900 |
|
783 | 2901 |
"recursion limit (actually: stack overflow) interrupt. |
2902 |
This interrupt is triggered, when a process stack grows above |
|
2903 |
its stackLimit - usually, this leads into the debugger, but |
|
2904 |
could be cought and the stackLimit increased in the handler. |
|
2905 |
At the time we arrive here, the system has still some stack |
|
2906 |
as a reserve so we can continue to do some useful work or cleanup or |
|
2907 |
debugging for a while. |
|
2908 |
If the signal is ignored, and the stack continues to grow, there |
|
2909 |
will be a few more chances (and more interrupts) before the VM |
|
2910 |
hard-terminates the process." |
|
2911 |
||
2912 |
thisContext isRecursive ifFalse:[ |
|
2913 |
^ RecursionInterruptSignal raise |
|
2914 |
] |
|
2915 |
! |
|
2916 |
||
2917 |
schedulerInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2918 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2919 |
|
783 | 2920 |
"scheduler interrupt (supposed to be sent to Processor). |
2921 |
If we arrive here, either the Processor does not understand it, |
|
2922 |
or it has been set to nil. In any case, this is a sign of some |
|
2923 |
big trouble. Enter debugger." |
|
2924 |
||
2925 |
self error:'schedulerInterrupt - but no Processor' |
|
2926 |
! |
|
2927 |
||
2928 |
signalInterrupt:signalNumber |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2929 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
2930 |
|
783 | 2931 |
"unix signal occured - some signals are handled as Smalltalk Exceptions |
2932 |
(SIGPIPE), others (SIGBUS) are rather fatal ... |
|
2933 |
In any case, if a smalltalk-signal has been connected to the OS signal, |
|
2934 |
that one is raised. |
|
2935 |
TODO: add another argument, giving more detailed signal info (PC, VADDR, |
|
2936 |
exact cause etc.). This helps if segvs occur in primitive code. |
|
2937 |
Currently (temporary kludge), these are passed as global variables." |
|
2938 |
||
2939 |
|box name here sig ignorable titles actions badContext msg pc addr| |
|
2940 |
||
2941 |
" |
|
2942 |
special case - since SIGPIPE has an ST-signal associated |
|
2943 |
" |
|
2944 |
(signalNumber == 13) ifTrue:[ |
|
2945 |
"SIGPIPE - write on a pipe with no one to read" |
|
2946 |
||
2947 |
^ PipeStream brokenPipeSignal raise. |
|
2948 |
]. |
|
2949 |
||
2950 |
"if there has been an ST-signal installed, use it ..." |
|
2951 |
||
2952 |
sig := OperatingSystem operatingSystemSignal:signalNumber. |
|
2953 |
sig notNil ifTrue:[ |
|
2954 |
^ sig raise |
|
2955 |
]. |
|
2956 |
||
2957 |
" |
|
2958 |
... otherwise , bring up a box asking for what to do ... |
|
2959 |
" |
|
2960 |
name := OperatingSystem nameForSignal:signalNumber. |
|
2961 |
here := thisContext. |
|
2962 |
||
2963 |
" |
|
2964 |
the context, in which the signal occurred: |
|
2965 |
" |
|
2966 |
badContext := here sender. |
|
2967 |
||
2968 |
" |
|
2969 |
ungrab - in case it happened in a box/popupview |
|
2970 |
otherwise display stays locked |
|
2971 |
" |
|
2972 |
Display notNil ifTrue:[ |
|
2973 |
Display ungrabPointer. |
|
2974 |
]. |
|
2975 |
||
2976 |
" |
|
2977 |
SIGBUS, SIGSEGV and SIGILL do not make sense to ignore (i.e. continue) |
|
2978 |
since the system will retry the faulty instruction, which leads to |
|
2979 |
another signal - to avoid frustration, better not offer this option. |
|
2980 |
" |
|
2981 |
ignorable := (signalNumber ~~ OperatingSystem sigBUS) |
|
2982 |
and:[signalNumber ~~ OperatingSystem sigILL |
|
2983 |
and:[signalNumber ~~ OperatingSystem sigSEGV]]. |
|
2984 |
||
2985 |
ignorable ifFalse:[ |
|
2986 |
here isRecursive ifTrue:[ |
|
2987 |
'fatal: signal ' errorPrint. signalNumber errorPrintNL. |
|
2988 |
MiniDebugger enterWithMessage:'recursive signal'. |
|
2989 |
^ self |
|
2990 |
]. |
|
2991 |
" |
|
2992 |
a hard signal - go into debugger immediately |
|
2993 |
" |
|
2994 |
msg := 'Signal ', name. |
|
2995 |
InterruptPcLow notNil ifTrue:[ |
|
2996 |
pc := InterruptPcLow + (InterruptPcHi bitShift:16). |
|
2997 |
pc ~~ 0 ifTrue:[ |
|
2998 |
msg := msg , ' PC=' , (pc printStringRadix:16) |
|
2999 |
]. |
|
3000 |
]. |
|
3001 |
InterruptAddrLow notNil ifTrue:[ |
|
3002 |
addr := InterruptAddrLow + (InterruptAddrHi bitShift:16). |
|
3003 |
addr ~~ 0 ifTrue:[ |
|
3004 |
msg := msg , ' ADDR=' , (addr printStringRadix:16) |
|
3005 |
]. |
|
3006 |
]. |
|
3007 |
Debugger enter:here withMessage:msg. |
|
3008 |
badContext return. |
|
3009 |
^ nil. |
|
3010 |
]. |
|
3011 |
||
3012 |
OptionBox isNil ifTrue:[ |
|
3013 |
" |
|
3014 |
a system without GUI ... |
|
3015 |
go into minidebugger (if there is one) |
|
3016 |
" |
|
3017 |
MiniDebugger isNil ifTrue:[ |
|
3018 |
" |
|
3019 |
a system without debugging facilities |
|
3020 |
(i.e. a standalone system) |
|
3021 |
output a message and exit. |
|
3022 |
" |
|
3023 |
('exit due to Signal ' , name) errorPrintNL. |
|
3024 |
Smalltalk exit. |
|
3025 |
]. |
|
3026 |
MiniDebugger enterWithMessage:'Signal cought (' , name, ')'. |
|
3027 |
^ self |
|
3028 |
]. |
|
3029 |
||
3030 |
box := OptionBox |
|
3031 |
title:'Signal cought (' , name, ')' |
|
3032 |
numberOfOptions:(ignorable ifTrue:[5] ifFalse:[4]). |
|
3033 |
||
3034 |
titles := #('return' 'debug' 'dump' 'exit'). |
|
3035 |
actions := Array |
|
3036 |
with:[badContext return] |
|
3037 |
with:[Debugger enter:here withMessage:('Signal ', name). ^nil] |
|
3038 |
with:[Smalltalk fatalAbort] |
|
3039 |
with:[Smalltalk exit]. |
|
3040 |
||
3041 |
ignorable ifTrue:[ |
|
3042 |
titles := #('ignore') , titles. |
|
3043 |
actions := (Array with:[^ nil]) , actions. |
|
3044 |
]. |
|
3045 |
box buttonTitles:titles. |
|
3046 |
box actions:actions. |
|
3047 |
box showAtPointer |
|
3048 |
! |
|
3049 |
||
3050 |
spyInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3051 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3052 |
|
783 | 3053 |
"spy interrupt and no handler - enter debugger" |
3054 |
||
3055 |
self error:'spy Interrupt - but no handler' |
|
3056 |
! |
|
3057 |
||
3058 |
timerInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3059 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3060 |
|
783 | 3061 |
"timer interrupt and no handler - enter debugger" |
3062 |
||
3063 |
self error:'timer Interrupt - but no handler' |
|
3064 |
! |
|
3065 |
||
3066 |
userInterrupt |
|
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3067 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3068 |
|
783 | 3069 |
"user (^c) interrupt - enter debugger" |
3070 |
||
3071 |
UserInterruptSignal raise |
|
71 | 3072 |
! ! |
3073 |
||
1 | 3074 |
!Object methodsFor:'message sending'! |
3075 |
||
3076 |
perform:aSelector |
|
3077 |
"send the message aSelector to the receiver" |
|
3078 |
||
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3079 |
%{ |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3080 |
struct inlineCache *pIlc; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3081 |
static struct inlineCache ilc_0 = _DUMMYILC0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3082 |
static struct inlineCache ilc_1 = _DUMMYILC0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3083 |
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
|
3084 |
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
|
3085 |
static flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3086 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3087 |
if (aSelector != last_0) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3088 |
if (aSelector != last_1) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3089 |
if (flip) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3090 |
pIlc = &ilc_0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3091 |
flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3092 |
last_0 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3093 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3094 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3095 |
flip = 1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3096 |
last_1 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3097 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3098 |
pIlc->ilc_func = __SEND0ADDR__; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3099 |
if (pIlc->ilc_poly) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3100 |
__flushPolyCache(pIlc->ilc_poly); |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3101 |
pIlc->ilc_poly = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3102 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3103 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3104 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3105 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3106 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3107 |
pIlc = &ilc_0; |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3108 |
} |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3109 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, CON_COMMA nil, pIlc) ); |
1 | 3110 |
%} |
3111 |
! |
|
3112 |
||
783 | 3113 |
perform:aSelector inClass:aClass withArguments:argArray |
3114 |
"send the message aSelector with all args taken from argArray |
|
3115 |
to the receiver as a super-send message. |
|
3116 |
This is actually more flexible than the normal super-send, since it allows |
|
3117 |
to execute a method in ANY superclass of the receiver (not just the |
|
3118 |
immediate superclass). |
|
3119 |
Thus, it is (theoretically) possible to do |
|
3120 |
'5 perform:#< inClass:Magnitude withArguments:#(6)' |
|
3121 |
and evaluate Magnitudes compare method even if there was one in Number. |
|
3122 |
This method is used by the interpreter to evaluate super sends |
|
3123 |
and could be used for very special behavior (language extension ?). |
|
3124 |
||
3125 |
WARNING: this is an ST/X feature - probably not found in other smalltalks." |
|
3126 |
||
3127 |
|numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
|
3128 |
||
3129 |
" |
|
3130 |
check, if aClass is really a superclass of the receiver |
|
3131 |
" |
|
3132 |
(self class isSubclassOf:aClass) ifFalse:[ |
|
3133 |
self error:'class argument is not a superclass of the receiver'. |
|
3134 |
^ nil |
|
3135 |
]. |
|
3136 |
numberOfArgs := argArray size. |
|
3137 |
%{ |
|
3138 |
REGISTER OBJ *argP; |
|
3139 |
int nargs, i; |
|
3140 |
static struct inlineCache ilc0 = _DUMMYILC0; |
|
3141 |
static struct inlineCache ilc1 = _DUMMYILC1; |
|
3142 |
static struct inlineCache ilc2 = _DUMMYILC2; |
|
3143 |
static struct inlineCache ilc3 = _DUMMYILC3; |
|
3144 |
static struct inlineCache ilc4 = _DUMMYILC4; |
|
3145 |
static struct inlineCache ilc5 = _DUMMYILC5; |
|
3146 |
static struct inlineCache ilc6 = _DUMMYILC6; |
|
3147 |
static struct inlineCache ilc7 = _DUMMYILC7; |
|
3148 |
static struct inlineCache ilc8 = _DUMMYILC8; |
|
3149 |
static struct inlineCache ilc9 = _DUMMYILC9; |
|
3150 |
static struct inlineCache ilc10 = _DUMMYILC10; |
|
3151 |
static struct inlineCache ilc11 = _DUMMYILC11; |
|
3152 |
static struct inlineCache ilc12 = _DUMMYILC12; |
|
3153 |
static struct inlineCache ilc13 = _DUMMYILC13; |
|
3154 |
static struct inlineCache ilc14 = _DUMMYILC14; |
|
3155 |
static struct inlineCache ilc15 = _DUMMYILC15; |
|
3156 |
||
3157 |
if (__isSmallInteger(numberOfArgs)) { |
|
3158 |
nargs = __intVal(numberOfArgs); |
|
3159 |
if (nargs == 0) { |
|
3160 |
RETURN (_SEND0(self, aSelector, CON_COMMA aClass, &ilc0)); |
|
3161 |
} |
|
3162 |
||
3163 |
argP = (OBJ *)(&a1); |
|
1133 | 3164 |
if (__Class(argArray) == @global(Array)) { |
783 | 3165 |
for (i=0; i < nargs; i++) { |
1133 | 3166 |
*argP++ = __ArrayInstPtr(argArray)->a_element[i]; |
783 | 3167 |
} |
3168 |
} else { |
|
3169 |
for (i=1; i <= nargs; i++) { |
|
3170 |
*argP++ = __AT_(argArray, CON_COMMA __MKSMALLINT(i)); |
|
3171 |
} |
|
3172 |
} |
|
3173 |
switch (nargs) { |
|
3174 |
case 1: |
|
3175 |
RETURN ( _SEND1(self, aSelector, CON_COMMA aClass, &ilc1, a1)); |
|
3176 |
||
3177 |
case 2: |
|
3178 |
RETURN ( _SEND2(self, aSelector, CON_COMMA aClass, &ilc2, a1, a2)); |
|
3179 |
||
3180 |
case 3: |
|
3181 |
RETURN ( _SEND3(self, aSelector, CON_COMMA aClass, &ilc3, a1, a2, a3)); |
|
3182 |
||
3183 |
case 4: |
|
3184 |
RETURN ( _SEND4(self, aSelector, CON_COMMA aClass, &ilc4, a1, a2, a3, a4)); |
|
3185 |
||
3186 |
case 5: |
|
3187 |
RETURN ( _SEND5(self, aSelector, CON_COMMA aClass, &ilc5, |
|
3188 |
a1, a2, a3, a4, a5)); |
|
3189 |
||
3190 |
case 6: |
|
3191 |
RETURN ( _SEND6(self, aSelector, CON_COMMA aClass, &ilc6, |
|
3192 |
a1, a2, a3, a4, a5, a6)); |
|
3193 |
||
3194 |
case 7: |
|
3195 |
RETURN ( _SEND7(self, aSelector, CON_COMMA aClass, &ilc7, |
|
3196 |
a1, a2, a3, a4, a5, a6, a7)); |
|
3197 |
||
3198 |
case 8: |
|
3199 |
RETURN ( _SEND8(self, aSelector, CON_COMMA aClass, &ilc8, |
|
3200 |
a1, a2, a3, a4, a5, a6, a7, a8)); |
|
3201 |
||
3202 |
case 9: |
|
3203 |
RETURN ( _SEND9(self, aSelector, CON_COMMA aClass, &ilc9, |
|
3204 |
a1, a2, a3, a4, a5, a6, a7, a8, a9)); |
|
3205 |
||
3206 |
case 10: |
|
3207 |
RETURN ( _SEND10(self, aSelector, CON_COMMA aClass, &ilc10, |
|
3208 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)); |
|
3209 |
||
3210 |
case 11: |
|
3211 |
RETURN ( _SEND11(self, aSelector, CON_COMMA aClass, &ilc11, |
|
3212 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11)); |
|
3213 |
||
3214 |
case 12: |
|
3215 |
RETURN ( _SEND12(self, aSelector, CON_COMMA aClass, &ilc12, |
|
3216 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)); |
|
3217 |
||
3218 |
case 13: |
|
3219 |
RETURN ( _SEND13(self, aSelector, CON_COMMA aClass, &ilc13, |
|
3220 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, |
|
3221 |
a13)); |
|
3222 |
||
3223 |
case 14: |
|
3224 |
RETURN ( _SEND14(self, aSelector, CON_COMMA aClass, &ilc14, |
|
3225 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, |
|
3226 |
a13, a14)); |
|
3227 |
||
3228 |
case 15: |
|
3229 |
RETURN ( _SEND15(self, aSelector, CON_COMMA aClass, &ilc15, |
|
3230 |
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, |
|
3231 |
a13, a14, a15)); |
|
3232 |
} |
|
3233 |
} |
|
1626 | 3234 |
%}. |
3235 |
"/ arrive here, if bad number of arguments (too many) |
|
3236 |
"/ ST/X (currently) only allows up to 15 method arguments |
|
3237 |
||
783 | 3238 |
^ self primitiveFailed |
3239 |
! |
|
3240 |
||
1 | 3241 |
perform:aSelector with:anObject |
3242 |
"send the one-arg-message aSelector to the receiver" |
|
3243 |
||
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3244 |
%{ |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3245 |
struct inlineCache *pIlc; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3246 |
static struct inlineCache ilc_0 = _DUMMYILC1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3247 |
static struct inlineCache ilc_1 = _DUMMYILC1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3248 |
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
|
3249 |
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
|
3250 |
static flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3251 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3252 |
if (aSelector != last_0) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3253 |
if (aSelector != last_1) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3254 |
if (flip) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3255 |
pIlc = &ilc_0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3256 |
flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3257 |
last_0 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3258 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3259 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3260 |
flip = 1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3261 |
last_1 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3262 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3263 |
pIlc->ilc_func = __SEND1ADDR__; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3264 |
if (pIlc->ilc_poly) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3265 |
__flushPolyCache(pIlc->ilc_poly); |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3266 |
pIlc->ilc_poly = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3267 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3268 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3269 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3270 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3271 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3272 |
pIlc = &ilc_0; |
1 | 3273 |
} |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3274 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, CON_COMMA nil, pIlc, anObject) ); |
1 | 3275 |
%} |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3276 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3277 |
! |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3278 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3279 |
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
|
3280 |
"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
|
3281 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3282 |
%{ |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3283 |
struct inlineCache *pIlc; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3284 |
static struct inlineCache ilc_0 = _DUMMYILC2; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3285 |
static struct inlineCache ilc_1 = _DUMMYILC2; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3286 |
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
|
3287 |
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
|
3288 |
static flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3289 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3290 |
if (aSelector != last_0) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3291 |
if (aSelector != last_1) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3292 |
if (flip) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3293 |
pIlc = &ilc_0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3294 |
flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3295 |
last_0 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3296 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3297 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3298 |
flip = 1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3299 |
last_1 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3300 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3301 |
pIlc->ilc_func = __SEND2ADDR__; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3302 |
if (pIlc->ilc_poly) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3303 |
__flushPolyCache(pIlc->ilc_poly); |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3304 |
pIlc->ilc_poly = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3305 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3306 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3307 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3308 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3309 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3310 |
pIlc = &ilc_0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3311 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3312 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, CON_COMMA nil, pIlc, arg1, arg2) ); |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3313 |
%} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3314 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3315 |
! |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3316 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3317 |
perform:aSelector with:arg1 with:arg2 with:arg3 |
1 | 3318 |
"send the three-arg-message aSelector to the receiver" |
3319 |
||
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3320 |
%{ |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3321 |
struct inlineCache *pIlc; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3322 |
static struct inlineCache ilc_0 = _DUMMYILC3; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3323 |
static struct inlineCache ilc_1 = _DUMMYILC3; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3324 |
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
|
3325 |
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
|
3326 |
static flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3327 |
|
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3328 |
if (aSelector != last_0) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3329 |
if (aSelector != last_1) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3330 |
if (flip) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3331 |
pIlc = &ilc_0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3332 |
flip = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3333 |
last_0 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3334 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3335 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3336 |
flip = 1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3337 |
last_1 = aSelector; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3338 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3339 |
pIlc->ilc_func = __SEND3ADDR__; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3340 |
if (pIlc->ilc_poly) { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3341 |
__flushPolyCache(pIlc->ilc_poly); |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3342 |
pIlc->ilc_poly = 0; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3343 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3344 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3345 |
pIlc = &ilc_1; |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3346 |
} |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3347 |
} else { |
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3348 |
pIlc = &ilc_0; |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3349 |
} |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3350 |
RETURN ( (*(pIlc->ilc_func))(self, aSelector, CON_COMMA nil, pIlc, arg1, arg2, arg3) ); |
1 | 3351 |
%} |
1533
179ce527e383
added a 2-slot cache to #perform: / #perform:with:* methods.
Claus Gittinger <cg@exept.de>
parents:
1528
diff
changeset
|
3352 |
|
1 | 3353 |
! |
3354 |
||
3355 |
perform:aSelector withArguments:argArray |
|
3356 |
"send the message aSelector with all args taken from argArray |
|
44 | 3357 |
to the receiver." |
1 | 3358 |
|
77 | 3359 |
|numberOfArgs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
1 | 3360 |
|
3361 |
numberOfArgs := argArray size. |
|
3362 |
%{ |
|
3363 |
REGISTER OBJ *argP; |
|
3364 |
int nargs, i; |
|
3365 |
static OBJ last0 = nil; static struct inlineCache ilc0 = _ILC0; |
|
3366 |
static OBJ last1 = nil; static struct inlineCache ilc1 = _ILC1; |
|
3367 |
static OBJ last2 = nil; static struct inlineCache ilc2 = _ILC2; |
|
3368 |
static OBJ last3 = nil; static struct inlineCache ilc3 = _ILC3; |
|
3369 |
static OBJ last4 = nil; static struct inlineCache ilc4 = _ILC4; |
|
3370 |
static OBJ last5 = nil; static struct inlineCache ilc5 = _ILC5; |
|
3371 |
static OBJ last6 = nil; static struct inlineCache ilc6 = _ILC6; |
|
3372 |
static OBJ last7 = nil; static struct inlineCache ilc7 = _ILC7; |
|
3373 |
static OBJ last8 = nil; static struct inlineCache ilc8 = _ILC8; |
|
3374 |
static OBJ last9 = nil; static struct inlineCache ilc9 = _ILC9; |
|
3375 |
static OBJ last10 = nil; static struct inlineCache ilc10 = _ILC10; |
|
3376 |
static OBJ last11 = nil; static struct inlineCache ilc11 = _ILC11; |
|
3377 |
static OBJ last12 = nil; static struct inlineCache ilc12 = _ILC12; |
|
71 | 3378 |
static OBJ last13 = nil; static struct inlineCache ilc13 = _ILC13; |
3379 |
static OBJ last14 = nil; static struct inlineCache ilc14 = _ILC14; |
|
3380 |
static OBJ last15 = nil; static struct inlineCache ilc15 = _ILC15; |
|
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3381 |
OBJ l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3382 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3383 |
#if defined(xxxTHIS_CONTEXT) /* not because this has a context */ |
71 | 3384 |
/* |
93 | 3385 |
* must set lineno in sender by hand here ... (because of NOCONTEXT) |
71 | 3386 |
*/ |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3387 |
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
|
3388 |
_ContextInstPtr(__thisContext)->c_lineno = l; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3389 |
} |
71 | 3390 |
#endif |
1 | 3391 |
|
253 | 3392 |
if (__isSmallInteger(numberOfArgs)) { |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3393 |
nargs = __intVal(numberOfArgs); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3394 |
if (nargs == 0) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3395 |
if (aSelector != last0) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3396 |
ilc0.ilc_func = __SEND0ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3397 |
if (ilc0.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3398 |
__flushPolyCache(ilc0.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3399 |
ilc0.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3400 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3401 |
last0 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3402 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3403 |
#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
|
3404 |
ilc0.ilc_lineNo = __pilc->ilc_lineNo; |
44 | 3405 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3406 |
RETURN ((*ilc0.ilc_func)(self, aSelector, CON_COMMA nil, &ilc0)); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3407 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3408 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3409 |
if (__isArray(argArray)) { |
1133 | 3410 |
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
|
3411 |
} else { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3412 |
argP = (OBJ *)(&a1); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3413 |
for (i=1; i <= nargs; i++) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3414 |
*argP++ = __AT_(argArray, CON_COMMA __MKSMALLINT(i)); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3415 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3416 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3417 |
switch (nargs) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3418 |
case 1: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3419 |
if (aSelector != last1) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3420 |
ilc1.ilc_func = __SEND1ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3421 |
if (ilc1.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3422 |
__flushPolyCache(ilc1.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3423 |
ilc1.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3424 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3425 |
last1 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3426 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3427 |
#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
|
3428 |
ilc1.ilc_lineNo = __pilc->ilc_lineNo; |
44 | 3429 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3430 |
RETURN ( (*ilc1.ilc_func)(self, aSelector, CON_COMMA nil, &ilc1, argP[0])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3431 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3432 |
case 2: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3433 |
if (aSelector != last2) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3434 |
ilc2.ilc_func = __SEND2ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3435 |
if (ilc2.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3436 |
__flushPolyCache(ilc2.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3437 |
ilc2.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3438 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3439 |
last2 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3440 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3441 |
#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
|
3442 |
ilc2.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3443 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3444 |
RETURN ( (*ilc2.ilc_func)(self, aSelector, CON_COMMA nil, &ilc2, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3445 |
argP[0], argP[1])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3446 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3447 |
case 3: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3448 |
if (aSelector != last3) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3449 |
ilc3.ilc_func = __SEND3ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3450 |
if (ilc3.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3451 |
__flushPolyCache(ilc3.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3452 |
ilc3.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3453 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3454 |
last3 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3455 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3456 |
#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
|
3457 |
ilc3.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3458 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3459 |
RETURN ( (*ilc3.ilc_func)(self, aSelector, CON_COMMA nil, &ilc3, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3460 |
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
|
3461 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3462 |
case 4: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3463 |
if (aSelector != last4) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3464 |
ilc4.ilc_func = __SEND4ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3465 |
if (ilc4.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3466 |
__flushPolyCache(ilc4.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3467 |
ilc4.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3468 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3469 |
last4 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3470 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3471 |
#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
|
3472 |
ilc4.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3473 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3474 |
RETURN ( (*ilc4.ilc_func)(self, aSelector, CON_COMMA nil, &ilc4, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3475 |
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
|
3476 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3477 |
case 5: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3478 |
if (aSelector != last5) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3479 |
ilc5.ilc_func = __SEND5ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3480 |
if (ilc5.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3481 |
__flushPolyCache(ilc5.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3482 |
ilc5.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3483 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3484 |
last5 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3485 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3486 |
#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
|
3487 |
ilc5.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3488 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3489 |
RETURN ( (*ilc5.ilc_func)(self, aSelector, CON_COMMA nil, &ilc5, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3490 |
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
|
3491 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3492 |
case 6: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3493 |
if (aSelector != last6) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3494 |
ilc6.ilc_func = __SEND6ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3495 |
if (ilc6.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3496 |
__flushPolyCache(ilc6.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3497 |
ilc6.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3498 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3499 |
last6 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3500 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3501 |
#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
|
3502 |
ilc6.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3503 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3504 |
RETURN ( (*ilc6.ilc_func)(self, aSelector, CON_COMMA nil, &ilc6, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3505 |
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
|
3506 |
argP[5])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3507 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3508 |
case 7: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3509 |
if (aSelector != last7) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3510 |
ilc7.ilc_func = __SEND7ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3511 |
if (ilc7.ilc_poly) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3512 |
__flushPolyCache(ilc7.ilc_poly); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3513 |
ilc7.ilc_poly = 0; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3514 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3515 |
last7 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3516 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3517 |
#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
|
3518 |
ilc7.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3519 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3520 |
RETURN ( (*ilc7.ilc_func)(self, aSelector, CON_COMMA nil, &ilc7, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3521 |
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
|
3522 |
argP[5], argP[6])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3523 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3524 |
case 8: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3525 |
if (aSelector != last8) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3526 |
ilc8.ilc_func = __SEND8ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3527 |
last8 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3528 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3529 |
#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
|
3530 |
ilc8.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3531 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3532 |
RETURN ( (*ilc8.ilc_func)(self, aSelector, CON_COMMA nil, &ilc8, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3533 |
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
|
3534 |
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
|
3535 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3536 |
case 9: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3537 |
if (aSelector != last9) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3538 |
ilc9.ilc_func = __SEND9ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3539 |
last9 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3540 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3541 |
#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
|
3542 |
ilc9.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3543 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3544 |
RETURN ( (*ilc9.ilc_func)(self, aSelector, CON_COMMA nil, &ilc9, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3545 |
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
|
3546 |
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
|
3547 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3548 |
case 10: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3549 |
if (aSelector != last10) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3550 |
ilc10.ilc_func = __SEND10ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3551 |
last10 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3552 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3553 |
#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
|
3554 |
ilc10.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3555 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3556 |
RETURN ( (*ilc10.ilc_func)(self, aSelector, CON_COMMA nil, &ilc10, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3557 |
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
|
3558 |
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
|
3559 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3560 |
case 11: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3561 |
if (aSelector != last11) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3562 |
ilc11.ilc_func = __SEND11ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3563 |
last11 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3564 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3565 |
#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
|
3566 |
ilc11.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3567 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3568 |
RETURN ( (*ilc11.ilc_func)(self, aSelector, CON_COMMA nil, &ilc11, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3569 |
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
|
3570 |
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
|
3571 |
argP[10])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3572 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3573 |
case 12: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3574 |
if (aSelector != last12) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3575 |
ilc12.ilc_func = __SEND12ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3576 |
last12 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3577 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3578 |
#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
|
3579 |
ilc12.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3580 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3581 |
RETURN ( (*ilc12.ilc_func)(self, aSelector, CON_COMMA nil, &ilc12, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3582 |
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
|
3583 |
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
|
3584 |
argP[10], argP[11])); |
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 |
case 13: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3587 |
if (aSelector != last13) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3588 |
ilc13.ilc_func = __SEND13ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3589 |
last13 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3590 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3591 |
#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
|
3592 |
ilc13.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3593 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3594 |
RETURN ( (*ilc13.ilc_func)(self, aSelector, CON_COMMA nil, &ilc13, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3595 |
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
|
3596 |
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
|
3597 |
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
|
3598 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3599 |
case 14: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3600 |
if (aSelector != last14) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3601 |
ilc14.ilc_func = __SEND14ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3602 |
last14 = aSelector; |
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 |
#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
|
3605 |
ilc14.ilc_lineNo = __pilc->ilc_lineNo; |
71 | 3606 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3607 |
RETURN ( (*ilc14.ilc_func)(self, aSelector, CON_COMMA nil, &ilc14, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3608 |
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
|
3609 |
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
|
3610 |
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
|
3611 |
|
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3612 |
case 15: |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3613 |
if (aSelector != last15) { |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3614 |
ilc15.ilc_func = __SEND15ADDR__; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3615 |
last15 = aSelector; |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3616 |
} |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3617 |
#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
|
3618 |
ilc15.ilc_lineNo = __pilc->ilc_lineNo; |
77 | 3619 |
#endif |
1085
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3620 |
RETURN ( (*ilc15.ilc_func)(self, aSelector, CON_COMMA nil, &ilc15, |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3621 |
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
|
3622 |
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
|
3623 |
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
|
3624 |
argP[14])); |
3f5ae1995e83
fixed lineNumber info with #perform (that used to work !)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
3625 |
} |
1 | 3626 |
} |
1626 | 3627 |
%}. |
3628 |
"/ arrive here, if bad number of arguments (too many) |
|
3629 |
"/ ST/X (currently) only allows up to 15 method arguments |
|
3630 |
||
1 | 3631 |
^ self primitiveFailed |
3632 |
! ! |
|
3633 |
||
783 | 3634 |
!Object methodsFor:'misc'! |
3635 |
||
3636 |
-> anObject |
|
3637 |
"return an association with the receiver as key and |
|
3638 |
the argument as value" |
|
3639 |
||
3640 |
^ Association key:self value:anObject |
|
2 | 3641 |
! ! |
3642 |
||
1 | 3643 |
!Object methodsFor:'printing & storing'! |
3644 |
||
3645 |
className |
|
3646 |
"return the classname of the receivers class" |
|
3647 |
||
3648 |
^ self class name |
|
56 | 3649 |
|
293 | 3650 |
" |
3651 |
1 className |
|
3652 |
1 class className 'this may change ...' |
|
3653 |
$a className |
|
3654 |
$a class className 'this may change ...' |
|
3655 |
" |
|
1 | 3656 |
! |
3657 |
||
3658 |
classNameWithArticle |
|
71 | 3659 |
"return a string consisting of classname preceeded by an article. |
3660 |
(dont expect me to write national variants for this ... :-) |
|
3661 |
If you have special preferences, redefine it ..." |
|
1 | 3662 |
|
1391 | 3663 |
|classname cls| |
3664 |
||
3665 |
(cls := self class) == self ifTrue:[ |
|
3666 |
^ 'a funny object' |
|
3667 |
]. |
|
3668 |
classname := cls displayString. |
|
85 | 3669 |
^ classname article , ' ' , classname |
56 | 3670 |
|
293 | 3671 |
" |
3672 |
1 classNameWithArticle |
|
3673 |
(1->2) classNameWithArticle |
|
3674 |
XWorkstation basicNew classNameWithArticle |
|
3675 |
" |
|
1391 | 3676 |
|
3677 |
"Modified: 13.5.1996 / 12:16:14 / cg" |
|
1 | 3678 |
! |
3679 |
||
1445
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3680 |
displayOn:aGc |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3681 |
"ST-80 Compatibility |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3682 |
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
|
3683 |
- 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
|
3684 |
(although the fallBack is to display its printString ...)" |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3685 |
|
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3686 |
^ self displayOn:aGc x:0 y:0. |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3687 |
|
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3688 |
"Created: 29.5.1996 / 16:28:58 / cg" |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3689 |
! |
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3690 |
|
783 | 3691 |
displayOn:aGc at:aPoint |
3692 |
"ST-80 Compatibility |
|
3693 |
display the receiver in a graphicsContext - this method allows |
|
3694 |
for any object to be displayed in a ListView - for example." |
|
3695 |
||
3696 |
^ self displayOn:aGc x:(aPoint x) y:(aPoint y). |
|
56 | 3697 |
! |
3698 |
||
783 | 3699 |
displayOn:aGc x:x y:y |
3700 |
"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
|
3701 |
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
|
3702 |
The fallBack here shows the receivers printString." |
783 | 3703 |
|
3704 |
^ 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
|
3705 |
|
c2dc94f9921b
added #displayOn: as a common fallBack
Claus Gittinger <cg@exept.de>
parents:
1425
diff
changeset
|
3706 |
"Modified: 29.5.1996 / 16:29:38 / cg" |
56 | 3707 |
! |
3708 |
||
783 | 3709 |
displayString |
3710 |
"return a string used when displaying the receiver in a view; |
|
3711 |
for example an Inspector. This is usually the same as printString, |
|
3712 |
but sometimes redefined for a better look." |
|
3713 |
||
3714 |
^ self printString |
|
3715 |
||
3716 |
" |
|
3717 |
#(1 2 3) printString |
|
3718 |
#(1 2 3) displayString |
|
3719 |
#(1 2 3) storeString |
|
3720 |
" |
|
1 | 3721 |
! |
3722 |
||
783 | 3723 |
errorPrint |
3724 |
"print the receiver on the standard error stream." |
|
3725 |
||
1089
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3726 |
Stream streamErrorSignal catch:[ |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3727 |
self printOn:Stderr |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3728 |
] |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3729 |
|
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3730 |
"Modified: 7.3.1996 / 19:11:29 / cg" |
783 | 3731 |
! |
3732 |
||
1425 | 3733 |
errorPrintCR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3734 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3735 |
|
1089
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3736 |
"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
|
3737 |
|
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3738 |
Stream streamErrorSignal catch:[ |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3739 |
self printOn:Stderr. |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3740 |
Stderr cr |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3741 |
] |
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3742 |
|
6df9414b354f
catch errors while errorPrinting (happened when controlling xterm was closed)
Claus Gittinger <cg@exept.de>
parents:
1085
diff
changeset
|
3743 |
"Modified: 7.3.1996 / 19:13:01 / cg" |
1425 | 3744 |
"Created: 20.5.1996 / 10:20:41 / cg" |
3745 |
! |
|
3746 |
||
3747 |
errorPrintNL |
|
3748 |
"{ Pragma: +optSpace }" |
|
3749 |
||
3750 |
"print the receiver followed by a cr on the standard error stream. |
|
3751 |
Please use #errorPrintCR - this method exists for backward compatibility." |
|
3752 |
||
3753 |
^ self errorPrintCR |
|
3754 |
||
3755 |
"Modified: 20.5.1996 / 10:24:45 / cg" |
|
3756 |
! |
|
3757 |
||
3758 |
errorPrintNewline |
|
3759 |
"{ Pragma: +optSpace }" |
|
3760 |
||
3761 |
"print the receiver followed by a cr on the standard error stream. |
|
3762 |
Please use #errorPrintCR - this method exists for backward compatibility." |
|
3763 |
||
3764 |
self errorPrintCR. |
|
3765 |
||
3766 |
"Modified: 20.5.1996 / 10:24:38 / cg" |
|
71 | 3767 |
! |
3768 |
||
356 | 3769 |
infoPrint |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3770 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3771 |
|
356 | 3772 |
"print the receiver on the standard error stream. |
3773 |
This is meant for information messages which are not warnings |
|
3774 |
or fatal messages. |
|
3775 |
These messages can be turned on/off by 'Object infoPrinting:true/false'" |
|
3776 |
||
3777 |
InfoPrinting ifTrue:[ |
|
3778 |
self printOn:Stderr |
|
3779 |
] |
|
3780 |
! |
|
3781 |
||
1425 | 3782 |
infoPrintCR |
1119
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3783 |
"{ Pragma: +optSpace }" |
956d62a5656c
compile seldom used methods with optSpace (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1109
diff
changeset
|
3784 |
|
356 | 3785 |
"print the receiver followed by a cr on the standard error stream. |
3786 |
This is meant for information messages which are not warnings |
|
3787 |
or fatal messages. |
|
3788 |
These messages can be turned on/off by 'Object infoPrinting:true/false'" |
|
3789 |
||
3790 |
InfoPrinting ifTrue:[ |
|
1425 | 3791 |
self errorPrintCR |
356 | 3792 |
] |
1425 | 3793 |
|
3794 |
"Created: 20.5.1996 / 10:21:28 / cg" |
|
3795 |
! |
|
3796 |
||
3797 |
infoPrintNL |
|
3798 |
"{ Pragma: +optSpace }" |
|
3799 |
||
3800 |
"print the receiver followed by a cr on the standard error stream. |
|
3801 |
This is meant for information messages which are not warnings |
|
3802 |
or fatal messages. |
|
3803 |
These messages can be turned on/off by 'Object infoPrinting:true/false'. |
|
3804 |
||
3805 |
Please use #infoPrintCR - this method exists for backward compatibility." |
|
3806 |
||
3807 |
InfoPrinting ifTrue:[ |
|
3808 |
self errorPrintCR |
|
3809 |
] |
|
3810 |
||
3811 |
"Modified: 20.5.1996 / 10:25:07 / cg" |
|
356 | 3812 |
! |
3813 |
||
783 | 3814 |
|
3815 |
"print the receiver on the standard output stream" |
|
3816 |
||
3817 |
self printOn:Stdout |
|
3818 |
! |
|
3819 |
||
1425 | 3820 |
printCR |
783 | 3821 |
"print the receiver followed by a cr on the standard output stream" |
3822 |
||
3823 |
self printOn:Stdout. |
|
3824 |
Stdout cr |
|
1425 | 3825 |
|
3826 |
"Created: 20.5.1996 / 10:21:37 / cg" |
|
3827 |
! |
|
3828 |
||
3829 |
printNL |
|
3830 |
"print the receiver followed by a cr on the standard output stream |
|
3831 |
This exists for GNU Smalltalk compatibility - please use #printCR." |
|
3832 |
||
3833 |
^ self printCR |
|
3834 |
||
3835 |
"Modified: 20.5.1996 / 10:25:31 / cg" |
|
3836 |
! |
|
3837 |
||
3838 |
printNewline |
|
3839 |
"print the receiver followed by a cr on the standard output stream. |
|
3840 |
This exists for backward compatibility - please use #printCR." |
|
3841 |
||
3842 |
self printCR |
|
3843 |
||
3844 |
"Modified: 20.5.1996 / 10:25:46 / cg" |
|
783 | 3845 |
! |
3846 |
||
3847 |
printOn:aStream |
|
3848 |
"print the receiver on the argument-stream. |
|
3849 |
The default here is to output the receivers class name. |
|
3850 |
BUT: this method is heavily redefined for objects which |
|
3851 |
can print prettier." |
|
3852 |
||
3853 |
aStream nextPutAll:self classNameWithArticle |
|
3854 |
! |
|
3855 |
||
3856 |
printOn:aStream leftPaddedTo:size |
|
3857 |
"print the receiver on aStream, padding with spaces up to size. |
|
3858 |
padding is done on the left." |
|
3859 |
||
3860 |
self printOn:aStream leftPaddedTo:size with:(Character space) |
|
3861 |
||
3862 |
" |
|
3863 |
123 printOn:Transcript leftPaddedTo:10. Transcript cr |
|
3864 |
123 printOn:Transcript leftPaddedTo:2. Transcript cr |
|
3865 |
" |
|
71 | 3866 |
! |
3867 |
||
783 | 3868 |
printOn:aStream leftPaddedTo:size with:padCharacter |
3869 |
"print the receiver on aStream, padding with padCharacters up to size. |
|
3870 |
padding is done on the left." |
|
3871 |
||
3872 |
aStream nextPutAll:(self printStringLeftPaddedTo:size with:padCharacter) |
|
3873 |
||
3874 |
" |
|
3875 |
123 printOn:Transcript leftPaddedTo:10 with:$_ . Transcript cr |
|
3876 |
123 printOn:Transcript leftPaddedTo:10 with:$. . Transcript cr |
|
3877 |
" |
|
3878 |
! |
|
3879 |
||
3880 |
printOn:aStream paddedTo:size |
|
3881 |
"print the receiver on aStream, padding with spaces up to size." |
|
3882 |
||
3883 |
self printOn:aStream paddedTo:size with:(Character space) |
|
3884 |
||
3885 |
" |
|
3886 |
123.0 printOn:Transcript paddedTo:10. Transcript nextPut:$|. Transcript cr |
|
3887 |
" |
|
71 | 3888 |
! |
3889 |
||
783 | 3890 |
printOn:aStream paddedTo:size with:padCharacter |
3891 |
"print the receiver on aStream, padding with padCharacter up to size" |
|
3892 |
||
3893 |
aStream nextPutAll:(self printStringPaddedTo:size with:padCharacter). |
|
3894 |
||
3895 |
" |
|
3896 |
123 printOn:Transcript paddedTo:10 with:$_ . Transcript cr |
|
3897 |
123 printOn:Transcript paddedTo:10 with:$. . Transcript cr |
|
3898 |
" |
|
3899 |
! |
|
3900 |
||
3901 |
printOn:aStream zeroPaddedTo:size |
|
3902 |
"print the receiver on aStream, padding with zeros up to size. |
|
3903 |
Usually used with float numbers." |
|
3904 |
||
3905 |
self printOn:aStream paddedTo:size with:$0. |
|
3906 |
||
3907 |
" |
|
3908 |
123.0 printOn:Transcript zeroPaddedTo:10 |
|
3909 |
" |
|
3910 |
! |
|
3911 |
||
3912 |
printRightAdjustLen:size |
|
3913 |
"obsolete - just a name confusion. |
|
3914 |
This method will go away ..." |
|
3915 |
||
3916 |
(self printStringLeftPaddedTo:size) printOn:Stdout |
|
71 | 3917 |
! |
3918 |
||
3919 |
printString |
|
3920 |
"return a string for printing the receiver. |
|
3921 |
Since we now use printOn: as the basic print mechanism, |
|
3922 |
we have to create a stream and print into it." |
|
3923 |
||
3924 |
|s| |
|
3925 |
||
3926 |
s := WriteStream on:(String new:30). |
|
3927 |
self printOn:s. |
|
3928 |
^ s contents |
|
3929 |
! |
|
3930 |
||
783 | 3931 |
printStringLeftPaddedTo:size |
3932 |
"return my printString as a right-adjusted string of length size; |
|
3933 |
characters on the left are filled with spaces. |
|
3934 |
If the printString is longer than size, |
|
3935 |
it is returned unchanged (i.e. not truncated)" |
|
3936 |
||
3937 |
^ self printStringLeftPaddedTo:size with:(Character space) |
|
3938 |
||
3939 |
" |
|
3940 |
10 printStringLeftPaddedTo:10 |
|
3941 |
1 printStringLeftPaddedTo:10 |
|
3942 |
" |
|
3943 |
! |
|
3944 |
||
3945 |
printStringLeftPaddedTo:size ifLarger:alternative |
|
3946 |
"return my printString as a right-adjusted string of length size; |
|
3947 |
characters on the left are filled with spaces. |
|
3948 |
If the printString is larger than size, |
|
3949 |
return the result from evaluating alternative." |
|
3950 |
||
3951 |
^ self printStringLeftPaddedTo:size with:(Character space) ifLarger:alternative |
|
3952 |
||
3953 |
" |
|
3954 |
12 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
3955 |
123 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
3956 |
1234 printStringLeftPaddedTo:3 ifLarger:['***'] |
|
3957 |
" |
|
3958 |
! |
|
3959 |
||
3960 |
printStringLeftPaddedTo:size with:padCharacter |
|
3961 |
"return my printString as a right-adjusted string of length size; |
|
3962 |
characters on the left are filled with padCharacter. |
|
3963 |
If the printString is longer than size, |
|
3964 |
it is returned unchanged (i.e. not truncated)" |
|
3965 |
||
3966 |
^ (self printString) leftPaddedTo:size with:padCharacter |
|
3967 |
||
3968 |
" |
|
3969 |
123 printStringLeftPaddedTo:10 with:$. |
|
3970 |
1 printStringLeftPaddedTo:10 with:$. |
|
3971 |
(Float pi) printStringLeftPaddedTo:20 with:$* |
|
3972 |
" |
|
3973 |
! |
|
3974 |
||
3975 |
printStringLeftPaddedTo:size with:padCharacter ifLarger:alternative |
|
3976 |
"return my printString as a right-adjusted string of length size; |
|
3977 |
characters on the left are filled with padCharacter. |
|
3978 |
If the printString is larger than size, |
|
369 | 3979 |
return the result from evaluating alternative." |
3980 |
||
3981 |
|s| |
|
3982 |
||
3983 |
s := self printString. |
|
3984 |
s size > size ifTrue:[^ alternative value]. |
|
783 | 3985 |
^ s leftPaddedTo:size with:padCharacter |
369 | 3986 |
|
3987 |
" |
|
783 | 3988 |
12 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
3989 |
123 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
|
3990 |
1234 printStringLeftPaddedTo:3 with:$. ifLarger:['***'] |
|
293 | 3991 |
" |
13 | 3992 |
! |
3993 |
||
3994 |
printStringPaddedTo:size |
|
56 | 3995 |
"return a printed representation of the receiver, |
369 | 3996 |
padded with spaces (at the right) up to size. |
293 | 3997 |
If the printString is longer than size, |
3998 |
it is returned unchanged (i.e. not truncated)" |
|
13 | 3999 |
|
4000 |
^ self printStringPaddedTo:size with:(Character space) |
|
4001 |
||
293 | 4002 |
" |
4003 |
123 printStringPaddedTo:10 |
|
4004 |
1234567890123456 printStringPaddedTo:10 |
|
4005 |
'hello' printStringPaddedTo:10 |
|
4006 |
" |
|
2 | 4007 |
! |
4008 |
||
369 | 4009 |
printStringPaddedTo:size ifLarger:alternative |
4010 |
"return a printed representation of the receiver, |
|
4011 |
padded with spaces (at the right) up to size. |
|
4012 |
If the resulting printString is too large, |
|
4013 |
return the result from evaluating alternative." |
|
4014 |
||
4015 |
^ self printStringPaddedTo:size with:(Character space) ifLarger:alternative |
|
4016 |
||
4017 |
" |
|
4018 |
12 printStringPaddedTo:3 ifLarger:['***'] |
|
4019 |
123 printStringPaddedTo:3 ifLarger:['***'] |
|
4020 |
1234 printStringPaddedTo:3 ifLarger:['***'] |
|
4021 |
" |
|
4022 |
! |
|
4023 |
||
783 | 4024 |
printStringPaddedTo:size with:padCharacter |
4025 |
"return a printed representation of the receiver, |
|
4026 |
padded with padCharacter (at the right) up to size. |
|
4027 |
If the printString is longer than size, |
|
4028 |
it is returned unchanged (i.e. not truncated)" |
|
4029 |
||
4030 |
^ (self printString) paddedTo:size with:padCharacter |
|
4031 |
||
4032 |
" |
|
4033 |
123 printStringPaddedTo:10 with:$. |
|
4034 |
123 printStringPaddedTo:10 with:$* |
|
4035 |
123 printStringPaddedTo:3 with:$* |
|
4036 |
1234 printStringPaddedTo:3 with:$* |
|
4037 |
" |
|
4038 |
! |
|
4039 |
||
4040 |
printStringPaddedTo:size with:padCharacter ifLarger:alternative |
|
4041 |
"return a printed representation of the receiver, |
|
4042 |
padded with padCharacter (at the right) up to size. |
|
4043 |
If the resulting printString is too large, |
|
4044 |
return the result from evaluating alternative." |
|
4045 |
||
4046 |
|s| |
|
4047 |
||
4048 |
s := self printString. |
|
4049 |
s size > size ifTrue:[^ alternative value]. |
|
4050 |
^ s paddedTo:size with:padCharacter |
|
4051 |
||
4052 |
" |
|
4053 |
123 printStringPaddedTo:3 with:$. ifLarger:['***'] |
|
4054 |
12345 printStringPaddedTo:3 with:$. ifLarger:['***'] |
|
4055 |
" |
|
4056 |
! |
|
4057 |
||
4058 |
printStringRightAdjustLen:size |
|
4059 |
"obsolete - just a name confusion. |
|
4060 |
This method will go away ..." |
|
4061 |
||
4062 |
^ self printStringLeftPaddedTo:size |
|
4063 |
! |
|
4064 |
||
2 | 4065 |
printStringZeroPaddedTo:size |
71 | 4066 |
"return a printed representation of the receiver, |
369 | 4067 |
padded with zero (at the right) characters up to size. |
13 | 4068 |
Usually used with float numbers." |
2 | 4069 |
|
4070 |
^ self printStringPaddedTo:size with:$0 |
|
13 | 4071 |
|
293 | 4072 |
" |
4073 |
123.0 printStringZeroPaddedTo:10 |
|
4074 |
" |
|
2 | 4075 |
! |
4076 |
||
783 | 4077 |
store |
4078 |
"store the receiver on standard output. |
|
4079 |
this method is useless, but included for compatibility." |
|
4080 |
||
4081 |
self storeOn:Stdout |
|
71 | 4082 |
! |
4083 |
||
1425 | 4084 |
storeCR |
4085 |
"store the receiver on standard output; append a carriage return." |
|
4086 |
||
4087 |
self store. |
|
4088 |
Character cr print |
|
4089 |
||
4090 |
"Created: 20.5.1996 / 10:26:01 / cg" |
|
4091 |
"Modified: 20.5.1996 / 10:26:57 / cg" |
|
4092 |
! |
|
4093 |
||
783 | 4094 |
storeNl |
4095 |
"store the receiver on standard output; append a newline. |
|
1425 | 4096 |
This method is included for backward compatibility- use #storeCR." |
4097 |
||
4098 |
self storeCR. |
|
4099 |
||
4100 |
"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
|
4101 |
! |
7e058858cc3b
New Method: displayOn:aGc at:aPoint (ST80-compatibility).
Stefan Vogel <sv@exept.de>
parents:
446
diff
changeset
|
4102 |
|
56 | 4103 |
storeOn:aStream |
4104 |
"store the receiver on aStream; i.e. print an expression which will |
|
293 | 4105 |
reconstruct the receiver. |
4106 |
Notice, that no self referencing or cyclic objects can be represented |
|
4107 |
in this format. |
|
4108 |
Use storeBinaryOn:, which handles these cases correctly." |
|
56 | 4109 |
|
4110 |
|myClass hasSemi sz "{ Class: SmallInteger }" | |
|
1 | 4111 |
|
25 | 4112 |
thisContext isRecursive ifTrue:[ |
1417 | 4113 |
Transcript showCR:'Error: storeString of self referencing object.'. |
4114 |
aStream nextPutAll:'#("recursive")'. |
|
4115 |
^ self |
|
25 | 4116 |
]. |
56 | 4117 |
|
1 | 4118 |
myClass := self class. |
56 | 4119 |
aStream nextPut:$(. |
4120 |
aStream nextPutAll:self class name. |
|
4121 |
||
1 | 4122 |
hasSemi := false. |
4123 |
myClass isVariable ifTrue:[ |
|
1417 | 4124 |
aStream nextPutAll:' basicNew:'. |
4125 |
self basicSize printOn:aStream |
|
1 | 4126 |
] ifFalse:[ |
1417 | 4127 |
aStream nextPutAll:' basicNew' |
1 | 4128 |
]. |
56 | 4129 |
|
1 | 4130 |
sz := myClass instSize. |
4131 |
1 to:sz do:[:i | |
|
1417 | 4132 |
aStream nextPutAll:' instVarAt:'. |
4133 |
i printOn:aStream. |
|
4134 |
aStream nextPutAll:' put:'. |
|
4135 |
(self instVarAt:i) storeOn:aStream. |
|
4136 |
aStream nextPut:$;. |
|
4137 |
hasSemi := true |
|
1 | 4138 |
]. |
4139 |
myClass isVariable ifTrue:[ |
|
1417 | 4140 |
sz := self basicSize. |
4141 |
1 to:sz do:[:i | |
|
4142 |
aStream nextPutAll:' basicAt:'. |
|
4143 |
i printOn:aStream. |
|
4144 |
aStream nextPutAll:' put:'. |
|
4145 |
(self basicAt:i) storeOn:aStream. |
|
4146 |
aStream nextPut:$;. |
|
4147 |
hasSemi := true |
|
4148 |
] |
|
1 | 4149 |
]. |
4150 |
hasSemi ifTrue:[ |
|
1417 | 4151 |
aStream nextPutAll:' yourself' |
1 | 4152 |
]. |
56 | 4153 |
aStream nextPut:$). |
293 | 4154 |
|
4155 |
" |
|
4156 |
|s| |
|
4157 |
||
4158 |
s := WriteStream on:(String new). |
|
4159 |
('hello' -> 'world') storeOn:s. |
|
4160 |
s := ReadStream on:(s contents). |
|
4161 |
(Object readFrom:s) inspect |
|
4162 |
" |
|
4163 |
" |
|
4164 |
|s| |
|
4165 |
||
4166 |
s := 'data' asFilename writeStream. |
|
4167 |
('hello' -> 'world') storeOn:s. |
|
4168 |
s close. |
|
4169 |
||
4170 |
s := 'data' asFilename readStream. |
|
4171 |
(Object readFrom:s) inspect |
|
4172 |
" |
|
4173 |
||
4174 |
"does not work example:" |
|
4175 |
" |
|
4176 |
|s a| |
|
4177 |
||
4178 |
a := Array new:2. |
|
4179 |
a at:1 put:a. |
|
4180 |
||
4181 |
s := 'data' asFilename writeStream. |
|
4182 |
a storeOn:s. |
|
4183 |
s close. |
|
4184 |
||
4185 |
s := 'data' asFilename readStream. |
|
4186 |
(Object readFrom:s) inspect |
|
4187 |
" |
|
1417 | 4188 |
|
4189 |
"Modified: 18.5.1996 / 15:43:35 / cg" |
|
1 | 4190 |
! |
4191 |
||
56 | 4192 |
storeString |
293 | 4193 |
"return a string representing an expression to reconstruct the receiver. |
4194 |
Notice, that no self referencing or cyclic objects can be represented |
|
4195 |
in this format. |
|
4196 |
Use storeBinaryOn:, which handles these cases correctly." |
|
56 | 4197 |
|
4198 |
|s| |
|
4199 |
||
4200 |
s := WriteStream on:(String new:50). |
|
4201 |
self storeOn:s. |
|
4202 |
^ s contents |
|
783 | 4203 |
! ! |
4204 |
||
4205 |
!Object methodsFor:'queries'! |
|
4206 |
||
4207 |
basicSize |
|
4208 |
"return the number of the receivers indexed instance variables, |
|
4209 |
0 if it has none. |
|
4210 |
||
4211 |
This method should NOT be redefined in any subclass" |
|
4212 |
||
4213 |
%{ /* NOCONTEXT */ |
|
4214 |
||
4215 |
REGISTER int nbytes; |
|
4216 |
REGISTER OBJ myClass; |
|
4217 |
REGISTER int flags; |
|
4218 |
||
4219 |
/* |
|
4220 |
* notice the missing test for self being a nonNilObject - |
|
4221 |
* this can be done since basicSize is defined both in UndefinedObject |
|
4222 |
* and SmallInteger |
|
4223 |
*/ |
|
4224 |
myClass = __qClass(self); |
|
4225 |
nbytes = __qSize(self) |
|
4226 |
- OHDR_SIZE |
|
1133 | 4227 |
- __OBJS2BYTES__(__intVal(__ClassInstPtr(myClass)->c_ninstvars)); |
4228 |
||
4229 |
flags = __intVal(__ClassInstPtr(myClass)->c_flags) & ARRAYMASK; |
|
783 | 4230 |
/* |
4231 |
* replaced switch by open-if; this is slightly faster since |
|
4232 |
* it avoids the range check and also checks the most common case first |
|
4233 |
*/ |
|
4234 |
if ((flags == POINTERARRAY) |
|
4235 |
|| (flags == WKPOINTERARRAY)) { |
|
4236 |
RETURN ( __MKSMALLINT(__BYTES2OBJS__(nbytes)) ); |
|
4237 |
} |
|
4238 |
if (flags == BYTEARRAY) { |
|
4239 |
RETURN ( __MKSMALLINT(nbytes / sizeof(char)) ); |
|
4240 |
} |
|
4241 |
if (flags == FLOATARRAY) { |
|
4242 |
RETURN ( __MKSMALLINT(nbytes / sizeof(float)) ); |
|
4243 |
} |
|
4244 |
if (flags == DOUBLEARRAY) { |
|
4245 |
#ifdef NEED_DOUBLE_ALIGN |
|
4246 |
/* |
|
4247 |
* care for filler |
|
4248 |
*/ |
|
4249 |
nbytes -= sizeof(FILLTYPE); |
|
4250 |
#endif |
|
4251 |
RETURN ( __MKSMALLINT(nbytes / sizeof(double)) ); |
|
4252 |
} |
|
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
4253 |
if ((flags == WORDARRAY) || (flags == SWORDARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
4254 |
RETURN ( __MKSMALLINT(nbytes / sizeof(short)) ); |
783 | 4255 |
} |
1515
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
4256 |
if ((flags == LONGARRAY) || (flags == SLONGARRAY)) { |
49a8587fcc8f
added support for signedWord and signedLong indexable classes.
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
4257 |
RETURN ( __MKSMALLINT(nbytes / sizeof(long)) ); |
783 | 4258 |
} |
4259 |
%}. |
|
4260 |
^ 0 |
|
1 | 4261 |
! |
4262 |
||
783 | 4263 |
class |
4264 |
"return the receivers class" |
|
4265 |
||
4266 |
%{ /* NOCONTEXT */ |
|
4267 |
||
4268 |
RETURN ( __Class(self) ); |
|
4269 |
%} |
|
4270 |
! |
|
4271 |
||
4272 |
isArray |
|
4273 |
"return true, if the receiver is some kind of array (or weakArray etc); |
|
4274 |
false is returned here - the method is only redefined in Array." |
|
4275 |
||
4276 |
^ false |
|
4277 |
! |
|
4278 |
||
1397 | 4279 |
isAssociation |
4280 |
"return true, if the receiver is some kind of association; |
|
4281 |
false is returned here - the method is only redefined in Association." |
|
4282 |
||
4283 |
^ false |
|
4284 |
||
4285 |
"Created: 14.5.1996 / 17:03:45 / cg" |
|
4286 |
! |
|
4287 |
||
783 | 4288 |
isBehavior |
4289 |
"return true, if the receiver is some kind of class (i.e. behavior); |
|
4290 |
false is returned here - the method is only redefined in Behavior." |
|
4291 |
||
4292 |
^ false |
|
4293 |
! |
|
4294 |
||
4295 |
isBlock |
|
4296 |
"return true, if the receiver is some kind of block; |
|
4297 |
false returned here - the method is only redefined in Block." |
|
4298 |
||
4299 |
^ false |
|
4300 |
! |
|
4301 |
||
4302 |
isCharacter |
|
4303 |
"return true, if the receiver is some kind of character; |
|
4304 |
false is returned here - the method is only redefined in Character." |
|
4305 |
||
4306 |
^ false |
|
4307 |
! |
|
4308 |
||
4309 |
isClass |
|
4310 |
"return true, if the receiver is some kind of class (real class, |
|
4311 |
not just behavior); |
|
4312 |
false is returned here - the method is only redefined in Class." |
|
4313 |
||
4314 |
^ false |
|
4315 |
! |
|
4316 |
||
4317 |
isCollection |
|
4318 |
"return true, if the receiver is some kind of collection; |
|
4319 |
false is returned here - the method is only redefined in Collection." |
|
4320 |
||
4321 |
^ false |
|
4322 |
! |
|
4323 |
||
4324 |
isColor |
|
4325 |
"return true, if the receiver is some kind of color; |
|
4326 |
false is returned here - the method is only redefined in Color." |
|
4327 |
||
4328 |
^ false |
|
4329 |
! |
|
4330 |
||
4331 |
isContext |
|
4332 |
"return true, if the receiver is some kind of context; |
|
4333 |
false returned here - the method is only redefined in Context." |
|
4334 |
||
4335 |
^ false |
|
4336 |
! |
|
4337 |
||
4338 |
isExternalStream |
|
4339 |
"return true, if the receiver is some kind of externalStream; |
|
4340 |
false is returned here - the method is only redefined in ExternalStream." |
|
4341 |
||
4342 |
^false |
|
4343 |
! |
|
4344 |
||
4345 |
isFileStream |
|
4346 |
"return true, if the receiver is some kind of fileStream; |
|
4347 |
false is returned here - the method is only redefined in FileStream." |
|
4348 |
||
4349 |
^false |
|
4350 |
! |
|
4351 |
||
4352 |
isFixedSize |
|
4353 |
"return true if the receiver cannot grow easily |
|
4354 |
(i.e. a grow may be expensive, since it involves a become:)" |
|
4355 |
||
4356 |
^ true |
|
4357 |
! |
|
4358 |
||
4359 |
isForm |
|
4360 |
"return true, if the receiver is some kind of form; |
|
4361 |
false is returned here - the method is only redefined in Form." |
|
4362 |
||
4363 |
^ false |
|
4364 |
! |
|
4365 |
||
4366 |
isFraction |
|
4367 |
"return true, if the receiver is some kind of fraction; |
|
4368 |
false is returned here - the method is only redefined in Fraction." |
|
4369 |
||
4370 |
^ false |
|
4371 |
! |
|
4372 |
||
4373 |
isImage |
|
4374 |
"return true, if the receiver is some kind of image; |
|
4375 |
false is returned here - the method is only redefined in Image." |
|
4376 |
||
4377 |
^ false |
|
4378 |
! |
|
4379 |
||
4380 |
isImageOrForm |
|
4381 |
"return true, if the receiver is some kind of image or form; |
|
4382 |
false is returned here - the method is only redefined in Image and Form." |
|
4383 |
||
4384 |
^ false |
|
4385 |
! |
|
4386 |
||
4387 |
isInteger |
|
4388 |
"return true, if the receiver is some kind of integer number; |
|
4389 |
false is returned here - the method is only redefined in Integer." |
|
4390 |
||
4391 |
^ false |
|
4392 |
! |
|
4393 |
||
4394 |
isKindOf:aClass |
|
4395 |
"return true, if the receiver is an instance of aClass or one of its |
|
4396 |
subclasses, false otherwise. |
|
4397 |
Advice: |
|
4398 |
use of this to check objects for certain attributes/protocoll should |
|
4399 |
be avoided; it limits the reusability of your classes by limiting use |
|
4400 |
to instances of certain classes and fences you into a specific inheritance |
|
4401 |
hierarchy. |
|
4402 |
Use check-methods to check an object for a certain attributes/protocol |
|
4403 |
(such as #isXXXX, #respondsTo: or #isNumber). |
|
4404 |
||
4405 |
Using #isKindOf: is considered BAD STYLE. |
|
4406 |
||
4407 |
Advice2: |
|
4408 |
Be aware, that using an #isXXX method is usually much faster than |
|
4409 |
using #isKindOf:; because isKindOf: has to walk up all the superclass |
|
4410 |
hierarchy, comparing every class on the way. |
|
4411 |
Due to caching in the VM, a call to #isXXX is normally reached via |
|
4412 |
a single function call. |
|
4413 |
" |
|
4414 |
||
4415 |
%{ /* NOCONTEXT */ |
|
4416 |
register OBJ thisClass; |
|
4417 |
||
4418 |
thisClass = __Class(self); |
|
4419 |
while (thisClass != nil) { |
|
4420 |
if (thisClass == aClass) { |
|
4421 |
RETURN ( true ); |
|
4422 |
} |
|
1133 | 4423 |
thisClass = __ClassInstPtr(thisClass)->c_superclass; |
783 | 4424 |
} |
4425 |
%} |
|
4426 |
. |
|
4427 |
"/ |
|
4428 |
"/ the above code is equivalent to: |
|
4429 |
"/ |
|
4430 |
"/ thisClass := self class. |
|
4431 |
"/ [thisClass notNil] whileTrue:[ |
|
4432 |
"/ thisClass == aClass ifTrue:[^ true]. |
|
4433 |
"/ thisClass := thisClass superclass |
|
4434 |
"/ ] |
|
4435 |
"/ |
|
4436 |
^ false |
|
4437 |
! |
|
4438 |
||
4439 |
isLayout |
|
4440 |
"return true, if the receiver is some kind of layout; |
|
4441 |
false is returned here - the method is only redefined in Layout." |
|
4442 |
||
4443 |
^ false |
|
4444 |
! |
|
4445 |
||
4446 |
isLiteral |
|
4447 |
"return true, if the receiver can be represented as a constant in ST syntax; |
|
4448 |
false is returned here - the method is redefined in some classes." |
|
4449 |
||
4450 |
^ false |
|
4451 |
! |
|
4452 |
||
4453 |
isMemberOf:aClass |
|
4454 |
"return true, if the receiver is an instance of aClass, false otherwise. |
|
4455 |
Advice: |
|
4456 |
use of this to check objects for certain attributes/protocoll should |
|
4457 |
be avoided; it limits the reusability of your classes by limiting use |
|
4458 |
to instances of a certain class. |
|
4459 |
Use check-methods to check an object for a certain attributes/protocol |
|
4460 |
(such as #isXXX, #respondsTo: or #isNumber); |
|
4461 |
||
4462 |
Using #isMemberOf: is considered BAD STYLE." |
|
4463 |
||
4464 |
^ (self class) == aClass |
|
4465 |
! |
|
4466 |
||
4467 |
isMeta |
|
4468 |
"return true, if the receiver is some kind of metaclass; |
|
4469 |
false is returned here - the method is only redefined in Metaclass." |
|
4470 |
||
4471 |
^ false |
|
4472 |
! |
|
4473 |
||
4474 |
isMethod |
|
4475 |
"return true, if the receiver is some kind of method; |
|
4476 |
false returned here - the method is only redefined in Method." |
|
4477 |
||
4478 |
^ false |
|
4479 |
! |
|
4480 |
||
4481 |
isNumber |
|
4482 |
"return true, if the receiver is some kind of number; |
|
4483 |
false is returned here - the method is only redefined in Number." |
|
4484 |
||
4485 |
^ false |
|
4486 |
! |
|
4487 |
||
4488 |
isPoint |
|
4489 |
"return true, if the receiver is some kind of point; |
|
4490 |
false is returned here - the method is only redefined in Point." |
|
4491 |
||
4492 |
^ false |
|
4493 |
! |
|
4494 |
||
4495 |
isReal |
|
4496 |
"return true, if the receiver is some kind of real number; |
|
4497 |
false is returned here - the method is only redefined in LimitedPrecisionReal." |
|
4498 |
||
4499 |
^ false |
|
4500 |
! |
|
4501 |
||
4502 |
isRectangle |
|
4503 |
"return true, if the receiver is some kind of rectangle; |
|
4504 |
false is returned here - the method is only redefined in Rectangle." |
|
4505 |
||
4506 |
^ false |
|
4507 |
! |
|
4508 |
||
4509 |
isSequenceable |
|
4510 |
"return true, if the receiver is some kind of sequenceable collection; |
|
4511 |
false is returned here - the method is only redefined in SequenceableCollection." |
|
4512 |
||
4513 |
^ false |
|
4514 |
! |
|
4515 |
||
4516 |
isSequenceableCollection |
|
4517 |
"OBSOLETE: use isSequenceable for ST-80 compatibility. |
|
4518 |
This method is a historic leftover and will be removed soon ..." |
|
4519 |
||
4520 |
self obsoleteMethodWarning:'use #isSequenceable'. |
|
4521 |
^ false |
|
4522 |
! |
|
4523 |
||
4524 |
isSignal |
|
4525 |
"return true, if the receiver is some kind of signal; |
|
4526 |
false returned here - the method is only redefined in Signal." |
|
4527 |
||
4528 |
^ false |
|
4529 |
! |
|
4530 |
||
4531 |
isStream |
|
4532 |
"return true, if the receiver is some kind of stream; |
|
4533 |
false is returned here - the method is only redefined in Stream." |
|
4534 |
||
4535 |
^ false |
|
4536 |
! |
|
4537 |
||
4538 |
isString |
|
4539 |
"return true, if the receiver is some kind of string; |
|
4540 |
false is returned here - the method is only redefined in String." |
|
4541 |
||
4542 |
^ false |
|
4543 |
! |
|
4544 |
||
4545 |
isSymbol |
|
4546 |
"return true, if the receiver is some kind of symbol; |
|
4547 |
false is returned here - the method is only redefined in Symbol." |
|
4548 |
||
4549 |
^ false |
|
4550 |
! |
|
4551 |
||
1377 | 4552 |
isText |
4553 |
"return true, if the receiver is some kind of text object; |
|
4554 |
false is returned here - the method is only redefined in Text." |
|
4555 |
||
4556 |
^ false |
|
4557 |
||
4558 |
"Created: 12.5.1996 / 10:56:50 / cg" |
|
4559 |
! |
|
4560 |
||
783 | 4561 |
isVariable |
4562 |
"return true if the receiver has indexed instance variables, |
|
4563 |
false otherwise." |
|
4564 |
||
4565 |
^ self class isVariable |
|
4566 |
! |
|
4567 |
||
4568 |
isView |
|
4569 |
"return true, if the receiver is some kind of view; |
|
4570 |
false is returned here - the method is only redefined in View." |
|
4571 |
||
4572 |
^ false |
|
4573 |
! |
|
4574 |
||
4575 |
respondsTo:aSelector |
|
4576 |
"return true, if the receiver implements a method with selector equal |
|
4577 |
to aSelector; i.e. if there is a method for aSelector in either the |
|
4578 |
receivers class or one of its superclasses. |
|
4579 |
||
4580 |
Notice, that this does not imply, that such a message can be sent without |
|
4581 |
an error being raised. For example, an implementation could send |
|
4582 |
#shouldNotImplement or #subclassResponsibility." |
|
4583 |
||
4584 |
" |
|
4585 |
should we go via the cache, or search (by class) ? |
|
4586 |
The first is faster, most of the time; while the 2nd fills |
|
4587 |
the cache with useless data if this is sent in a loop over all objects. |
|
4588 |
For now, use the cache ... |
|
4589 |
" |
|
4590 |
%{ /* NOCONTEXT */ |
|
4591 |
||
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
816
diff
changeset
|
4592 |
if (__lookup(__Class(self), aSelector) == nil) { |
783 | 4593 |
RETURN ( false ); |
4594 |
} |
|
4595 |
RETURN ( true ); |
|
4596 |
%} |
|
4597 |
. |
|
4598 |
" |
|
4599 |
^ self class canUnderstand:aSelector |
|
4600 |
" |
|
4601 |
||
4602 |
"'aString' respondsTo:#+" |
|
4603 |
"'aString' respondsTo:#," |
|
4604 |
"'aString' respondsTo:#collect:" |
|
4605 |
! |
|
4606 |
||
4607 |
respondsToArithmetic |
|
4608 |
"return true, if the receiver responds to arithmetic messages. |
|
4609 |
false is returned here - the method is redefined in ArithmeticValue." |
|
4610 |
||
4611 |
^ false |
|
4612 |
! |
|
4613 |
||
4614 |
size |
|
4615 |
"return the number of the receivers indexed instance variables; |
|
4616 |
this method may be redefined in subclasses" |
|
4617 |
||
4618 |
^ self basicSize |
|
4619 |
! |
|
4620 |
||
4621 |
species |
|
4622 |
"return a class which is similar to (or the same as) the receivers class. |
|
4623 |
This is used to create an appropriate object when creating derived |
|
4624 |
copies in the collection classes (sometimes redefined)." |
|
4625 |
||
4626 |
^ self class |
|
4627 |
! |
|
4628 |
||
4629 |
yourself |
|
4630 |
"return the receiver - used for cascades to return self at the end" |
|
4631 |
||
4632 |
^ self |
|
4633 |
! ! |
|
4634 |
||
4635 |
!Object methodsFor:'secure message sending'! |
|
4636 |
||
4637 |
askFor:aSelector |
|
4638 |
"try to send the receiver the message, aSelector. |
|
4639 |
If it does not understand it, return false. Otherwise |
|
4640 |
the real value returned. |
|
4641 |
Useful to send messages such as: 'isColor' to unknown |
|
4642 |
receivers." |
|
4643 |
||
4644 |
^ self perform:aSelector ifNotUnderstood:[false] |
|
4645 |
||
4646 |
" |
|
4647 |
1 askFor:#isColor |
|
4648 |
" |
|
4649 |
! |
|
4650 |
||
4651 |
perform:aSelector ifNotUnderstood:exceptionBlock |
|
4652 |
"try to send message aSelector to the receiver. |
|
4653 |
If its understood, return the methods returned value, |
|
4654 |
otherwise return the value of the exceptionBlock" |
|
4655 |
||
4656 |
|val| |
|
4657 |
||
4658 |
MessageNotUnderstoodSignal handle:[:ex | |
|
4659 |
^ exceptionBlock value |
|
4660 |
] do:[ |
|
4661 |
val := self perform:aSelector |
|
4662 |
]. |
|
4663 |
^ val |
|
4664 |
||
4665 |
" |
|
4666 |
1.2345 perform:#foo ifNotUnderstood:['sorry'] |
|
4667 |
" |
|
1 | 4668 |
! |
4669 |
||
783 | 4670 |
perform:aSelector with:argument ifNotUnderstood:exceptionBlock |
4671 |
"try to send message aSelector to the receiver. |
|
4672 |
If its understood, return the methods returned value, |
|
4673 |
otherwise return the value of the exceptionBlock" |
|
4674 |
||
4675 |
|val| |
|
4676 |
||
4677 |
MessageNotUnderstoodSignal handle:[:ex | |
|
4678 |
^ exceptionBlock value |
|
4679 |
] do:[ |
|
4680 |
val := self perform:aSelector with:argument |
|
4681 |
]. |
|
4682 |
^ val |
|
4683 |
||
4684 |
" |
|
4685 |
|unknown| |
|
4686 |
||
4687 |
unknown := 1. |
|
4688 |
(unknown perform:#+ with:2 ifNotUnderstood:['sorry']) printNewline. |
|
4689 |
unknown := 'high there'. |
|
4690 |
(unknown perform:#+ with:2 ifNotUnderstood:['sorry']) printNewline. |
|
4691 |
" |
|
4692 |
! ! |
|
4693 |
||
4694 |
!Object methodsFor:'special queries'! |
|
4695 |
||
4696 |
allOwners |
|
4697 |
"return a collection of all objects referencing the receiver" |
|
4698 |
||
4699 |
^ ObjectMemory whoReferences:self |
|
4700 |
! |
|
4701 |
||
4702 |
references:anObject |
|
4703 |
"return true, if the receiver refers to the argument, anObject. |
|
4704 |
- for debugging only" |
|
4705 |
||
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4706 |
"/ |myClass |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4707 |
"/ numInst "{ Class: SmallInteger }" | |
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 |
%{ /* NOCONTEXT */ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4710 |
OBJ cls, flags; |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4711 |
int nInsts, i; |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4712 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4713 |
if (! __isNonNilObject(self)) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4714 |
RETURN (false); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4715 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4716 |
|
783 | 4717 |
/* |
4718 |
* a little optimization: use the fact that all old objects |
|
4719 |
* refering to a new object are on the remSet; if I am not, |
|
4720 |
* a trivial reject is possible, if anObject is a newbee |
|
4721 |
*/ |
|
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4722 |
if (__isNonNilObject(anObject)) { |
783 | 4723 |
if ((__qSpace(self) <= OLDSPACE) && !__isRemembered(self)) { |
4724 |
int spc; |
|
4725 |
||
4726 |
if (((spc = __qSpace(anObject)) == NEWSPACE) || (spc == SURVSPACE)) { |
|
4727 |
RETURN (false); |
|
4728 |
} |
|
4729 |
} |
|
4730 |
} |
|
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4731 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4732 |
cls = __qClass(self); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4733 |
if (cls == anObject) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4734 |
RETURN (true); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4735 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4736 |
|
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4737 |
flags = __ClassInstPtr(cls)->c_flags; |
1386
a31cecccdfd8
_MASKSMALLINT -> __MASKSMALLINT;
Claus Gittinger <cg@exept.de>
parents:
1377
diff
changeset
|
4738 |
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
|
4739 |
nInsts = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4740 |
} else { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4741 |
nInsts = __intVal(__ClassInstPtr(cls)->c_ninstvars); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4742 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4743 |
if (! nInsts) { |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4744 |
RETURN (false); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4745 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4746 |
for (i=0; i<nInsts; i++) { |
1133 | 4747 |
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
|
4748 |
RETURN (true); |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4749 |
} |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4750 |
} |
783 | 4751 |
%}. |
4752 |
||
1109
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4753 |
"/ myClass := self class. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4754 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4755 |
"/ "check the class" |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4756 |
"/ (myClass == anObject) ifTrue:[^ true]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4757 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4758 |
"/ "check the instance variables" |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4759 |
"/ numInst := myClass instSize. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4760 |
"/ 1 to:numInst do:[:i | |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4761 |
"/ ((self instVarAt:i) == anObject) ifTrue:[^ true] |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4762 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4763 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4764 |
"/ "check the indexed variables" |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4765 |
"/ myClass isVariable ifTrue:[ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4766 |
"/ myClass isPointers ifFalse:[ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4767 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4768 |
"/ "/ 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
|
4769 |
"/ "/ 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
|
4770 |
"/ "/ 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
|
4771 |
"/ "/ 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
|
4772 |
"/ "/ 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
|
4773 |
"/ "/ 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
|
4774 |
"/ "/ 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
|
4775 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4776 |
"/ ^ false. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4777 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4778 |
"/ "/ alternative: |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4779 |
"/ "/ anObject isNumber ifFalse:[^ false]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4780 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4781 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4782 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4783 |
"/ "/ 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
|
4784 |
"/ "/ idenitytIndex method, use it |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4785 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4786 |
"/ myClass == Array ifTrue:[ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4787 |
"/ ^ (self identityIndexOf:anObject) ~~ 0 |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4788 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4789 |
"/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4790 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4791 |
"/ "/ otherwise, do it the slow way |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4792 |
"/ "/ |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4793 |
"/ numInst := self basicSize. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4794 |
"/ 1 to:numInst do:[:i | |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4795 |
"/ ((self basicAt:i) == anObject) ifTrue:[^ true] |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4796 |
"/ ] |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4797 |
"/ ]. |
38956a3cd61e
speeded up #references: (needed for allOwners etc.)
Claus Gittinger <cg@exept.de>
parents:
1101
diff
changeset
|
4798 |
|
783 | 4799 |
^ false |
4800 |
||
4801 |
" |
|
4802 |
|v| |
|
4803 |
||
4804 |
v := View new initialize. |
|
4805 |
v references:Display. |
|
4806 |
" |
|
4807 |
! |
|
4808 |
||
4809 |
referencesDerivedInstanceOf:aClass |
|
4810 |
"return true, if the receiver refers to an instance of |
|
4811 |
the argument, aClass or its subclass. This method exists |
|
4812 |
to support searching for users of a class." |
|
4813 |
||
4814 |
|myClass |
|
4815 |
numInst "{ Class: SmallInteger }" | |
|
4816 |
||
4817 |
myClass := self class. |
|
4818 |
||
4819 |
"check the class" |
|
4820 |
(myClass isKindOf:aClass) ifTrue:[^ true]. |
|
4821 |
||
4822 |
"check the instance variables" |
|
4823 |
numInst := myClass instSize. |
|
4824 |
1 to:numInst do:[:i | |
|
4825 |
((self instVarAt:i) isKindOf:aClass) ifTrue:[^ true] |
|
4826 |
]. |
|
4827 |
||
4828 |
"check the indexed variables" |
|
4829 |
myClass isVariable ifTrue:[ |
|
4830 |
myClass isPointers ifFalse:[ |
|
4831 |
"no need to search in non pointer fields" |
|
4832 |
((aClass == Number) or:[aClass isSubclassOf:Number]) ifFalse:[^ false]. |
|
4833 |
]. |
|
4834 |
numInst := self basicSize. |
|
4835 |
1 to:numInst do:[:i | |
|
4836 |
((self basicAt:i) isKindOf:aClass) ifTrue:[^ true] |
|
4837 |
] |
|
4838 |
]. |
|
4839 |
^ false |
|
4840 |
||
4841 |
" |
|
4842 |
(1 @ 3.4) referencesDerivedInstanceOf:Number |
|
4843 |
(1 @ 3.4) referencesDerivedInstanceOf:Array |
|
4844 |
View new initialize referencesDerivedInstanceOf:DeviceWorkstation |
|
4845 |
" |
|
4846 |
! |
|
4847 |
||
4848 |
referencesInstanceOf:aClass |
|
4849 |
"return true, if the receiver refers to an instance of |
|
4850 |
the argument, aClass.This method exists |
|
4851 |
to support searching for users of a class." |
|
4852 |
||
4853 |
|myClass |
|
4854 |
numInst "{ Class: SmallInteger }" | |
|
4855 |
||
4856 |
myClass := self class. |
|
4857 |
||
4858 |
"check the class" |
|
4859 |
(myClass isMemberOf:aClass) ifTrue:[^ true]. |
|
4860 |
||
4861 |
"check the instance variables" |
|
4862 |
numInst := myClass instSize. |
|
4863 |
1 to:numInst do:[:i | |
|
4864 |
((self instVarAt:i) isMemberOf:aClass) ifTrue:[^ true] |
|
4865 |
]. |
|
4866 |
||
4867 |
"check the indexed variables" |
|
4868 |
myClass isVariable ifTrue:[ |
|
4869 |
myClass isPointers ifFalse:[ |
|
4870 |
"no need to search in non-pointer indexed fields" |
|
4871 |
myClass isLongs ifTrue:[ |
|
4872 |
(aClass == SmallInteger or:[aClass == LargeInteger]) ifFalse:[^ false]. |
|
4873 |
] ifFalse:[ |
|
4874 |
myClass isFloatsOrDoubles ifTrue:[^ aClass == Float]. |
|
4875 |
^ aClass == SmallInteger |
|
4876 |
] |
|
4877 |
]. |
|
4878 |
numInst := self basicSize. |
|
4879 |
1 to:numInst do:[:i | |
|
4880 |
((self basicAt:i) isMemberOf:aClass) ifTrue:[^ true] |
|
4881 |
] |
|
4882 |
]. |
|
4883 |
^ false |
|
4884 |
||
4885 |
" |
|
4886 |
(1 @ 3.4) referencesInstanceOf:Float |
|
4887 |
(1 @ 3.4) referencesInstanceOf:Fraction |
|
4888 |
View new initialize referencesInstanceOf:(Display class) |
|
4889 |
" |
|
1 | 4890 |
! ! |
783 | 4891 |
|
4892 |
!Object methodsFor:'system primitives'! |
|
4893 |
||
4894 |
become:anotherObject |
|
4895 |
"make all references to the receiver become references to anotherObject |
|
859 | 4896 |
and vice-versa. Notice the vice-versa; see #becomeSameAs: for a one-way become. |
4897 |
This can be a very dangerous operation - be warned. |
|
861 | 4898 |
In general, using #become: should be avoided if possible, since it may |
4899 |
produce many strange effects (think of hashing in Sets, Dictionaries etc.). |
|
4900 |
||
4901 |
This may also be an expensive (i.e. slow) operation, |
|
783 | 4902 |
since in the worst case, the whole memory has to be searched for |
4903 |
references to the two objects (although the primitive tries hard to |
|
4904 |
limit the search, for acceptable performance in most cases). |
|
4905 |
This method fails, if the receiver or the argument is a SmallInteger |
|
4906 |
or nil, or is a context of a living method (i.e. one that has not already |
|
4907 |
returned). |
|
859 | 4908 |
(notice that #become: is not used heavily by the system |
783 | 4909 |
- the Collection-classes have been rewritten to not use it.)" |
4910 |
%{ |
|
859 | 4911 |
if (__primBecome(self, anotherObject COMMA_CON)) { |
783 | 4912 |
RETURN ( self ); |
859 | 4913 |
} |
4914 |
%}. |
|
783 | 4915 |
self primitiveFailed |
4916 |
! |
|
4917 |
||
4918 |
becomeNil |
|
4919 |
"make all references to the receiver become nil - effectively getting |
|
859 | 4920 |
rid of the receiver. |
4921 |
This can be a very dangerous operation - be warned. |
|
4922 |
||
4923 |
This may be an expensive (i.e. slow) operation. |
|
783 | 4924 |
The receiver may not be a SmallInteger or a context of a living method." |
4925 |
||
4926 |
%{ |
|
859 | 4927 |
if (__primBecomeNil(self COMMA_CON )) { |
783 | 4928 |
RETURN ( nil ); |
859 | 4929 |
} |
4930 |
%}. |
|
4931 |
self primitiveFailed |
|
4932 |
! |
|
4933 |
||
4934 |
becomeSameAs:anotherObject |
|
4935 |
"make all references to the receiver become references to anotherObject |
|
861 | 4936 |
but NOT vice versa (as done in #become:). |
859 | 4937 |
This can be a very dangerous operation - be warned. |
861 | 4938 |
In general, using #become: should be avoided if possible, since it may |
4939 |
produce many strange effects (think of hashing in Sets, Dictionaries etc.). |
|
4940 |
||
4941 |
This may also be an expensive (i.e. slow) operation, |
|
859 | 4942 |
since in the worst case, the whole memory has to be searched for |
4943 |
references to the two objects (although the primitive tries hard to |
|
4944 |
limit the search, for acceptable performance in most cases). |
|
4945 |
This method fails, if the receiver or the argument is a SmallInteger |
|
4946 |
or nil, or is a context of a living method (i.e. one that has not already returned)." |
|
4947 |
%{ |
|
4948 |
if (__primBecomeSameAs(self, anotherObject COMMA_CON)) { |
|
4949 |
RETURN ( self ); |
|
4950 |
} |
|
4951 |
%}. |
|
783 | 4952 |
self primitiveFailed |
4953 |
! |
|
4954 |
||
4955 |
changeClassTo:otherClass |
|
4956 |
"changes the class of the receiver to the argument, otherClass. |
|
4957 |
This is only allowed (possible), if the receivers class and the argument |
|
4958 |
have the same structure (i.e. number of named instance variables and |
|
4959 |
type of indexed instance variables). |
|
4960 |
If the structures do not match, or any of the original class or new class |
|
4961 |
is UndefinedObject or a Smallinteger, a primitive error is triggered." |
|
4962 |
||
4963 |
|myClass ok| |
|
4964 |
||
4965 |
"check for UndefinedObject/SmallInteger receiver or newClass" |
|
4966 |
%{ |
|
1133 | 4967 |
{ |
4968 |
OBJ other = otherClass; |
|
4969 |
||
4970 |
if (__isNonNilObject(self) |
|
4971 |
&& __isNonNilObject(other) |
|
4972 |
&& (other != UndefinedObject) |
|
4973 |
&& (other != SmallInteger)) { |
|
4974 |
ok = true; |
|
4975 |
} else { |
|
4976 |
ok = false; |
|
4977 |
} |
|
783 | 4978 |
} |
4979 |
%}. |
|
4980 |
ok ifTrue:[ |
|
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4981 |
ok := false. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4982 |
myClass := self class. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4983 |
myClass flags == otherClass flags ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4984 |
myClass instSize == otherClass instSize ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4985 |
"same instance layout and types: its ok to do it" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4986 |
ok := true. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4987 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4988 |
myClass isPointers ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4989 |
myClass isVariable ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4990 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4991 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4992 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4993 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4994 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4995 |
myClass isPointers ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4996 |
"if newClass is a variable class, with instSize <= my instsize, |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4997 |
we can do it (effectively mapping additional instvars into the |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4998 |
variable part) - usefulness is questionable, though" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
4999 |
|
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5000 |
otherClass isPointers ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5001 |
otherClass isVariable ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5002 |
otherClass instSize <= (myClass instSize + self basicSize) |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5003 |
ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5004 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5005 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5006 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5007 |
otherClass instSize == (myClass instSize + self basicSize) |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5008 |
ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5009 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5010 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5011 |
] |
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 |
"it does not make sense to convert pointers to bytes ..." |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5014 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5015 |
] ifFalse:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5016 |
"does it make sense, to convert bits ?" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5017 |
"could allow byteArray->wordArray->longArray->floatArray->doubleArray here ..." |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5018 |
(myClass isBits and:[otherClass isBits]) ifTrue:[ |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5019 |
ok := true |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5020 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5021 |
] |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5022 |
] |
783 | 5023 |
]. |
5024 |
ok ifTrue:[ |
|
1022
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5025 |
"now, change the receivers class ..." |
783 | 5026 |
%{ |
1133 | 5027 |
{ |
5028 |
OBJ me = self; |
|
5029 |
||
5030 |
__qClass(me) = otherClass; |
|
5031 |
__STORE(me, otherClass); |
|
5032 |
RETURN (me); |
|
5033 |
} |
|
783 | 5034 |
%}. |
5035 |
]. |
|
1022
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 |
" |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5038 |
the receiver cannot be represented as a instance of |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5039 |
the desired class. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5040 |
For example, you cannot change a bitInstance (byteArray etc.) |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5041 |
into a pointer object and vice versa. |
f526a827ea1a
allow changeClass of bitObjects
Claus Gittinger <cg@exept.de>
parents:
1021
diff
changeset
|
5042 |
" |
783 | 5043 |
self primitiveFailed |
5044 |
! |
|
5045 |
||
5046 |
changeClassToThatOf:anObject |
|
5047 |
"changes the class of the receiver to that of the argument, anObject. |
|
5048 |
This is only allowed (possible), if the receivers class and the arguments |
|
5049 |
class have the same structure (i.e. number of named instance variables and |
|
5050 |
type of indexed instance variables). If the structures do not match, or any |
|
5051 |
of the objects is nil or a Smallinteger, a primitive error is triggered." |
|
5052 |
||
5053 |
self changeClassTo:(anObject class) |
|
5054 |
! ! |
|
5055 |
||
5056 |
!Object methodsFor:'user interaction & notifications'! |
|
5057 |
||
5058 |
activityNotification:aString |
|
5059 |
"this can be sent from deeply nested methods, which are going to perform |
|
5060 |
some long-time activity. |
|
5061 |
If there is a handler for the ActivityNotificationSignal signal, that one is raised, |
|
5062 |
passing the argument. The handler should show this message whereever it likes, |
|
5063 |
and proceed. If there is no handler, this is simply ignored. |
|
5064 |
||
5065 |
This is very useful to pass busy messages up to some higher level (typically a view) |
|
5066 |
which likes to display that message in its label or a busy-box. |
|
5067 |
It could also be put into some logfile or printed on the standard output/error." |
|
5068 |
||
5069 |
ActivityNotificationSignal isHandled ifTrue:[ |
|
861 | 5070 |
^ ActivityNotificationSignal raiseRequestWith:self errorString:aString |
783 | 5071 |
]. |
5072 |
||
5073 |
" |
|
5074 |
nil activityNotification:'hello there' |
|
5075 |
self activityNotification:'hello there' |
|
5076 |
" |
|
5077 |
||
5078 |
" |
|
5079 |
ActivityNotificationSignal handle:[:ex | |
|
861 | 5080 |
ex errorString printNL. |
5081 |
ex proceed. |
|
783 | 5082 |
] do:[ |
861 | 5083 |
'hello' printNL. |
5084 |
self activityNotification:'doing some long time computation'. |
|
5085 |
'world' printNL. |
|
783 | 5086 |
] |
5087 |
" |
|
5088 |
||
5089 |
"Modified: 16.12.1995 / 18:23:42 / cg" |
|
5090 |
! |
|
5091 |
||
5092 |
confirm:aString |
|
5093 |
"launch a confirmer, which allows user to enter yes or no. |
|
5094 |
return true for yes, false for no" |
|
5095 |
||
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5096 |
" |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5097 |
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
|
5098 |
and return true (as if yes was answered) |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5099 |
Q: should we ask user by reading Stdin ? |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5100 |
" |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5101 |
Smalltalk isInitialized ifFalse:[ |
1417 | 5102 |
'confirmation: ' print. aString print. |
1425 | 5103 |
'continue, assuming <yes>' printCR. |
1417 | 5104 |
^ true |
925
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5105 |
]. |
020a15fa450f
use less memory for single-dependencies;
Claus Gittinger <cg@exept.de>
parents:
899
diff
changeset
|
5106 |
|
783 | 5107 |
Dialog isNil ifTrue:[ |
1417 | 5108 |
Transcript showCR:aString. |
5109 |
Transcript showCR:'continue, assuming <yes>'. |
|
5110 |
^ true |
|
783 | 5111 |
]. |
5112 |
Dialog autoload. "in case its autoloaded" |
|
5113 |
^ Dialog confirm:aString |
|
5114 |
||
5115 |
" |
|
5116 |
nil confirm:'hello' |
|
5117 |
self confirm:'hello' |
|
5118 |
" |
|
1417 | 5119 |
|
1425 | 5120 |
"Modified: 20.5.1996 / 10:28:40 / cg" |
783 | 5121 |
! |
5122 |
||
5123 |
errorNotify:aString |
|
5124 |
"launch a Notifier, showing top stack, telling user something |
|
5125 |
and give a chance to enter debugger." |
|
5126 |
||
5127 |
|info con sender| |
|
5128 |
||
891 | 5129 |
Smalltalk isInitialized ifFalse:[ |
1425 | 5130 |
'errorNotification: ' print. aString printCR. |
1417 | 5131 |
^ self |
891 | 5132 |
]. |
5133 |
||
783 | 5134 |
Dialog isNil ifTrue:[ |
1417 | 5135 |
" |
5136 |
on systems without GUI, simply show |
|
5137 |
the message on the Transcript. |
|
5138 |
" |
|
5139 |
Transcript showCR:aString. |
|
5140 |
^ self |
|
783 | 5141 |
]. |
5142 |
Dialog autoload. "in case its autoloaded" |
|
5143 |
||
5144 |
con := sender := thisContext sender. |
|
5145 |
info := aString , Character cr asString , Character cr asString. |
|
5146 |
1 to:5 do:[:n | |
|
1417 | 5147 |
con notNil ifTrue:[ |
5148 |
info := info , con printString , Character cr asString. |
|
5149 |
con := con sender |
|
5150 |
] |
|
783 | 5151 |
]. |
5152 |
||
5153 |
(Dialog choose:info |
|
1417 | 5154 |
labels:#('proceed' 'debug') |
5155 |
values:#(#proceed #debug) |
|
5156 |
default:#debug) == #debug |
|
783 | 5157 |
ifTrue:[ |
1417 | 5158 |
Debugger enter:sender withMessage:aString |
783 | 5159 |
] |
5160 |
||
5161 |
" |
|
5162 |
nil errorNotify:'hello there' |
|
5163 |
self errorNotify:'hello there' |
|
5164 |
" |
|
1417 | 5165 |
|
1425 | 5166 |
"Modified: 20.5.1996 / 10:28:45 / cg" |
783 | 5167 |
! |
5168 |
||
5169 |
information:aString |
|
5170 |
"launch an InfoBox, telling user something. |
|
5171 |
These info-boxes can be suppressed by handling the |
|
5172 |
UserNotification- or InformationSignal and proceeding in the handler." |
|
5173 |
||
5174 |
InformationSignal isHandled ifTrue:[ |
|
5175 |
^ InformationSignal raiseRequestWith:self errorString:aString |
|
5176 |
]. |
|
5177 |
self notify:aString |
|
5178 |
||
5179 |
" |
|
5180 |
nil information:'hello there' |
|
5181 |
self information:'hello there' |
|
5182 |
" |
|
5183 |
||
5184 |
" |
|
5185 |
InformationSignal handle:[:ex | |
|
5186 |
'no box popped' printNL. |
|
5187 |
ex proceed. |
|
5188 |
] do:[ |
|
5189 |
'hello' printNL. |
|
5190 |
self information:'some info'. |
|
5191 |
'world' printNL. |
|
5192 |
] |
|
5193 |
" |
|
5194 |
||
5195 |
"Modified: 24.11.1995 / 22:29:49 / cg" |
|
5196 |
! |
|
5197 |
||
5198 |
notify:aString |
|
5199 |
"launch a Notifier, telling user something. |
|
5200 |
Use #information: for ignorable messages." |
|
5201 |
||
891 | 5202 |
Smalltalk isInitialized ifFalse:[ |
1425 | 5203 |
'information: ' print. aString printCR. |
1417 | 5204 |
^ self |
891 | 5205 |
]. |
5206 |
||
783 | 5207 |
Dialog isNil ifTrue:[ |
1417 | 5208 |
" |
5209 |
on systems without GUI, simply show |
|
5210 |
the message on the Transcript. |
|
5211 |
" |
|
5212 |
Transcript showCR:aString. |
|
5213 |
^ self |
|
783 | 5214 |
]. |
5215 |
Dialog autoload. "in case its autoloaded" |
|
5216 |
Dialog information:aString |
|
5217 |
||
5218 |
" |
|
5219 |
nil notify:'hello there' |
|
5220 |
self notify:'hello there' |
|
5221 |
" |
|
1417 | 5222 |
|
1425 | 5223 |
"Modified: 20.5.1996 / 10:28:48 / cg" |
783 | 5224 |
! |
5225 |
||
5226 |
warn:aString |
|
5227 |
"launch a WarningBox, telling user something. |
|
5228 |
These warn-boxes can be suppressed by handling the |
|
5229 |
UserNotification- or WarningSignal and proceeding in the handler." |
|
5230 |
||
5231 |
WarningSignal isHandled ifTrue:[ |
|
1417 | 5232 |
^ WarningSignal raiseRequestWith:self errorString:aString |
783 | 5233 |
]. |
5234 |
||
891 | 5235 |
Smalltalk isInitialized ifFalse:[ |
1425 | 5236 |
'warning: ' print. aString printCR. |
1417 | 5237 |
^ self |
891 | 5238 |
]. |
5239 |
||
783 | 5240 |
Dialog isNil ifTrue:[ |
1417 | 5241 |
" |
5242 |
on systems without GUI, simply show |
|
5243 |
the message on the Transcript. |
|
5244 |
" |
|
5245 |
Transcript showCR:aString. |
|
5246 |
^ self |
|
783 | 5247 |
]. |
5248 |
Dialog autoload. "in case its autoloaded" |
|
5249 |
Dialog warn:aString |
|
5250 |
||
5251 |
" |
|
5252 |
nil warn:'hello there' |
|
5253 |
self warn:'hello there' |
|
5254 |
" |
|
5255 |
||
5256 |
" |
|
5257 |
WarningSignal handle:[:ex | |
|
1417 | 5258 |
ex proceed. |
783 | 5259 |
] do:[ |
1417 | 5260 |
'hello' printNL. |
5261 |
self warn:'some info'. |
|
5262 |
'world' printNL. |
|
783 | 5263 |
] |
5264 |
" |
|
1417 | 5265 |
|
1425 | 5266 |
"Modified: 20.5.1996 / 10:28:53 / cg" |
783 | 5267 |
! ! |
5268 |
||
1528
af168e6dadc9
added #instVarNamed:ifAbsent:
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
5269 |
!Object class methodsFor:'documentation'! |
783 | 5270 |
|
5271 |
version |
|
1684 | 5272 |
^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.134 1996-09-24 16:47:33 cg Exp $' |
783 | 5273 |
! ! |
5274 |
Object initialize! |