author | Jan Vrany <jan.vrany@labware.com> |
Wed, 03 Feb 2021 11:52:30 +0000 | |
branch | jv |
changeset 25410 | c91ea94445d1 |
parent 25398 | b0d020199bd0 |
child 25415 | 4ea1fe7c363f |
permissions | -rwxr-xr-x |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
23107 | 3 |
COPYRIGHT (c) 2009-2010 Jan Vrany |
4 |
COPYRIGHT (c) 2016 Jan Vrany |
|
5 |
COPYRIGHT (c) 2017 Claus Gittinger |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
6 |
COPYRIGHT (c) 2020 LabWare |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
7 |
All Rights Reserved |
1 | 8 |
|
9 |
This software is furnished under a license and may be used |
|
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
15 |
" |
|
5385 | 16 |
"{ Package: 'stx:libbasic' }" |
17 |
||
17278 | 18 |
"{ NameSpace: Smalltalk }" |
19 |
||
3934 | 20 |
CompiledCode variableSubclass:#Method |
16261 | 21 |
instanceVariableNames:'source sourcePosition category package mclass lookupObject |
22 |
annotations' |
|
23 |
classVariableNames:'PrivateMethodSignal LastFileReference LastSourceFileName |
|
24 |
LastWhoClass LastFileLock LastMethodSources LastMethodSourcesLock |
|
17254 | 25 |
CompilationLock Overrides LastParseTreeCache' |
16261 | 26 |
poolDictionaries:'' |
27 |
category:'Kernel-Methods' |
|
1 | 28 |
! |
29 |
||
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
30 |
Object subclass:#MethodWhoInfo |
16261 | 31 |
instanceVariableNames:'myClass mySelector' |
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
privateIn:Method |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
35 |
! |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
36 |
|
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
37 |
Object subclass:#ParseTreeCacheEntry |
16261 | 38 |
instanceVariableNames:'parserClass method parser' |
39 |
classVariableNames:'' |
|
40 |
poolDictionaries:'' |
|
41 |
privateIn:Method |
|
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
42 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
43 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
44 |
Object subclass:#ParserCacheEntry |
19716 | 45 |
instanceVariableNames:'method parser' |
16261 | 46 |
classVariableNames:'' |
47 |
poolDictionaries:'' |
|
48 |
privateIn:Method |
|
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
49 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
50 |
|
1775
6892b91ddc0b
F_CALLED flag is no longer present
Claus Gittinger <cg@exept.de>
parents:
1692
diff
changeset
|
51 |
!Method class methodsFor:'documentation'! |
42 | 52 |
|
88 | 53 |
copyright |
54 |
" |
|
55 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
23107 | 56 |
COPYRIGHT (c) 2009-2010 Jan Vrany |
57 |
COPYRIGHT (c) 2016 Jan Vrany |
|
58 |
COPYRIGHT (c) 2017 Claus Gittinger |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
59 |
COPYRIGHT (c) 2020 LabWare |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
60 |
All Rights Reserved |
88 | 61 |
|
62 |
This software is furnished under a license and may be used |
|
63 |
only in accordance with the terms of that license and with the |
|
64 |
inclusion of the above copyright notice. This software may not |
|
65 |
be provided or otherwise made available to, or used by, any |
|
66 |
other person. No title to or ownership of the software is |
|
67 |
hereby transferred. |
|
68 |
" |
|
69 |
! |
|
70 |
||
42 | 71 |
documentation |
72 |
" |
|
68 | 73 |
this class defines protocol for executable methods; |
74 |
both compiled and interpreted methods are represented by this class. |
|
75 |
Compiled methods have a non-nil code field, while interpreted methods have |
|
76 |
a nil code field and non-nil byteCode field. |
|
88 | 77 |
If there are both non-nil code and bytecode fields, the VM will execute |
18417 | 78 |
the machine-code of a method. If both are nil when executed, a #noByteCode |
79 |
message is sent (by the VM) to the method, where a signal is raised. |
|
80 |
(or, a user defined interpreter can be invoked on the smalltalk level) |
|
81 |
||
82 |
The method's sourcecode is represented by source and sourcePosition: |
|
227 | 83 |
- if sourcePosition is a Number, the source-field is the fileName and |
84 |
sourcePosition is the character offset of the source-chunk in this source file. |
|
18417 | 85 |
- If sourcePosition is nil, the source fields holds the source string. |
227 | 86 |
(an old version used ExternalString instances here, but that lead to |
18417 | 87 |
10000's of additional little objects ...) |
1 | 88 |
|
68 | 89 |
The flags field defines things like the number of method-locals, |
227 | 90 |
method arguments and stack requirements (for interpreted methods). |
68 | 91 |
Do not depend on any value in the flags field - it may change without |
92 |
notice. |
|
1 | 93 |
|
438 | 94 |
Notice, that in ST/X, method can be subclassed; executable code is |
5277
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
95 |
identified not by being an instance of Block or Method, but instead by |
438 | 96 |
having the executable flag bit set in the class. The VM can execute anything |
97 |
which is identified as executable (assuming that the first instance variable |
|
98 |
is the machine-code address) - this allows for easy future extension. |
|
99 |
||
19732 | 100 |
Literals: |
101 |
Notice that stc compiled methods do not list all of their used literals. |
|
102 |
In fact, stc-code uses a kind of class-constant-table, |
|
103 |
and only message-send symbols are found in the literal array. |
|
104 |
Thus, in order to find constants (literals) used by a method, |
|
105 |
you have to parse its source. |
|
20208 | 106 |
|
1293 | 107 |
[Instance variables:] |
93 | 108 |
|
19732 | 109 |
source <String> the source itself (if sourcePosition isNil) |
110 |
or the fileName where the source is found |
|
111 |
||
112 |
sourcePosition <Integer> the position of the methods chunk in the file |
|
113 |
||
114 |
category <Symbol> the methods category |
|
115 |
package <Symbol> the package, in which the methods was defined |
|
116 |
mclass <Class> the class in which I am defined |
|
117 |
indexed slots literals |
|
227 | 118 |
|
1293 | 119 |
[Class variables:] |
227 | 120 |
|
19732 | 121 |
PrivateMethodSignal raised on privacy violation (see docu) |
122 |
||
123 |
LastFileReference weak reference to the last sourceFile |
|
124 |
LastSourceFileName to speedup source access via NFS |
|
93 | 125 |
|
20804 | 126 |
WARNING: layout known by compiler and runtime system - don't change |
1293 | 127 |
|
128 |
[author:] |
|
19732 | 129 |
Claus Gittinger |
42 | 130 |
" |
176 | 131 |
! |
132 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
133 |
dynamicMethods |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
134 |
" |
5277
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
135 |
On systems which support dynamic loading of stc-compiled machine code (SYS5.4, Linux), |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
136 |
methods may now be compiled to machine code from within the browser, |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
137 |
and the resulting machine code object be loaded in. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
138 |
The ObjectFileLoader keeps (weak) handles to the resulting methods and |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
139 |
invalidates the corresponding method objects, if the underlying methods |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
140 |
object code is unloaded. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
141 |
Invalid methods will trap into the debugger when executed; |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
142 |
also, the browser marks them as '(* not executable *)' in its method list. |
5277
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
143 |
|
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
144 |
Notice: this has nothing to do with JIT compilation, which is always possible. |
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
145 |
JIT-compilation is done from bytecodes to a machineCode cache. |
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
146 |
In contrast, dynamic loading of stc-compiled code goes via intermediate C-code |
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
147 |
which is compiled by the machines native C-compiler. |
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
148 |
As opposed to JITted code, this allows for embedded primitive C-code. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
149 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
150 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
151 |
|
12854 | 152 |
privacy |
176 | 153 |
" |
154 |
ST/X includes an EXPERIMENTAL implementation of method privacy. |
|
155 |
Individual methods may be set to private or protected via the |
|
5277
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
156 |
privacy:#private and privacy:#protected messages. Also, categories may be |
202 | 157 |
filedIn as a whole as private using #privateMethodsFor: or as |
158 |
protected using #protectedMethodsFor: instead of the well known #methodsFor:. |
|
159 |
||
176 | 160 |
The additional #publicMethodsFor: is for documentation purposes, and |
227 | 161 |
is equivalent to #methodsFor: (also to support fileIn of ENVY methods). |
176 | 162 |
|
8518
7dc3f9909640
Interchanged the meaning of method privacy -
Stefan Vogel <sv@exept.de>
parents:
8465
diff
changeset
|
163 |
Protected methods may be executed only when called via a self-send |
5277
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
164 |
from the superclass-methods and self or super-sends from methods in the |
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
165 |
class itself or subclasses. |
12854 | 166 |
Private methods may not be called from subclasses-methods, |
5277
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
167 |
i.e. they may only be called via self sends from within the current class. |
8518
7dc3f9909640
Interchanged the meaning of method privacy -
Stefan Vogel <sv@exept.de>
parents:
8465
diff
changeset
|
168 |
(i.e. protected methods are less private than private ones) |
176 | 169 |
|
170 |
When such a situation arises, the VM (runtime system) will raise the |
|
171 |
PrivateMethodSignal exception (if nonNil), which usually brings you into the |
|
172 |
debugger. |
|
173 |
||
227 | 174 |
If PrivateMethodSignal is nil, the VM will not check for this, and |
176 | 175 |
execution is as usual. (you may want to nil-it for production code, |
176 |
and leave it non nil during development). |
|
177 |
||
20208 | 178 |
NOTICE: there is no (not yet?) standard defined for method privacy, |
12854 | 179 |
however, the definition protocol was designed to be somewhat ENVY compatible |
5277
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
180 |
(from what can be deduced by reading PD code). |
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
181 |
|
176 | 182 |
Also, the usability of privacy is still to be tested. |
415 | 183 |
This interface, the implementation and the rules for when a privacy violation |
184 |
may change (in case of some ANSI standard being defined). |
|
227 | 185 |
Be warned and send me suggestions & critics (constructive ;-) |
5277
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
186 |
|
d457937a69e5
comments & code-cleanup in #who
Claus Gittinger <cg@exept.de>
parents:
5241
diff
changeset
|
187 |
Late note (Feb 2000): |
20208 | 188 |
the privacy feature has now been in ST/X for some years and was NOT heavily |
189 |
used - neither at eXept, nor by customers. |
|
190 |
In Smalltalk, it seems to be a very questionable feature, actually limiting |
|
191 |
code reusability. |
|
192 |
The privacy features are left in the system to demonstrate that it can be |
|
193 |
done in Smalltalk (for religious C++ fans ... to avoid useless discussions) |
|
194 |
(the check is not expensive, w.r.t. the VM runtime behavior). |
|
176 | 195 |
" |
42 | 196 |
! ! |
1 | 197 |
|
1775
6892b91ddc0b
F_CALLED flag is no longer present
Claus Gittinger <cg@exept.de>
parents:
1692
diff
changeset
|
198 |
!Method class methodsFor:'initialization'! |
109 | 199 |
|
200 |
initialize |
|
1254 | 201 |
"create signals" |
202 |
||
109 | 203 |
PrivateMethodSignal isNil ifTrue:[ |
20032 | 204 |
"EXPERIMENTAL" |
205 |
PrivateMethodSignal := ExecutionError newSignalMayProceed:true. |
|
206 |
PrivateMethodSignal nameClass:self message:#privateMethodSignal. |
|
207 |
PrivateMethodSignal notifierString:'attempt to execute private/protected method'. |
|
2079
bcf84ab30304
Make cached sourcefile thread-protected.
Stefan Vogel <sv@exept.de>
parents:
2066
diff
changeset
|
208 |
]. |
bcf84ab30304
Make cached sourcefile thread-protected.
Stefan Vogel <sv@exept.de>
parents:
2066
diff
changeset
|
209 |
|
bcf84ab30304
Make cached sourcefile thread-protected.
Stefan Vogel <sv@exept.de>
parents:
2066
diff
changeset
|
210 |
LastFileLock isNil ifTrue:[ |
20032 | 211 |
LastFileLock := RecursionLock new name:'Method-LastFile'. |
212 |
LastMethodSourcesLock := RecursionLock new name:'Method-LastMethodSources'. |
|
213 |
||
214 |
LastFileReference := WeakArray new:1. |
|
2079
bcf84ab30304
Make cached sourcefile thread-protected.
Stefan Vogel <sv@exept.de>
parents:
2066
diff
changeset
|
215 |
]. |
1254 | 216 |
|
5387
f855cf3b2f67
need a recursionLock as compilationLock
Claus Gittinger <cg@exept.de>
parents:
5386
diff
changeset
|
217 |
CompilationLock := RecursionLock new name:'MethodCompilation'. |
4290
5e43473d7a35
moved recompilation semaphore from LazyMethod to Method
Claus Gittinger <cg@exept.de>
parents:
4015
diff
changeset
|
218 |
|
14231
a61fd41fe0d6
variable renamed in: #initialize
Claus Gittinger <cg@exept.de>
parents:
14161
diff
changeset
|
219 |
"Modified: / 03-01-1997 / 16:58:16 / stefan" |
a61fd41fe0d6
variable renamed in: #initialize
Claus Gittinger <cg@exept.de>
parents:
14161
diff
changeset
|
220 |
"Modified (comment): / 20-07-2012 / 18:41:11 / cg" |
10375 | 221 |
! |
222 |
||
223 |
lastMethodSourcesLock |
|
224 |
LastMethodSourcesLock isNil ifTrue:[ |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
225 |
self initialize |
10375 | 226 |
]. |
227 |
^ LastMethodSourcesLock |
|
109 | 228 |
! ! |
229 |
||
1775
6892b91ddc0b
F_CALLED flag is no longer present
Claus Gittinger <cg@exept.de>
parents:
1692
diff
changeset
|
230 |
!Method class methodsFor:'Signal constants'! |
159 | 231 |
|
232 |
privateMethodSignal |
|
176 | 233 |
"return the signal raised when a private/protected method is called |
234 |
by some other object (i.e. not a self- or super send)" |
|
235 |
||
159 | 236 |
^ PrivateMethodSignal |
237 |
! ! |
|
238 |
||
11022
8dd9f699915f
+shouldBeSkippedInDebuggersWalkBack
Claus Gittinger <cg@exept.de>
parents:
11016
diff
changeset
|
239 |
|
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
240 |
!Method class methodsFor:'cleanup'! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
241 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
242 |
lowSpaceCleanup |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
243 |
LastParseTreeCache := nil. |
13572 | 244 |
LastSourceFileName := LastWhoClass := nil. |
14236 | 245 |
self flushSourceStreamCache. |
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
246 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
247 |
"Created: / 08-08-2011 / 19:11:23 / cg" |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
248 |
! ! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
249 |
|
1775
6892b91ddc0b
F_CALLED flag is no longer present
Claus Gittinger <cg@exept.de>
parents:
1692
diff
changeset
|
250 |
!Method class methodsFor:'queries'! |
3 | 251 |
|
18462 | 252 |
binarySelectorCharacters |
253 |
"return a collection of characters which are allowed in binary selectors" |
|
254 |
||
255 |
^ '&-+=*/\<>~@,?!!|%#'. |
|
256 |
! |
|
257 |
||
3 | 258 |
isBuiltInClass |
1264 | 259 |
"return true if this class is known by the run-time-system. |
260 |
Here, true is returned for myself, false for subclasses." |
|
3 | 261 |
|
262 |
^ self == Method |
|
1264 | 263 |
|
264 |
"Modified: 23.4.1996 / 15:59:50 / cg" |
|
44 | 265 |
! |
266 |
||
18462 | 267 |
maxBinarySelectorSize |
268 |
^ 3 |
|
269 |
||
270 |
" |
|
271 |
in ST/X, binops are allowed with up-to 3 characters; |
|
272 |
for example: |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
273 |
<-> |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
274 |
<=> |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
275 |
+++ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
276 |
:=: |
18462 | 277 |
etc. are valid binOps here |
278 |
" |
|
279 |
! |
|
280 |
||
6089 | 281 |
methodDefinitionTemplateForSelector:aSelector |
282 |
"given a selector, return a prototype definition string" |
|
283 |
||
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
284 |
^ self programmingLanguage |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
285 |
methodDefinitionTemplateForSelector:aSelector |
6090 | 286 |
|
287 |
" |
|
12854 | 288 |
Method methodDefinitionTemplateForSelector:#foo |
289 |
Method methodDefinitionTemplateForSelector:#+ |
|
290 |
Method methodDefinitionTemplateForSelector:#foo:bar:baz: |
|
6090 | 291 |
" |
292 |
! |
|
293 |
||
294 |
methodDefinitionTemplateForSelector:aSelector andArgumentNames:argNames |
|
295 |
"given a selector, return a prototype definition string" |
|
296 |
||
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
297 |
^ self programmingLanguage |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
298 |
methodDefinitionTemplateForSelector:aSelector andArgumentNames:argNames |
6089 | 299 |
|
300 |
" |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
301 |
Method methodDefinitionTemplateForSelector:#foo andArgumentNames:#() |
12854 | 302 |
Method methodDefinitionTemplateForSelector:#+ andArgumentNames:#('aNumber') |
303 |
Method methodDefinitionTemplateForSelector:#foo:bar:baz: andArgumentNames:#('fooArg' 'barArg' 'bazArg') |
|
6089 | 304 |
" |
305 |
! |
|
306 |
||
747 | 307 |
methodPrivacySupported |
308 |
"return true, if the system was compiled to support methodPrivacy. |
|
309 |
You should not depend on that feature being available." |
|
310 |
||
311 |
%{ /* NOCONTEXT */ |
|
312 |
#if defined(F_PRIVATE) || defined(F_CLASSPRIVATE) |
|
313 |
RETURN (true); |
|
314 |
#else |
|
315 |
RETURN (false); |
|
316 |
#endif |
|
317 |
%} |
|
3342 | 318 |
! |
319 |
||
320 |
resourceTypes |
|
321 |
"get the types of resources for which a spec definition and corresponding editor exist" |
|
322 |
||
8526 | 323 |
^ #(canvas menu image fileImage help hierarchicalList tabList tableColumns) |
3 | 324 |
! ! |
325 |
||
1775
6892b91ddc0b
F_CALLED flag is no longer present
Claus Gittinger <cg@exept.de>
parents:
1692
diff
changeset
|
326 |
!Method class methodsFor:'special'! |
957 | 327 |
|
14039
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
328 |
flushParseTreeCache |
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
329 |
"used by lint and the compiler" |
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
330 |
|
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
331 |
LastParseTreeCache := nil |
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
332 |
|
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
333 |
" |
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
334 |
Method flushParseTreeCache |
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
335 |
" |
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
336 |
|
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
337 |
"Created: / 01-03-2012 / 16:45:34 / cg" |
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
338 |
! |
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
339 |
|
957 | 340 |
flushSourceStreamCache |
11663
6ef3b25bd306
changed #sourceStream - honor lock
Stefan Vogel <sv@exept.de>
parents:
11428
diff
changeset
|
341 |
LastFileLock critical:[ |
20035 | 342 |
LastSourceFileName := LastMethodSources := nil. |
343 |
LastFileReference at:1 put:nil. |
|
11663
6ef3b25bd306
changed #sourceStream - honor lock
Stefan Vogel <sv@exept.de>
parents:
11428
diff
changeset
|
344 |
]. |
957 | 345 |
|
7830 | 346 |
" |
347 |
Method flushSourceStreamCache |
|
348 |
" |
|
349 |
||
957 | 350 |
"Created: 9.2.1996 / 19:05:28 / cg" |
351 |
! ! |
|
352 |
||
13657
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
353 |
!Method class methodsFor:'trap methods'! |
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
354 |
|
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
355 |
trapMethodForNumArgs:numArgs |
13805
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
356 |
"return a method which will raise an invalid code object exception. |
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
357 |
Before recompiling methods (due to changed variable scopes, for example), |
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
358 |
all method's code is replaced by this. If recompilation fails, this code |
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
359 |
remains in the method to make it trap, whenever executed later. |
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
360 |
Otherwise, if recompilation succeeeds, that code will vanish after the compile" |
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
361 |
|
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
362 |
|trapSel trapMethod| |
13657
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
363 |
|
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
364 |
trapSel := #( |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
365 |
invalidCodeObject |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
366 |
invalidCodeObjectWith: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
367 |
invalidCodeObjectWith:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
368 |
invalidCodeObjectWith:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
369 |
invalidCodeObjectWith:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
370 |
invalidCodeObjectWith:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
371 |
invalidCodeObjectWith:with:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
372 |
invalidCodeObjectWith:with:with:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
373 |
invalidCodeObjectWith:with:with:with:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
374 |
invalidCodeObjectWith:with:with:with:with:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
375 |
invalidCodeObjectWith:with:with:with:with:with:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
376 |
invalidCodeObjectWith:with:with:with:with:with:with:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
377 |
invalidCodeObjectWith:with:with:with:with:with:with:with:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
378 |
invalidCodeObjectWith:with:with:with:with:with:with:with:with:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
379 |
invalidCodeObjectWith:with:with:with:with:with:with:with:with:with:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
380 |
invalidCodeObjectWith:with:with:with:with:with:with:with:with:with:with:with:with:with:with: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
381 |
) at:(numArgs + 1). |
13657
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
382 |
|
13805
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
383 |
(trapMethod := self compiledMethodAt:trapSel) isNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
384 |
trapMethod := Method compiledMethodAt:trapSel. |
13805
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
385 |
]. |
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
386 |
^ trapMethod. |
13657
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
387 |
|
16261 | 388 |
" |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
389 |
self trapMethodForNumArgs:2 |
16261 | 390 |
" |
391 |
||
13657
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
392 |
"Created: / 04-11-1996 / 21:58:58 / cg" |
13693 | 393 |
"Modified: / 14-09-2011 / 11:23:09 / sr" |
13805
dec466a100bc
changed: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13693
diff
changeset
|
394 |
"Modified (comment): / 30-10-2011 / 11:04:24 / cg" |
13657
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
395 |
! ! |
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
396 |
|
20357
0eae8bf21a91
Method: don't try to figure out a source code manager for method when using local source
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20210
diff
changeset
|
397 |
|
13634 | 398 |
!Method methodsFor:'Compatibility-Squeak'! |
399 |
||
14161 | 400 |
isCompiledMethod |
401 |
^ true |
|
402 |
||
403 |
"Created: / 13-06-2012 / 14:51:19 / cg" |
|
404 |
! |
|
405 |
||
13676 | 406 |
pragmaAt:aKey |
407 |
^ self annotationAt:aKey |
|
408 |
||
409 |
"Created: / 11-09-2011 / 18:09:05 / cg" |
|
410 |
! |
|
411 |
||
13634 | 412 |
pragmas |
16193 | 413 |
"for squeak compatibility, we only present real pragmas" |
414 |
||
415 |
^ (self annotations ? #()) select:[:a | a isArray not and:[ a isResource not ] ] |
|
13679 | 416 |
! |
417 |
||
418 |
propertyValueAt:aKey |
|
419 |
"for now - no properties" |
|
420 |
||
421 |
^ nil |
|
422 |
||
423 |
"Created: / 12-09-2011 / 08:42:02 / cg" |
|
16910
8f814706ef37
Added Method>>sourceCode Squeak compatibility method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16877
diff
changeset
|
424 |
! |
8f814706ef37
Added Method>>sourceCode Squeak compatibility method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16877
diff
changeset
|
425 |
|
8f814706ef37
Added Method>>sourceCode Squeak compatibility method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16877
diff
changeset
|
426 |
sourceCode |
8f814706ef37
Added Method>>sourceCode Squeak compatibility method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16877
diff
changeset
|
427 |
^ self source |
8f814706ef37
Added Method>>sourceCode Squeak compatibility method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16877
diff
changeset
|
428 |
|
8f814706ef37
Added Method>>sourceCode Squeak compatibility method
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16877
diff
changeset
|
429 |
"Created: / 30-10-2014 / 23:24:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13634 | 430 |
! ! |
13422 | 431 |
|
7261 | 432 |
!Method methodsFor:'Compatibility-VW'! |
5967 | 433 |
|
17647 | 434 |
attributeAt:aSymbol ifAbsent:exceptionValue |
435 |
|annots| |
|
436 |
||
437 |
annots := self annotationsAt:aSymbol. |
|
17693 | 438 |
annots isEmptyOrNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
439 |
(aSymbol endsWith:$:) ifFalse:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
440 |
annots := self annotationsAt:(aSymbol,$:) asSymbol. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
441 |
]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
442 |
annots isEmptyOrNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
443 |
^ exceptionValue value |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
444 |
]. |
17693 | 445 |
]. |
17647 | 446 |
^ annots first arguments first |
447 |
! |
|
448 |
||
449 |
attributeMessages |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
450 |
^ self annotations |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
451 |
collect:[:annot | Message selector:annot key arguments:annot arguments] |
17647 | 452 |
! |
453 |
||
11146 | 454 |
classIsMeta |
455 |
"return true, if this method is a class method" |
|
456 |
||
12854 | 457 |
^ self mclass isMeta |
11146 | 458 |
! |
459 |
||
17175 | 460 |
sendsAnySelector:aCollectionOfSymbols |
461 |
"return true, if this method contains a message-send |
|
462 |
with any from aCollectionOfSymbols as selector." |
|
463 |
||
464 |
^ self sendsAny:aCollectionOfSymbols |
|
465 |
! |
|
466 |
||
5967 | 467 |
sendsSelector:aSelectorSymbol |
468 |
"return true, if this method contains a message-send |
|
469 |
with aSelectorSymbol as selector." |
|
470 |
||
471 |
^ self sends:aSelectorSymbol |
|
472 |
! ! |
|
473 |
||
9096 | 474 |
|
1 | 475 |
!Method methodsFor:'accessing'! |
476 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
477 |
category |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
478 |
"return the methods category or nil" |
737
4ed893ad3f0f
try more to find source of obsolete methods
Claus Gittinger <cg@exept.de>
parents:
690
diff
changeset
|
479 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
480 |
^ category |
1 | 481 |
! |
482 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
483 |
category:aStringOrSymbol |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
484 |
"set the methods category" |
1 | 485 |
|
5724
96c2a5cf4217
category: and package: now send change notifications.
Claus Gittinger <cg@exept.de>
parents:
5721
diff
changeset
|
486 |
|newCategory oldCategory cls| |
5721
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
487 |
|
3934 | 488 |
aStringOrSymbol notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
489 |
newCategory := aStringOrSymbol. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
490 |
newCategory ~= (oldCategory := category) ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
491 |
self setCategory:newCategory. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
492 |
|
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
493 |
cls := self mclass. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
494 |
cls notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
495 |
cls addChangeRecordForMethodCategory:self category:newCategory. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
496 |
self changed:#category with:oldCategory. "/ will vanish |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
497 |
cls changed:#organization with:self selector. "/ will vanish |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
498 |
Smalltalk changed:#methodCategory with:(Array with:cls with:self with:oldCategory). |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
499 |
] |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
500 |
] |
3934 | 501 |
] |
502 |
||
10729 | 503 |
"Modified: / 25-09-2007 / 16:15:24 / cg" |
1 | 504 |
! |
505 |
||
39 | 506 |
comment |
16847 | 507 |
"return the method's comment. |
68 | 508 |
This is done by searching for and returning the first comment |
12854 | 509 |
from the methods source (excluding any double-quotes). |
68 | 510 |
Returns nil if there is no comment (or source is not available)." |
39 | 511 |
|
14152 | 512 |
|src parserClass| |
39 | 513 |
|
159 | 514 |
src := self source. |
515 |
src isNil ifTrue:[^ nil]. |
|
14152 | 516 |
(parserClass := self programmingLanguage parserClass) isNil ifTrue:[^ nil]. |
517 |
^ parserClass methodCommentFromSource:src |
|
93 | 518 |
|
519 |
" |
|
13463 | 520 |
(Method compiledMethodAt:#comment) comment |
12854 | 521 |
(Object class compiledMethodAt:#infoPrinting:) comment |
93 | 522 |
" |
1236
5c9bc68e3c71
use new scanner feature to extract comment
Claus Gittinger <cg@exept.de>
parents:
1194
diff
changeset
|
523 |
|
12948 | 524 |
"Modified: / 23-02-1998 / 10:26:08 / stefan" |
14152 | 525 |
"Modified: / 01-06-2012 / 23:03:57 / cg" |
39 | 526 |
! |
527 |
||
14595 | 528 |
getMclass |
17278 | 529 |
"return the last known class in which this method was (or still is) contained in. |
530 |
Notice, that the mclass query returns nil, if a method is wrapped or no longer valid |
|
531 |
due to an accept in a browser or debugger. However, the mclass slot still contains a |
|
532 |
reference to the once valid class" |
|
533 |
||
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
534 |
^ mclass |
14595 | 535 |
! |
536 |
||
9702 | 537 |
getPackage |
538 |
"return the package-ID of the method" |
|
539 |
||
540 |
^ package |
|
541 |
! |
|
542 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
543 |
getSource |
3160 | 544 |
"low-level access to the source instance-variable. |
4751 | 545 |
For internal (compiler) use only. |
3160 | 546 |
This is NOT always the methods source string" |
547 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
548 |
^ source |
414 | 549 |
! |
550 |
||
4751 | 551 |
getSourcePosition |
552 |
"low-level access to the sourcePosition instance-variable. |
|
553 |
For internal (compiler) use only. |
|
554 |
This is NOT always the methods sourcePosition" |
|
555 |
||
556 |
^ sourcePosition |
|
557 |
! |
|
558 |
||
2176
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
559 |
localSourceFilename:aFileName position:aNumber |
15346 | 560 |
"set the method's sourcefile/position indicating, that |
561 |
this is a local file (i.e. the 'st.src' file). |
|
562 |
The indicator for this is a negative source position." |
|
563 |
||
564 |
self assert:(aFileName isText not). "/ will break monticello-binary-data-writing |
|
2176
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
565 |
source := aFileName. |
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
566 |
sourcePosition := aNumber negated |
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
567 |
|
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
568 |
"Created: 16.1.1997 / 01:25:52 / cg" |
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
569 |
! |
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
570 |
|
13422 | 571 |
lookupObject |
572 |
||
18368 | 573 |
"/ lookupObject isNil ifTrue:[^ BuiltinLookup instance "Lookup builtin"]. |
574 |
^ lookupObject |
|
13422 | 575 |
|
576 |
"Created: / 28-04-2010 / 18:36:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13817 | 577 |
"Modified: / 18-11-2011 / 14:47:12 / cg" |
13422 | 578 |
! |
579 |
||
580 |
lookupObject: anObject |
|
18368 | 581 |
anObject == BuiltinLookup instance ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
582 |
self setLookupObject: nil |
18368 | 583 |
] ifFalse:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
584 |
self setLookupObject: anObject. |
18368 | 585 |
]. |
13422 | 586 |
|
587 |
"Created: / 28-04-2010 / 18:36:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
588 |
"Modified: / 11-07-2010 / 19:32:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
589 |
! |
|
590 |
||
5152
2aacfb3976d4
when changing the package, make certain that the source
Claus Gittinger <cg@exept.de>
parents:
5115
diff
changeset
|
591 |
makeLocalStringSource |
2aacfb3976d4
when changing the package, make certain that the source
Claus Gittinger <cg@exept.de>
parents:
5115
diff
changeset
|
592 |
"assure that the methods source code is stored locally as a string |
2aacfb3976d4
when changing the package, make certain that the source
Claus Gittinger <cg@exept.de>
parents:
5115
diff
changeset
|
593 |
within the method (as opposed to an external string, which is accessed |
2aacfb3976d4
when changing the package, make certain that the source
Claus Gittinger <cg@exept.de>
parents:
5115
diff
changeset
|
594 |
by reading the source code file). |
15346 | 595 |
This is required, when a method's package is changed, to assure that its |
5152
2aacfb3976d4
when changing the package, make certain that the source
Claus Gittinger <cg@exept.de>
parents:
5115
diff
changeset
|
596 |
sourceCode is not lost." |
2aacfb3976d4
when changing the package, make certain that the source
Claus Gittinger <cg@exept.de>
parents:
5115
diff
changeset
|
597 |
|
2aacfb3976d4
when changing the package, make certain that the source
Claus Gittinger <cg@exept.de>
parents:
5115
diff
changeset
|
598 |
source notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
599 |
sourcePosition notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
600 |
"/ this looks wierd - but (self source) will retrieve the external source |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
601 |
"/ (from the file) and store it. So afterwards, we will have the string and |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
602 |
"/ sourcePosition will be nil |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
603 |
self source:(self source) |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
604 |
] |
5152
2aacfb3976d4
when changing the package, make certain that the source
Claus Gittinger <cg@exept.de>
parents:
5115
diff
changeset
|
605 |
]. |
2aacfb3976d4
when changing the package, make certain that the source
Claus Gittinger <cg@exept.de>
parents:
5115
diff
changeset
|
606 |
! |
2aacfb3976d4
when changing the package, make certain that the source
Claus Gittinger <cg@exept.de>
parents:
5115
diff
changeset
|
607 |
|
5324 | 608 |
mclass:aClass |
14508 | 609 |
"set the method's class. That is the class in which I am installed. |
610 |
This is a cache; the validity of which will be checked and the cache |
|
611 |
possibly be invalidated when mclass is asked for." |
|
612 |
||
613 |
"/ mclass == aClass ifTrue:[ ^ self ]. |
|
614 |
"/ |
|
12323 | 615 |
"/ (mclass notNil and:[aClass notNil]) ifTrue:[ |
616 |
"/ 'Method [warning]: mclass already set' errorPrintCR. |
|
617 |
"/ ]. |
|
5696 | 618 |
mclass := aClass. |
10207
b5ca553d15ad
localSourceFirst for extensions.
Claus Gittinger <cg@exept.de>
parents:
10201
diff
changeset
|
619 |
|
b5ca553d15ad
localSourceFirst for extensions.
Claus Gittinger <cg@exept.de>
parents:
10201
diff
changeset
|
620 |
"Modified: / 28-11-2006 / 12:12:27 / cg" |
5696 | 621 |
! |
5324 | 622 |
|
13422 | 623 |
nameSpace |
624 |
"Returns my namespace or nil. If no explicit method namespace |
|
625 |
is set, my programmming language is used as default namespace |
|
17514 | 626 |
(for compatibility reasons, nil is returned for smalltalk methods, |
13422 | 627 |
which means that the method is not namespaced). |
628 |
" |
|
629 |
||
14552 | 630 |
| nsA prefix | |
14264
fd05137bd3c3
comment/format in: #nameSpace
Claus Gittinger <cg@exept.de>
parents:
14261
diff
changeset
|
631 |
|
13422 | 632 |
nsA := self annotationAt: #namespace:. |
14552 | 633 |
nsA notNil ifTrue:[^nsA nameSpace]. |
634 |
||
635 |
prefix := self programmingLanguage defaultSelectorNameSpacePrefix. |
|
636 |
(prefix isNil or:[prefix = 'Smalltalk']) ifTrue:[ ^ nil]. |
|
15045 | 637 |
^ NameSpace name:prefix |
13422 | 638 |
|
639 |
" |
|
15045 | 640 |
(Method >> #nameSpace) nameSpace |
641 |
(Object >> #yourself) nameSpace |
|
13422 | 642 |
" |
643 |
||
644 |
"Created: / 26-04-2010 / 16:30:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
645 |
"Modified: / 20-05-2010 / 09:38:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14264
fd05137bd3c3
comment/format in: #nameSpace
Claus Gittinger <cg@exept.de>
parents:
14261
diff
changeset
|
646 |
"Modified (format): / 27-07-2012 / 14:17:09 / cg" |
13422 | 647 |
! |
648 |
||
649 |
nameSpace: aNameSpace |
|
650 |
||
14261 | 651 |
self annotateWith: (Annotation nameSpace: aNameSpace name) |
13422 | 652 |
|
653 |
"Created: / 20-05-2010 / 10:05:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
654 |
"Modified: / 20-05-2010 / 11:30:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14261 | 655 |
"Modified: / 26-07-2012 / 23:08:48 / cg" |
13422 | 656 |
! |
657 |
||
658 |
nameSpaceName |
|
659 |
| ns | |
|
16261 | 660 |
ns := self nameSpace. |
661 |
^ ns isNil ifTrue:[''] ifFalse:[ns name] |
|
13422 | 662 |
! |
663 |
||
13100 | 664 |
originalMethodIfWrapped |
665 |
"return the method the receiver is wrapping - none here" |
|
666 |
||
667 |
^ self |
|
668 |
||
669 |
"Created: / 22-10-2010 / 11:46:07 / cg" |
|
670 |
! |
|
671 |
||
13422 | 672 |
overriddenMethod |
15952 | 673 |
<resource: #obsolete> |
674 |
||
675 |
self obsoleteMethodWarning: 'Use overwrittenMethod instead, stupid naming'. |
|
676 |
^self overwrittenMethod |
|
677 |
||
678 |
"Created: / 17-06-2009 / 19:09:58 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
679 |
"Modified (format): / 18-11-2011 / 14:48:07 / cg" |
|
680 |
"Modified: / 05-07-2012 / 10:51:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
681 |
! |
|
682 |
||
683 |
overriddenMethod: aMethod |
|
684 |
<resource: #obsolete> |
|
685 |
||
686 |
self obsoleteMethodWarning: 'Use overwrittenMethod: instead, stupid naming'. |
|
687 |
self overwrittenMethod: aMethod |
|
688 |
||
689 |
"Created: / 17-06-2009 / 19:09:17 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
690 |
"Modified: / 22-08-2009 / 10:47:42 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
691 |
"Modified: / 18-11-2011 / 14:48:26 / cg" |
|
692 |
"Modified: / 05-07-2012 / 10:51:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
693 |
! |
|
694 |
||
695 |
overwrittenMethod |
|
13422 | 696 |
"Answers overridden method or nil." |
20208 | 697 |
|
20035 | 698 |
Overrides isNil ifTrue:[ |
699 |
^ nil |
|
700 |
]. |
|
701 |
^ Overrides at:self ifAbsent:nil. |
|
13422 | 702 |
|
15952 | 703 |
"Created: / 05-07-2012 / 10:49:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13422 | 704 |
! |
705 |
||
15952 | 706 |
overwrittenMethod: aMethod |
13422 | 707 |
"Set overridden method to aMethod" |
708 |
||
13817 | 709 |
Overrides isNil ifTrue:[Overrides := WeakIdentityDictionary new:10]. |
710 |
aMethod notNil ifTrue:[aMethod makeLocalStringSource]. |
|
20035 | 711 |
Overrides at:self put:aMethod |
13422 | 712 |
|
15952 | 713 |
"Created: / 05-07-2012 / 10:50:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13422 | 714 |
! |
715 |
||
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
716 |
package |
14573 | 717 |
"return the package-symbol of the method (nil is translated to noProject here)" |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
718 |
|
5385 | 719 |
|cls| |
720 |
||
721 |
package notNil ifTrue:[ ^ package ]. |
|
14573 | 722 |
|
723 |
"/ get it from my class |
|
5385 | 724 |
(cls := self mclass) isNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
725 |
^ PackageId noProjectID. |
5385 | 726 |
]. |
5724
96c2a5cf4217
category: and package: now send change notifications.
Claus Gittinger <cg@exept.de>
parents:
5721
diff
changeset
|
727 |
"/ set it. |
9692
d53de4f90660
allow for and hide nil-packageID (== NoProject)
Claus Gittinger <cg@exept.de>
parents:
9661
diff
changeset
|
728 |
package := cls getPackage. |
d53de4f90660
allow for and hide nil-packageID (== NoProject)
Claus Gittinger <cg@exept.de>
parents:
9661
diff
changeset
|
729 |
package isNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
730 |
^ PackageId noProjectID. |
9692
d53de4f90660
allow for and hide nil-packageID (== NoProject)
Claus Gittinger <cg@exept.de>
parents:
9661
diff
changeset
|
731 |
]. |
d53de4f90660
allow for and hide nil-packageID (== NoProject)
Claus Gittinger <cg@exept.de>
parents:
9661
diff
changeset
|
732 |
^ package |
3950 | 733 |
|
10207
b5ca553d15ad
localSourceFirst for extensions.
Claus Gittinger <cg@exept.de>
parents:
10201
diff
changeset
|
734 |
"Modified: / 28-11-2006 / 12:12:43 / cg" |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
735 |
! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
736 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
737 |
package:aSymbol |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
738 |
"set the package-symbol" |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
739 |
|
9692
d53de4f90660
allow for and hide nil-packageID (== NoProject)
Claus Gittinger <cg@exept.de>
parents:
9661
diff
changeset
|
740 |
|cls oldPackage newPackage| |
d53de4f90660
allow for and hide nil-packageID (== NoProject)
Claus Gittinger <cg@exept.de>
parents:
9661
diff
changeset
|
741 |
|
19025 | 742 |
newPackage := aSymbol. |
12216
692af7a76600
Project noProjectId -> PackageId noProjectId
Claus Gittinger <cg@exept.de>
parents:
12193
diff
changeset
|
743 |
aSymbol == PackageId noProjectID ifTrue:[ |
19025 | 744 |
Transcript showCR:'warning: unassigning method from any package'. |
745 |
"/ newPackage := nil |
|
9692
d53de4f90660
allow for and hide nil-packageID (== NoProject)
Claus Gittinger <cg@exept.de>
parents:
9661
diff
changeset
|
746 |
]. |
d53de4f90660
allow for and hide nil-packageID (== NoProject)
Claus Gittinger <cg@exept.de>
parents:
9661
diff
changeset
|
747 |
|
9713 | 748 |
package ~~ newPackage ifTrue:[ |
19025 | 749 |
oldPackage := package. |
750 |
"/ this is required, because otherwise I would no longer be able to |
|
751 |
"/ reconstruct my sourcecode (as the connection to the source-file is lost). |
|
752 |
self makeLocalStringSource. |
|
753 |
package := newPackage. |
|
754 |
||
755 |
cls := self mclass. |
|
756 |
"JV@2011-01-27: BUG FIX: method may be wrapped (breakpoint on it). |
|
757 |
Search for the wrapper, if none is found, return immediately |
|
758 |
(avoids DNU)" |
|
759 |
cls isNil ifTrue:[ |
|
760 |
| wrapper | |
|
761 |
||
762 |
wrapper := self wrapper. |
|
763 |
wrapper isNil ifTrue:[ ^ self ]. |
|
764 |
cls := wrapper mclass. |
|
765 |
cls isNil ifTrue:[ ^ self ]. |
|
766 |
]. |
|
767 |
||
768 |
self changed:#package. "/ will vanish |
|
769 |
cls changed:#methodPackage with:self selector. "/ will vanish |
|
770 |
||
771 |
Smalltalk changed:#projectOrganization with:(Array with:cls with:self with:oldPackage). |
|
772 |
cls addChangeRecordForMethodPackage:self package:newPackage. |
|
5724
96c2a5cf4217
category: and package: now send change notifications.
Claus Gittinger <cg@exept.de>
parents:
5721
diff
changeset
|
773 |
] |
10196 | 774 |
|
775 |
"Modified: / 23-11-2006 / 17:01:02 / cg" |
|
15952 | 776 |
"Modified: / 27-01-2012 / 17:15:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
777 |
"Modified (comment): / 27-01-2012 / 21:22:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
778 |
! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
779 |
|
13422 | 780 |
setAnnotations: anObject |
781 |
"set the annotations (low level - use do not use)" |
|
782 |
||
783 |
annotations := anObject |
|
784 |
||
785 |
"Created: / 20-05-2010 / 11:27:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
786 |
! |
|
787 |
||
5721
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
788 |
setCategory:aStringOrSymbol |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
789 |
"set the methods category (without change notification)" |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
790 |
|
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
791 |
aStringOrSymbol notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
792 |
category := aStringOrSymbol asSymbol |
5721
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
793 |
] |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
794 |
|
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
795 |
"Modified: / 13.11.1998 / 23:55:05 / cg" |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
796 |
! |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
797 |
|
5398 | 798 |
setPackage:aSymbol |
9702 | 799 |
"set the package-symbol (low level - use package:)" |
5398 | 800 |
|
801 |
package := aSymbol |
|
802 |
! |
|
803 |
||
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
804 |
source |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
805 |
"return the sourcestring for the receiver" |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
806 |
|
12598 | 807 |
|sourceStream chunk| |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
808 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
809 |
" |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
810 |
if sourcePosition is nonNil, its the fileName and |
2176
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
811 |
abs(sourcePosition) is the offset. |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
812 |
Otherwise, source is the real source |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
813 |
" |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
814 |
sourcePosition isNil ifTrue:[^ source]. |
13381
e16cafbd22bd
comment/format in: #sourceStreamUsingCache:
Claus Gittinger <cg@exept.de>
parents:
13189
diff
changeset
|
815 |
source isNil ifTrue:[^ nil]. |
e16cafbd22bd
comment/format in: #sourceStreamUsingCache:
Claus Gittinger <cg@exept.de>
parents:
13189
diff
changeset
|
816 |
|
20035 | 817 |
LastMethodSources notNil ifTrue:[ |
818 |
self class lastMethodSourcesLock critical:[ |
|
819 |
LastMethodSources notNil ifTrue:[ |
|
820 |
chunk := LastMethodSources at:self ifAbsent:nil. |
|
821 |
]. |
|
822 |
]. |
|
823 |
chunk notNil ifTrue:[ |
|
824 |
^ chunk |
|
825 |
]. |
|
13381
e16cafbd22bd
comment/format in: #sourceStreamUsingCache:
Claus Gittinger <cg@exept.de>
parents:
13189
diff
changeset
|
826 |
]. |
e16cafbd22bd
comment/format in: #sourceStreamUsingCache:
Claus Gittinger <cg@exept.de>
parents:
13189
diff
changeset
|
827 |
|
13463 | 828 |
LastFileLock |
20035 | 829 |
critical:[ |
830 |
"have to protect sourceStream from being closed as a side effect |
|
831 |
of some other process fetching some the source from a different source file" |
|
832 |
||
833 |
sourceStream := self sourceStreamUsingCache:true. |
|
834 |
sourceStream notNil ifTrue:[ |
|
835 |
[ |
|
836 |
chunk := self sourceChunkFromStream:sourceStream. |
|
837 |
] on:DecodingError do:[:ex| |
|
838 |
"CharacterEncoder>>#guessEncoding is not fail safe - retry with plain unencoded data" |
|
839 |
||
840 |
Logger info:'DecodingError ignored when reading %1 (%2)' with:self whoString with:ex description. |
|
841 |
sourceStream := self rawSourceStreamUsingCache:true. |
|
842 |
ex restart. |
|
843 |
]. |
|
844 |
]. |
|
845 |
] |
|
846 |
timeoutMs:100 |
|
847 |
ifBlocking:[ |
|
848 |
"take care if LastFileLock is not available - maybe we are |
|
849 |
called by a debugger while someone holds the lock. |
|
850 |
Use uncached source streams" |
|
851 |
sourceStream := self sourceStreamUsingCache:false. |
|
852 |
sourceStream notNil ifTrue:[ |
|
853 |
[ |
|
854 |
chunk := self sourceChunkFromStream:sourceStream. |
|
855 |
sourceStream close. |
|
856 |
] on:DecodingError do:[:ex| |
|
857 |
"CharacterEncoder>>#guessEncoding is not fail safe - retry with plain unencoded data" |
|
858 |
Logger info:'DecodingError ignored when reading %1 (%2)' with:self whoString with:ex description. |
|
859 |
sourceStream close. |
|
860 |
sourceStream := self rawSourceStreamUsingCache:false. |
|
861 |
ex restart. |
|
862 |
]. |
|
863 |
]. |
|
864 |
]. |
|
2979 | 865 |
|
10673
05229646ecd7
#source - handle DecodingError when fetching the method's source
Stefan Vogel <sv@exept.de>
parents:
10608
diff
changeset
|
866 |
"Cache the source of recently used methods" |
10608
82b1346f3e8d
Use similar code when accessing method and class source code
Stefan Vogel <sv@exept.de>
parents:
10482
diff
changeset
|
867 |
chunk notNil ifTrue:[ |
20035 | 868 |
"JV@2013-08-19: Don't consult UserPreferences if the system is initializing. This may |
869 |
lead in funny side-effect as #initializeDefaultPreferences is called which tries to |
|
870 |
initialize some colors. But Color itself is likely not yet initialized, so DNU is |
|
871 |
thrown. |
|
872 |
CG: also care for standalone non-GUI progs, which have no userPreferences class" |
|
873 |
(Smalltalk isInitialized |
|
874 |
and:[UserPreferences notNil |
|
875 |
and:[UserPreferences current keepMethodSourceCode]]) ifTrue:[ |
|
876 |
source := chunk. |
|
877 |
sourcePosition := nil. |
|
878 |
^ source. |
|
879 |
]. |
|
880 |
||
881 |
CacheDictionary notNil ifTrue:[ |
|
882 |
self class lastMethodSourcesLock critical:[ |
|
883 |
LastMethodSources isNil ifTrue:[ |
|
884 |
LastMethodSources := CacheDictionary new:50. |
|
885 |
]. |
|
886 |
LastMethodSources at:self put:chunk. |
|
887 |
] |
|
888 |
]. |
|
2979 | 889 |
]. |
890 |
||
10608
82b1346f3e8d
Use similar code when accessing method and class source code
Stefan Vogel <sv@exept.de>
parents:
10482
diff
changeset
|
891 |
^ chunk |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
892 |
|
10201 | 893 |
"Modified: / 07-01-1997 / 16:20:09 / stefan" |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
894 |
! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
895 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
896 |
source:aString |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
897 |
"set the methods sourcestring" |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
898 |
|
15346 | 899 |
self assert:(aString isText not). "/ will break monticello-binary-data-writing |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
900 |
source := aString. |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
901 |
sourcePosition := nil |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
902 |
! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
903 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
904 |
sourceFilename |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
905 |
"return the sourcefilename if source is extern; nil otherwise" |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
906 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
907 |
sourcePosition notNil ifTrue:[^ source]. |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
908 |
^ nil |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
909 |
! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
910 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
911 |
sourceFilename:aFileName position:aNumber |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
912 |
"set the methods sourcefile/position" |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
913 |
|
15346 | 914 |
self assert:(aFileName isText not). "/ will break monticello-binary-data-writing |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
915 |
source := aFileName. |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
916 |
sourcePosition := aNumber |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
917 |
! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
918 |
|
2812 | 919 |
sourceLineNumber |
920 |
"return the lineNumber of my source within the returned |
|
921 |
source sourcestring. |
|
922 |
For ST methods, the returned sourceString is always the |
|
923 |
methods pure source; therefore, the lineNumber is always 1." |
|
924 |
||
925 |
^ 1 |
|
926 |
||
927 |
"Created: 30.7.1997 / 15:42:01 / cg" |
|
928 |
! |
|
929 |
||
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
930 |
sourcePosition |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
931 |
"return the sourceposition if source is extern; nil otherwise" |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
932 |
|
2176
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
933 |
sourcePosition isNil ifTrue:[^ sourcePosition]. |
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
934 |
^ sourcePosition abs |
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
935 |
|
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
936 |
"Modified: 16.1.1997 / 01:28:25 / cg" |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
937 |
! ! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
938 |
|
14508 | 939 |
!Method methodsFor:'accessing-annotations'! |
940 |
||
941 |
annotateWith: annotation |
|
16221 | 942 |
"add a (hidden) annotation. |
943 |
This is only present in the image, not in the method's source code" |
|
944 |
||
14508 | 945 |
| index | |
946 |
||
947 |
index := self annotationIndexOf: annotation key. |
|
948 |
index isNil ifTrue:[ |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
949 |
annotations := annotations isNil |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
950 |
ifTrue:[Array with: annotation] |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
951 |
ifFalse:[annotations copyWith:annotation] |
14508 | 952 |
] ifFalse:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
953 |
annotations at: index put: annotation |
14508 | 954 |
]. |
955 |
"/ annotation annotatesMethod: self. |
|
956 |
||
957 |
" |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
958 |
(Object >> #yourself) annotateWith: (Annotation namespace: 'Fictious'). |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
959 |
(Object >> #yourself) annotations. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
960 |
(Object >> #yourself) annotationAt: #namespace: |
14508 | 961 |
" |
962 |
||
963 |
"Created: / 19-05-2010 / 16:20:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
964 |
"Modified: / 20-05-2010 / 11:22:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
965 |
"Modified (format): / 26-07-2012 / 15:47:51 / cg" |
|
966 |
! |
|
967 |
||
968 |
annotationAt: key |
|
969 |
| index | |
|
970 |
||
971 |
index := self annotationIndexOf: key. |
|
972 |
index isNil ifTrue:[^ nil]. |
|
973 |
^ self annotationAtIndex: index. |
|
974 |
||
975 |
" |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
976 |
(Object >> #yourself) annotationAt: #namespace: |
14508 | 977 |
" |
978 |
||
979 |
"Created: / 19-05-2010 / 16:16:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
980 |
"Modified: / 02-07-2010 / 22:35:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
981 |
"Modified: / 18-11-2011 / 14:46:21 / cg" |
|
982 |
"Modified (format): / 26-07-2012 / 15:47:54 / cg" |
|
983 |
! |
|
984 |
||
985 |
annotations |
|
18411 | 986 |
"return (a copy) of the annotations array" |
987 |
||
16220
0834bd0e9d85
Fixed bug in Method>>#annotations - always return an array with Annotation (sub)instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16218
diff
changeset
|
988 |
| retval | |
14508 | 989 |
|
16261 | 990 |
annotations isNil ifTrue:[^ #()]. |
18411 | 991 |
|
16220
0834bd0e9d85
Fixed bug in Method>>#annotations - always return an array with Annotation (sub)instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16218
diff
changeset
|
992 |
retval := Array new: annotations size. |
0834bd0e9d85
Fixed bug in Method>>#annotations - always return an array with Annotation (sub)instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16218
diff
changeset
|
993 |
1 to: annotations size do: [:i| |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
994 |
retval at: i put: (self annotationAtIndex: i). |
16220
0834bd0e9d85
Fixed bug in Method>>#annotations - always return an array with Annotation (sub)instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16218
diff
changeset
|
995 |
]. |
0834bd0e9d85
Fixed bug in Method>>#annotations - always return an array with Annotation (sub)instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16218
diff
changeset
|
996 |
^ retval. |
0834bd0e9d85
Fixed bug in Method>>#annotations - always return an array with Annotation (sub)instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16218
diff
changeset
|
997 |
|
14508 | 998 |
"Modified: / 18-11-2011 / 14:46:56 / cg" |
999 |
"Modified (comment): / 26-07-2012 / 15:50:26 / cg" |
|
16220
0834bd0e9d85
Fixed bug in Method>>#annotations - always return an array with Annotation (sub)instances.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16218
diff
changeset
|
1000 |
"Modified: / 05-03-2014 / 15:18:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
14508 | 1001 |
! |
1002 |
||
1003 |
annotations: anObject |
|
1004 |
"set the annotations" |
|
1005 |
||
1006 |
self setAnnotations: anObject. |
|
1007 |
"/ "iterate over annotations just to invoke |
|
19868 | 1008 |
"/ annotationAtIndex: which lazily initializes annotations |
1009 |
"/ and sends #annotatesMethod:" |
|
14508 | 1010 |
"/ self annotationsDo:[:annotation|] |
1011 |
||
1012 |
"Created: / 02-07-2010 / 22:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1013 |
! |
|
1014 |
||
1015 |
annotationsAt: key |
|
1016 |
||
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1017 |
^OrderedCollection |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1018 |
streamContents:[:annotStream| |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1019 |
self annotationsAt: key do: [:annot| annotStream nextPut: annot] |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1020 |
] |
14508 | 1021 |
|
1022 |
"Created: / 16-07-2010 / 11:41:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1023 |
"Modified (format): / 26-07-2012 / 15:46:56 / cg" |
|
1024 |
! |
|
1025 |
||
1026 |
annotationsAt: key do: block |
|
1027 |
self annotationsDo: [:annot| |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1028 |
annot key == key ifTrue:[block value: annot] |
14508 | 1029 |
] |
1030 |
||
1031 |
"Created: / 16-07-2010 / 11:48:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1032 |
"Modified (format): / 26-07-2012 / 15:48:37 / cg" |
|
1033 |
! |
|
1034 |
||
1035 |
annotationsAt: key1 orAt: key2 |
|
1036 |
||
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1037 |
^OrderedCollection |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1038 |
streamContents:[:annotStream| |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1039 |
self annotationsAt: key1 orAt: key2 do: [:annot|annotStream nextPut: annot] |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1040 |
] |
14508 | 1041 |
|
1042 |
"Created: / 16-07-2010 / 11:41:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1043 |
"Modified (format): / 26-07-2012 / 15:49:11 / cg" |
|
1044 |
! |
|
1045 |
||
1046 |
annotationsAt: key1 orAt: key2 do: block |
|
1047 |
self annotationsDo:[:annot | |
|
19585 | 1048 |
|key| |
1049 |
key := annot key. |
|
1050 |
(key == key1 or:[key == key2]) ifTrue:[ |
|
1051 |
block value: annot |
|
1052 |
] |
|
14508 | 1053 |
] |
1054 |
||
1055 |
"Created: / 16-07-2010 / 11:47:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1056 |
"Modified (format): / 26-07-2012 / 15:49:30 / cg" |
|
1057 |
! |
|
1058 |
||
1059 |
annotationsDo: aBlock |
|
1060 |
annotations isNil ifTrue:[^nil]. |
|
1061 |
1 to: annotations size do: [:i| |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1062 |
aBlock value: (self annotationAtIndex: i) |
14508 | 1063 |
]. |
1064 |
||
1065 |
"Created: / 02-07-2010 / 22:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1066 |
"Modified: / 11-07-2010 / 19:38:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1067 |
"Modified (format): / 18-11-2011 / 14:47:06 / cg" |
|
1068 |
! ! |
|
1069 |
||
21156 | 1070 |
|
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
1071 |
!Method methodsFor:'accessing-visibility'! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
1072 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1073 |
isIgnored |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1074 |
"return true, if this is an ignored method. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1075 |
Ignored methods are physically present in the source file, |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1076 |
but no code is generated for it by stc, and the VM does not see |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1077 |
it in its message lookup. |
747 | 1078 |
(i.e. setting a method to #ignored, and sending that selector, |
12854 | 1079 |
leads to either the superclasses implementation to be called, |
747 | 1080 |
or a doesNotUnderstand exception to be raised) |
1081 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1082 |
Notice: this is a nonstandard feature, not supported |
747 | 1083 |
by other smalltalk implementations and not specified in the ANSI spec. |
1084 |
||
1085 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
1086 |
It may change or even vanish (if it shows to be not useful)." |
|
1087 |
||
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1088 |
^ self privacy == #ignored |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1089 |
|
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1090 |
"Modified: / 23.1.1998 / 15:23:02 / stefan" |
176 | 1091 |
! |
1092 |
||
1093 |
isPrivate |
|
1094 |
"return true, if this is a private method. |
|
8518
7dc3f9909640
Interchanged the meaning of method privacy -
Stefan Vogel <sv@exept.de>
parents:
8465
diff
changeset
|
1095 |
Execution of private methods is only allowed via self sends |
7dc3f9909640
Interchanged the meaning of method privacy -
Stefan Vogel <sv@exept.de>
parents:
8465
diff
changeset
|
1096 |
from superclasses or the class itself. |
176 | 1097 |
If a private method is called by some other class, a runtime |
1098 |
error (PrivateMethodSignal) is raised. |
|
1099 |
Notice: method privacy is a nonstandard feature, not supported |
|
1100 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
747 | 1101 |
|
176 | 1102 |
This is EXPERIMENTAL - and being evaluated for usability. |
1103 |
It may change or even vanish (if it shows to be not useful)." |
|
1104 |
||
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1105 |
^ self privacy == #private |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1106 |
|
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1107 |
"Modified: / 23.1.1998 / 15:23:13 / stefan" |
68 | 1108 |
! |
1109 |
||
176 | 1110 |
isProtected |
1111 |
"return true, if this is a protected method. |
|
8518
7dc3f9909640
Interchanged the meaning of method privacy -
Stefan Vogel <sv@exept.de>
parents:
8465
diff
changeset
|
1112 |
Execution of protected methods is only allowed via self/super sends |
7dc3f9909640
Interchanged the meaning of method privacy -
Stefan Vogel <sv@exept.de>
parents:
8465
diff
changeset
|
1113 |
from superclasses, the class itself or subclasse. |
176 | 1114 |
If a protected method is called by some other class, a runtime |
1115 |
error (PrivateMethodSignal) is raised. |
|
747 | 1116 |
|
176 | 1117 |
Notice: method privacy is a nonstandard feature, not supported |
1118 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
747 | 1119 |
|
176 | 1120 |
This is EXPERIMENTAL - and being evaluated for usability. |
1121 |
It may change or even vanish (if it shows to be not useful)." |
|
1122 |
||
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1123 |
^ self privacy == #protected |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1124 |
|
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1125 |
"Modified: / 23.1.1998 / 15:23:27 / stefan" |
176 | 1126 |
! |
1127 |
||
1128 |
isPublic |
|
1129 |
"return true, if this is a public method - I.e. can be executed via any send. |
|
747 | 1130 |
This is the default and how other smalltalk implementations treat all methods. |
1131 |
||
360 | 1132 |
Notice: method privacy is a nonstandard feature, not supported |
1133 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
747 | 1134 |
|
360 | 1135 |
This is EXPERIMENTAL - and being evaluated for usability. |
1136 |
It may change or even vanish (if it shows to be not useful)." |
|
176 | 1137 |
|
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1138 |
^ self privacy == #public |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1139 |
|
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1140 |
"Modified: / 23.1.1998 / 15:23:40 / stefan" |
176 | 1141 |
! |
1142 |
||
747 | 1143 |
isRestricted |
1144 |
"return the flag bit stating that this method is restricted. |
|
1145 |
Execution of the receiver will only be allowed if the system is not in |
|
12854 | 1146 |
'trap restricted mode' (-->ObjectMemory) otherise a runtime |
747 | 1147 |
error (PrivateMethodSignal) is raised. |
1148 |
||
1149 |
Notice: method restriction is a nonstandard feature, not supported |
|
1150 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
1151 |
||
1152 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
1153 |
It may change or even vanish (if it shows to be not useful)." |
|
1154 |
||
1155 |
%{ /* NOCONTEXT */ |
|
1156 |
#ifdef F_RESTRICTED |
|
2868 | 1157 |
INT f = __intVal(__INST(flags)); |
747 | 1158 |
|
1159 |
if (f & F_RESTRICTED) { |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1160 |
RETURN (true); |
747 | 1161 |
} |
1162 |
#endif |
|
1163 |
%}. |
|
1164 |
^ false |
|
8526 | 1165 |
! ! |
1166 |
||
1167 |
!Method privateMethodsFor:'accessing-visibility'! |
|
1168 |
||
1169 |
primSetPrivacy:aSymbol |
|
1170 |
"set the methods access rights (privacy) from a symbol; |
|
1171 |
Currently, this must be one of #private, #protected, #public or #ignored. |
|
12854 | 1172 |
#setPrivacy: simply sets the attribute. When changing methods, that |
8526 | 1173 |
have already been called, #privacy: should be used. |
1174 |
||
1175 |
Notice: method privacy is a nonstandard feature, not supported |
|
1176 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
1177 |
If at all, use it for debugging purposes, to catch messagesends |
|
1178 |
which are not supposed to be sent by others. |
|
1179 |
(especially, if working in a team, while integrating other peoples work) |
|
1180 |
||
1181 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
1182 |
It may change or even vanish (if it shows to be not useful)." |
|
1183 |
||
1184 |
%{ /* NOCONTEXT */ |
|
1185 |
||
1186 |
#if defined(M_PRIVACY) |
|
1187 |
INT f = __intVal(__INST(flags)); |
|
1188 |
INT p; |
|
1189 |
||
1190 |
if (aSymbol == @symbol(public)) |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1191 |
p = 0; |
8526 | 1192 |
else if (aSymbol == @symbol(protected)) |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1193 |
p = F_PRIVATE; |
8526 | 1194 |
else if (aSymbol == @symbol(private)) |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1195 |
p = F_CLASSPRIVATE; |
8526 | 1196 |
else if (aSymbol == @symbol(ignored)) |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1197 |
p = F_IGNORED; |
8526 | 1198 |
else |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1199 |
RETURN(false); /* illegal symbol */ |
12854 | 1200 |
|
8526 | 1201 |
|
1202 |
f = (f & ~M_PRIVACY) | p; |
|
8913 | 1203 |
__INST(flags) = __mkSmallInteger(f); |
8526 | 1204 |
#endif |
1205 |
||
1206 |
%}. |
|
1207 |
^ true |
|
1208 |
||
1209 |
"Modified: 27.8.1995 / 22:58:08 / claus" |
|
1210 |
! ! |
|
1211 |
||
1212 |
!Method methodsFor:'accessing-visibility'! |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1213 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1214 |
privacy |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1215 |
"return a symbol describing the methods access rights (privacy); |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1216 |
Currently, this is one of #private, #protected, #public or #ignored. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1217 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1218 |
Notice: method privacy is a nonstandard feature, not supported |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1219 |
by other smalltalk implementations and not specified in the ANSI spec. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1220 |
If at all, use it for debugging purposes, to catch messagesends |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1221 |
which are not supposed to be sent by others. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1222 |
(especially, if working in a team, while integrating other peoples work) |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1223 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1224 |
This is EXPERIMENTAL - and being evaluated for usability. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1225 |
It may change or even vanish (if it shows to be not useful)." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1226 |
|
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1227 |
%{ /* NOCONTEXT */ |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1228 |
/* I made this a primitive to get the define constant from stc.h */ |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1229 |
|
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1230 |
#if defined(M_PRIVACY) && (defined(F_PRIVATE) || defined(F_CLASSPRIVATE) || defined(F_IGNORED)) |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1231 |
|
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1232 |
INT f = __intVal(__INST(flags)); |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1233 |
switch (f & M_PRIVACY) { |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1234 |
|
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1235 |
# ifdef F_PRIVATE |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1236 |
case F_PRIVATE: |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1237 |
RETURN (@symbol(protected)); |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1238 |
break; |
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1239 |
# endif |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1240 |
# ifdef F_CLASSPRIVATE |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1241 |
case F_CLASSPRIVATE: |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1242 |
RETURN (@symbol(private)); |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1243 |
break; |
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1244 |
# endif |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1245 |
# ifdef F_IGNORED |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1246 |
case F_IGNORED: |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1247 |
RETURN (@symbol(ignored)); |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1248 |
break; |
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1249 |
# endif |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1250 |
} |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1251 |
#endif |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1252 |
%}. |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1253 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1254 |
^ #public |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1255 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1256 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1257 |
privacy:aSymbol |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1258 |
"set the methods access rights (privacy) from a symbol; |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1259 |
Currently, this must be one of #private, #protected, #public or #ignored. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1260 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1261 |
Notice: method privacy is a nonstandard feature, not supported |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1262 |
by other smalltalk implementations and not specified in the ANSI spec. |
8518
7dc3f9909640
Interchanged the meaning of method privacy -
Stefan Vogel <sv@exept.de>
parents:
8465
diff
changeset
|
1263 |
If at all, use it for debugging purposes, to catch message sends |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1264 |
which are not supposed to be sent by others. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1265 |
(especially, if working in a team, while integrating other peoples work) |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1266 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1267 |
This is EXPERIMENTAL - and being evaluated for usability. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1268 |
It may change or even vanish (if it shows to be not useful)." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1269 |
|
8526 | 1270 |
|oldPrivacy| |
1271 |
||
1272 |
oldPrivacy := self privacy. |
|
1273 |
||
1274 |
(self setPrivacy:aSymbol flushCaches:true) ifTrue:[ |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1275 |
|myClass mySelector| |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1276 |
|
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1277 |
myClass := self mclass. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1278 |
mySelector := self selector. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1279 |
|
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1280 |
self changed:#privacy. "/ will vanish |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1281 |
myClass notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1282 |
mySelector notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1283 |
myClass changed:#methodPrivacy with:mySelector. "/ will vanish |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1284 |
Smalltalk changed:#privacyOfMethod with:(Array with:myClass with:self with:oldPrivacy). |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1285 |
myClass addChangeRecordForMethodPrivacy:self. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1286 |
] |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1287 |
] |
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1288 |
] |
10196 | 1289 |
|
1290 |
"Modified: / 23-11-2006 / 17:03:20 / cg" |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1291 |
! |
747 | 1292 |
|
532
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1293 |
restricted:aBoolean |
12854 | 1294 |
"set or clear the flag bit stating that this method is restricted. |
532
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1295 |
Execution of the receiver will only be allowed if the system is not in |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1296 |
'trap restricted mode' (-->ObjectMemory) otherise a runtime |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1297 |
error (PrivateMethodSignal) is raised. |
747 | 1298 |
|
532
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1299 |
Notice: method restriction is a nonstandard feature, not supported |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1300 |
by other smalltalk implementations and not specified in the ANSI spec. |
747 | 1301 |
|
532
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1302 |
This is EXPERIMENTAL - and being evaluated for usability. |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1303 |
It may change or even vanish (if it shows to be not useful)." |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1304 |
|
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1305 |
%{ /* NOCONTEXT */ |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1306 |
/* I made this a primitive to get the define constant from stc.h */ |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1307 |
|
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1308 |
#ifdef F_RESTRICTED |
2868 | 1309 |
INT f = __intVal(__INST(flags)); |
1310 |
INT old; |
|
532
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1311 |
|
747 | 1312 |
old = f; |
12854 | 1313 |
if (aBoolean == true) |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1314 |
f |= F_RESTRICTED; |
532
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1315 |
else |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1316 |
f &= ~F_RESTRICTED; |
8913 | 1317 |
__INST(flags) = __mkSmallInteger(f); |
532
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1318 |
if (old & F_RESTRICTED) |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1319 |
RETURN(true); |
532
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1320 |
#endif |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1321 |
%}. |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1322 |
^ false |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1323 |
|
747 | 1324 |
" |
1325 |
(ObjectMemory class compiledMethodAt:#compressingGarbageCollect) restricted:true |
|
1326 |
" |
|
532
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1327 |
|
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1328 |
"Created: 7.11.1995 / 20:36:19 / stefan" |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1329 |
! |
2511c99de912
New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents:
530
diff
changeset
|
1330 |
|
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1331 |
setPrivacy:aSymbol |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1332 |
"set the methods access rights (privacy) from a symbol; |
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1333 |
Currently, this must be one of #private, #protected, #public or #ignored. |
12854 | 1334 |
#setPrivacy: simply sets the attribute. When changing methods, that |
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1335 |
have already been called, #privacy: should be used. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1336 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1337 |
Notice: method privacy is a nonstandard feature, not supported |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1338 |
by other smalltalk implementations and not specified in the ANSI spec. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1339 |
If at all, use it for debugging purposes, to catch messagesends |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1340 |
which are not supposed to be sent by others. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1341 |
(especially, if working in a team, while integrating other peoples work) |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1342 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1343 |
This is EXPERIMENTAL - and being evaluated for usability. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1344 |
It may change or even vanish (if it shows to be not useful)." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1345 |
|
8526 | 1346 |
^ self setPrivacy:aSymbol flushCaches:true |
1347 |
! |
|
1348 |
||
1349 |
setPrivacy:aSymbol flushCaches:doFlush |
|
17526 | 1350 |
"set the method's access rights (privacy) from a symbol; |
8526 | 1351 |
Currently, this must be one of #private, #protected, #public or #ignored. |
12854 | 1352 |
#setPrivacy: simply sets the attribute. When changing methods, that |
8526 | 1353 |
have already been called, #privacy: should be used. |
1354 |
||
1355 |
Notice: method privacy is a nonstandard feature, not supported |
|
17526 | 1356 |
by other Smalltalk implementations and not specified in the ANSI spec. |
1357 |
If at all, use it for debugging purposes, to catch message sends |
|
8526 | 1358 |
which are not supposed to be sent by others. |
1359 |
(especially, if working in a team, while integrating other peoples work) |
|
1360 |
||
1361 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
1362 |
It may change or even vanish (if it shows to be not useful)." |
|
1363 |
||
1364 |
|old sel| |
|
1365 |
||
1366 |
old := self privacy. |
|
1367 |
old == aSymbol ifTrue:[^ false]. |
|
1368 |
(self primSetPrivacy:aSymbol) ifFalse:[^ false]. |
|
1369 |
||
1370 |
"/ |
|
1371 |
"/ no need to flush, if changing from private to public |
|
1372 |
"/ |
|
1373 |
doFlush ifTrue:[ |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1374 |
(aSymbol == #public and:[old ~~ #ignored]) ifFalse:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1375 |
(sel := self selector) notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1376 |
ObjectMemory flushCachesForSelector:sel numArgs:self argumentCount |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1377 |
] ifFalse:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1378 |
ObjectMemory flushCaches. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1379 |
]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1380 |
]. |
8526 | 1381 |
]. |
3216
e0f3f49118ed
Simplify privacy stuff to make redirection from WrappedMethod easier.
Stefan Vogel <sv@exept.de>
parents:
3168
diff
changeset
|
1382 |
^ true |
1 | 1383 |
! ! |
1384 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1385 |
!Method methodsFor:'binary storage'! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1386 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1387 |
asByteCodeMethod |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1388 |
"if the receiver has no bytecodes, create & return a method having |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1389 |
the same semantics as the receiver, but uses interpreted bytecodes. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1390 |
Otherwise, return the receiver. The new method is not installed in |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1391 |
the methodDictionary of any class - just returned. |
2064 | 1392 |
If the method contains primitive code, this may return a method |
1393 |
without bytecode. |
|
12854 | 1394 |
Can be used to obtain a bytecode version of a machine-code method, |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1395 |
for binary storage or dynamic recompilation (which is not yet finished) |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1396 |
or to compile lazy methods down to executable ones." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1397 |
|
9096 | 1398 |
|mthd| |
1 | 1399 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1400 |
byteCode notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1401 |
" |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1402 |
is already a bytecoded method |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1403 |
" |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1404 |
^ self |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1405 |
]. |
9096 | 1406 |
|
1407 |
ParserFlags |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1408 |
withSTCCompilation:#never |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1409 |
do:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1410 |
mthd := self asExecutableMethod. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1411 |
]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1412 |
^ mthd |
68 | 1413 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1414 |
"Created: 24.10.1995 / 14:02:32 / cg" |
2064 | 1415 |
"Modified: 5.1.1997 / 01:01:53 / cg" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1416 |
! |
306 | 1417 |
|
5405 | 1418 |
asByteCodeMethodWithSource:newSource |
9096 | 1419 |
|mthd| |
1420 |
||
12854 | 1421 |
ParserFlags |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1422 |
withSTCCompilation:#never |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1423 |
do:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1424 |
mthd := self asExecutableMethodWithSource:newSource. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1425 |
]. |
5405 | 1426 |
^ mthd |
1427 |
||
1428 |
"Created: 24.10.1995 / 14:02:32 / cg" |
|
1429 |
"Modified: 5.1.1997 / 01:01:53 / cg" |
|
1430 |
! |
|
1431 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1432 |
asExecutableMethod |
12854 | 1433 |
"if the receiver has neither bytecodes nor machinecode, create & return a |
19449 | 1434 |
method having semantics as the receiver's source. This may be machine code, |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1435 |
if the system supports dynamic loading of object code and the source includes |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1436 |
primitive code. However, bytecode is preferred, since it compiles faster. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1437 |
Otherwise, return the receiver. The new method is not installed in |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1438 |
the methodDictionary of any class - just returned. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1439 |
Can be used to compile lazy methods down to executable ones." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1440 |
|
5700
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1441 |
|temporaryMethod sourceString| |
306 | 1442 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1443 |
byteCode notNil ifTrue:[ |
19449 | 1444 |
" |
1445 |
is already a bytecoded method |
|
1446 |
" |
|
1447 |
^ self |
|
5700
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1448 |
]. |
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1449 |
|
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1450 |
sourceString := self source. |
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1451 |
sourceString isNil ifTrue:[ |
19449 | 1452 |
'Method [warning]: cannot generate bytecode (no source for compilation)' errorPrintCR. |
1453 |
^ nil |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1454 |
]. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1455 |
|
5700
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1456 |
temporaryMethod := self asExecutableMethodWithSource:sourceString. |
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1457 |
|
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1458 |
(temporaryMethod isNil or:[temporaryMethod == #Error]) ifTrue:[ |
19449 | 1459 |
'Method [warning]: cannot generate bytecode (contains primitive code or error)' errorPrintCR. |
1460 |
^ nil. |
|
5700
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1461 |
]. |
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1462 |
"/ |
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1463 |
"/ try to save a bit of memory, by sharing the source (whatever it is) |
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1464 |
"/ |
12854 | 1465 |
temporaryMethod sourceFilename:source position:sourcePosition. |
5700
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1466 |
^ temporaryMethod |
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1467 |
! |
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1468 |
|
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1469 |
asExecutableMethodWithSource:newSource |
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1470 |
|temporaryMethod cls| |
ee59aff043c4
asExecutableMethod / asExecutableMethodWith: - code reuse
Claus Gittinger <cg@exept.de>
parents:
5696
diff
changeset
|
1471 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1472 |
cls := self containingClass. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1473 |
cls isNil ifTrue:[ |
20804 | 1474 |
'Method [warning]: cannot generate bytecode (no class for compilation)' errorPrintCR. |
1475 |
^ nil |
|
306 | 1476 |
]. |
1 | 1477 |
|
4290
5e43473d7a35
moved recompilation semaphore from LazyMethod to Method
Claus Gittinger <cg@exept.de>
parents:
4015
diff
changeset
|
1478 |
"we have to sequentialize this using a lock-semaphore, |
5e43473d7a35
moved recompilation semaphore from LazyMethod to Method
Claus Gittinger <cg@exept.de>
parents:
4015
diff
changeset
|
1479 |
to make sure only one method is compiled at a time. |
5e43473d7a35
moved recompilation semaphore from LazyMethod to Method
Claus Gittinger <cg@exept.de>
parents:
4015
diff
changeset
|
1480 |
Otherwise, we might get into trouble, if (due to a timeout) |
5e43473d7a35
moved recompilation semaphore from LazyMethod to Method
Claus Gittinger <cg@exept.de>
parents:
4015
diff
changeset
|
1481 |
another recompile is forced while compiling this one ... |
5e43473d7a35
moved recompilation semaphore from LazyMethod to Method
Claus Gittinger <cg@exept.de>
parents:
4015
diff
changeset
|
1482 |
(happened when autoloading animation demos) |
176 | 1483 |
" |
4290
5e43473d7a35
moved recompilation semaphore from LazyMethod to Method
Claus Gittinger <cg@exept.de>
parents:
4015
diff
changeset
|
1484 |
CompilationLock critical:[ |
20804 | 1485 |
" |
1486 |
don't want this to go into the changes file, |
|
1487 |
don't want output on Transcript and definitely |
|
1488 |
don't want a lazy method ... |
|
1489 |
" |
|
1490 |
Class withoutUpdatingChangesDo:[ |
|
1491 |
|silent lazy| |
|
1492 |
||
1493 |
silent := Smalltalk silentLoading:true. |
|
1494 |
lazy := Compiler compileLazy:false. |
|
1495 |
||
1496 |
[ |
|
1497 |
|compiler| |
|
1498 |
||
1499 |
Class nameSpaceQuerySignal answer:(cls nameSpace) |
|
1500 |
do:[ |
|
1501 |
compiler := cls compilerClass. |
|
1502 |
||
1503 |
"/ |
|
1504 |
"/ kludge - have to make ST/X's compiler protocol |
|
1505 |
"/ be compatible to ST-80's |
|
1506 |
"/ |
|
1507 |
(compiler respondsTo:#compile:forClass:inCategory:notifying:install:) |
|
1508 |
ifTrue:[ |
|
1509 |
temporaryMethod := compiler |
|
1510 |
compile:newSource |
|
1511 |
forClass:cls |
|
1512 |
inCategory:(self category) |
|
1513 |
notifying:nil |
|
1514 |
install:false. |
|
1515 |
] ifFalse:[ |
|
1516 |
temporaryMethod := compiler new |
|
1517 |
compile:newSource |
|
1518 |
in:cls |
|
1519 |
notifying:nil |
|
1520 |
ifFail:nil |
|
1521 |
]. |
|
1522 |
]. |
|
1523 |
] ensure:[ |
|
1524 |
Compiler compileLazy:lazy. |
|
1525 |
Smalltalk silentLoading:silent. |
|
1526 |
] |
|
1527 |
]. |
|
463
447ead9f870c
be silent on transcript when parsing for args, vars and primitiveCode
Claus Gittinger <cg@exept.de>
parents:
444
diff
changeset
|
1528 |
]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1529 |
(temporaryMethod isNil or:[temporaryMethod == #Error]) ifTrue:[ |
20804 | 1530 |
'Method [warning]: cannot generate bytecode (contains primitive code or error)' errorPrintCR. |
1531 |
^ nil. |
|
5405 | 1532 |
]. |
1533 |
"/ |
|
1534 |
"/ try to save a bit of memory, by sharing the source (whatever it is) |
|
1535 |
"/ |
|
12854 | 1536 |
temporaryMethod source:newSource. |
5405 | 1537 |
"/ |
20804 | 1538 |
"/ don't forget the methods class & package ... |
5405 | 1539 |
"/ |
1540 |
temporaryMethod setPackage:package. |
|
17250 | 1541 |
temporaryMethod mclass:(self getMclass). |
5405 | 1542 |
^ temporaryMethod |
1 | 1543 |
! ! |
1544 |
||
20357
0eae8bf21a91
Method: don't try to figure out a source code manager for method when using local source
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20210
diff
changeset
|
1545 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1546 |
!Method methodsFor:'copying'! |
438 | 1547 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1548 |
copy |
2176
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
1549 |
"redefined to change a source ref into a real string" |
438 | 1550 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1551 |
|aCopy| |
438 | 1552 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1553 |
aCopy := super copy. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1554 |
sourcePosition notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1555 |
aCopy source:(self source) |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1556 |
]. |
5676 | 1557 |
aCopy mclass:nil. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1558 |
^ aCopy |
2176
1a24b0cef25a
when compressing sources, make certain to avoid later
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
1559 |
|
5696 | 1560 |
"Modified: 16.1.1997 / 01:27:25 / cg" |
1561 |
! ! |
|
438 | 1562 |
|
1 | 1563 |
!Method methodsFor:'error handling'! |
1564 |
||
328 | 1565 |
invalidCodeObject |
1873 | 1566 |
"{ Pragma: +optSpace }" |
1567 |
||
93 | 1568 |
"this method is triggered by the interpreter when a nil or non method |
1569 |
is about to be executed. |
|
1570 |
In this case, the VM sends this to the bad method (the receiver). |
|
1571 |
||
1572 |
Also, the Compiler creates methods with their code/bytecode set to |
|
1573 |
this method if - after a class change - a method cannot be compiled |
|
1574 |
and is therefore no longer executable (for example, after an instvar |
|
68 | 1575 |
has been removed, and a method still tries to access this instvar) |
44 | 1576 |
|
93 | 1577 |
Thus, we arrive here, when playing around in a classes methodArray, |
12854 | 1578 |
or compiler/runtime system is broken :-(, |
93 | 1579 |
or you ignore the error messages during some recompile." |
1 | 1580 |
|
1873 | 1581 |
%{ |
1582 |
/* |
|
1583 |
* for reasons too far from being explained here, |
|
1584 |
* this MUST be a compiled method |
|
1585 |
*/ |
|
1586 |
%}. |
|
7601 | 1587 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1588 |
raiseErrorString:'invalid method - not executable'. |
1873 | 1589 |
|
1590 |
"Modified: 4.11.1996 / 22:45:06 / cg" |
|
1 | 1591 |
! |
1592 |
||
13693 | 1593 |
invalidCodeObjectWith:arg |
1594 |
"{ Pragma: +optSpace }" |
|
1595 |
||
1596 |
"When recompiling classes after a definition-change, all |
|
1597 |
uncompilable methods (with 2 args) will be bound to this method here, |
|
1598 |
so that evaluating such an uncompilable method will trigger an error." |
|
1599 |
||
1600 |
%{ |
|
1601 |
/* |
|
1602 |
* for reasons too far from being explained here, |
|
1603 |
* this MUST be a compiled method |
|
1604 |
*/ |
|
1605 |
%}. |
|
1606 |
^ InvalidCodeError |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1607 |
raiseErrorString:'invalid method - not executable'. |
13693 | 1608 |
|
1609 |
"Created: / 14-09-2011 / 11:23:49 / sr" |
|
1610 |
! |
|
1611 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1612 |
invalidCodeObjectWith:arg with:arg2 |
1873 | 1613 |
"{ Pragma: +optSpace }" |
1614 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1615 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1616 |
uncompilable methods (with 2 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1617 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1618 |
|
1873 | 1619 |
%{ |
1620 |
/* |
|
1621 |
* for reasons too far from being explained here, |
|
1622 |
* this MUST be a compiled method |
|
1623 |
*/ |
|
1624 |
%}. |
|
7601 | 1625 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1626 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1627 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1628 |
"Created: 4.11.1996 / 21:16:41 / cg" |
1873 | 1629 |
"Modified: 4.11.1996 / 22:45:15 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1630 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1631 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1632 |
invalidCodeObjectWith:arg with:arg2 with:arg3 |
1873 | 1633 |
"{ Pragma: +optSpace }" |
1634 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1635 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1636 |
uncompilable methods (with 3 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1637 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1638 |
|
1873 | 1639 |
%{ |
1640 |
/* |
|
1641 |
* for reasons too far from being explained here, |
|
1642 |
* this MUST be a compiled method |
|
1643 |
*/ |
|
1644 |
%}. |
|
7601 | 1645 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1646 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1647 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1648 |
"Created: 4.11.1996 / 21:16:51 / cg" |
1873 | 1649 |
"Modified: 4.11.1996 / 22:45:18 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1650 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1651 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1652 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 |
1873 | 1653 |
"{ Pragma: +optSpace }" |
1654 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1655 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1656 |
uncompilable methods (with 4 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1657 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1658 |
|
1873 | 1659 |
%{ |
1660 |
/* |
|
1661 |
* for reasons too far from being explained here, |
|
1662 |
* this MUST be a compiled method |
|
1663 |
*/ |
|
1664 |
%}. |
|
7601 | 1665 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1666 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1667 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1668 |
"Created: 4.11.1996 / 21:17:00 / cg" |
1873 | 1669 |
"Modified: 4.11.1996 / 22:45:22 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1670 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1671 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1672 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 |
1873 | 1673 |
"{ Pragma: +optSpace }" |
1674 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1675 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1676 |
uncompilable methods (with 5 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1677 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1678 |
|
1873 | 1679 |
%{ |
1680 |
/* |
|
1681 |
* for reasons too far from being explained here, |
|
1682 |
* this MUST be a compiled method |
|
1683 |
*/ |
|
1684 |
%}. |
|
7601 | 1685 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1686 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1687 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1688 |
"Created: 4.11.1996 / 21:17:09 / cg" |
1873 | 1689 |
"Modified: 4.11.1996 / 22:45:25 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1690 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1691 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1692 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 |
1873 | 1693 |
"{ Pragma: +optSpace }" |
1694 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1695 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1696 |
uncompilable methods (with 6 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1697 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1698 |
|
1873 | 1699 |
%{ |
1700 |
/* |
|
1701 |
* for reasons too far from being explained here, |
|
1702 |
* this MUST be a compiled method |
|
1703 |
*/ |
|
1704 |
%}. |
|
7601 | 1705 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1706 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1707 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1708 |
"Created: 4.11.1996 / 21:17:17 / cg" |
1873 | 1709 |
"Modified: 4.11.1996 / 22:45:28 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1710 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1711 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1712 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 |
1873 | 1713 |
"{ Pragma: +optSpace }" |
1714 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1715 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1716 |
uncompilable methods (with 7 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1717 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1718 |
|
1873 | 1719 |
%{ |
1720 |
/* |
|
1721 |
* for reasons too far from being explained here, |
|
1722 |
* this MUST be a compiled method |
|
1723 |
*/ |
|
1724 |
%}. |
|
7601 | 1725 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1726 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1727 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1728 |
"Created: 4.11.1996 / 21:17:25 / cg" |
1873 | 1729 |
"Modified: 4.11.1996 / 22:45:31 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1730 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1731 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1732 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 with:arg8 |
1873 | 1733 |
"{ Pragma: +optSpace }" |
1734 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1735 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1736 |
uncompilable methods (with 8 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1737 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1738 |
|
1873 | 1739 |
%{ |
1740 |
/* |
|
1741 |
* for reasons too far from being explained here, |
|
1742 |
* this MUST be a compiled method |
|
1743 |
*/ |
|
1744 |
%}. |
|
7601 | 1745 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1746 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1747 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1748 |
"Created: 4.11.1996 / 21:17:32 / cg" |
1873 | 1749 |
"Modified: 4.11.1996 / 22:45:38 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1750 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1751 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1752 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 with:arg8 with:arg9 |
1873 | 1753 |
"{ Pragma: +optSpace }" |
1754 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1755 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1756 |
uncompilable methods (with 9 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1757 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1758 |
|
1873 | 1759 |
%{ |
1760 |
/* |
|
1761 |
* for reasons too far from being explained here, |
|
1762 |
* this MUST be a compiled method |
|
1763 |
*/ |
|
1764 |
%}. |
|
7601 | 1765 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1766 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1767 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1768 |
"Created: 4.11.1996 / 21:17:37 / cg" |
1873 | 1769 |
"Modified: 4.11.1996 / 22:45:41 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1770 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1771 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1772 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 with:arg8 with:arg9 with:arg10 |
1873 | 1773 |
"{ Pragma: +optSpace }" |
1774 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1775 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1776 |
uncompilable methods (with 10 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1777 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1778 |
|
1873 | 1779 |
%{ |
1780 |
/* |
|
1781 |
* for reasons too far from being explained here, |
|
1782 |
* this MUST be a compiled method |
|
1783 |
*/ |
|
1784 |
%}. |
|
7601 | 1785 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1786 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1787 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1788 |
"Created: 4.11.1996 / 21:17:45 / cg" |
1873 | 1789 |
"Modified: 4.11.1996 / 22:45:44 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1790 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1791 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1792 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 with:arg8 with:arg9 with:arg10 with:arg11 |
1873 | 1793 |
"{ Pragma: +optSpace }" |
1794 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1795 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1796 |
uncompilable methods (with 11 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1797 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1798 |
|
1873 | 1799 |
%{ |
1800 |
/* |
|
1801 |
* for reasons too far from being explained here, |
|
1802 |
* this MUST be a compiled method |
|
1803 |
*/ |
|
1804 |
%}. |
|
7601 | 1805 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1806 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1807 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1808 |
"Created: 4.11.1996 / 21:17:52 / cg" |
1873 | 1809 |
"Modified: 4.11.1996 / 22:45:47 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1810 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1811 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1812 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 with:arg8 with:arg9 with:arg10 with:arg11 with:arg12 |
1873 | 1813 |
"{ Pragma: +optSpace }" |
1814 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1815 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1816 |
uncompilable methods (with 12 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1817 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1818 |
|
1873 | 1819 |
%{ |
1820 |
/* |
|
1821 |
* for reasons too far from being explained here, |
|
1822 |
* this MUST be a compiled method |
|
1823 |
*/ |
|
1824 |
%}. |
|
7601 | 1825 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1826 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1827 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1828 |
"Created: 4.11.1996 / 20:51:28 / cg" |
1873 | 1829 |
"Modified: 4.11.1996 / 22:46:01 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1830 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1831 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1832 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 with:arg8 with:arg9 with:arg10 with:arg11 with:arg12 with:arg13 |
1873 | 1833 |
"{ Pragma: +optSpace }" |
1834 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1835 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1836 |
uncompilable methods (with 13 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1837 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1838 |
|
1873 | 1839 |
%{ |
1840 |
/* |
|
1841 |
* for reasons too far from being explained here, |
|
1842 |
* this MUST be a compiled method |
|
1843 |
*/ |
|
1844 |
%}. |
|
7601 | 1845 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1846 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1847 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1848 |
"Created: 4.11.1996 / 21:18:09 / cg" |
1873 | 1849 |
"Modified: 4.11.1996 / 22:45:57 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1850 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1851 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1852 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 with:arg8 with:arg9 with:arg10 with:arg11 with:arg12 with:arg13 with:arg14 |
1873 | 1853 |
"{ Pragma: +optSpace }" |
1854 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1855 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1856 |
uncompilable methods (with 14 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1857 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1858 |
|
1873 | 1859 |
%{ |
1860 |
/* |
|
1861 |
* for reasons too far from being explained here, |
|
1862 |
* this MUST be a compiled method |
|
1863 |
*/ |
|
1864 |
%}. |
|
7601 | 1865 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1866 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1867 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1868 |
"Created: 4.11.1996 / 21:18:17 / cg" |
1873 | 1869 |
"Modified: 4.11.1996 / 22:45:55 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1870 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1871 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1872 |
invalidCodeObjectWith:arg with:arg2 with:arg3 with:arg4 with:arg5 with:arg6 with:arg7 with:arg8 with:arg9 with:arg10 with:arg11 with:arg12 with:arg13 with:arg14 with:arg15 |
1873 | 1873 |
"{ Pragma: +optSpace }" |
1874 |
||
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1875 |
"When recompiling classes after a definition-change, all |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1876 |
uncompilable methods (with 15 args) will be bound to this method here, |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1877 |
so that evaluating such an uncompilable method will trigger an error." |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1878 |
|
1873 | 1879 |
%{ |
1880 |
/* |
|
1881 |
* for reasons too far from being explained here, |
|
1882 |
* this MUST be a compiled method |
|
1883 |
*/ |
|
1884 |
%}. |
|
7601 | 1885 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1886 |
raiseErrorString:'invalid method - not executable'. |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1887 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1888 |
"Created: 4.11.1996 / 21:18:22 / cg" |
1873 | 1889 |
"Modified: 4.11.1996 / 22:45:52 / cg" |
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1890 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
1891 |
|
109 | 1892 |
privateMethodCalled |
1873 | 1893 |
"{ Pragma: +optSpace }" |
1894 |
||
980 | 1895 |
"this error is triggered, if a private or protected method is called. |
1896 |
||
360 | 1897 |
If you continue in the debugger, the method will be called, |
12854 | 1898 |
and further privacy exceptions will NOT be reported at this call location, |
360 | 1899 |
until any new method is compiled, or the privacy of any method changes, |
1900 |
or the caches are flushed. |
|
20209 | 1901 |
(the reason is that after the continue, the method is entered into the |
360 | 1902 |
calling cache, for which method privacy is not checked. |
1903 |
Any of the above actions flushes this cache and a privacy check |
|
1904 |
is performed again.) |
|
1905 |
Future versions may not enter private methods into the cache, to fix this |
|
1906 |
(unobvious) behavior. However, then you will get an exception for EVERY |
|
1907 |
call to a private method ... |
|
1908 |
||
1909 |
Notice: method privacy is a nonstandard feature, not supported |
|
1910 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
1911 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
1912 |
It may change or even vanish (if it shows to be not useful)." |
|
68 | 1913 |
|
8518
7dc3f9909640
Interchanged the meaning of method privacy -
Stefan Vogel <sv@exept.de>
parents:
8465
diff
changeset
|
1914 |
^ PrivateMethodSignal raiseRequest |
1873 | 1915 |
|
1916 |
"Modified: 4.11.1996 / 22:46:09 / cg" |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1917 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1918 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1919 |
uncompiledCodeObject |
1873 | 1920 |
"{ Pragma: +optSpace }" |
1921 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1922 |
"this method is invoked by methods which contain primitive code, |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1923 |
but have not been compiled to machine code (either due to an error |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1924 |
when compiling, or simply because no stc is available. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
1925 |
For those methods, the compiler generated a method object consisting |
1873 | 1926 |
of the original source code, but with this methods machine/byte code." |
1927 |
||
1928 |
%{ |
|
1929 |
/* |
|
1930 |
* for reasons too far from being explained here, |
|
1931 |
* this MUST be a compiled method |
|
1932 |
*/ |
|
1933 |
%}. |
|
7601 | 1934 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1935 |
raiseRequestWith:self |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1936 |
errorString:'invalid method - not compiled'. |
1873 | 1937 |
|
1938 |
"Modified: 4.11.1996 / 22:58:02 / cg" |
|
1939 |
! |
|
1940 |
||
1941 |
unloadedCodeObject |
|
1942 |
"{ Pragma: +optSpace }" |
|
1943 |
||
1944 |
"this method is invoked by methods which have been binary-unloaded |
|
1945 |
For those the source info consists |
|
1946 |
of the original source code, but with this methods machine/byte code." |
|
1947 |
||
1948 |
%{ |
|
1949 |
/* |
|
1950 |
* for reasons too far from being explained here, |
|
1951 |
* this MUST be a compiled method |
|
1952 |
*/ |
|
1953 |
%}. |
|
7601 | 1954 |
^ InvalidCodeError |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1955 |
raiseRequestWith:self |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
1956 |
errorString:'invalid method - unloaded'. |
1873 | 1957 |
|
1958 |
"Created: 4.11.1996 / 22:57:54 / cg" |
|
1959 |
"Modified: 4.11.1996 / 22:58:28 / cg" |
|
1 | 1960 |
! ! |
1961 |
||
9987 | 1962 |
|
93 | 1963 |
!Method methodsFor:'printing & storing'! |
1 | 1964 |
|
1965 |
printOn:aStream |
|
56 | 1966 |
"put a printed representation of the receiver onto aStream. |
1967 |
Since methods do not store their class/selector, we have to search |
|
1968 |
for it here." |
|
1 | 1969 |
|
227 | 1970 |
|classAndSelector m wrapped| |
1 | 1971 |
|
253 | 1972 |
wrapped := false. |
1973 |
||
6234
d8083875f657
fixed pixmap readout for win32, where red and green are exchanged
Claus Gittinger <cg@exept.de>
parents:
6160
diff
changeset
|
1974 |
self basicPrintOn:aStream."/ aStream nextPutAll:(self classNameWithArticle). |
159 | 1975 |
aStream nextPut:$(. |
227 | 1976 |
|
176 | 1977 |
classAndSelector := self who. |
227 | 1978 |
classAndSelector isNil ifTrue:[ |
19847 | 1979 |
" |
1980 |
not anchored in any class. |
|
1981 |
check if wrapped (to be more informative in inspectors) |
|
1982 |
" |
|
1983 |
m := self wrapper. |
|
1984 |
m notNil ifTrue:[ |
|
1985 |
classAndSelector := m who. |
|
1986 |
wrapped := true. |
|
1987 |
] |
|
227 | 1988 |
]. |
176 | 1989 |
classAndSelector notNil ifTrue:[ |
19847 | 1990 |
(classAndSelector methodClass) name printOn:aStream. |
1991 |
"/ print out in a form that can directly be evaluated (>> is a selector in Behavior) |
|
21156 | 1992 |
"/ in order to not break existing code which parses those strings, |
21246 | 1993 |
"/ do not replace '>>' by ' ' |
19847 | 1994 |
aStream nextPutAll:' >> '. |
1995 |
(classAndSelector methodSelector) printOn:aStream. |
|
1 | 1996 |
] ifFalse:[ |
19847 | 1997 |
" |
1998 |
sorry, a method which is nowhere anchored |
|
1999 |
" |
|
2000 |
aStream nextPutAll:'unbound' |
|
56 | 2001 |
]. |
13101 | 2002 |
aStream nextPut:$). |
2003 |
||
2004 |
wrapped ifTrue:[ |
|
19847 | 2005 |
aStream nextPutAll:'; wrapped' |
13101 | 2006 |
]. |
176 | 2007 |
|
2008 |
" |
|
253 | 2009 |
(Object compiledMethodAt:#at:) printOn:Transcript. Transcript cr. |
2010 |
(Object compiledMethodAt:#at:) copy printOn:Transcript. Transcript cr. |
|
10083 | 2011 |
|
2012 |
(Object compiledMethodAt:#at:) whoString printOn:Transcript. Transcript cr. |
|
2013 |
(Object compiledMethodAt:#at:) copy whoString printOn:Transcript. Transcript cr. |
|
176 | 2014 |
" |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
2015 |
|
13101 | 2016 |
"Modified: / 22-10-2010 / 12:07:25 / cg" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2017 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2018 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2019 |
whoString |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2020 |
"return a string as className>>selector, if this is not an unbound |
20208 | 2021 |
method. |
19782 | 2022 |
Otherwise return 'unbound'. Used with debugging." |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2023 |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
2024 |
|who| |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2025 |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
2026 |
who := self who. |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
2027 |
who notNil ifTrue:[ |
19782 | 2028 |
"/ in order to not break existing code which parses those strings, |
20579 | 2029 |
"/ do not replace '>>' by ' ' |
19782 | 2030 |
^ who methodClass name , ' >> ' , (who methodSelector storeString) |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2031 |
]. |
6071 | 2032 |
^ 'unboundMethod' |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2033 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2034 |
" |
12854 | 2035 |
Method new whoString |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2036 |
(Method compiledMethodAt:#whoString) whoString |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2037 |
" |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
2038 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
2039 |
"Modified: 1.11.1996 / 16:27:04 / cg" |
21156 | 2040 |
! |
2041 |
||
2042 |
whoStringWith:sep |
|
2043 |
"return a string like className>>selector, |
|
2044 |
if this is not an unbound method. |
|
2045 |
Otherwise return 'unbound'. Used with debugging." |
|
2046 |
||
2047 |
|who| |
|
2048 |
||
2049 |
who := self who. |
|
2050 |
who notNil ifTrue:[ |
|
2051 |
^ who methodClass name , sep , (who methodSelector storeString) |
|
2052 |
]. |
|
2053 |
^ 'unboundMethod' |
|
2054 |
||
2055 |
" |
|
2056 |
Method new whoStringWith:' >> ' |
|
2057 |
(Method compiledMethodAt:#whoString) whoStringWith:' >> ' |
|
21246 | 2058 |
(Method compiledMethodAt:#whoString) whoStringWith:' ' |
21157 | 2059 |
(Method compiledMethodAt:#whoString) whoStringWith:' -> ' |
21156 | 2060 |
" |
1 | 2061 |
! ! |
2062 |
||
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2063 |
!Method methodsFor:'private'! |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2064 |
|
13422 | 2065 |
annotationAtIndex: index |
14253 | 2066 |
"return the annotation at given index. |
18411 | 2067 |
any raw annotation array (as generated by the compiler) |
2068 |
is lazily initialized from the 2-element format to real annotation instances here. |
|
2069 |
This is done to avoid the need for knowledge about annotation instances in the stc compiler." |
|
13422 | 2070 |
|
13662
7d7ae1e5f589
changed: #annotationAtIndex:
Claus Gittinger <cg@exept.de>
parents:
13660
diff
changeset
|
2071 |
| annotationOrArray annotation args | |
13683
1b6be902030b
comment/format in: #annotationAtIndex:
Claus Gittinger <cg@exept.de>
parents:
13679
diff
changeset
|
2072 |
|
13817 | 2073 |
annotations isNil ifTrue:[^nil]. |
18411 | 2074 |
|
13662
7d7ae1e5f589
changed: #annotationAtIndex:
Claus Gittinger <cg@exept.de>
parents:
13660
diff
changeset
|
2075 |
annotationOrArray := annotation := annotations at: index. |
7d7ae1e5f589
changed: #annotationAtIndex:
Claus Gittinger <cg@exept.de>
parents:
13660
diff
changeset
|
2076 |
annotationOrArray isArray ifTrue:[ |
20547 | 2077 |
args := annotationOrArray size == 2 |
2078 |
ifTrue:[annotationOrArray second] |
|
2079 |
ifFalse:[#()]. |
|
2080 |
args isArray ifFalse:[args := Array with: args]. |
|
2081 |
annotation := Annotation |
|
2082 |
method:self |
|
2083 |
key: annotationOrArray first |
|
2084 |
arguments: args. |
|
2085 |
annotation isUnknown ifFalse:[ |
|
2086 |
annotations isImmutable ifTrue:[ |
|
2087 |
annotations := annotations asMutableCollection |
|
2088 |
]. |
|
2089 |
annotations at: index put: annotation. |
|
13422 | 2090 |
"/ annotation annotatesMethod: self |
20547 | 2091 |
]. |
13422 | 2092 |
]. |
2093 |
^annotation |
|
2094 |
||
2095 |
"Created: / 02-07-2010 / 22:30:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2096 |
"Modified: / 11-07-2010 / 19:39:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13817 | 2097 |
"Modified: / 18-11-2011 / 14:46:27 / cg" |
14253 | 2098 |
"Modified (comment): / 26-07-2012 / 15:48:07 / cg" |
13422 | 2099 |
! |
2100 |
||
2101 |
annotationIndexOf: key |
|
14253 | 2102 |
"Returns the index of annotation with given key |
13422 | 2103 |
or nil if there is no such annotation" |
2104 |
||
13817 | 2105 |
annotations isNil ifTrue:[^nil]. |
2106 |
||
2107 |
annotations keysAndValuesDo: [:index :annotationOrArray| |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2108 |
annotationOrArray isArray |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2109 |
ifTrue: [annotationOrArray first == key ifTrue:[^index]] |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2110 |
ifFalse:[annotationOrArray key == key ifTrue:[^index]] |
13817 | 2111 |
]. |
13422 | 2112 |
^nil. |
2113 |
||
2114 |
"Created: / 19-05-2010 / 16:40:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2115 |
"Modified: / 11-07-2010 / 19:23:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14253 | 2116 |
"Modified (comment): / 26-07-2012 / 15:48:14 / cg" |
13422 | 2117 |
! |
2118 |
||
12695 | 2119 |
cacheSourceStream:aStream |
2120 |
"remember a (raw) source stream for later use" |
|
2121 |
||
2122 |
|lastStream| |
|
2123 |
||
2124 |
(package notNil and:[package ~= PackageId noProjectID]) ifTrue:[ |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2125 |
LastFileLock critical:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2126 |
lastStream := LastFileReference at:1. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2127 |
(lastStream notNil |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2128 |
and:[lastStream class ~~ SmallInteger |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2129 |
and:[lastStream isOpen]]) ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2130 |
lastStream close. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2131 |
]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2132 |
LastSourceFileName := package,'/',source. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2133 |
LastFileReference at:1 put:aStream. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2134 |
]. |
12695 | 2135 |
]. |
2136 |
! |
|
2137 |
||
13422 | 2138 |
getAnnotations |
2139 |
^annotations |
|
2140 |
||
2141 |
"Created: / 10-07-2010 / 21:55:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2142 |
"Modified: / 11-07-2010 / 19:30:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14253 | 2143 |
"Modified (format): / 26-07-2012 / 15:49:38 / cg" |
13422 | 2144 |
! |
2145 |
||
2146 |
getLookupObject |
|
2147 |
||
2148 |
^lookupObject |
|
2149 |
||
2150 |
"Created: / 10-07-2010 / 21:55:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2151 |
! |
|
2152 |
||
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2153 |
localSourceStream |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2154 |
"try to open a stream from a local source file, |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2155 |
searching in standard places." |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2156 |
|
20358
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2157 |
|dir fileName sourceBaseName aStream| |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2158 |
|
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2159 |
"/ Source may be absolute. If so, try it first without searching |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2160 |
"/ along package path. This should be much faster when running from |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2161 |
"/ build-directory (the usual case when developing) |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2162 |
(source includes: Filename separator) ifTrue:[ |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2163 |
aStream := source asFilename readStreamOrNil. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2164 |
aStream notNil ifTrue:[^ aStream]. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2165 |
sourceBaseName := source asFilename baseName. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2166 |
] ifFalse:[ |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2167 |
sourceBaseName := source. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2168 |
]. |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2169 |
|
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2170 |
package notNil ifTrue:[ |
20358
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2171 |
"/ |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2172 |
"/ old: look in 'source/<filename>' |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2173 |
"/ this is still kept in order to find user-private |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2174 |
"/ classes in her currentDirectory. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2175 |
"/ |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2176 |
fileName := Smalltalk getSourceFileName:(package copyReplaceAll:$: with:$/) , '/' , sourceBaseName. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2177 |
fileName notNil ifTrue:[ |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2178 |
aStream := fileName asFilename readStreamOrNil. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2179 |
aStream notNil ifTrue:[^ aStream]. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2180 |
]. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2181 |
"/ |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2182 |
"/ new: look in package-dir |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2183 |
"/ |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2184 |
dir := Smalltalk getPackageDirectoryForPackage:package. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2185 |
dir notNil ifTrue:[ |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2186 |
fileName := dir construct:sourceBaseName. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2187 |
aStream := fileName asFilename readStreamOrNil. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2188 |
aStream notNil ifTrue:[^ aStream]. |
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2189 |
]. |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2190 |
]. |
20358
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2191 |
fileName := Smalltalk getSourceFileName:sourceBaseName. |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2192 |
fileName notNil ifTrue:[ |
20358
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2193 |
aStream := fileName asFilename readStreamOrNil. |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2194 |
]. |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2195 |
^ aStream |
20358
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2196 |
|
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2197 |
"Modified: / 07-09-2016 / 09:20:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2198 |
! |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2199 |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2200 |
rawSourceStreamUsingCache:usingCache |
12682 | 2201 |
"return an open sourceStream (needs positioning). |
2202 |
If usingCacheBoolean is true, cache the stream (but take care against concurrent access). |
|
13390
3bee59036719
comment/format in: #rawSourceStreamUsingCache:
Stefan Vogel <sv@exept.de>
parents:
13381
diff
changeset
|
2203 |
You have to close the stream, if usingCacheBoolean is false, and should not close it |
12682 | 2204 |
if usingCacheBoolean is true." |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2205 |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2206 |
| sourceStream fileName | |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2207 |
|
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2208 |
" |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2209 |
if sourcePosition is nonNil, its the fileName and |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2210 |
abs(sourcePosition) is the offset. |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2211 |
Otherwise, source is the real source |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2212 |
" |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2213 |
source isNil ifTrue:[^ nil]. |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2214 |
sourcePosition isNil ifTrue:[^ source readStream]. |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2215 |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2216 |
usingCache ifTrue:[ |
20035 | 2217 |
(package notNil and:[package ~= PackageId noProjectID]) ifTrue:[ |
2218 |
"/ keep the last source file open, because open/close |
|
2219 |
"/ operations maybe slow on NFS-mounted file systems. |
|
2220 |
"/ Since the reference to the file is weak, it will be closed |
|
2221 |
"/ automatically if the file is not referenced for a while. |
|
2222 |
"/ Neat trick. |
|
2223 |
||
2224 |
LastFileLock critical:[ |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2225 |
sourceStream := LastFileReference at:1. |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2226 |
(sourceStream isNil |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2227 |
or:[sourceStream class == SmallInteger |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2228 |
or:[sourceStream isOpen not]]) ifTrue:[ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2229 |
sourceStream := nil. |
20035 | 2230 |
LastFileReference at:1 put:nil. |
2231 |
]. |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2232 |
(sourceStream notNil |
20035 | 2233 |
and:[LastSourceFileName ~= (package,'/',source)]) ifTrue:[ |
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2234 |
sourceStream := nil. |
20035 | 2235 |
]. |
2236 |
]. |
|
2237 |
||
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2238 |
sourceStream notNil ifTrue:[ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2239 |
^ sourceStream |
20035 | 2240 |
]. |
2241 |
]. |
|
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2242 |
]. |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2243 |
|
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2244 |
"/ a negative sourcePosition indicates |
12854 | 2245 |
"/ that this is a local file |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2246 |
"/ (not to be requested via the sourceCodeManager) |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2247 |
"/ This kludge was added, to allow sourceCode to be |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2248 |
"/ saved to a local source file (i.e. 'st.src') |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2249 |
"/ and having a clue for which file is meant later. |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2250 |
|
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2251 |
sourcePosition < 0 ifTrue:[ |
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2252 |
sourceStream := source asFilename readStreamOrNil. |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2253 |
sourceStream isNil ifTrue:[ |
20035 | 2254 |
"/ search in some standard places |
2255 |
fileName := Smalltalk getSourceFileName:source. |
|
2256 |
fileName notNil ifTrue:[ |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2257 |
sourceStream := fileName asFilename readStreamOrNil. |
20035 | 2258 |
]. |
2259 |
]. |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2260 |
sourceStream notNil ifTrue:[ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2261 |
usingCache ifTrue:[ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2262 |
self cacheSourceStream:sourceStream. |
20357
0eae8bf21a91
Method: don't try to figure out a source code manager for method when using local source
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20210
diff
changeset
|
2263 |
]. |
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2264 |
^ sourceStream |
20035 | 2265 |
]. |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2266 |
]. |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2267 |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2268 |
|
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2269 |
(mclass notNil and:[package == mclass package]) ifTrue: [ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2270 |
"/ If this is not an extension, ask class for source stream. |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2271 |
sourceStream := mclass sourceStream. |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2272 |
sourceStream notNil ifTrue:[ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2273 |
usingCache ifTrue:[ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2274 |
self cacheSourceStream:sourceStream. |
20035 | 2275 |
]. |
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2276 |
^ sourceStream |
20035 | 2277 |
]. |
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2278 |
] ifFalse: [ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2279 |
"/ If it is an extension, return local source. |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2280 |
"/ This one may have been invalid, but we have no chance to |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2281 |
"/ check this (no checksum) |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2282 |
sourceStream := self localSourceStream. |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2283 |
]. |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2284 |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2285 |
(sourceStream notNil and:[usingCache]) ifTrue:[ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2286 |
self cacheSourceStream:sourceStream. |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2287 |
]. |
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2288 |
^ sourceStream. |
10201 | 2289 |
|
2290 |
"Modified: / 26-11-2006 / 22:33:38 / cg" |
|
20358
310244bfc8b3
Allow for absolute filenames as method's and class source's files
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20357
diff
changeset
|
2291 |
"Modified: / 07-09-2016 / 08:53:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2292 |
"Modified: / 09-07-2020 / 22:28:05 / Jan Vrany <jan.vrany@labware.com>" |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2293 |
! |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2294 |
|
13422 | 2295 |
setLookupObject: lookup |
2296 |
"set the lookupObject (low level - use lookupObject:)" |
|
2297 |
||
14536 | 2298 |
lookupObject ~~ lookup ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2299 |
lookupObject := lookup. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2300 |
ObjectMemory flushCaches. |
14536 | 2301 |
]. |
13422 | 2302 |
|
2303 |
"Created: / 11-07-2010 / 19:31:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2304 |
! |
|
2305 |
||
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2306 |
sourceChunkFromStream:aStream |
10673
05229646ecd7
#source - handle DecodingError when fetching the method's source
Stefan Vogel <sv@exept.de>
parents:
10608
diff
changeset
|
2307 |
PositionError handle:[:ex | |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2308 |
^ nil |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2309 |
] do:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2310 |
aStream position:(sourcePosition ? 1) abs - 1. |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2311 |
]. |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2312 |
^ aStream nextChunk. |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2313 |
! |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2314 |
|
12682 | 2315 |
sourceStreamUsingCache:usingCacheBoolean |
2316 |
"return an open sourceStream (needs positioning). |
|
2317 |
If usingCacheBoolean is true, cache the stream (but take care against concurrent access). |
|
14090
bb45ad9b6aab
changed: #sourceStreamUsingCache:
Stefan Vogel <sv@exept.de>
parents:
14047
diff
changeset
|
2318 |
You have to close the stream, if usingCacheBoolean is false, and should not close it |
12682 | 2319 |
if usingCacheBoolean is true." |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2320 |
|
12695 | 2321 |
|rawStream| |
2322 |
||
2323 |
rawStream := self rawSourceStreamUsingCache:usingCacheBoolean. |
|
2324 |
rawStream isNil ifTrue:[ |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2325 |
^ nil. |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2326 |
]. |
14090
bb45ad9b6aab
changed: #sourceStreamUsingCache:
Stefan Vogel <sv@exept.de>
parents:
14047
diff
changeset
|
2327 |
rawStream position:0. |
12695 | 2328 |
|
2329 |
"/ see if its utf8 encoded... |
|
25398
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2330 |
rawStream isEncodedStream ifTrue:[ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2331 |
^ rawStream |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2332 |
] ifFalse: [ |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2333 |
^ EncodedStream decodedStreamFor:rawStream. |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2334 |
] |
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2335 |
|
b0d020199bd0
Refactor class- and method- source stream access
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
2336 |
"Modified: / 20-07-2020 / 15:31:49 / Jan Vrany <jan.vrany@labware.com>" |
8141
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2337 |
! ! |
41b25e5f7532
sourceStream access refactored (preps for utf8 decoding)
Claus Gittinger <cg@exept.de>
parents:
8117
diff
changeset
|
2338 |
|
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2339 |
!Method methodsFor:'private-compiler interface'! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2340 |
|
5405 | 2341 |
primitiveNumber |
2342 |
"for stx rel >= 5.x only: |
|
2343 |
return the primitive number." |
|
2344 |
||
2345 |
%{ /* NOCONTEXT */ |
|
2346 |
||
2347 |
#ifdef F_PRIMITIVE |
|
2348 |
INT f = __intVal(__INST(flags)); |
|
6014 | 2349 |
OBJ nr = 0; |
5405 | 2350 |
|
2351 |
if (f & F_PRIMITIVE) { |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2352 |
nr = __INST(code_); |
5405 | 2353 |
} |
2354 |
RETURN (nr); |
|
2355 |
#endif |
|
2356 |
%}. |
|
2357 |
self primitiveFailed |
|
2358 |
! |
|
2359 |
||
2360 |
setPrimitiveNumber:aNumber |
|
2361 |
"for stx rel >= 5.x only: |
|
2362 |
mark the method as having primitive code." |
|
2363 |
||
2364 |
%{ /* NOCONTEXT */ |
|
2365 |
||
2366 |
#ifdef F_PRIMITIVE |
|
2367 |
INT f = __intVal(__INST(flags)); |
|
2368 |
||
2369 |
f |= F_PRIMITIVE; |
|
8913 | 2370 |
__INST(flags) = __mkSmallInteger(f); |
5405 | 2371 |
__INST(code_) = aNumber; |
2372 |
RETURN (self); |
|
2373 |
#endif |
|
2374 |
%}. |
|
2375 |
self primitiveFailed |
|
2376 |
||
2377 |
||
2378 |
||
2379 |
! |
|
2380 |
||
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2381 |
setResourceFlag |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2382 |
"mark the method as having a <resource> definition in its |
8518
7dc3f9909640
Interchanged the meaning of method privacy -
Stefan Vogel <sv@exept.de>
parents:
8465
diff
changeset
|
2383 |
source. This flag can be used to find resource-flagged methods quicker." |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2384 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2385 |
%{ /* NOCONTEXT */ |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2386 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2387 |
#ifdef F_RESOURCE |
2868 | 2388 |
INT f = __intVal(__INST(flags)); |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2389 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2390 |
f |= F_RESOURCE; |
8913 | 2391 |
__INST(flags) = __mkSmallInteger(f); |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2392 |
#endif |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2393 |
%} |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2394 |
! ! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2395 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2396 |
!Method methodsFor:'queries'! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2397 |
|
2702 | 2398 |
accessedInstVars |
2399 |
"return a collection of instVarNames, which are accessed by |
|
2400 |
the receiver method" |
|
2401 |
||
2402 |
|src parser| |
|
2403 |
||
2404 |
src := self source. |
|
2405 |
src notNil ifTrue:[ |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2406 |
parser := Parser |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2407 |
parseMethod:src |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2408 |
in:self containingClass |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2409 |
ignoreErrors:true |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2410 |
ignoreWarnings:true. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2411 |
|
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2412 |
(parser notNil and:[parser ~~ #Error]) ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2413 |
^ parser usedInstVars |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2414 |
]. |
2702 | 2415 |
]. |
2416 |
^ #() "/ actually: unknown |
|
2417 |
||
2418 |
"Modified: 19.6.1997 / 17:54:09 / cg" |
|
2419 |
! |
|
2420 |
||
14237 | 2421 |
accessesField:instVarIndex |
2422 |
"return true, if the instvar at instVarIndex is accessed by the receiver. |
|
2423 |
Uses parser (for now); could look at bytecode as well here..." |
|
2424 |
||
2425 |
|instVarName| |
|
2426 |
||
2427 |
instVarName := (self mclass allInstVarNames) at:instVarIndex. |
|
2428 |
^ self accessesInstVar:instVarName |
|
2429 |
||
2430 |
"Created: / 23-07-2012 / 11:13:54 / cg" |
|
2431 |
! |
|
2432 |
||
2433 |
accessesInstVar:instVarName |
|
2434 |
"return true, if the named instvar is accessed by the receiver. |
|
2435 |
Uses parser (for now); could look at bytecode as well here..." |
|
2436 |
||
2437 |
|usedInstVars| |
|
2438 |
||
2439 |
(self source includesString:instVarName) ifFalse:[^ false]. "/ that's much faster than parsing... |
|
2440 |
usedInstVars := self parse:#'parseMethodSilent:in:' with:self mclass return:#usedInstVars or:#(). |
|
2441 |
^ usedInstVars includes:instVarName. |
|
2442 |
||
2443 |
"Created: / 23-07-2012 / 11:15:02 / cg" |
|
2444 |
! |
|
2445 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2446 |
containingClass |
12854 | 2447 |
"return the class I am defined in. |
17278 | 2448 |
Notice, that the containingClass query returns nil, if a method is wrapped or no longer valid |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2449 |
due to an accept in a browser or debugger. |
17278 | 2450 |
However, the mclass slot still contains a reference to the once valid class and can be fetched |
2451 |
via getMclass. |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2452 |
See comment in who." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2453 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2454 |
"based on who, which has been added for ST-80 compatibility" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2455 |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
2456 |
|who| |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2457 |
|
5704
aeeece3a93ef
flush mclass, if no longer valid
Claus Gittinger <cg@exept.de>
parents:
5700
diff
changeset
|
2458 |
mclass notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2459 |
"/ check if this (cached) info is still valid... |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2460 |
(mclass containsMethod:self) ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2461 |
^ mclass |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2462 |
]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2463 |
^ nil. |
5704
aeeece3a93ef
flush mclass, if no longer valid
Claus Gittinger <cg@exept.de>
parents:
5700
diff
changeset
|
2464 |
]. |
5324 | 2465 |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
2466 |
who := self who. |
17254 | 2467 |
who notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2468 |
mclass := who methodClass. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2469 |
^ mclass |
17254 | 2470 |
]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2471 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2472 |
none found - sorry |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2473 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2474 |
^ nil |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2475 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2476 |
" |
12854 | 2477 |
(Object compiledMethodAt:#at:) containingClass |
2478 |
||
2479 |
(Object class compiledMethodAt:#version) containingClass |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2480 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2481 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2482 |
|
10482 | 2483 |
externalLibraryFunction |
2484 |
"if this is an externalLibraryFunction call, return the externalLibraryFunction. |
|
2485 |
Returns nil otherwise." |
|
2486 |
||
13189
96fe3d9e3f3a
changed: #externalLibraryFunction
Claus Gittinger <cg@exept.de>
parents:
13156
diff
changeset
|
2487 |
|newMethod function| |
96fe3d9e3f3a
changed: #externalLibraryFunction
Claus Gittinger <cg@exept.de>
parents:
13156
diff
changeset
|
2488 |
|
13463 | 2489 |
(self |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2490 |
literalsDetect:[:lit | |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2491 |
#( |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2492 |
#'invoke' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2493 |
#'invokeWith:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2494 |
#'invokeWith:with:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2495 |
#'invokeWith:with:with:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2496 |
#'invokeWith:with:with:with:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2497 |
#'invokeWithArguments:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2498 |
#'invokeCPPVirtualOn:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2499 |
#'invokeCPPVirtualOn:with:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2500 |
#'invokeCPPVirtualOn:with:with:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2501 |
#'invokeCPPVirtualOn:with:with:with:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2502 |
#'invokeCPPVirtualOn:with:with:with:with:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2503 |
#'invokeCPPVirtualOn:withArguments:' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2504 |
) includes:lit |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2505 |
] |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2506 |
ifNone:nil) notNil |
13189
96fe3d9e3f3a
changed: #externalLibraryFunction
Claus Gittinger <cg@exept.de>
parents:
13156
diff
changeset
|
2507 |
ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2508 |
"/ sigh - for stc-compiled code, this does not work: |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2509 |
function := self literalsDetect:[:lit | lit isExternalLibraryFunction] ifNone:nil. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2510 |
function isNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2511 |
"/ parse it and ask the parser |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2512 |
newMethod := Compiler compile:self source forClass:self mclass install:false. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2513 |
function := newMethod literalsDetect:[:lit | lit isExternalLibraryFunction] ifNone:nil. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2514 |
]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2515 |
^ function |
13189
96fe3d9e3f3a
changed: #externalLibraryFunction
Claus Gittinger <cg@exept.de>
parents:
13156
diff
changeset
|
2516 |
]. |
96fe3d9e3f3a
changed: #externalLibraryFunction
Claus Gittinger <cg@exept.de>
parents:
13156
diff
changeset
|
2517 |
^ nil |
96fe3d9e3f3a
changed: #externalLibraryFunction
Claus Gittinger <cg@exept.de>
parents:
13156
diff
changeset
|
2518 |
|
96fe3d9e3f3a
changed: #externalLibraryFunction
Claus Gittinger <cg@exept.de>
parents:
13156
diff
changeset
|
2519 |
" |
96fe3d9e3f3a
changed: #externalLibraryFunction
Claus Gittinger <cg@exept.de>
parents:
13156
diff
changeset
|
2520 |
(IDispatchPointer compiledMethodAt:#'invokeGetTypeInfo:_:_:') |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2521 |
externalLibraryFunction |
13189
96fe3d9e3f3a
changed: #externalLibraryFunction
Claus Gittinger <cg@exept.de>
parents:
13156
diff
changeset
|
2522 |
" |
10482 | 2523 |
! |
2524 |
||
13422 | 2525 |
hasAnnotation |
14253 | 2526 |
"Return true iff the method has any annotation" |
13422 | 2527 |
|
2528 |
^annotations notNil |
|
2529 |
||
2530 |
"Created: / 11-07-2010 / 19:27:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14253 | 2531 |
"Modified (comment): / 26-07-2012 / 15:49:59 / cg" |
13422 | 2532 |
! |
2533 |
||
2534 |
hasAnnotation: key |
|
14253 | 2535 |
"Return true iff the method is annotated with the given key" |
13422 | 2536 |
|
17463 | 2537 |
annotations isNil ifTrue:[^ false]. |
2538 |
^ (self annotationIndexOf: key) notNil |
|
13422 | 2539 |
|
2540 |
"Created: / 11-07-2010 / 19:28:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14253 | 2541 |
"Modified (comment): / 26-07-2012 / 15:49:54 / cg" |
13422 | 2542 |
! |
2543 |
||
12913 | 2544 |
hasAnyResource:aCollectionOfSymbols |
2545 |
"return true if the method has a <resource> definition for any symbol in aCollectionOfSymbols" |
|
2546 |
||
2547 |
^ self hasResource and:[ self resources keys includesAny:aCollectionOfSymbols ] |
|
2548 |
||
2549 |
" |
|
2550 |
Method allInstancesDo:[:m | |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2551 |
(m hasAnyResource:#(image canvas)) ifTrue:[self halt] |
12913 | 2552 |
]. |
2553 |
" |
|
2554 |
! |
|
2555 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2556 |
hasPrimitiveCode |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2557 |
"return true, if the method contains primitive code; false if not. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2558 |
Uses Parser to parse methods source and get the information." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2559 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2560 |
|src| |
159 | 2561 |
|
2218 | 2562 |
"/ first a trivial reject, if the source does not |
5534 | 2563 |
"/ contain a '% {' sequence |
2218 | 2564 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2565 |
src := self source. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2566 |
src notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2567 |
(src includesString:(String with:$% with:${) "<- no constant here - to avoid trouble with stupid scanners" ) ifFalse:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2568 |
"/ cannot contain primitive code. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2569 |
^ false |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2570 |
] |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2571 |
]. |
2218 | 2572 |
|
2573 |
"/ ok; it may or may not ... |
|
2574 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2575 |
^ self parse:#'parseMethodSilent:' return:#hasPrimitiveCode or:false |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2576 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2577 |
" |
12854 | 2578 |
(Method compiledMethodAt:#hasPrimitiveCode) hasPrimitiveCode |
2579 |
(Object compiledMethodAt:#at:) hasPrimitiveCode |
|
2580 |
(Object compiledMethodAt:#basicAt:) hasPrimitiveCode |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2581 |
" |
159 | 2582 |
|
2218 | 2583 |
"Modified: 22.1.1997 / 00:03:45 / cg" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2584 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2585 |
|
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2586 |
hasResource |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2587 |
"return true if the method had a <resource> definition in its |
8518
7dc3f9909640
Interchanged the meaning of method privacy -
Stefan Vogel <sv@exept.de>
parents:
8465
diff
changeset
|
2588 |
source. This flag can be used to find resource-flagged methods quicker." |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2589 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2590 |
%{ /* NOCONTEXT */ |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2591 |
|
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2592 |
#ifdef F_RESOURCE |
1133 | 2593 |
RETURN (((INT)__INST(flags) & __MASKSMALLINT(F_RESOURCE)) ? true : false); |
1093
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2594 |
#endif |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2595 |
%}. |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2596 |
^ false |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2597 |
! |
1e742016eea0
category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents:
1087
diff
changeset
|
2598 |
|
10482 | 2599 |
indexOfOLECall |
14357
08d5b662477a
comment/format in: #indexOfOLECall
Claus Gittinger <cg@exept.de>
parents:
14274
diff
changeset
|
2600 |
"return the vtable inedx, if the method contains an ole call; nil if not. |
10482 | 2601 |
Uses Parser to parse methods source and get the information." |
2602 |
||
2603 |
|funcOrNil| |
|
2604 |
||
2605 |
funcOrNil := self externalLibraryFunction. |
|
2606 |
(funcOrNil isNil or:[funcOrNil isCallTypeOLE not]) ifTrue:[^ nil]. |
|
2607 |
^ funcOrNil vtableIndex |
|
2608 |
||
2609 |
" |
|
12854 | 2610 |
(Method compiledMethodAt:#hasPrimitiveCode) isOLECall |
2611 |
(Method compiledMethodAt:#hasPrimitiveCode) indexOfOLECall |
|
2612 |
||
2613 |
(Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) isOLECall |
|
2614 |
(Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) indexOfOLECall |
|
2615 |
(Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) isExternalLibraryFunctionCall |
|
2616 |
(Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) externalLibraryFunctionCall |
|
2617 |
||
2618 |
(IUnknownPointer compiledMethodAt:#invokeAddRef) isExternalLibraryFunctionCall |
|
2619 |
(IUnknownPointer compiledMethodAt:#invokeAddRef) externalLibraryFunction |
|
2620 |
(IUnknownPointer compiledMethodAt:#invokeAddRef) isOLECall |
|
2621 |
(IUnknownPointer compiledMethodAt:#invokeAddRef) indexOfOLECall |
|
10482 | 2622 |
" |
14357
08d5b662477a
comment/format in: #indexOfOLECall
Claus Gittinger <cg@exept.de>
parents:
14274
diff
changeset
|
2623 |
|
08d5b662477a
comment/format in: #indexOfOLECall
Claus Gittinger <cg@exept.de>
parents:
14274
diff
changeset
|
2624 |
"Modified (comment): / 25-09-2012 / 12:01:32 / cg" |
10482 | 2625 |
! |
2626 |
||
11986 | 2627 |
isDocumentationMethod |
11987 | 2628 |
"Return true, if this is a documentation only (only a comment) method |
2629 |
(implies being a metaclass method)" |
|
11986 | 2630 |
|
12275
8ca2aabefa4e
changed: #isDocumentationMethod
Claus Gittinger <cg@exept.de>
parents:
12216
diff
changeset
|
2631 |
self mclass isMeta ifFalse:[^ false]. |
12283
54b6f67bcc26
changed: #isDocumentationMethod
Claus Gittinger <cg@exept.de>
parents:
12275
diff
changeset
|
2632 |
self isVersionMethod ifTrue:[^ false]. |
12159 | 2633 |
^ self parse:#'parseMethodSilent:' return:#isEmptyMethod or:false. |
11986 | 2634 |
! |
2635 |
||
13639 | 2636 |
isExtension |
2637 |
"return true, if this method is an extension (i.e. package ~= classes' package)" |
|
2638 |
||
2639 |
^ package ~= self mclass package |
|
2640 |
||
2641 |
"Created: / 07-09-2011 / 09:29:13 / cg" |
|
2642 |
! |
|
2643 |
||
10482 | 2644 |
isExternalLibraryFunctionCall |
2645 |
"Return true, if this is an externalLibraryFunction call." |
|
2646 |
||
12569
b97efbbc1ac7
comment/format in: #isExternalLibraryFunctionCall
Claus Gittinger <cg@exept.de>
parents:
12546
diff
changeset
|
2647 |
"/ sigh - for now, stc-compiled code does not have it in the literal array |
b97efbbc1ac7
comment/format in: #isExternalLibraryFunctionCall
Claus Gittinger <cg@exept.de>
parents:
12546
diff
changeset
|
2648 |
"/ to be fixed... |
b97efbbc1ac7
comment/format in: #isExternalLibraryFunctionCall
Claus Gittinger <cg@exept.de>
parents:
12546
diff
changeset
|
2649 |
|
10482 | 2650 |
^ self externalLibraryFunction notNil |
2651 |
! |
|
2652 |
||
20683 | 2653 |
isForCompatibility |
2654 |
"returns true, if this method only used for compatibility |
|
2655 |
and should use only when porting foreign code but not otherwise" |
|
2656 |
||
2657 |
|res| |
|
2658 |
||
2659 |
^ self package == #'stx:libcompat' |
|
2660 |
or:[(res := self resources) notNil and:[res includesKey:#compatibility]] |
|
2661 |
! |
|
2662 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2663 |
isInvalid |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2664 |
"return true, if this method is not executable due to |
1194
628abcb5fbb6
moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents:
1190
diff
changeset
|
2665 |
a (re)-compilation error. Since invalidation is by patching the |
17452 | 2666 |
method's code-pointer to a trap function, check for that here. |
1194
628abcb5fbb6
moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents:
1190
diff
changeset
|
2667 |
(see comment in Method>>invalidCodeObject)." |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2668 |
|
2558 | 2669 |
|m myCode| |
1873 | 2670 |
|
2671 |
myCode := self code. |
|
2672 |
||
18438 | 2673 |
m := self trapMethodForNumArgs:(self argumentCount). |
1873 | 2674 |
(m notNil and:[self ~~ m]) ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2675 |
(myCode notNil and:[myCode = m code]) ifTrue:[^ true]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2676 |
(byteCode notNil and:[byteCode == m byteCode]) ifTrue:[^ true]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2677 |
]. |
159 | 2678 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2679 |
m := Method compiledMethodAt:#uncompiledCodeObject. |
1873 | 2680 |
(m notNil and:[self ~~ m]) ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2681 |
(myCode notNil and:[myCode = m code]) ifTrue:[^ true]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2682 |
(byteCode notNil and:[byteCode == m byteCode]) ifTrue:[^ true]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2683 |
]. |
1873 | 2684 |
|
2685 |
m := Method compiledMethodAt:#unloadedCodeObject. |
|
2686 |
(m notNil and:[self ~~ m]) ifTrue:[ |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2687 |
(myCode notNil and:[myCode = m code]) ifTrue:[^ true]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2688 |
(byteCode notNil and:[byteCode == m byteCode]) ifTrue:[^ true]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2689 |
]. |
1873 | 2690 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2691 |
^ false |
1194
628abcb5fbb6
moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents:
1190
diff
changeset
|
2692 |
|
1873 | 2693 |
"Modified: 4.11.1996 / 23:34:24 / cg" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2694 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2695 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2696 |
isMethod |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2697 |
"return true, if the receiver is some kind of method; |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2698 |
true returned here - the method is redefined from Object." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2699 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2700 |
^ true |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2701 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2702 |
|
14274
cee19bad32a0
added: #isMethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14266
diff
changeset
|
2703 |
isMethodWithBreakpoints |
cee19bad32a0
added: #isMethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14266
diff
changeset
|
2704 |
"only redefined in MethodWithBreakpoints" |
cee19bad32a0
added: #isMethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14266
diff
changeset
|
2705 |
|
cee19bad32a0
added: #isMethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14266
diff
changeset
|
2706 |
^ false |
cee19bad32a0
added: #isMethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14266
diff
changeset
|
2707 |
|
cee19bad32a0
added: #isMethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14266
diff
changeset
|
2708 |
"Created: / 01-08-2012 / 17:26:43 / cg" |
cee19bad32a0
added: #isMethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14266
diff
changeset
|
2709 |
! |
cee19bad32a0
added: #isMethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14266
diff
changeset
|
2710 |
|
10482 | 2711 |
isOLECall |
2712 |
"return true, if the method is an ole call; false if not." |
|
2713 |
||
2714 |
|funcOrNil| |
|
2715 |
||
2716 |
funcOrNil := self externalLibraryFunction. |
|
2717 |
^ funcOrNil notNil and:[funcOrNil isCallTypeOLE] |
|
2718 |
! |
|
2719 |
||
5894
ed6193fa6040
Define #isObsolete and fix various comments
Stefan Vogel <sv@exept.de>
parents:
5818
diff
changeset
|
2720 |
isObsolete |
ed6193fa6040
Define #isObsolete and fix various comments
Stefan Vogel <sv@exept.de>
parents:
5818
diff
changeset
|
2721 |
"returns true, if this method is obsolete and should not be used any longer" |
ed6193fa6040
Define #isObsolete and fix various comments
Stefan Vogel <sv@exept.de>
parents:
5818
diff
changeset
|
2722 |
|
ed6193fa6040
Define #isObsolete and fix various comments
Stefan Vogel <sv@exept.de>
parents:
5818
diff
changeset
|
2723 |
|res| |
ed6193fa6040
Define #isObsolete and fix various comments
Stefan Vogel <sv@exept.de>
parents:
5818
diff
changeset
|
2724 |
|
ed6193fa6040
Define #isObsolete and fix various comments
Stefan Vogel <sv@exept.de>
parents:
5818
diff
changeset
|
2725 |
^ (res := self resources) notNil and:[res includesKey:#obsolete] |
ed6193fa6040
Define #isObsolete and fix various comments
Stefan Vogel <sv@exept.de>
parents:
5818
diff
changeset
|
2726 |
! |
ed6193fa6040
Define #isObsolete and fix various comments
Stefan Vogel <sv@exept.de>
parents:
5818
diff
changeset
|
2727 |
|
15079 | 2728 |
isShadowingExtension |
2729 |
"return true, if this method is an extension (i.e. package ~= classes' package) |
|
2730 |
which shadows an existing method from another package (i.e. a package conflict)" |
|
2731 |
||
16877
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
2732 |
^ self shadowedMethod notNil. |
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
2733 |
|
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
2734 |
"Modified: / 03-10-2014 / 15:16:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
15079 | 2735 |
! |
2736 |
||
22909 | 2737 |
isSubclassResponsibility |
2738 |
^ self |
|
2739 |
sendsAnySelector:#( |
|
2740 |
#subclassResponsibility #subclassResponsibility: |
|
2741 |
#implementedBySubclass "/ ST/V code uses this |
|
2742 |
). |
|
2743 |
||
2744 |
"Created: / 16-07-2017 / 11:25:54 / cg" |
|
2745 |
! |
|
2746 |
||
13422 | 2747 |
isSynthetic |
13638 | 2748 |
"a syntheric method does not really exist - it is only shown in a browser's list" |
2749 |
||
2750 |
^ false |
|
2751 |
||
2752 |
"Modified (format): / 07-09-2011 / 09:00:56 / cg" |
|
13422 | 2753 |
! |
2754 |
||
11985 | 2755 |
isVersionMethod |
12017
908685b92c3e
comment/format in: #isVersionMethod
Claus Gittinger <cg@exept.de>
parents:
12016
diff
changeset
|
2756 |
"Return true, if this is a CVS, SVN or other version method. |
908685b92c3e
comment/format in: #isVersionMethod
Claus Gittinger <cg@exept.de>
parents:
12016
diff
changeset
|
2757 |
Stupid: need to know all of them here; better add a pragma or |
908685b92c3e
comment/format in: #isVersionMethod
Claus Gittinger <cg@exept.de>
parents:
12016
diff
changeset
|
2758 |
method attribute for that..." |
11985 | 2759 |
|
12016 | 2760 |
^ self mclass isMeta |
12165 | 2761 |
and:[(AbstractSourceCodeManager isVersionMethodSelector:self selector)] |
11985 | 2762 |
|
2763 |
" |
|
12854 | 2764 |
(Method class compiledMethodAt:#version) isVersionMethod |
11985 | 2765 |
(Method class compiledMethodAt:#documentation) isVersionMethod |
2766 |
" |
|
2767 |
! |
|
2768 |
||
11848 | 2769 |
isVisualWorksTypedef |
2770 |
"Return true, if this is a type-returning method (a visualWorks typedef)" |
|
2771 |
||
2772 |
^ (self literals size > 0) |
|
2773 |
and:[ (self literalAt:1) isKindOf:CType ] |
|
2774 |
! |
|
2775 |
||
2695
79229a9ab2da
added #mclass for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
2776 |
mclass |
17278 | 2777 |
"return the class in which the receiver is currently contained in. |
2778 |
Notice, that the mclass query returns nil, if a method is wrapped or no longer valid |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2779 |
due to an accept in a browser or debugger. |
17278 | 2780 |
However, the mclass slot still contains a reference to the once valid class and can be fetched |
2781 |
via getMclass. |
|
2695
79229a9ab2da
added #mclass for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
2782 |
Same as #containingClass, for ST80 compatibility." |
79229a9ab2da
added #mclass for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
2783 |
|
79229a9ab2da
added #mclass for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
2784 |
^ self containingClass |
79229a9ab2da
added #mclass for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
2785 |
|
79229a9ab2da
added #mclass for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
2786 |
"Created: 19.6.1997 / 16:26:13 / cg" |
79229a9ab2da
added #mclass for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
2787 |
! |
79229a9ab2da
added #mclass for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2694
diff
changeset
|
2788 |
|
5696 | 2789 |
messages |
2790 |
"return a collection of message-selectors, sent by this method." |
|
2791 |
||
2792 |
^ self messagesSent |
|
2793 |
! |
|
2794 |
||
5584
b175797a8c4d
#messagesDo: (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
5582
diff
changeset
|
2795 |
messagesDo:aBlock |
b175797a8c4d
#messagesDo: (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
5582
diff
changeset
|
2796 |
"evaluate aBlock for each message-selector sent by this method. |
b175797a8c4d
#messagesDo: (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
5582
diff
changeset
|
2797 |
Uses Parser to parse methods source and extract the names." |
b175797a8c4d
#messagesDo: (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
5582
diff
changeset
|
2798 |
|
b175797a8c4d
#messagesDo: (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
5582
diff
changeset
|
2799 |
^ self messagesSent do:aBlock |
b175797a8c4d
#messagesDo: (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
5582
diff
changeset
|
2800 |
! |
b175797a8c4d
#messagesDo: (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
5582
diff
changeset
|
2801 |
|
14402 | 2802 |
messagesPossiblySent |
2803 |
"return a collection with the message selectors possibly sent to by the receiver. |
|
2804 |
Uses Parser to parse methods source and extract the names. |
|
2805 |
The returned collection includes perform-like and possibly performed messages" |
|
2806 |
||
2807 |
^ self parse:#'parseMethodSilent:in:' with:self mclass return:#messagesPossiblySent or:#() |
|
2808 |
||
2809 |
" |
|
2810 |
(Method compiledMethodAt:#printOn:) messagesSent |
|
2811 |
(Point compiledMethodAt:#x:) messagesSent |
|
17173 | 2812 |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2813 |
(WindowEvent class compiledMethodAt:#focusInView:) messagesSent |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2814 |
(WindowEvent class compiledMethodAt:#focusInView:) messagesPossiblySent |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2815 |
|
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2816 |
(Method compiledMethodAt:#messagesPossiblySent) messagesSent |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2817 |
(Method compiledMethodAt:#messagesPossiblySent) messagesPossiblySent |
14402 | 2818 |
" |
2819 |
! |
|
2820 |
||
5582 | 2821 |
messagesSent |
2822 |
"return a collection with the message selectors sent to by the receiver. |
|
2823 |
Uses Parser to parse methods source and extract the names. |
|
2824 |
The returned collection includes all used message selectors (i.e. including super-send messages)" |
|
2825 |
||
12854 | 2826 |
^ self parse:#'parseMethodSilent:in:' with:self mclass return:#messagesSent or:#() |
5582 | 2827 |
|
2828 |
" |
|
12854 | 2829 |
(Method compiledMethodAt:#printOn:) messagesSent |
2830 |
(Point compiledMethodAt:#x:) messagesSent |
|
5582 | 2831 |
" |
2832 |
! |
|
2833 |
||
2834 |
messagesSentToSelf |
|
2835 |
"return a collection with the message selectors sent to self by the receiver. |
|
2836 |
Uses Parser to parse methods source and extract the names." |
|
2837 |
||
12854 | 2838 |
^ self parse:#'parseMethodSilent:in:' with:self mclass return:#messagesSentToSelf or:#() |
5652 | 2839 |
|
5582 | 2840 |
! |
2841 |
||
2842 |
messagesSentToSuper |
|
2843 |
"return a collection with the message selectors sent to super by the receiver. |
|
2844 |
Uses Parser to parse methods source and extract the names." |
|
2845 |
||
12854 | 2846 |
^ self parse:#'parseMethodSilent:in:' with:self mclass return:#messagesSentToSuper or:#() |
5652 | 2847 |
|
5582 | 2848 |
! |
2849 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2850 |
methodArgAndVarNames |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2851 |
"return a collection with the methods argument and variable names. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2852 |
Uses Parser to parse methods source and extract the names. |
15787 | 2853 |
Returns an empty collection if the source is not available, or some other |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2854 |
syntax/parse error occurred. |
15787 | 2855 |
For methods with no args and no vars, an empty collection is returned." |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2856 |
|
8427 | 2857 |
|parserClass parser sourceString argNames varNames| |
2858 |
||
2859 |
parserClass := self parserClass. |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2860 |
sourceString := self source. |
8427 | 2861 |
(parserClass notNil and:[sourceString notNil]) ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2862 |
parser := parserClass parseMethodArgAndVarSpecificationSilent:sourceString. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2863 |
(parser isNil or:[parser == #Error]) ifTrue:[^ #()]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2864 |
argNames := parser methodArgs. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2865 |
varNames := parser methodVars. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2866 |
argNames isNil ifTrue:[^ varNames ? #()]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2867 |
varNames isNil ifTrue:[^ argNames ? #()]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2868 |
^ (argNames , varNames) |
159 | 2869 |
]. |
15787 | 2870 |
^ #() |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2871 |
|
159 | 2872 |
" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2873 |
(Method compiledMethodAt:#printOn:) methodArgAndVarNames |
159 | 2874 |
" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2875 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2876 |
|
15649 | 2877 |
methodArgAndVarNamesInContext: context |
15727 | 2878 |
"return a collection with the method's argument and variable names. |
15649 | 2879 |
Uses Parser to parse methods source and extract the names. |
2880 |
Returns nil if the source is not available, or some other |
|
2881 |
syntax/parse error occurred. For methods with no args and no vars, |
|
2882 |
an empty collection is returned." |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2883 |
|
15649 | 2884 |
^self methodArgAndVarNames |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2885 |
|
15649 | 2886 |
"Created: / 18-12-2012 / 18:17:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2887 |
! |
|
2888 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2889 |
methodArgNames |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2890 |
"return a collection with the methods argument names. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2891 |
Uses Parser to parse methods source and extract the names." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2892 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2893 |
^ self parse:#'parseMethodSpecificationSilent:' return:#methodArgs or:nil |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2894 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2895 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2896 |
(Method compiledMethodAt:#printOn:) methodArgNames |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2897 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2898 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2899 |
"Modified: 31.10.1995 / 14:36:46 / cg" |
872 | 2900 |
! |
2901 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2902 |
methodComment |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2903 |
"return the methods first comment, nil if there is none. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2904 |
This is a somewhat stupid implementation." |
872 | 2905 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2906 |
|text line nQuote index qIndex qIndex2 comment| |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2907 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2908 |
text := self source asCollectionOfLines. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2909 |
(text size < 2) ifTrue:[^nil]. |
872 | 2910 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2911 |
line := (text at:2). |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2912 |
nQuote := line occurrencesOf:(Character doubleQuote). |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2913 |
(nQuote == 2) ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2914 |
qIndex := line indexOf:(Character doubleQuote). |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2915 |
qIndex2 := line indexOf:(Character doubleQuote) startingAt:(qIndex + 1). |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2916 |
^ line copyFrom:(qIndex + 1) to:(qIndex2 - 1) |
872 | 2917 |
]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2918 |
(nQuote == 1) ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2919 |
qIndex := line indexOf:(Character doubleQuote). |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2920 |
comment := line copyFrom:(qIndex + 1). |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2921 |
(line indexOf:$/ startingAt:qIndex) == (qIndex+1) ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2922 |
"/ an EOL comment |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2923 |
^ (comment copyFrom:2) withoutSeparators |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2924 |
]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2925 |
|
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2926 |
"/ not an EOL comment |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2927 |
index := 3. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2928 |
line := text at:index. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2929 |
nQuote := line occurrencesOf:(Character doubleQuote). |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2930 |
[nQuote ~~ 1] whileTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2931 |
comment := comment , Character cr asString , line withoutSpaces. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2932 |
index := index + 1. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2933 |
line := text at:index. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2934 |
nQuote := line occurrencesOf:(Character doubleQuote) |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2935 |
]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2936 |
qIndex := line indexOf:(Character doubleQuote). |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2937 |
^ comment , Character cr asString , (line copyTo:(qIndex - 1)) withoutSpaces |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2938 |
]. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2939 |
^ nil |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2940 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2941 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2942 |
(Method compiledMethodAt:#methodComment) methodComment |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2943 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2944 |
! |
872 | 2945 |
|
9364 | 2946 |
methodDefinitionTemplate |
2947 |
"return the string that defines the method and the arguments" |
|
2948 |
||
16261 | 2949 |
^ self class |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2950 |
methodDefinitionTemplateForSelector:self selector |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
2951 |
andArgumentNames:self methodArgNames |
9364 | 2952 |
|
2953 |
" |
|
2954 |
(self compiledMethodAt:#printOn:) methodDefinitionTemplate |
|
2955 |
" |
|
2956 |
! |
|
2957 |
||
12900
4cda19285039
category of: #methodInvocationInfo
Claus Gittinger <cg@exept.de>
parents:
12899
diff
changeset
|
2958 |
methodInvocationInfo |
13567
fe6564553977
comment: #methodInvocationInfo
Claus Gittinger <cg@exept.de>
parents:
13463
diff
changeset
|
2959 |
"redefined by InstrumentedMethod, to return the collected info" |
fe6564553977
comment: #methodInvocationInfo
Claus Gittinger <cg@exept.de>
parents:
13463
diff
changeset
|
2960 |
|
12900
4cda19285039
category of: #methodInvocationInfo
Claus Gittinger <cg@exept.de>
parents:
12899
diff
changeset
|
2961 |
^ nil |
4cda19285039
category of: #methodInvocationInfo
Claus Gittinger <cg@exept.de>
parents:
12899
diff
changeset
|
2962 |
|
4cda19285039
category of: #methodInvocationInfo
Claus Gittinger <cg@exept.de>
parents:
12899
diff
changeset
|
2963 |
"Created: / 27-04-2010 / 13:36:12 / cg" |
4cda19285039
category of: #methodInvocationInfo
Claus Gittinger <cg@exept.de>
parents:
12899
diff
changeset
|
2964 |
! |
4cda19285039
category of: #methodInvocationInfo
Claus Gittinger <cg@exept.de>
parents:
12899
diff
changeset
|
2965 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2966 |
methodVarNames |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2967 |
"return a collection with the methods local-variable names. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2968 |
Uses Parser to parse methods source and extract the names." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2969 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2970 |
^ self parse:#'parseMethodArgAndVarSpecificationSilent:' return:#methodVars or:nil |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2971 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2972 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2973 |
(Method compiledMethodAt:#printOn:) methodVarNames |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2974 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2975 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2976 |
"Modified: 31.10.1995 / 14:36:49 / cg" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2977 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2978 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2979 |
modificationTime |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2980 |
"try to extract the modificationTime as a timeStamp from |
19449 | 2981 |
the receiver's source. If there is no source or no history line, |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2982 |
we do not know the modification time, and nil is returned." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2983 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2984 |
|s list histLine| |
877
63ebb325ed20
flush global-access cache (using snapshotID) when saving a methods binary code
Claus Gittinger <cg@exept.de>
parents:
872
diff
changeset
|
2985 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2986 |
HistoryManager isNil ifTrue:[^ nil]. |
1873 | 2987 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2988 |
s := self source. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2989 |
s isNil ifTrue:[^ nil]. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2990 |
list := HistoryManager getAllHistoriesFrom:s. |
16261 | 2991 |
list isEmptyOrNil ifTrue:[^ nil]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2992 |
histLine := list last. |
12854 | 2993 |
^ Timestamp |
19449 | 2994 |
fromDate:histLine date |
2995 |
andTime:histLine time |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2996 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2997 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
2998 |
(Method compiledMethodAt:#modificationTime) modificationTime |
12854 | 2999 |
(Method compiledMethodAt:#isMethod) modificationTime |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3000 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3001 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3002 |
"Modified: 8.9.1995 / 15:08:22 / claus" |
1873 | 3003 |
"Modified: 4.11.1996 / 22:28:17 / cg" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3004 |
! |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3005 |
|
15424 | 3006 |
modifiedInstVars |
3007 |
"returns a collection of instance variables which are modified by this method. |
|
3008 |
Uses parser (for now); could look at bytecode as well here..." |
|
3009 |
||
3010 |
^ self parse:#'parseMethodSilent:in:' with:self mclass return:#modifiedInstVars or:#(). |
|
3011 |
! |
|
3012 |
||
3845
729fda604d59
added #name (for javaMethod compatibility)
Claus Gittinger <cg@exept.de>
parents:
3697
diff
changeset
|
3013 |
name |
729fda604d59
added #name (for javaMethod compatibility)
Claus Gittinger <cg@exept.de>
parents:
3697
diff
changeset
|
3014 |
"for compatibility with javaMethods" |
729fda604d59
added #name (for javaMethod compatibility)
Claus Gittinger <cg@exept.de>
parents:
3697
diff
changeset
|
3015 |
|
729fda604d59
added #name (for javaMethod compatibility)
Claus Gittinger <cg@exept.de>
parents:
3697
diff
changeset
|
3016 |
^ self selector |
729fda604d59
added #name (for javaMethod compatibility)
Claus Gittinger <cg@exept.de>
parents:
3697
diff
changeset
|
3017 |
|
729fda604d59
added #name (for javaMethod compatibility)
Claus Gittinger <cg@exept.de>
parents:
3697
diff
changeset
|
3018 |
"Created: / 9.11.1998 / 06:15:08 / cg" |
729fda604d59
added #name (for javaMethod compatibility)
Claus Gittinger <cg@exept.de>
parents:
3697
diff
changeset
|
3019 |
! |
729fda604d59
added #name (for javaMethod compatibility)
Claus Gittinger <cg@exept.de>
parents:
3697
diff
changeset
|
3020 |
|
20208 | 3021 |
overwrites:aMethod |
20035 | 3022 |
|mth| |
3023 |
||
3024 |
mth := self. |
|
3025 |
[ mth := mth overwrittenMethod. mth notNil ] whileTrue:[ |
|
3026 |
mth == aMethod ifTrue:[ |
|
3027 |
^ true |
|
3028 |
]. |
|
3029 |
]. |
|
3030 |
^ false |
|
13422 | 3031 |
|
15952 | 3032 |
"Created: / 05-07-2012 / 10:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13422 | 3033 |
! |
3034 |
||
12854 | 3035 |
parse:parseSelector return:accessSelector or:valueIfNoSource |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3036 |
"helper for methodArgNames, methodVarNames etc. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3037 |
Get the source, let parser parse it using parseSelector, |
1873 | 3038 |
return parser-info using accessSelector" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3039 |
|
5633
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3040 |
^ self parse:parseSelector with:nil return:accessSelector or:valueIfNoSource |
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3041 |
|
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3042 |
" |
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3043 |
(Method compiledMethodAt:#parse:return:or:) |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3044 |
parse:#'parseMethodSilent:' return:#sentMessages or:#() |
5633
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3045 |
" |
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3046 |
! |
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3047 |
|
12854 | 3048 |
parse:parseSelector with:arg2 return:accessSelector or:valueIfNoSource |
5633
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3049 |
"helper for methodArgNames, methodVarNames etc. |
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3050 |
Get the source, let parser parse it using parseSelector, |
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3051 |
return parser-info using accessSelector" |
15b028ad5e03
#usedGlobals check was wrong sometimes
Claus Gittinger <cg@exept.de>
parents:
5584
diff
changeset
|
3052 |
|
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3053 |
|parser parserClass sourceString cachedInfo| |
8427 | 3054 |
|
3055 |
parserClass := self parserClass. |
|
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3056 |
|
14039
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
3057 |
"/ because parsing the same method multiple times for different aspects |
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3058 |
"/ is very common with the new browser's info displays, we cache a few |
14047
016eab1c3b9a
comment/format in: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
14039
diff
changeset
|
3059 |
"/ of them. If the same is parsed soon after, we do not have to parse again. |
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3060 |
LastParseTreeCache notNil ifTrue:[ |
19716 | 3061 |
"/ to flush: LastParseTreeCache removeAll. |
3062 |
cachedInfo := LastParseTreeCache at:self ifAbsent:nil. |
|
3063 |
cachedInfo notNil ifTrue:[ |
|
3064 |
cachedInfo method == self ifTrue:[ |
|
3065 |
cachedInfo parser class == parserClass ifTrue:[ |
|
3066 |
"/ Transcript show:'hit '; showCR:self. |
|
3067 |
^ cachedInfo parser perform:accessSelector |
|
3068 |
] |
|
3069 |
]. |
|
3070 |
LastParseTreeCache removeKey:self |
|
3071 |
] |
|
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3072 |
]. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3073 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3074 |
sourceString := self source. |
8427 | 3075 |
(parserClass notNil and:[sourceString notNil]) ifTrue:[ |
19716 | 3076 |
parseSelector argumentCount == 2 ifTrue:[ |
3077 |
parser := parserClass perform:parseSelector with:sourceString with:arg2. |
|
3078 |
] ifFalse:[ |
|
3079 |
parser := parserClass perform:parseSelector with:sourceString. |
|
3080 |
]. |
|
3081 |
(parser isNil or:[parser == #Error]) ifTrue:[^ valueIfNoSource]. |
|
3082 |
"do not cache the parser, if it was parsing for code - a lot of information is missing then" |
|
3083 |
(self mclass notNil and:[parser wasParsedForCode not]) ifTrue:[ |
|
3084 |
LastParseTreeCache isNil ifTrue:[ |
|
3085 |
LastParseTreeCache := CacheDictionary new:500. |
|
3086 |
]. |
|
3087 |
LastParseTreeCache at:self put:(ParserCacheEntry new method:self parser:parser). |
|
3088 |
]. |
|
3089 |
^ parser perform:accessSelector |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3090 |
]. |
1873 | 3091 |
^ valueIfNoSource |
3092 |
||
5500
8bc3b30296ae
more queries (sentMessages ...)
Claus Gittinger <cg@exept.de>
parents:
5406
diff
changeset
|
3093 |
" |
15579 | 3094 |
LastParseTreeCache removeAll. |
3095 |
||
5500
8bc3b30296ae
more queries (sentMessages ...)
Claus Gittinger <cg@exept.de>
parents:
5406
diff
changeset
|
3096 |
(Method compiledMethodAt:#parse:return:or:) |
19716 | 3097 |
parse:#'parseMethodSilent:' return:#sentMessages or:#() |
5500
8bc3b30296ae
more queries (sentMessages ...)
Claus Gittinger <cg@exept.de>
parents:
5406
diff
changeset
|
3098 |
" |
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3099 |
|
14039
30251b45156a
added: #flushParseTreeCache
Claus Gittinger <cg@exept.de>
parents:
13847
diff
changeset
|
3100 |
"Modified: / 01-03-2012 / 14:30:50 / cg" |
15579 | 3101 |
"Modified (comment): / 30-07-2013 / 15:53:41 / cg" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3102 |
! |
159 | 3103 |
|
13422 | 3104 |
parseAnnotations |
17361 | 3105 |
"return the method's annotations." |
13422 | 3106 |
|
3107 |
|src parser| |
|
3108 |
||
3109 |
src := self source. |
|
3110 |
src isNil ifTrue:[ |
|
20804 | 3111 |
^ nil "/ actually: don't know |
13422 | 3112 |
]. |
3113 |
||
3114 |
self parserClass isNil ifTrue:[ |
|
20804 | 3115 |
^ nil |
13422 | 3116 |
]. |
3117 |
parser := self parserClass parseMethod: src. |
|
3118 |
(parser isNil or: [parser == #Error]) ifTrue:[ |
|
20804 | 3119 |
^ nil "/ actually error |
13422 | 3120 |
]. |
3121 |
^ annotations := parser annotations. |
|
3122 |
||
3123 |
"Created: / 10-07-2010 / 21:16:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3124 |
! |
|
3125 |
||
5721
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3126 |
parseResources |
16218 | 3127 |
"return the method's resource spec; either nil or a collection of symbols. |
3128 |
Resources are a special kind of annotation, of the form: |
|
20804 | 3129 |
<resource: #symbol...> |
16218 | 3130 |
and flags methods which depend on keyboard bindings or provide menus, specs or bitmap images" |
5721
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3131 |
|
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3132 |
|src parser| |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3133 |
|
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3134 |
src := self source. |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3135 |
src isNil ifTrue:[ |
20804 | 3136 |
^ nil "/ actually: don't know |
5721
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3137 |
]. |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3138 |
|
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3139 |
(src findString:'resource:') == 0 ifTrue:[ |
20804 | 3140 |
^ nil "/ actually: error |
5721
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3141 |
]. |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3142 |
"/ no need to parse all - only interested in resource-info |
8427 | 3143 |
self parserClass isNil ifTrue:[ |
20804 | 3144 |
^ nil |
8427 | 3145 |
]. |
8419 | 3146 |
parser := self parserClass parseMethodArgAndVarSpecificationSilent:src in:nil. |
5721
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3147 |
parser isNil ifTrue:[ |
20804 | 3148 |
^ nil "/ actually error |
5721
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3149 |
]. |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3150 |
^ parser primitiveResources. |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3151 |
! |
5f97733ff519
methods now send change-notifications when the category changes
Claus Gittinger <cg@exept.de>
parents:
5704
diff
changeset
|
3152 |
|
14402 | 3153 |
possiblySends:aSelectorSymbol |
3154 |
"return true, if this method contains an indirect message-send |
|
3155 |
(such as perform) with aSelectorSymbol as selector." |
|
3156 |
||
3157 |
(self referencesLiteral:aSelectorSymbol) ifTrue:[ |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3158 |
^ self messagesPossiblySent includesIdentical:aSelectorSymbol |
14402 | 3159 |
]. |
3160 |
^ false |
|
3161 |
! |
|
3162 |
||
1923
97b099fef985
optionally keep a history of changed methods
Claus Gittinger <cg@exept.de>
parents:
1873
diff
changeset
|
3163 |
previousVersion |
19449 | 3164 |
"return the receiver's previous version's source code" |
14251 | 3165 |
|
3166 |
|previous| |
|
3167 |
||
3168 |
previous := self previousVersions:2. |
|
3169 |
previous isEmptyOrNil ifTrue:[^ nil]. |
|
3170 |
^ previous first. |
|
3171 |
||
3172 |
"/ |sel cls previous| |
|
3173 |
"/ |
|
3174 |
"/ sel := self selector. |
|
3175 |
"/ sel isNil ifTrue:[ ^ nil ]. |
|
3176 |
"/ |
|
3177 |
"/ cls := self mclass. |
|
3178 |
"/ cls isNil ifTrue:[ ^ nil ]. |
|
3179 |
"/ |
|
3180 |
"/ ChangeSet current reverseDo:[:change | |
|
3181 |
"/ (change isMethodChange |
|
3182 |
"/ and:[ (change selector == sel) |
|
3183 |
"/ and:[ change changeClass == cls ]]) |
|
3184 |
"/ ifTrue:[ |
|
3185 |
"/ previous := change previousVersion. |
|
3186 |
"/ previous notNil ifTrue:[ |
|
3187 |
"/ ^ previous |
|
3188 |
"/ ] |
|
3189 |
"/ ] |
|
3190 |
"/ ]. |
|
3191 |
"/ ^ nil. |
|
6644
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3192 |
|
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3193 |
"/ history := Class methodHistory. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3194 |
"/ history isNil ifTrue:[^ nil]. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3195 |
"/ |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3196 |
"/ entry := history detect:[:entry | |type old new| |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3197 |
"/ type := entry first. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3198 |
"/ type == #methodChange ifTrue:[ |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3199 |
"/ old := entry second. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3200 |
"/ new := entry third. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3201 |
"/ new == self |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3202 |
"/ ] ifFalse:[ |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3203 |
"/ false |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3204 |
"/ ] |
12854 | 3205 |
"/ ] |
6644
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3206 |
"/ ifNone:nil. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3207 |
"/ entry isNil ifTrue:[^nil]. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3208 |
"/ ^ entry second. |
5339 | 3209 |
"/ ^ history at:self ifAbsent:nil |
1923
97b099fef985
optionally keep a history of changed methods
Claus Gittinger <cg@exept.de>
parents:
1873
diff
changeset
|
3210 |
|
14251 | 3211 |
"Modified: / 26-07-2012 / 13:16:34 / cg" |
1923
97b099fef985
optionally keep a history of changed methods
Claus Gittinger <cg@exept.de>
parents:
1873
diff
changeset
|
3212 |
! |
97b099fef985
optionally keep a history of changed methods
Claus Gittinger <cg@exept.de>
parents:
1873
diff
changeset
|
3213 |
|
7210 | 3214 |
previousVersionCode |
19449 | 3215 |
"return the receiver's previous version's source code" |
7210 | 3216 |
|
3217 |
|previous| |
|
3218 |
||
3219 |
previous := self previousVersion. |
|
3220 |
previous isNil ifTrue:[ ^ nil ]. |
|
3221 |
||
3222 |
^ previous source |
|
3223 |
! |
|
3224 |
||
6644
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3225 |
previousVersions |
14251 | 3226 |
"return a collection of the receiver's previous versions (sources)" |
3227 |
||
3228 |
^ self previousVersions:nil |
|
3229 |
||
3230 |
"Modified (comment): / 26-07-2012 / 12:04:15 / cg" |
|
3231 |
! |
|
3232 |
||
3233 |
previousVersions:count |
|
3234 |
"return a collection of the receiver's count previous versions (sources). |
|
3235 |
A nil count will retrieve all versions" |
|
6644
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3236 |
|
7453 | 3237 |
|sel cls versions lastChange firstSrc last| |
6644
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3238 |
|
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3239 |
sel := self selector. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3240 |
sel isNil ifTrue:[^ #()]. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3241 |
|
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3242 |
cls := self mclass. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3243 |
cls isNil ifTrue:[^ #()]. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3244 |
|
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3245 |
versions := OrderedCollection new. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3246 |
|
12854 | 3247 |
ChangeSet current reverseDo:[:change | |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3248 |
(change isMethodChange |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3249 |
and:[ (change selector == sel) |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3250 |
and:[ change changeClass == cls ]]) |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3251 |
ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3252 |
versions addFirst:change. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3253 |
lastChange := change. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3254 |
(count notNil and:[versions size == count]) ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3255 |
^ versions |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3256 |
] |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3257 |
] |
6644
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3258 |
]. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3259 |
|
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3260 |
lastChange notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3261 |
last := lastChange previousVersion. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3262 |
last notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3263 |
firstSrc := last source. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3264 |
(firstSrc notEmptyOrNil |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3265 |
and:[ firstSrc ~= lastChange source]) ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3266 |
versions addFirst:(MethodDefinitionChange |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3267 |
className:lastChange className |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3268 |
selector:lastChange selector |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3269 |
source:firstSrc |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3270 |
category:lastChange category). |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3271 |
] |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3272 |
] |
6644
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3273 |
]. |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3274 |
^ versions |
14251 | 3275 |
|
3276 |
" |
|
3277 |
(Method compiledMethodAt:#previousVersions:) previousVersions:nil |
|
3278 |
" |
|
3279 |
||
3280 |
"Created: / 26-07-2012 / 11:59:57 / cg" |
|
6644
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3281 |
! |
141198d9b865
previousVersions stuff moved from NewSystemBrowser to here
Claus Gittinger <cg@exept.de>
parents:
6541
diff
changeset
|
3282 |
|
5564
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3283 |
readsField:instVarIndex |
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3284 |
"return true, if the instvar at instVarIndex is read by the receiver. |
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3285 |
Uses parser (for now); could look at bytecode as well here..." |
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3286 |
|
14237 | 3287 |
|instVarName| |
3288 |
||
3289 |
instVarName := (self mclass allInstVarNames) at:instVarIndex. |
|
3290 |
^ self readsInstVar:instVarName |
|
3291 |
||
3292 |
"Modified: / 23-07-2012 / 11:16:08 / cg" |
|
3293 |
! |
|
3294 |
||
3295 |
readsInstVar:instVarName |
|
3296 |
"return true, if the named instvar is read by the receiver. |
|
3297 |
Uses parser (for now); could look at bytecode as well here..." |
|
3298 |
||
3299 |
|readInstVars| |
|
3300 |
||
3301 |
(self source includesString:instVarName) ifFalse:[^ false]. "/ that's much faster than parsing... |
|
5636 | 3302 |
readInstVars := self parse:#'parseMethodSilent:in:' with:self mclass return:#readInstVars or:#(). |
14237 | 3303 |
^ readInstVars includes:instVarName. |
3304 |
||
3305 |
"Created: / 23-07-2012 / 11:15:56 / cg" |
|
5564
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3306 |
! |
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3307 |
|
14253 | 3308 |
refersToLiteral: anObject |
3309 |
"redefined to search in annotations" |
|
3310 |
||
3311 |
(super refersToLiteral: anObject) ifTrue:[^ true]. |
|
3312 |
||
15387 | 3313 |
self annotationsDo:[:annot | |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3314 |
(annot refersToLiteral: anObject) ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3315 |
"/ self halt. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3316 |
^ true |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3317 |
]. |
14253 | 3318 |
]. |
3319 |
^ false |
|
3320 |
||
3321 |
"Created: / 26-07-2012 / 15:51:14 / cg" |
|
3322 |
! |
|
3323 |
||
3324 |
refersToLiteralMatching: aMatchString |
|
3325 |
(super refersToLiteralMatching: aMatchString) ifTrue:[^ true]. |
|
3326 |
||
15387 | 3327 |
self annotationsDo:[:annot | |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3328 |
(annot refersToLiteralMatching: aMatchString) ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3329 |
"/ self halt. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3330 |
^ true |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3331 |
]. |
14253 | 3332 |
]. |
3333 |
^ false |
|
3334 |
||
3335 |
"Created: / 26-07-2012 / 15:51:36 / cg" |
|
3336 |
! |
|
3337 |
||
3052
f384e7082ee9
more resource stuff (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
3030
diff
changeset
|
3338 |
resourceType |
f384e7082ee9
more resource stuff (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
3030
diff
changeset
|
3339 |
"ST-80 compatibility: |
12854 | 3340 |
return the methods first resource specs key. |
8526 | 3341 |
Returns either nil, or a single symbol." |
3052
f384e7082ee9
more resource stuff (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
3030
diff
changeset
|
3342 |
|
3387 | 3343 |
|resources| |
3344 |
||
3345 |
(resources := self resources) notNil ifTrue:[ |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3346 |
resources keysAndValuesDo:[:key :val| |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3347 |
^ key |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3348 |
]. |
3341 | 3349 |
]. |
3387 | 3350 |
^ nil |
3052
f384e7082ee9
more resource stuff (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
3030
diff
changeset
|
3351 |
! |
f384e7082ee9
more resource stuff (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
3030
diff
changeset
|
3352 |
|
f384e7082ee9
more resource stuff (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
3030
diff
changeset
|
3353 |
resources |
5894
ed6193fa6040
Define #isObsolete and fix various comments
Stefan Vogel <sv@exept.de>
parents:
5818
diff
changeset
|
3354 |
"return the methods resource spec; either nil or a collection of symbols." |
3052
f384e7082ee9
more resource stuff (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
3030
diff
changeset
|
3355 |
|
13422 | 3356 |
| resources | |
13817 | 3357 |
|
3052
f384e7082ee9
more resource stuff (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
3030
diff
changeset
|
3358 |
self hasResource ifFalse:[^ nil]. |
13817 | 3359 |
annotations isNil ifTrue:[^ self parseResources]. |
13422 | 3360 |
|
3361 |
resources := IdentityDictionary new. |
|
18753 | 3362 |
self annotationsAt: #resource: orAt: #resource:values: do:[:annot| |
3363 |
resources at: annot type put: annot value ? true |
|
13817 | 3364 |
]. |
3365 |
^ resources |
|
13422 | 3366 |
|
3367 |
"Modified: / 16-07-2010 / 11:49:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13817 | 3368 |
"Modified: / 18-11-2011 / 14:48:41 / cg" |
3052
f384e7082ee9
more resource stuff (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
3030
diff
changeset
|
3369 |
! |
f384e7082ee9
more resource stuff (VW compatibility)
Claus Gittinger <cg@exept.de>
parents:
3030
diff
changeset
|
3370 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3371 |
selector |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3372 |
"return the selector under which I am found in my containingClasses |
12854 | 3373 |
method-table. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3374 |
See comment in who." |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3375 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3376 |
"based on who, which has been added for ST-80 compatibility" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3377 |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3378 |
|who| |
68 | 3379 |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3380 |
who := self who. |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3381 |
who notNil ifTrue:[^ who methodSelector]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3382 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3383 |
none found - sorry |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3384 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3385 |
^ nil |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3386 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3387 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3388 |
|m| |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3389 |
m := Object compiledMethodAt:#at:. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3390 |
m selector |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3391 |
" |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3392 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3393 |
"Modified: 1.11.1996 / 16:25:48 / cg" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3394 |
! |
68 | 3395 |
|
5534 | 3396 |
sends:aSelectorSymbol |
3397 |
"return true, if this method contains a message-send |
|
3398 |
with aSelectorSymbol as selector." |
|
3399 |
||
3400 |
(self referencesLiteral:aSelectorSymbol) ifTrue:[ |
|
19693 | 3401 |
"/ cg: was temporarily disabled to speed up some searches. |
3402 |
"/ I think, we have to change the callers to call referencesLiteral: instead, |
|
3403 |
"/ if there is any speed problem there. Not here. |
|
3404 |
"/ ^ true. |
|
3405 |
"/ the self messagesSent does a parse-tree analysis |
|
3406 |
^ self messagesSent includesIdentical:aSelectorSymbol |
|
5534 | 3407 |
]. |
3408 |
^ false |
|
3409 |
! |
|
3410 |
||
12363 | 3411 |
sends:selectorSymbol1 or:selectorSymbol2 |
3412 |
"return true, if this method contains a message-send |
|
13569
82bcca38e855
comment/format in: #sends:or:
Claus Gittinger <cg@exept.de>
parents:
13567
diff
changeset
|
3413 |
to either selectorSymbol1 or selectorSymbol2. |
82bcca38e855
comment/format in: #sends:or:
Claus Gittinger <cg@exept.de>
parents:
13567
diff
changeset
|
3414 |
This is a hack, because calling sends: twice parses twice (should cache parse trees)" |
12363 | 3415 |
|
17514 | 3416 |
^ self sendsAny:{ selectorSymbol1 selectorSymbol2 } |
13569
82bcca38e855
comment/format in: #sends:or:
Claus Gittinger <cg@exept.de>
parents:
13567
diff
changeset
|
3417 |
|
82bcca38e855
comment/format in: #sends:or:
Claus Gittinger <cg@exept.de>
parents:
13567
diff
changeset
|
3418 |
"Modified (comment): / 08-08-2011 / 18:43:04 / cg" |
12363 | 3419 |
! |
3420 |
||
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3421 |
sendsAny:aCollectionOfSelectorSymbols |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3422 |
"return true, if this method contains a message-send |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3423 |
to any of aCollectionOfSelectorSymbols." |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3424 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3425 |
|msgs| |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3426 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3427 |
(aCollectionOfSelectorSymbols contains:[:sym | self referencesLiteral:sym]) ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3428 |
"/ cg: was temporarily disabled to speed up some searches. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3429 |
"/ I think, we have to change the caller's to call referencesLiteral: instead, |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3430 |
"/ if there is any speed problem there. Not here. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3431 |
"/ ^ true. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3432 |
|
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3433 |
msgs := self messagesSent. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3434 |
^ aCollectionOfSelectorSymbols contains:[:sym | msgs includesIdentical:sym] |
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3435 |
]. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3436 |
^ false |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3437 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3438 |
"Created: / 08-08-2011 / 18:53:24 / cg" |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3439 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3440 |
|
19739 | 3441 |
sendsMessageForWhich:aCheckBlock |
3442 |
"return true, if this method contains a message-send |
|
3443 |
for which aCheckBlock returns true, when given the selector." |
|
3444 |
||
3445 |
self literalsDo:[:each | |
|
3446 |
each isSymbol ifTrue:[ |
|
3447 |
"/ first check if the selector matches |
|
3448 |
(aCheckBlock value:each) ifTrue:[ |
|
3449 |
"/ then, if this is really a message send |
|
3450 |
(self messagesSent includes:each) ifTrue:[^ true]. |
|
3451 |
] |
|
3452 |
] |
|
20208 | 3453 |
]. |
19739 | 3454 |
^ false |
3455 |
||
3456 |
" |
|
20208 | 3457 |
(self compiledMethodAt:#sendsAnyForWhich:) |
19739 | 3458 |
sendsAnyForWhich:[:sel | sel startsWith:'message'] |
20208 | 3459 |
(self compiledMethodAt:#sendsAnyForWhich:) |
19739 | 3460 |
sendsAnyForWhich:[:sel | sel startsWith:'foo'] |
3461 |
" |
|
3462 |
! |
|
3463 |
||
16877
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3464 |
shadowedMethod |
17562 | 3465 |
"Return the shadowed method if this method is an extension (i.e. package ~= classes' package) |
3466 |
AND it shadows (redefines) an existing method from the method's class. |
|
16877
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3467 |
If this method does not shadow any other method, return nil." |
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3468 |
|
17562 | 3469 |
| myClass nonMetaClass myProjectDefinition originalMethod| |
16877
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3470 |
|
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3471 |
myClass := self mclass. |
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3472 |
myClass isNil ifTrue:[^ nil]. |
17562 | 3473 |
nonMetaClass := myClass theNonMetaclass. |
3474 |
||
3475 |
(package ~= nonMetaClass package |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3476 |
and:[ package ~= PackageId noProjectID |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3477 |
and:[ (myProjectDefinition := nonMetaClass projectDefinitionClass) notNil ]]) |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3478 |
ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3479 |
originalMethod := myProjectDefinition savedOverwrittenMethodForClass:myClass selector:self selector. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3480 |
|
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3481 |
"/ mhm - what if it does no make a difference? |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3482 |
"/ (originalMethod notNil and:[originalMethod source = self source]) ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3483 |
"/ "/ self halt. ^ nil |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3484 |
"/ ]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3485 |
^ originalMethod |
17562 | 3486 |
]. |
16877
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3487 |
^ nil |
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3488 |
|
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3489 |
"Created: / 03-10-2014 / 15:16:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3490 |
! |
d4a452edacb5
Added Method>>shadowedMethod returning shadowed method or nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16847
diff
changeset
|
3491 |
|
11022
8dd9f699915f
+shouldBeSkippedInDebuggersWalkBack
Claus Gittinger <cg@exept.de>
parents:
11016
diff
changeset
|
3492 |
shouldBeSkippedInDebuggersWalkBack |
8dd9f699915f
+shouldBeSkippedInDebuggersWalkBack
Claus Gittinger <cg@exept.de>
parents:
11016
diff
changeset
|
3493 |
"return true, if this method thinks, it should be skipped in a walkback. |
17463 | 3494 |
This is done by looking for a #skipInDebuggersWalkBack flag in the method's resources." |
11022
8dd9f699915f
+shouldBeSkippedInDebuggersWalkBack
Claus Gittinger <cg@exept.de>
parents:
11016
diff
changeset
|
3495 |
|
8dd9f699915f
+shouldBeSkippedInDebuggersWalkBack
Claus Gittinger <cg@exept.de>
parents:
11016
diff
changeset
|
3496 |
|resources| |
8dd9f699915f
+shouldBeSkippedInDebuggersWalkBack
Claus Gittinger <cg@exept.de>
parents:
11016
diff
changeset
|
3497 |
|
8dd9f699915f
+shouldBeSkippedInDebuggersWalkBack
Claus Gittinger <cg@exept.de>
parents:
11016
diff
changeset
|
3498 |
resources := self resources. |
20208 | 3499 |
^ resources notNil |
19699 | 3500 |
and:[ resources includesKey:#skipInDebuggersWalkBack ]. |
11022
8dd9f699915f
+shouldBeSkippedInDebuggersWalkBack
Claus Gittinger <cg@exept.de>
parents:
11016
diff
changeset
|
3501 |
! |
8dd9f699915f
+shouldBeSkippedInDebuggersWalkBack
Claus Gittinger <cg@exept.de>
parents:
11016
diff
changeset
|
3502 |
|
5696 | 3503 |
superMessages |
3504 |
"return a collection of message-selectors, sent to super by this method." |
|
3505 |
||
3506 |
^ self messagesSentToSuper |
|
3507 |
! |
|
3508 |
||
5523 | 3509 |
usedGlobals |
3510 |
"return a collection with the global names referred to by the receiver. |
|
3511 |
Uses Parser to parse methods source and extract them." |
|
3512 |
||
12854 | 3513 |
^ self parse:#'parseMethodSilent:in:' with:self mclass return:#usedGlobals or:#() |
5523 | 3514 |
|
3515 |
" |
|
12854 | 3516 |
(Method compiledMethodAt:#resources) usedGlobals |
5523 | 3517 |
" |
3518 |
! |
|
3519 |
||
5509 | 3520 |
usedSymbols |
3521 |
"return a collection with the symbols referred to by the receiver. |
|
3522 |
Uses Parser to parse methods source and extract them. |
|
12854 | 3523 |
This collection only includes implicit symbols references |
8895 | 3524 |
(i.e. not messages sent)" |
5509 | 3525 |
|
12854 | 3526 |
^ self parse:#'parseMethodSilent:in:' with:self mclass return:#usedSymbols or:#() |
5509 | 3527 |
|
3528 |
" |
|
12854 | 3529 |
(Method compiledMethodAt:#usedSymbols) usedSymbols |
3530 |
(Method compiledMethodAt:#usedSymbols) messagesSent |
|
5509 | 3531 |
" |
3532 |
! |
|
3533 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3534 |
who |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3535 |
"return the class and selector of where I am defined in; |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3536 |
nil is returned for unbound methods. |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3537 |
|
12854 | 3538 |
ST/X special notice: |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3539 |
returns an instance of MethodWhoInfo, which |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3540 |
responds to #methodClass and #methodSelector query messages. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3541 |
For backward- (& ST-80) compatibility, the returned object also |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3542 |
responds to #at:1 and #at:2 messages. |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3543 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3544 |
Implementation notice: |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3545 |
To avoid an expensive search, the once valid containing class is kept and remembered |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3546 |
in the mclass slot. However, if a method gets recompiled or wrapped, the mclass field is |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3547 |
no longer valid and who on the old method returns nil (because the method is actually no longer |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3548 |
contained in that class). However, to allow easier unwrapping (and gathering of the corresponding |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3549 |
wrapper), the mclass field is never nilled. I.e. it still refers to the original class. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3550 |
Therefore, a validation of the mclass slot is done here." |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3551 |
|
17250 | 3552 |
|cls sel fn clsName checkBlock| |
3553 |
||
5324 | 3554 |
mclass notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3555 |
"/ check if this (cached) info is still valid... |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3556 |
sel := mclass selectorAtMethod:self. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3557 |
sel notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3558 |
^ MethodWhoInfo class:mclass selector:sel |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3559 |
]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3560 |
^ nil. |
5324 | 3561 |
]. |
3562 |
||
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3563 |
checkBlock := |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3564 |
[:cls | |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3565 |
|sel| |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3566 |
|
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3567 |
sel := cls selectorAtMethod:self. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3568 |
sel notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3569 |
LastWhoClass := cls theNonMetaclass name. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3570 |
mclass := cls. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3571 |
^ MethodWhoInfo class:cls selector:sel |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3572 |
]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3573 |
]. |
17250 | 3574 |
|
3575 |
" |
|
3576 |
first, look in the class we found something the last time |
|
3577 |
this may often give a hit, when asking who repeatingly for |
|
3578 |
a context chain. (keep last by its name, to not keep classes from |
|
3579 |
being garbage collected) |
|
3580 |
" |
|
3581 |
LastWhoClass notNil ifTrue:[ |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3582 |
cls := Smalltalk at:LastWhoClass ifAbsent:nil. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3583 |
cls notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3584 |
checkBlock value:cls theNonMetaclass. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3585 |
checkBlock value:cls theMetaclass. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3586 |
] |
6420 | 3587 |
]. |
3588 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3589 |
" |
5294
f2d689cf7be4
speedup #who (guess className from sourceFileName)
Claus Gittinger <cg@exept.de>
parents:
5284
diff
changeset
|
3590 |
speedup kludge: if my sourceFileName is valid, |
f2d689cf7be4
speedup #who (guess className from sourceFileName)
Claus Gittinger <cg@exept.de>
parents:
5284
diff
changeset
|
3591 |
extract the className from it and try that class first. |
f2d689cf7be4
speedup #who (guess className from sourceFileName)
Claus Gittinger <cg@exept.de>
parents:
5284
diff
changeset
|
3592 |
" |
f2d689cf7be4
speedup #who (guess className from sourceFileName)
Claus Gittinger <cg@exept.de>
parents:
5284
diff
changeset
|
3593 |
(fn := self sourceFilename) notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3594 |
clsName := fn asFilename nameWithoutSuffix. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3595 |
clsName := clsName asSymbolIfInterned. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3596 |
clsName notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3597 |
cls := Smalltalk at:clsName ifAbsent:nil. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3598 |
cls notNil ifTrue:[ |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3599 |
checkBlock value:cls theNonMetaclass. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3600 |
checkBlock value:cls theMetaclass. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3601 |
] |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3602 |
]. |
5294
f2d689cf7be4
speedup #who (guess className from sourceFileName)
Claus Gittinger <cg@exept.de>
parents:
5284
diff
changeset
|
3603 |
]. |
f2d689cf7be4
speedup #who (guess className from sourceFileName)
Claus Gittinger <cg@exept.de>
parents:
5284
diff
changeset
|
3604 |
|
f2d689cf7be4
speedup #who (guess className from sourceFileName)
Claus Gittinger <cg@exept.de>
parents:
5284
diff
changeset
|
3605 |
" |
17250 | 3606 |
limit the search to global classes only - |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3607 |
since probability is high, that the receiver is found in there ... |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3608 |
" |
17250 | 3609 |
Smalltalk allClassesDo:[:cls | |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3610 |
checkBlock value:cls theNonMetaclass. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3611 |
checkBlock value:cls theMetaclass. |
142 | 3612 |
]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3613 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3614 |
LastWhoClass := nil. |
6397
311358bdeed6
do not search for anonymous classes in #who
Claus Gittinger <cg@exept.de>
parents:
6365
diff
changeset
|
3615 |
"/ " |
311358bdeed6
do not search for anonymous classes in #who
Claus Gittinger <cg@exept.de>
parents:
6365
diff
changeset
|
3616 |
"/ mhmh - must be a method of some anonymous class (i.e. one not |
311358bdeed6
do not search for anonymous classes in #who
Claus Gittinger <cg@exept.de>
parents:
6365
diff
changeset
|
3617 |
"/ in the Smalltalk dictionary). Search all instances of Behavior |
311358bdeed6
do not search for anonymous classes in #who
Claus Gittinger <cg@exept.de>
parents:
6365
diff
changeset
|
3618 |
"/ " |
6420 | 3619 |
"/ Behavior allSubInstancesDo:[:someClassLikeThingy | |
3620 |
"/ (classes includes:someClassLikeThingy) ifFalse:[ |
|
3621 |
"/ checkBlock value:someClassLikeThingy. |
|
6397
311358bdeed6
do not search for anonymous classes in #who
Claus Gittinger <cg@exept.de>
parents:
6365
diff
changeset
|
3622 |
"/ ] |
311358bdeed6
do not search for anonymous classes in #who
Claus Gittinger <cg@exept.de>
parents:
6365
diff
changeset
|
3623 |
"/ ]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3624 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3625 |
none found - sorry |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3626 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3627 |
^ nil |
444 | 3628 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3629 |
"typical situation: some well-known class" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3630 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3631 |
|m| |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3632 |
m := Object compiledMethodAt:#copy. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3633 |
m who |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3634 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3635 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3636 |
"untypical situation: an anonymous class" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3637 |
" |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3638 |
|m cls| |
444 | 3639 |
|
12854 | 3640 |
Object |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3641 |
subclass:#FunnyClass |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3642 |
instanceVariableNames:'foo' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3643 |
classVariableNames:'' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3644 |
poolDictionaries:'' |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3645 |
category:'testing'. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3646 |
cls := Smalltalk at:#FunnyClass. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3647 |
Smalltalk removeClass:cls. |
444 | 3648 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3649 |
cls compile:'testMethod1:arg foo:=arg'. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3650 |
cls compile:'testMethod2 ^ foo'. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3651 |
m := cls compiledMethodAt:#testMethod1:. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3652 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3653 |
m who |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3654 |
" |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3655 |
|
10156 | 3656 |
"Modified: / 07-11-2006 / 13:58:50 / cg" |
68 | 3657 |
! |
3658 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3659 |
wrapper |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3660 |
"only for wrapped methods: return the wrapper. |
14419
eef0be88cb60
comment/format in: #wrapper
Claus Gittinger <cg@exept.de>
parents:
14402
diff
changeset
|
3661 |
That's the WrapperMethod which contains myself." |
159 | 3662 |
|
13847 | 3663 |
WrappedMethod notNil ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3664 |
WrappedMethod allInstancesDo:[:m | |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3665 |
m originalMethod == self ifTrue:[^ m]. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3666 |
]. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3667 |
]. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3668 |
^ nil |
13847 | 3669 |
|
3670 |
"Modified: / 05-12-2011 / 11:15:26 / cg" |
|
5564
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3671 |
! |
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3672 |
|
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3673 |
writesField:instVarIndex |
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3674 |
"return true, if the instvar at instVarIndex is written (modified) by the receiver. |
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3675 |
Uses parser (for now); could look at bytecode as well here..." |
0f513f04c50f
#readsFields: and #writesField: for st80 compatibility
Claus Gittinger <cg@exept.de>
parents:
5562
diff
changeset
|
3676 |
|
14237 | 3677 |
|instVarName| |
3678 |
||
3679 |
instVarName := (self mclass allInstVarNames) at:instVarIndex. |
|
3680 |
^ self writesInstVar:instVarName |
|
3681 |
||
3682 |
"Modified: / 23-07-2012 / 11:16:51 / cg" |
|
3683 |
! |
|
3684 |
||
3685 |
writesInstVar:instVarName |
|
3686 |
"return true, if the named instvar is written (modified) by the receiver. |
|
3687 |
Uses parser (for now); could look at bytecode as well here..." |
|
3688 |
||
3689 |
|modifiedInstVars| |
|
3690 |
||
3691 |
(self source includesString:instVarName) ifFalse:[^ false]. "/ that's much faster than parsing... |
|
5636 | 3692 |
modifiedInstVars := self parse:#'parseMethodSilent:in:' with:self mclass return:#modifiedInstVars or:#(). |
14237 | 3693 |
^ modifiedInstVars includes:instVarName. |
3694 |
||
3695 |
"Created: / 23-07-2012 / 11:16:36 / cg" |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3696 |
! ! |
13 | 3697 |
|
21156 | 3698 |
|
14863 | 3699 |
!Method methodsFor:'source management'! |
3700 |
||
3701 |
revisionInfo |
|
17402 | 3702 |
"cg: is this correct for extensions? (shouldn't this be the revisionInfo from the extensions container?)" |
14863 | 3703 |
|
3704 |
^self containingClass theNonMetaclass revisionInfo |
|
3705 |
||
3706 |
"Created: / 28-08-2010 / 22:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3707 |
"Modified: / 12-09-2010 / 16:38:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3708 |
! ! |
|
3709 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3710 |
!Method methodsFor:'trap methods'! |
13 | 3711 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3712 |
makeInvalid |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3713 |
"make the receiver an invalid method, which raises an invalidCodeObject |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3714 |
signal when executed. This is not for public use - it is required for |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3715 |
the objectFileLoader to invalidate methods whose code is unloaded." |
1 | 3716 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3717 |
|invldMethod| |
159 | 3718 |
|
18438 | 3719 |
invldMethod := self trapMethodForNumArgs:(self argumentCount). |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3720 |
self code:invldMethod code. |
1873 | 3721 |
self byteCode:nil. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3722 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3723 |
"Created: 17.9.1995 / 15:00:52 / claus" |
1873 | 3724 |
"Modified: 4.11.1996 / 23:04:34 / cg" |
1 | 3725 |
! |
3726 |
||
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3727 |
makeUncompiled |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3728 |
"make the receiver an uncompiled method, which raises an invalidCodeObject |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3729 |
signal when executed. This is not for public use - it is required for |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3730 |
the compiler to invalidate methods which cannot be compiled due to errors |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3731 |
after a class definition change (for example: instvars are no longer there)." |
1 | 3732 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3733 |
|invldMethod| |
872 | 3734 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3735 |
invldMethod := self class compiledMethodAt:#uncompiledCodeObject. |
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3736 |
self code:invldMethod code. |
1873 | 3737 |
self byteCode:nil. |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3738 |
|
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3739 |
"Created: 17.9.1995 / 15:01:14 / claus" |
1873 | 3740 |
"Modified: 4.11.1996 / 23:04:46 / cg" |
3741 |
! |
|
3742 |
||
3743 |
makeUnloaded |
|
3744 |
"make the receiver an unloaded method, which raises an invalidCodeObject |
|
3745 |
signal when executed. This is not for public use - it is required for |
|
3746 |
the objectFileLoader to invalidate methods for which a shared library has |
|
3747 |
been removed." |
|
3748 |
||
3749 |
|invldMethod| |
|
3750 |
||
3751 |
invldMethod := self class compiledMethodAt:#unloadedCodeObject. |
|
3752 |
self code:invldMethod code. |
|
3753 |
self byteCode:nil. |
|
3754 |
||
3755 |
"Created: 4.11.1996 / 22:59:21 / cg" |
|
3756 |
"Modified: 4.11.1996 / 23:04:52 / cg" |
|
1870
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
3757 |
! |
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
3758 |
|
2623b60c27e1
lifted numVars; added access for invalidCodeObject-trappers
Claus Gittinger <cg@exept.de>
parents:
1855
diff
changeset
|
3759 |
trapMethodForNumArgs:numArgs |
13657
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
3760 |
^ self class trapMethodForNumArgs:numArgs |
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
3761 |
|
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
3762 |
"Created: / 04-11-1996 / 21:58:58 / cg" |
206c6696707b
added: #trapMethodForNumArgs:
Claus Gittinger <cg@exept.de>
parents:
13651
diff
changeset
|
3763 |
"Modified: / 08-09-2011 / 05:35:48 / cg" |
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3764 |
! ! |
872 | 3765 |
|
2022
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3766 |
!Method::MethodWhoInfo class methodsFor:'documentation'! |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3767 |
|
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3768 |
documentation |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3769 |
" |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3770 |
In earlier times, Method>>who returned an array filled |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3771 |
with the methods class and selector. |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3772 |
This was done, since a smalltalk method cannot return multiple |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3773 |
values, but 2 values had to be returned from that method. |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3774 |
Thus, the who-interface was used as: |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3775 |
info := <someMethod> who. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3776 |
class := info at:1. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3777 |
sel := info at:2. |
2022
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3778 |
|
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3779 |
Sure, this is ugly coding style, and the system has been changed to return |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3780 |
an object (an instance of MethodWhoInfo) which responds to the two |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3781 |
messages: #methodClass and #methodSelector. |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3782 |
This allows to write things much more intuitive: |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3783 |
info := <someMethod> who. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3784 |
class := info methodClass. |
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3785 |
sel := info methodSelector. |
2022
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3786 |
|
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3787 |
However, to be backward compatible, the returned object still responds to |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3788 |
the #at: message, but only allows inices of 1 and 2 to be used. |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3789 |
|
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3790 |
The MethodWhoInfo class is private to Method - its not visible to other |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3791 |
classes. |
2242 | 3792 |
|
3793 |
[author:] |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3794 |
Claus Gittinger |
2242 | 3795 |
|
3796 |
[see also:] |
|
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3797 |
Method |
2022
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3798 |
" |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3799 |
! ! |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3800 |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3801 |
!Method::MethodWhoInfo class methodsFor:'instance creation'! |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3802 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3803 |
class:cls selector:sel |
2023 | 3804 |
"return a new MethodWhoInfo object; |
3805 |
this is a private interface for Method" |
|
3806 |
||
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3807 |
^ self basicNew class:cls selector:sel |
2023 | 3808 |
|
3809 |
"Modified: 2.1.1997 / 15:27:59 / cg" |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3810 |
! ! |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3811 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3812 |
!Method::MethodWhoInfo methodsFor:'accessing'! |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3813 |
|
4669
828addb1c376
source code access - care for package different from my classes
Claus Gittinger <cg@exept.de>
parents:
4595
diff
changeset
|
3814 |
method |
828addb1c376
source code access - care for package different from my classes
Claus Gittinger <cg@exept.de>
parents:
4595
diff
changeset
|
3815 |
^ myClass compiledMethodAt:mySelector |
828addb1c376
source code access - care for package different from my classes
Claus Gittinger <cg@exept.de>
parents:
4595
diff
changeset
|
3816 |
! |
828addb1c376
source code access - care for package different from my classes
Claus Gittinger <cg@exept.de>
parents:
4595
diff
changeset
|
3817 |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3818 |
methodClass |
2022
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3819 |
"return the class which contains the method represented by myself" |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3820 |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3821 |
^ myClass |
2022
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3822 |
|
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3823 |
" |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3824 |
(Method compiledMethodAt:#who) who methodClass |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3825 |
(Method::MethodWhoInfo compiledMethodAt:#methodClass) who methodClass |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3826 |
" |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3827 |
|
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3828 |
"Modified: 2.1.1997 / 14:59:02 / cg" |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3829 |
! |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3830 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3831 |
methodSelector |
2022
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3832 |
"return the selector under which the the method represented by myself |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3833 |
is found in the class" |
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3834 |
|
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3835 |
^ mySelector |
2022
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3836 |
|
24529e2b7cee
commentary for MethodWhoInfo
Claus Gittinger <cg@exept.de>
parents:
1995
diff
changeset
|
3837 |
"Modified: 2.1.1997 / 14:59:24 / cg" |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3838 |
! ! |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3839 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3840 |
!Method::MethodWhoInfo methodsFor:'compatibility'! |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3841 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3842 |
at:index |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3843 |
"simulate the old behavior (when Method>>who returned an array)" |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3844 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3845 |
index == 1 ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3846 |
^ myClass |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3847 |
]. |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3848 |
index == 2 ifTrue:[ |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3849 |
^ mySelector |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3850 |
]. |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3851 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3852 |
"/ sigh - full compatibility ? |
7219
7c7b9d76af21
subscriptBoundsError -> subscriptBoundsError:
Claus Gittinger <cg@exept.de>
parents:
7210
diff
changeset
|
3853 |
^ self indexNotIntegerOrOutOfBounds:index |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3854 |
! ! |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3855 |
|
7258 | 3856 |
!Method::MethodWhoInfo methodsFor:'private-accessing'! |
1851
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3857 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3858 |
class:cls selector:sel |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3859 |
myClass := cls. |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3860 |
mySelector := sel |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3861 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3862 |
|
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3863 |
! ! |
4accc9fafd19
change #who to return a proper object
Claus Gittinger <cg@exept.de>
parents:
1813
diff
changeset
|
3864 |
|
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3865 |
!Method::ParseTreeCacheEntry methodsFor:'accessing'! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3866 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3867 |
method |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3868 |
^ method |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3869 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3870 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3871 |
method:something |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3872 |
method := something. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3873 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3874 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3875 |
parser |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3876 |
^ parser |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3877 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3878 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3879 |
parser:something |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3880 |
parser := something. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3881 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3882 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3883 |
parserClass |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3884 |
^ parserClass |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3885 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3886 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3887 |
parserClass:something |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3888 |
parserClass := something. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3889 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3890 |
|
13660 | 3891 |
parserClass:parserClassArg method:methodArg |
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3892 |
parserClass := parserClassArg. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3893 |
method := methodArg. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3894 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3895 |
|
13660 | 3896 |
parserClass:parserClassArg method:methodArg parser:parserArg |
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3897 |
parserClass := parserClassArg. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3898 |
method := methodArg. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3899 |
parser := parserArg. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3900 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3901 |
"Created: / 08-08-2011 / 19:05:02 / cg" |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3902 |
! ! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3903 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3904 |
!Method::ParserCacheEntry methodsFor:'accessing'! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3905 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3906 |
method |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3907 |
^ method |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3908 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3909 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3910 |
method:something |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3911 |
method := something. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3912 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3913 |
|
19716 | 3914 |
method:methodArg parser:parserArg |
3915 |
method := methodArg. |
|
3916 |
parser := parserArg. |
|
3917 |
||
3918 |
"Created: / 08-08-2011 / 19:05:02 / cg" |
|
3919 |
! |
|
3920 |
||
13570
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3921 |
parser |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3922 |
^ parser |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3923 |
! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3924 |
|
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3925 |
parser:something |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3926 |
parser := something. |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3927 |
! ! |
382db10e848d
changed: #parse:with:return:or:
Claus Gittinger <cg@exept.de>
parents:
13569
diff
changeset
|
3928 |
|
1775
6892b91ddc0b
F_CALLED flag is no longer present
Claus Gittinger <cg@exept.de>
parents:
1692
diff
changeset
|
3929 |
!Method class methodsFor:'documentation'! |
872 | 3930 |
|
13569
82bcca38e855
comment/format in: #sends:or:
Claus Gittinger <cg@exept.de>
parents:
13567
diff
changeset
|
3931 |
version |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3932 |
^ '$Header$' |
13569
82bcca38e855
comment/format in: #sends:or:
Claus Gittinger <cg@exept.de>
parents:
13567
diff
changeset
|
3933 |
! |
82bcca38e855
comment/format in: #sends:or:
Claus Gittinger <cg@exept.de>
parents:
13567
diff
changeset
|
3934 |
|
13422 | 3935 |
version_CVS |
18620
b4e9f25d6ce6
preparations for lined index list in WeakArray
Claus Gittinger <cg@exept.de>
parents:
18462
diff
changeset
|
3936 |
^ '$Header$' |
12159 | 3937 |
! |
3938 |
||
20357
0eae8bf21a91
Method: don't try to figure out a source code manager for method when using local source
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20210
diff
changeset
|
3939 |
version_HG |
0eae8bf21a91
Method: don't try to figure out a source code manager for method when using local source
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20210
diff
changeset
|
3940 |
|
0eae8bf21a91
Method: don't try to figure out a source code manager for method when using local source
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20210
diff
changeset
|
3941 |
^ '$Changeset: <not expanded> $' |
0eae8bf21a91
Method: don't try to figure out a source code manager for method when using local source
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20210
diff
changeset
|
3942 |
! |
0eae8bf21a91
Method: don't try to figure out a source code manager for method when using local source
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20210
diff
changeset
|
3943 |
|
13422 | 3944 |
version_SVN |
15245 | 3945 |
^ '$ Id: Method.st 10648 2011-06-23 15:55:10Z vranyj1 $' |
1 | 3946 |
! ! |
6956
23f0066163ff
oops - EOL comments were handled wrong
Claus Gittinger <cg@exept.de>
parents:
6725
diff
changeset
|
3947 |
|
14863 | 3948 |
|
952
d600e08a5936
handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents:
934
diff
changeset
|
3949 |
Method initialize! |