10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 "{ Package: 'stx:libbasic' }" |
12 "{ Package: 'stx:libbasic' }" |
13 |
13 |
14 CompiledCode variableSubclass:#Method |
14 CompiledCode variableSubclass:#Method |
15 instanceVariableNames:'source sourcePosition category package mclass' |
15 instanceVariableNames:'source sourcePosition category package mclass' |
16 classVariableNames:'PrivateMethodSignal LastFileReference LastSourceFileName |
16 classVariableNames:'PrivateMethodSignal LastFileReference LastSourceFileName |
17 LastWhoClass LastFileLock LastMethodSources LastMethodSourcesLock |
17 LastWhoClass LastFileLock LastMethodSources LastMethodSourcesLock |
18 CompilationLock' |
18 CompilationLock' |
19 poolDictionaries:'' |
19 poolDictionaries:'' |
20 category:'Kernel-Methods' |
20 category:'Kernel-Methods' |
21 ! |
21 ! |
22 |
22 |
23 Object subclass:#MethodWhoInfo |
23 Object subclass:#MethodWhoInfo |
24 instanceVariableNames:'myClass mySelector' |
24 instanceVariableNames:'myClass mySelector' |
25 classVariableNames:'' |
25 classVariableNames:'' |
26 poolDictionaries:'' |
26 poolDictionaries:'' |
27 privateIn:Method |
27 privateIn:Method |
28 ! |
28 ! |
29 |
29 |
30 !Method class methodsFor:'documentation'! |
30 !Method class methodsFor:'documentation'! |
31 |
31 |
32 copyright |
32 copyright |
128 is equivalent to #methodsFor: (also to support fileIn of ENVY methods). |
128 is equivalent to #methodsFor: (also to support fileIn of ENVY methods). |
129 |
129 |
130 Protected methods may be executed only when called via a self-send |
130 Protected methods may be executed only when called via a self-send |
131 from the superclass-methods and self or super-sends from methods in the |
131 from the superclass-methods and self or super-sends from methods in the |
132 class itself or subclasses. |
132 class itself or subclasses. |
133 Private methods may not be called from subclasses-methods, |
133 Private methods may not be called from subclasses-methods, |
134 i.e. they may only be called via self sends from within the current class. |
134 i.e. they may only be called via self sends from within the current class. |
135 (i.e. protected methods are less private than private ones) |
135 (i.e. protected methods are less private than private ones) |
136 |
136 |
137 When such a situation arises, the VM (runtime system) will raise the |
137 When such a situation arises, the VM (runtime system) will raise the |
138 PrivateMethodSignal exception (if nonNil), which usually brings you into the |
138 PrivateMethodSignal exception (if nonNil), which usually brings you into the |
141 If PrivateMethodSignal is nil, the VM will not check for this, and |
141 If PrivateMethodSignal is nil, the VM will not check for this, and |
142 execution is as usual. (you may want to nil-it for production code, |
142 execution is as usual. (you may want to nil-it for production code, |
143 and leave it non nil during development). |
143 and leave it non nil during development). |
144 |
144 |
145 NOTICE: there is no (not yet ?) standard defined for method privacy, |
145 NOTICE: there is no (not yet ?) standard defined for method privacy, |
146 however, the definition protocol was designed to be somewhat ENVY compatible |
146 however, the definition protocol was designed to be somewhat ENVY compatible |
147 (from what can be deduced by reading PD code). |
147 (from what can be deduced by reading PD code). |
148 |
148 |
149 Also, the usability of privacy is still to be tested. |
149 Also, the usability of privacy is still to be tested. |
150 This interface, the implementation and the rules for when a privacy violation |
150 This interface, the implementation and the rules for when a privacy violation |
151 may change (in case of some ANSI standard being defined). |
151 may change (in case of some ANSI standard being defined). |
229 (nA := aSelector numArgs) == 1 ifTrue:[ |
229 (nA := aSelector numArgs) == 1 ifTrue:[ |
230 argNames := #('arg') |
230 argNames := #('arg') |
231 ] ifFalse:[ |
231 ] ifFalse:[ |
232 argNames := (1 to:nA) collect:[:i | 'arg' , i printString]. |
232 argNames := (1 to:nA) collect:[:i | 'arg' , i printString]. |
233 ]. |
233 ]. |
234 ^ self |
234 ^ self |
235 methodDefinitionTemplateForSelector:aSelector |
235 methodDefinitionTemplateForSelector:aSelector |
236 andArgumentNames:argNames. |
236 andArgumentNames:argNames. |
237 |
237 |
238 " |
238 " |
239 Method methodDefinitionTemplateForSelector:#foo |
239 Method methodDefinitionTemplateForSelector:#foo |
240 Method methodDefinitionTemplateForSelector:#+ |
240 Method methodDefinitionTemplateForSelector:#+ |
241 Method methodDefinitionTemplateForSelector:#foo:bar:baz: |
241 Method methodDefinitionTemplateForSelector:#foo:bar:baz: |
242 " |
242 " |
243 ! |
243 ! |
244 |
244 |
245 methodDefinitionTemplateForSelector:aSelector andArgumentNames:argNames |
245 methodDefinitionTemplateForSelector:aSelector andArgumentNames:argNames |
246 "given a selector, return a prototype definition string" |
246 "given a selector, return a prototype definition string" |
247 |
247 |
248 aSelector numArgs > 0 ifTrue:[ |
248 aSelector numArgs > 0 ifTrue:[ |
249 aSelector isKeyword ifTrue:[ |
249 aSelector isKeyword ifTrue:[ |
250 ^ String streamContents:[:stream | |
250 ^ String streamContents:[:stream | |
251 aSelector keywords with:argNames do:[:eachKeyword :eachArgName| |
251 aSelector keywords with:argNames do:[:eachKeyword :eachArgName| |
252 stream nextPutAll:eachKeyword; nextPutAll:eachArgName; space. |
252 stream nextPutAll:eachKeyword; nextPutAll:eachArgName; space. |
253 ]. |
253 ]. |
254 stream backStep. "remove the last space" |
254 stream backStep. "remove the last space" |
255 ]. |
255 ]. |
256 ]. |
256 ]. |
257 ^ aSelector , ' ' , (argNames at:1) |
257 ^ aSelector , ' ' , (argNames at:1) |
258 ]. |
258 ]. |
259 ^ aSelector |
259 ^ aSelector |
260 |
260 |
261 " |
261 " |
262 Method methodDefinitionTemplateForSelector:#foo andArgumentNames:#() |
262 Method methodDefinitionTemplateForSelector:#foo andArgumentNames:#() |
263 Method methodDefinitionTemplateForSelector:#+ andArgumentNames:#('aNumber') |
263 Method methodDefinitionTemplateForSelector:#+ andArgumentNames:#('aNumber') |
264 Method methodDefinitionTemplateForSelector:#foo:bar:baz: andArgumentNames:#('fooArg' 'barArg' 'bazArg') |
264 Method methodDefinitionTemplateForSelector:#foo:bar:baz: andArgumentNames:#('fooArg' 'barArg' 'bazArg') |
265 " |
265 " |
266 ! |
266 ! |
267 |
267 |
268 methodPrivacySupported |
268 methodPrivacySupported |
269 "return true, if the system was compiled to support methodPrivacy. |
269 "return true, if the system was compiled to support methodPrivacy. |
336 cls := self mclass. |
336 cls := self mclass. |
337 cls notNil ifTrue:[ |
337 cls notNil ifTrue:[ |
338 cls addChangeRecordForMethodCategory:self category:newCategory. |
338 cls addChangeRecordForMethodCategory:self category:newCategory. |
339 self changed:#category with:oldCategory. "/ will vanish |
339 self changed:#category with:oldCategory. "/ will vanish |
340 cls changed:#organization with:self selector. "/ will vanish |
340 cls changed:#organization with:self selector. "/ will vanish |
341 Smalltalk changed:#methodCategory with:(Array with:cls with:self with:oldCategory). |
341 Smalltalk changed:#methodCategory with:(Array with:cls with:self with:oldCategory). |
342 ] |
342 ] |
343 ] |
343 ] |
344 ] |
344 ] |
345 |
345 |
346 "Modified: / 25-09-2007 / 16:15:24 / cg" |
346 "Modified: / 25-09-2007 / 16:15:24 / cg" |
347 ! |
347 ! |
348 |
348 |
349 comment |
349 comment |
350 "return the methods comment. |
350 "return the methods comment. |
351 This is done by searching for and returning the first comment |
351 This is done by searching for and returning the first comment |
352 from the methods source (excluding any double-quotes). |
352 from the methods source (excluding any double-quotes). |
353 Returns nil if there is no comment (or source is not available)." |
353 Returns nil if there is no comment (or source is not available)." |
354 |
354 |
355 |src comment comments parser| |
355 |src comment comments parser| |
356 |
356 |
357 src := self source. |
357 src := self source. |
639 "return true, if this is an ignored method. |
639 "return true, if this is an ignored method. |
640 Ignored methods are physically present in the source file, |
640 Ignored methods are physically present in the source file, |
641 but no code is generated for it by stc, and the VM does not see |
641 but no code is generated for it by stc, and the VM does not see |
642 it in its message lookup. |
642 it in its message lookup. |
643 (i.e. setting a method to #ignored, and sending that selector, |
643 (i.e. setting a method to #ignored, and sending that selector, |
644 leads to either the superclasses implementation to be called, |
644 leads to either the superclasses implementation to be called, |
645 or a doesNotUnderstand exception to be raised) |
645 or a doesNotUnderstand exception to be raised) |
646 |
646 |
647 Notice: this is a nonstandard feature, not supported |
647 Notice: this is a nonstandard feature, not supported |
648 by other smalltalk implementations and not specified in the ANSI spec. |
648 by other smalltalk implementations and not specified in the ANSI spec. |
649 |
649 |
732 !Method privateMethodsFor:'accessing-visibility'! |
732 !Method privateMethodsFor:'accessing-visibility'! |
733 |
733 |
734 primSetPrivacy:aSymbol |
734 primSetPrivacy:aSymbol |
735 "set the methods access rights (privacy) from a symbol; |
735 "set the methods access rights (privacy) from a symbol; |
736 Currently, this must be one of #private, #protected, #public or #ignored. |
736 Currently, this must be one of #private, #protected, #public or #ignored. |
737 #setPrivacy: simply sets the attribute. When changing methods, that |
737 #setPrivacy: simply sets the attribute. When changing methods, that |
738 have already been called, #privacy: should be used. |
738 have already been called, #privacy: should be used. |
739 |
739 |
740 Notice: method privacy is a nonstandard feature, not supported |
740 Notice: method privacy is a nonstandard feature, not supported |
741 by other smalltalk implementations and not specified in the ANSI spec. |
741 by other smalltalk implementations and not specified in the ANSI spec. |
742 If at all, use it for debugging purposes, to catch messagesends |
742 If at all, use it for debugging purposes, to catch messagesends |
844 |
844 |
845 self changed:#privacy. "/ will vanish |
845 self changed:#privacy. "/ will vanish |
846 myClass notNil ifTrue:[ |
846 myClass notNil ifTrue:[ |
847 mySelector notNil ifTrue:[ |
847 mySelector notNil ifTrue:[ |
848 myClass changed:#methodPrivacy with:mySelector. "/ will vanish |
848 myClass changed:#methodPrivacy with:mySelector. "/ will vanish |
849 Smalltalk changed:#privacyOfMethod with:(Array with:myClass with:self with:oldPrivacy). |
849 Smalltalk changed:#privacyOfMethod with:(Array with:myClass with:self with:oldPrivacy). |
850 myClass addChangeRecordForMethodPrivacy:self. |
850 myClass addChangeRecordForMethodPrivacy:self. |
851 ] |
851 ] |
852 ] |
852 ] |
853 ] |
853 ] |
854 |
854 |
855 "Modified: / 23-11-2006 / 17:03:20 / cg" |
855 "Modified: / 23-11-2006 / 17:03:20 / cg" |
856 ! |
856 ! |
857 |
857 |
858 restricted:aBoolean |
858 restricted:aBoolean |
859 "set or clear the flag bit stating that this method is restricted. |
859 "set or clear the flag bit stating that this method is restricted. |
860 Execution of the receiver will only be allowed if the system is not in |
860 Execution of the receiver will only be allowed if the system is not in |
861 'trap restricted mode' (-->ObjectMemory) otherise a runtime |
861 'trap restricted mode' (-->ObjectMemory) otherise a runtime |
862 error (PrivateMethodSignal) is raised. |
862 error (PrivateMethodSignal) is raised. |
863 |
863 |
864 Notice: method restriction is a nonstandard feature, not supported |
864 Notice: method restriction is a nonstandard feature, not supported |
894 ! |
894 ! |
895 |
895 |
896 setPrivacy:aSymbol |
896 setPrivacy:aSymbol |
897 "set the methods access rights (privacy) from a symbol; |
897 "set the methods access rights (privacy) from a symbol; |
898 Currently, this must be one of #private, #protected, #public or #ignored. |
898 Currently, this must be one of #private, #protected, #public or #ignored. |
899 #setPrivacy: simply sets the attribute. When changing methods, that |
899 #setPrivacy: simply sets the attribute. When changing methods, that |
900 have already been called, #privacy: should be used. |
900 have already been called, #privacy: should be used. |
901 |
901 |
902 Notice: method privacy is a nonstandard feature, not supported |
902 Notice: method privacy is a nonstandard feature, not supported |
903 by other smalltalk implementations and not specified in the ANSI spec. |
903 by other smalltalk implementations and not specified in the ANSI spec. |
904 If at all, use it for debugging purposes, to catch messagesends |
904 If at all, use it for debugging purposes, to catch messagesends |
912 ! |
912 ! |
913 |
913 |
914 setPrivacy:aSymbol flushCaches:doFlush |
914 setPrivacy:aSymbol flushCaches:doFlush |
915 "set the methods access rights (privacy) from a symbol; |
915 "set the methods access rights (privacy) from a symbol; |
916 Currently, this must be one of #private, #protected, #public or #ignored. |
916 Currently, this must be one of #private, #protected, #public or #ignored. |
917 #setPrivacy: simply sets the attribute. When changing methods, that |
917 #setPrivacy: simply sets the attribute. When changing methods, that |
918 have already been called, #privacy: should be used. |
918 have already been called, #privacy: should be used. |
919 |
919 |
920 Notice: method privacy is a nonstandard feature, not supported |
920 Notice: method privacy is a nonstandard feature, not supported |
921 by other smalltalk implementations and not specified in the ANSI spec. |
921 by other smalltalk implementations and not specified in the ANSI spec. |
922 If at all, use it for debugging purposes, to catch messagesends |
922 If at all, use it for debugging purposes, to catch messagesends |
954 the same semantics as the receiver, but uses interpreted bytecodes. |
954 the same semantics as the receiver, but uses interpreted bytecodes. |
955 Otherwise, return the receiver. The new method is not installed in |
955 Otherwise, return the receiver. The new method is not installed in |
956 the methodDictionary of any class - just returned. |
956 the methodDictionary of any class - just returned. |
957 If the method contains primitive code, this may return a method |
957 If the method contains primitive code, this may return a method |
958 without bytecode. |
958 without bytecode. |
959 Can be used to obtain a bytecode version of a machine-code method, |
959 Can be used to obtain a bytecode version of a machine-code method, |
960 for binary storage or dynamic recompilation (which is not yet finished) |
960 for binary storage or dynamic recompilation (which is not yet finished) |
961 or to compile lazy methods down to executable ones." |
961 or to compile lazy methods down to executable ones." |
962 |
962 |
963 |mthd| |
963 |mthd| |
964 |
964 |
993 "Created: 24.10.1995 / 14:02:32 / cg" |
993 "Created: 24.10.1995 / 14:02:32 / cg" |
994 "Modified: 5.1.1997 / 01:01:53 / cg" |
994 "Modified: 5.1.1997 / 01:01:53 / cg" |
995 ! |
995 ! |
996 |
996 |
997 asExecutableMethod |
997 asExecutableMethod |
998 "if the receiver has neither bytecodes nor machinecode, create & return a |
998 "if the receiver has neither bytecodes nor machinecode, create & return a |
999 method having semantics as the receivers source. This may be machine code, |
999 method having semantics as the receivers source. This may be machine code, |
1000 if the system supports dynamic loading of object code and the source includes |
1000 if the system supports dynamic loading of object code and the source includes |
1001 primitive code. However, bytecode is preferred, since it compiles faster. |
1001 primitive code. However, bytecode is preferred, since it compiles faster. |
1002 Otherwise, return the receiver. The new method is not installed in |
1002 Otherwise, return the receiver. The new method is not installed in |
1003 the methodDictionary of any class - just returned. |
1003 the methodDictionary of any class - just returned. |
1137 this method if - after a class change - a method cannot be compiled |
1137 this method if - after a class change - a method cannot be compiled |
1138 and is therefore no longer executable (for example, after an instvar |
1138 and is therefore no longer executable (for example, after an instvar |
1139 has been removed, and a method still tries to access this instvar) |
1139 has been removed, and a method still tries to access this instvar) |
1140 |
1140 |
1141 Thus, we arrive here, when playing around in a classes methodArray, |
1141 Thus, we arrive here, when playing around in a classes methodArray, |
1142 or compiler/runtime system is broken :-(, |
1142 or compiler/runtime system is broken :-(, |
1143 or you ignore the error messages during some recompile." |
1143 or you ignore the error messages during some recompile." |
1144 |
1144 |
1145 %{ |
1145 %{ |
1146 /* |
1146 /* |
1147 * for reasons too far from being explained here, |
1147 * for reasons too far from being explained here, |
1458 "{ Pragma: +optSpace }" |
1458 "{ Pragma: +optSpace }" |
1459 |
1459 |
1460 "this error is triggered, if a private or protected method is called. |
1460 "this error is triggered, if a private or protected method is called. |
1461 |
1461 |
1462 If you continue in the debugger, the method will be called, |
1462 If you continue in the debugger, the method will be called, |
1463 and further privacy exceptions will NOT be reported at this call location, |
1463 and further privacy exceptions will NOT be reported at this call location, |
1464 until any new method is compiled, or the privacy of any method changes, |
1464 until any new method is compiled, or the privacy of any method changes, |
1465 or the caches are flushed. |
1465 or the caches are flushed. |
1466 (the reason is that after the continue, the method is enterred into the |
1466 (the reason is that after the continue, the method is enterred into the |
1467 calling cache, for which method privacy is not checked. |
1467 calling cache, for which method privacy is not checked. |
1468 Any of the above actions flushes this cache and a privacy check |
1468 Any of the above actions flushes this cache and a privacy check |
1669 usingCacheBoolean ifTrue:[ |
1669 usingCacheBoolean ifTrue:[ |
1670 (package notNil and:[package ~= PackageId noProjectID]) ifTrue:[ |
1670 (package notNil and:[package ~= PackageId noProjectID]) ifTrue:[ |
1671 "/ keep the last source file open, because open/close |
1671 "/ keep the last source file open, because open/close |
1672 "/ operations maybe slow on NFS-mounted file systems. |
1672 "/ operations maybe slow on NFS-mounted file systems. |
1673 "/ Since the reference to the file is weak, it will be closed |
1673 "/ Since the reference to the file is weak, it will be closed |
1674 "/ automatically if the file is not referenced for a while. |
1674 "/ automatically if the file is not referenced for a while. |
1675 "/ Neat trick. |
1675 "/ Neat trick. |
1676 |
1676 |
1677 LastFileLock critical:[ |
1677 LastFileLock critical:[ |
1678 aStream := LastFileReference at:1. |
1678 aStream := LastFileReference at:1. |
1679 (aStream isNil or:[aStream == 0 or:[aStream isOpen not]]) ifTrue:[ |
1679 (aStream isNil or:[aStream == 0 or:[aStream isOpen not]]) ifTrue:[ |
2063 funcOrNil := self externalLibraryFunction. |
2063 funcOrNil := self externalLibraryFunction. |
2064 (funcOrNil isNil or:[funcOrNil isCallTypeOLE not]) ifTrue:[^ nil]. |
2064 (funcOrNil isNil or:[funcOrNil isCallTypeOLE not]) ifTrue:[^ nil]. |
2065 ^ funcOrNil vtableIndex |
2065 ^ funcOrNil vtableIndex |
2066 |
2066 |
2067 " |
2067 " |
2068 (Method compiledMethodAt:#hasPrimitiveCode) isOLECall |
2068 (Method compiledMethodAt:#hasPrimitiveCode) isOLECall |
2069 (Method compiledMethodAt:#hasPrimitiveCode) indexOfOLECall |
2069 (Method compiledMethodAt:#hasPrimitiveCode) indexOfOLECall |
2070 |
2070 |
2071 (Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) isOLECall |
2071 (Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) isOLECall |
2072 (Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) indexOfOLECall |
2072 (Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) indexOfOLECall |
2073 (Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) isExternalLibraryFunctionCall |
2073 (Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) isExternalLibraryFunctionCall |
2074 (Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) externalLibraryFunctionCall |
2074 (Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) externalLibraryFunctionCall |
2075 |
2075 |
2076 (IUnknownPointer compiledMethodAt:#invokeAddRef) isExternalLibraryFunctionCall |
2076 (IUnknownPointer compiledMethodAt:#invokeAddRef) isExternalLibraryFunctionCall |
2077 (IUnknownPointer compiledMethodAt:#invokeAddRef) externalLibraryFunction |
2077 (IUnknownPointer compiledMethodAt:#invokeAddRef) externalLibraryFunction |
2078 (IUnknownPointer compiledMethodAt:#invokeAddRef) isOLECall |
2078 (IUnknownPointer compiledMethodAt:#invokeAddRef) isOLECall |
2079 (IUnknownPointer compiledMethodAt:#invokeAddRef) indexOfOLECall |
2079 (IUnknownPointer compiledMethodAt:#invokeAddRef) indexOfOLECall |
2080 " |
2080 " |
2081 ! |
2081 ! |
2082 |
2082 |
2083 isDocumentationMethod |
2083 isDocumentationMethod |
2084 "Return true, if this is a documentation only (only a comment) method |
2084 "Return true, if this is a documentation only (only a comment) method |
2201 messagesSent |
2201 messagesSent |
2202 "return a collection with the message selectors sent to by the receiver. |
2202 "return a collection with the message selectors sent to by the receiver. |
2203 Uses Parser to parse methods source and extract the names. |
2203 Uses Parser to parse methods source and extract the names. |
2204 The returned collection includes all used message selectors (i.e. including super-send messages)" |
2204 The returned collection includes all used message selectors (i.e. including super-send messages)" |
2205 |
2205 |
2206 ^ self parse:#'parseMethodSilent:in:' with:self mclass return:#messagesSent or:#() |
2206 ^ self parse:#'parseMethodSilent:in:' with:self mclass return:#messagesSent or:#() |
2207 |
2207 |
2208 " |
2208 " |
2209 (Method compiledMethodAt:#printOn:) messagesSent |
2209 (Method compiledMethodAt:#printOn:) messagesSent |
2210 (Point compiledMethodAt:#x:) messagesSent |
2210 (Point compiledMethodAt:#x:) messagesSent |
2211 " |
2211 " |
2212 ! |
2212 ! |
2213 |
2213 |
2214 messagesSentToSelf |
2214 messagesSentToSelf |
2215 "return a collection with the message selectors sent to self by the receiver. |
2215 "return a collection with the message selectors sent to self by the receiver. |
2216 Uses Parser to parse methods source and extract the names." |
2216 Uses Parser to parse methods source and extract the names." |
2217 |
2217 |
2218 ^ self parse:#'parseMethodSilent:in:' with:self mclass return:#messagesSentToSelf or:#() |
2218 ^ self parse:#'parseMethodSilent:in:' with:self mclass return:#messagesSentToSelf or:#() |
2219 |
2219 |
2220 ! |
2220 ! |
2221 |
2221 |
2222 messagesSentToSuper |
2222 messagesSentToSuper |
2223 "return a collection with the message selectors sent to super by the receiver. |
2223 "return a collection with the message selectors sent to super by the receiver. |
2224 Uses Parser to parse methods source and extract the names." |
2224 Uses Parser to parse methods source and extract the names." |
2225 |
2225 |
2226 ^ self parse:#'parseMethodSilent:in:' with:self mclass return:#messagesSentToSuper or:#() |
2226 ^ self parse:#'parseMethodSilent:in:' with:self mclass return:#messagesSentToSuper or:#() |
2227 |
2227 |
2228 ! |
2228 ! |
2229 |
2229 |
2230 methodArgAndVarNames |
2230 methodArgAndVarNames |
2231 "return a collection with the methods argument and variable names. |
2231 "return a collection with the methods argument and variable names. |
2348 s := self source. |
2348 s := self source. |
2349 s isNil ifTrue:[^ nil]. |
2349 s isNil ifTrue:[^ nil]. |
2350 list := HistoryManager getAllHistoriesFrom:s. |
2350 list := HistoryManager getAllHistoriesFrom:s. |
2351 list size == 0 ifTrue:[^ nil]. |
2351 list size == 0 ifTrue:[^ nil]. |
2352 histLine := list last. |
2352 histLine := list last. |
2353 ^ Timestamp |
2353 ^ Timestamp |
2354 fromDate:histLine date |
2354 fromDate:histLine date |
2355 andTime:histLine time |
2355 andTime:histLine time |
2356 |
2356 |
2357 " |
2357 " |
2358 (Method compiledMethodAt:#modificationTime) modificationTime |
2358 (Method compiledMethodAt:#modificationTime) modificationTime |
2359 (Method compiledMethodAt:#isMethod) modificationTime |
2359 (Method compiledMethodAt:#isMethod) modificationTime |
2360 " |
2360 " |
2361 |
2361 |
2362 "Modified: 8.9.1995 / 15:08:22 / claus" |
2362 "Modified: 8.9.1995 / 15:08:22 / claus" |
2363 "Modified: 4.11.1996 / 22:28:17 / cg" |
2363 "Modified: 4.11.1996 / 22:28:17 / cg" |
2364 ! |
2364 ! |
2369 ^ self selector |
2369 ^ self selector |
2370 |
2370 |
2371 "Created: / 9.11.1998 / 06:15:08 / cg" |
2371 "Created: / 9.11.1998 / 06:15:08 / cg" |
2372 ! |
2372 ! |
2373 |
2373 |
2374 parse:parseSelector return:accessSelector or:valueIfNoSource |
2374 parse:parseSelector return:accessSelector or:valueIfNoSource |
2375 "helper for methodArgNames, methodVarNames etc. |
2375 "helper for methodArgNames, methodVarNames etc. |
2376 Get the source, let parser parse it using parseSelector, |
2376 Get the source, let parser parse it using parseSelector, |
2377 return parser-info using accessSelector" |
2377 return parser-info using accessSelector" |
2378 |
2378 |
2379 ^ self parse:parseSelector with:nil return:accessSelector or:valueIfNoSource |
2379 ^ self parse:parseSelector with:nil return:accessSelector or:valueIfNoSource |
2380 |
2380 |
2381 " |
2381 " |
2382 (Method compiledMethodAt:#parse:return:or:) |
2382 (Method compiledMethodAt:#parse:return:or:) |
2383 parse:#'parseMethodSilent:' return:#sentMessages or:#() |
2383 parse:#'parseMethodSilent:' return:#sentMessages or:#() |
2384 " |
2384 " |
2385 ! |
2385 ! |
2386 |
2386 |
2387 parse:parseSelector with:arg2 return:accessSelector or:valueIfNoSource |
2387 parse:parseSelector with:arg2 return:accessSelector or:valueIfNoSource |
2388 "helper for methodArgNames, methodVarNames etc. |
2388 "helper for methodArgNames, methodVarNames etc. |
2389 Get the source, let parser parse it using parseSelector, |
2389 Get the source, let parser parse it using parseSelector, |
2390 return parser-info using accessSelector" |
2390 return parser-info using accessSelector" |
2391 |
2391 |
2392 |parser parserClass sourceString| |
2392 |parser parserClass sourceString| |
2501 cls := self mclass. |
2501 cls := self mclass. |
2502 cls isNil ifTrue:[^ #()]. |
2502 cls isNil ifTrue:[^ #()]. |
2503 |
2503 |
2504 versions := OrderedCollection new. |
2504 versions := OrderedCollection new. |
2505 |
2505 |
2506 ChangeSet current reverseDo:[:change | |
2506 ChangeSet current reverseDo:[:change | |
2507 (change isMethodChange |
2507 (change isMethodChange |
2508 and:[ (change selector == sel) |
2508 and:[ (change selector == sel) |
2509 and:[ change changeClass == cls ]]) |
2509 and:[ change changeClass == cls ]]) |
2510 ifTrue:[ |
2510 ifTrue:[ |
2511 versions addFirst:change. |
2511 versions addFirst:change. |
2512 lastChange := change. |
2512 lastChange := change. |
2513 ] |
2513 ] |
2514 ]. |
2514 ]. |
2515 |
2515 |
2516 lastChange notNil ifTrue:[ |
2516 lastChange notNil ifTrue:[ |
2517 last := lastChange previousVersion. |
2517 last := lastChange previousVersion. |
2518 last notNil ifTrue:[ |
2518 last notNil ifTrue:[ |
2519 firstSrc := last source. |
2519 firstSrc := last source. |
2520 (firstSrc size > 0 |
2520 (firstSrc size > 0 |
2521 and:[ firstSrc ~= lastChange source]) ifTrue:[ |
2521 and:[ firstSrc ~= lastChange source]) ifTrue:[ |
2522 versions addFirst:(MethodChange |
2522 versions addFirst:(MethodChange |
2523 className:lastChange className |
2523 className:lastChange className |
2524 selector:lastChange selector |
2524 selector:lastChange selector |
2525 source:firstSrc |
2525 source:firstSrc |
2526 category:lastChange category). |
2526 category:lastChange category). |
2527 ] |
2527 ] |
2528 ] |
2528 ] |
2629 |
2629 |
2630 usedGlobals |
2630 usedGlobals |
2631 "return a collection with the global names referred to by the receiver. |
2631 "return a collection with the global names referred to by the receiver. |
2632 Uses Parser to parse methods source and extract them." |
2632 Uses Parser to parse methods source and extract them." |
2633 |
2633 |
2634 ^ self parse:#'parseMethodSilent:in:' with:self mclass return:#usedGlobals or:#() |
2634 ^ self parse:#'parseMethodSilent:in:' with:self mclass return:#usedGlobals or:#() |
2635 |
2635 |
2636 " |
2636 " |
2637 (Method compiledMethodAt:#resources) usedGlobals |
2637 (Method compiledMethodAt:#resources) usedGlobals |
2638 " |
2638 " |
2639 ! |
2639 ! |
2640 |
2640 |
2641 usedSymbols |
2641 usedSymbols |
2642 "return a collection with the symbols referred to by the receiver. |
2642 "return a collection with the symbols referred to by the receiver. |
2643 Uses Parser to parse methods source and extract them. |
2643 Uses Parser to parse methods source and extract them. |
2644 This collection only includes implicit symbols references |
2644 This collection only includes implicit symbols references |
2645 (i.e. not messages sent)" |
2645 (i.e. not messages sent)" |
2646 |
2646 |
2647 ^ self parse:#'parseMethodSilent:in:' with:self mclass return:#usedSymbols or:#() |
2647 ^ self parse:#'parseMethodSilent:in:' with:self mclass return:#usedSymbols or:#() |
2648 |
2648 |
2649 " |
2649 " |
2650 (Method compiledMethodAt:#usedSymbols) usedSymbols |
2650 (Method compiledMethodAt:#usedSymbols) usedSymbols |
2651 (Method compiledMethodAt:#usedSymbols) messagesSent |
2651 (Method compiledMethodAt:#usedSymbols) messagesSent |
2652 " |
2652 " |
2653 ! |
2653 ! |
2654 |
2654 |
2655 who |
2655 who |
2656 "return the class and selector of where I am defined in; |
2656 "return the class and selector of where I am defined in; |
2657 nil is returned for unbound methods. |
2657 nil is returned for unbound methods. |
2658 |
2658 |
2659 ST/X special notice: |
2659 ST/X special notice: |
2660 returns an instance of MethodWhoInfo, which |
2660 returns an instance of MethodWhoInfo, which |
2661 responds to #methodClass and #methodSelector query messages. |
2661 responds to #methodClass and #methodSelector query messages. |
2662 For backward- (& ST-80) compatibility, the returned object also |
2662 For backward- (& ST-80) compatibility, the returned object also |
2663 responds to #at:1 and #at:2 messages. |
2663 responds to #at:1 and #at:2 messages. |
2664 |
2664 |
2665 Implementation notice: |
2665 Implementation notice: |
2666 Since there is no information of the containing class |
2666 Since there is no information of the containing class |
2667 in the method, we have to do a search here. |
2667 in the method, we have to do a search here. |
2668 |
2668 |
2669 Normally, this is not a problem, except when a method is |
2669 Normally, this is not a problem, except when a method is |
2670 accepted in the debugger or redefined from within a method |
2670 accepted in the debugger or redefined from within a method |
2671 (maybe done indirectly, if #doIt is done recursively) |
2671 (maybe done indirectly, if #doIt is done recursively) |
2672 - the information about which class the original method was |
2672 - the information about which class the original method was |
2673 defined in is lost in this case. |
2673 defined in is lost in this case. |
2674 |
2674 |
2675 Problem: |
2675 Problem: |
2676 this is heavily called for in the debugger to create |
2676 this is heavily called for in the debugger to create |
2677 a readable context walkback. For unbound methods, it is |
2677 a readable context walkback. For unbound methods, it is |
2678 slow, since the search (over all classes) will always fail. |
2678 slow, since the search (over all classes) will always fail. |
2679 |
2679 |
2680 Q: should we add a backref from the method to the class |
2680 Q: should we add a backref from the method to the class |
2681 and/or add a subclass of Method for unbound ones ? |
2681 and/or add a subclass of Method for unbound ones ? |
2682 Q2: if so, what about the bad guy then, who copies methods around to |
2682 Q2: if so, what about the bad guy then, who copies methods around to |
2683 other classes ?" |
2683 other classes ?" |
2684 |
2684 |
2685 |classes cls sel fn clsName checkBlock| |
2685 |classes cls sel fn clsName checkBlock| |