|
Class: Method
Object
|
+--ExecutableFunction
|
+--CompiledCode
|
+--Method
|
+--InstrumentedMethod
|
+--JavaScriptFunction
|
+--LazyMethod
|
+--MethodWithBreakpoints
|
+--SmalltalkShareClient::RemoteMethod
|
+--Tools::MethodCategoryList::MissingMethod
|
+--WrappedMethod
- Package:
- stx:libbasic
- Category:
- Kernel-Methods
- Version:
- rev:
1.576
date: 2024/03/11 13:43:54
- user: cg
- file: Method.st directory: libbasic
- module: stx stc-classLibrary: libbasic
this class defines protocol for executable methods;
both compiled and interpreted methods are represented by this class.
Compiled methods have a non-nil code field, while interpreted methods have
a nil code field and non-nil byteCode field.
If there are both non-nil code and bytecode fields, the VM will execute
the machine-code of a method. If both are nil when executed, a #noByteCode
message is sent (by the VM) to the method, where a signal is raised.
(or, a user defined interpreter can be invoked on the smalltalk level)
The method's sourcecode is represented by source and sourcePosition:
- if sourcePosition is a Number, the source-field is the fileName and
sourcePosition is the character offset of the source-chunk in this source file.
- If sourcePosition is nil, the source fields holds the source string.
(an old version used ExternalString instances here, but that lead to
10000's of additional little objects ...)
The flags field defines things like the number of method-locals,
method arguments and stack requirements (for interpreted methods).
Do not depend on any value in the flags field - it may change without
notice.
Notice, that in ST/X, method can be subclassed; executable code is
identified not by being an instance of Block or Method, but instead by
having the executable flag bit set in the class. The VM can execute anything
which is identified as executable (assuming that the first instance variable
is the machine-code address) - this allows for easy future extension.
Literals:
Notice that stc compiled methods do not list all of their used literals.
In fact, stc-code uses a kind of class-constant-table,
and only message-send symbols are found in the literal array.
Thus, in order to find constants (literals) used by a method,
you have to parse its source.
[Instance variables:]
source <String> the source itself (if sourcePosition isNil)
or the fileName where the source is found
sourcePosition <Integer> the position of the method's chunk in the file
category <Symbol> the method's category
package <Symbol> the package, in which the method was defined
mclass <Class> the class in which I am defined
indexed slots literals
[Class variables:]
PrivateMethodSignal raised on privacy violation (see docu)
LastFileReference weak reference to the last sourceFile
LastSourceFileName to speedup source access via NFS
WARNING: layout known by compiler and runtime system - don't change
copyrightCOPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
dynamicMethodsOn systems which support dynamic loading of stc-compiled machine code (SYS5.4, Linux),
methods may now be compiled to machine code from within the browser,
and the resulting machine code object be loaded in.
The ObjectFileLoader keeps (weak) handles to the resulting methods and
invalidates the corresponding method objects, if the underlying methods
object code is unloaded.
Invalid methods will trap into the debugger when executed;
also, the browser marks them as '(* not executable *)' in its method list.
Notice: this has nothing to do with JIT compilation, which is always possible.
JIT-compilation is done from bytecodes to a machineCode cache.
In contrast, dynamic loading of stc-compiled code goes via intermediate C-code
which is compiled by the machines native C-compiler.
As opposed to JITted code, this allows for embedded primitive C-code.
privacyST/X includes an EXPERIMENTAL implementation of method privacy.
Individual methods may be set to private or protected via the
privacy:#private and privacy:#protected messages. Also, categories may be
filedIn as a whole as private using #privateMethodsFor: or as
protected using #protectedMethodsFor: instead of the well known #methodsFor:.
The additional #publicMethodsFor: is for documentation purposes, and
is equivalent to #methodsFor: (also to support fileIn of ENVY methods).
Protected methods may be executed only when called via a self-send
from the superclass-methods and self or super-sends from methods in the
class itself or subclasses.
Private methods may not be called from subclasses-methods,
i.e. they may only be called via self sends from within the current class.
(i.e. protected methods are less private than private ones)
When such a situation arises, the VM (runtime system) will raise the
PrivateMethodSignal exception (if nonNil), which usually brings you into the
debugger.
If PrivateMethodSignal is nil, the VM will not check for this, and
execution is as usual. (you may want to nil-it for production code,
and leave it non nil during development).
NOTICE: there is no (not yet?) standard defined for method privacy,
however, the definition protocol was designed to be somewhat ENVY compatible
(from what can be deduced by reading PD code).
Also, the usability of privacy is still to be tested.
This interface, the implementation and the rules for when a privacy violation
may change (in case of some ANSI standard being defined).
Be warned and send me suggestions & critics (constructive ;-)
Late note (Feb 2000):
the privacy feature has now been in ST/X for some years and was NOT heavily
used - neither at eXept, nor by customers.
In Smalltalk, it seems to be a very questionable feature, actually limiting
code reusability.
The privacy features are left in the system to demonstrate that it can be
done in Smalltalk (for religious C++ fans ... to avoid useless discussions)
(the check is not expensive, w.r.t. the VM runtime behavior).
Signal constants
-
privateMethodSignal
-
return the signal raised when a private/protected method is called
by some other object (i.e. not a self- or super send)
-
skipSourcecodeManagerQuery
-
cleanup
-
lowSpaceCleanup
-
cleanup in low-memory situations
initialization
-
initialize
-
create signals
queries
-
binarySelectorCharacters
-
return a collection of characters which are allowed in binary selectors
-
imageResourceTypes
-
get the types of resources which generate an image
(that is the resource-annotation keys of those)
-
isBuiltInClass
-
return true if this class is known by the run-time-system.
Here, true is returned for myself, false for subclasses.
-
maxBinarySelectorSize
-
in ST/X, binops are allowed with up-to 3 characters;
for example:
<->
<=>
+++
:=:
etc. are valid binOps here
-
methodDefinitionTemplateForSelector: aSelector
-
given a selector, return a prototype definition string
Usage example(s):
Method methodDefinitionTemplateForSelector:#foo
Method methodDefinitionTemplateForSelector:#+
Method methodDefinitionTemplateForSelector:#foo:bar:baz:
|
-
methodDefinitionTemplateForSelector: aSelector andArgumentNames: argNames
-
given a selector, return a prototype definition string
Usage example(s):
Method methodDefinitionTemplateForSelector:#foo andArgumentNames:#()
Method methodDefinitionTemplateForSelector:#+ andArgumentNames:#('aNumber')
Method methodDefinitionTemplateForSelector:#foo:bar:baz: andArgumentNames:#('fooArg' 'barArg' 'bazArg')
|
-
methodPrivacySupported
-
return true, if the system was compiled to support methodPrivacy.
You should not depend on that feature being available.
-
resourceTypes
-
get the types of resources for which a spec definition and corresponding editor exist
special
-
flushParseTreeCache
-
used by lint and the compiler
Usage example(s):
Method flushParseTreeCache
|
-
flushSourceStreamCache
-
Method flushSourceStreamCache
trap methods
-
trapMethodForNumArgs: numArgs
-
return a method which will raise an invalid code object exception.
Before recompiling methods (due to changed variable scopes, for example),
all method's code is replaced by this. If recompilation fails, this code
remains in the method to make it trap, whenever executed later.
Otherwise, if recompilation succeeds, that code will vanish after the compile
Usage example(s):
self trapMethodForNumArgs:2
|
Compatibility-Squeak
-
isCompiledMethod
-
(comment from inherited method)
same as isMethod - for squeak compatibility
-
numTemps
( an extension from the stx:libcompat package )
-
-
pragmaAt: aKey
-
-
pragmas
-
for squeak compatibility, we only present real pragmas
-
propertyValueAt: aKey
-
for now - no properties
-
sourceCode
-
-
timeStamp
( an extension from the stx:libcompat package )
-
Compatibility-VW
-
attributeAt: aSymbol ifAbsent: exceptionValue
-
-
attributeMessages
-
-
classIsMeta
-
return true, if this method is a class method
-
protocol
-
called 'category' here
RefactoringBrowser
-
equivalentTo: aCompiledMethod
( an extension from the stx:goodies/refactoryBrowser/parser package )
-
accessing
-
category
-
return the method's category or nil
-
category: aStringOrSymbol
-
set the method's category
-
comment
-
return the method's comment.
This is done by searching for and returning the first comment
from the method's source (excluding any double-quotes).
Returns nil if there is no comment (or source is not available).
Usage example(s):
(Method compiledMethodAt:#comment) comment
(Object class compiledMethodAt:#infoPrinting:) comment
|
Usage example(s):
Modified (comment): / 21-11-2017 / 13:03:59 / cg
|
-
getMclass
-
return the last known class in which this method was (or still is) contained in.
Notice, that the mclass query returns nil, if a method is wrapped or no longer valid
due to an accept in a browser or debugger. However, the mclass slot still contains a
reference to the once valid class
-
getPackage
-
return the package-ID of the method
-
getSource
-
low-level access to the source instance-variable.
For internal (compiler) use only.
This is NOT always the method's source string,
but may also be the source file name (if pos is non-nil)
-
getSourcePosition
-
low-level access to the sourcePosition instance-variable.
For internal (compiler) use only.
This is NOT always the method's sourcePosition
(it may be nil, if the source is in memory)
-
localSourceFilename: aFileNameOrString position: aNumber
-
set the method's sourcefile/position indicating, that
this is a local file (i.e. the 'st.src' file).
The indicator for this is a negative source position.
-
lookupObject
-
lookupObject isNil ifTrue:[^ BuiltinLookup instance "Lookup builtin"].
-
lookupObject: anObject
-
-
makeLocalStringSource
-
assure that the method's source code is stored locally as a string
within the method (as opposed to an external string, which is accessed
by reading the source code file).
This is required, when a method's package is changed, to assure that its
sourceCode is not lost.
-
mclass: aClass
-
set the method's class. That is the class in which I am installed.
This is a cache; the validity of which will be checked and the cache
possibly be invalidated when mclass is asked for.
-
nameSpace
-
Returns my namespace or nil. If no explicit method namespace
is set, my programming language is used as default namespace
(for compatibility reasons, nil is returned for smalltalk methods,
which means that the method is not namespaced).
Usage example(s):
(Method >> #nameSpace) nameSpace
(Object >> #yourself) nameSpace
|
-
nameSpace: aNameSpace
-
-
nameSpaceName
-
-
originalMethodIfWrapped
-
return the method the receiver is wrapping - none here
-
overriddenMethod
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
overriddenMethod: aMethod
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
overwrittenMethod
-
Answers overridden method or nil.
-
overwrittenMethod: aMethod
-
Set overridden method to aMethod
-
package
-
return the package-symbol of the method (nil is translated to noProject here)
-
package: aSymbol
-
set the package-symbol
-
setCategory: aStringOrSymbol
-
set the method's category (without change notification)
-
setPackage: aSymbol
-
set the package-symbol (low level - use package:)
-
setSource: aString
-
set the method's source
-
setSource: aString setSourcePosition: aNumberOrNil
-
set the method's source
-
source
-
return the sourcestring for the receiver.
Return nil, if we do not know the source.
Usage example(s):
if sourcePosition is nonNil, its the fileName and abs(sourcePosition) is the offset.
Otherwise, source is the real source
|
Usage example(s):
nonNil sourcePosition: source contains filename - if nil, no source
|
Usage example(s):
have to protect sourceStream from being closed as a side effect
of some other process fetching some the source from a different source file
|
Usage example(s):
take care if LastFileLock is not available - maybe we are
called by a debugger while someone holds the lock.
Use uncached source streams
|
Usage example(s):
Cache the source of recently used methods
|
-
source: aString
-
set the method's source string
-
sourceFilename
-
return the sourcefilename if source is extern; nil otherwise
-
sourceFilename: aFileNameOrString position: aNumberOrNil
-
set the method's sourcefile/position (position not nil),
or the method's source string (position is nil)
-
sourceLineNumber
-
return the lineNumber of my source within the returned
source sourcestring.
For ST methods, the returned sourceString is always the
methods pure source; therefore, the lineNumber is always 1.
-
sourcePosition
-
return the sourceposition if source is extern; nil otherwise
accessing-annotations
-
annotateWith: annotation
-
add a (hidden) annotation.
This is only present in the image, not in the method's source code
Usage example(s):
(Object >> #yourself) annotateWith: (Annotation namespace: 'Fictious').
(Object >> #yourself) annotations.
(Object >> #yourself) annotationAt: #namespace:
|
-
annotationAt: key
-
(Object >> #yourself) annotationAt: #namespace:
(WindowsAutomation2::Client >> #stopRecording) annotationAt: #foreignSelectors:
-
annotations
-
return (a copy) of the annotations array.
Convert stc generated Array annotations to Annotation objects on the fly.
-
annotations: anObject
-
set the annotations
-
annotationsAt: key
-
-
annotationsAt: key do: block
-
-
annotationsAt: key1 orAt: key2
-
-
annotationsAt: key1 orAt: key2 do: block
-
-
annotationsDo: aBlock
-
accessing-visibility
-
isIgnored
-
return true, if this is an ignored method.
Ignored methods are physically present in the source file,
but no code is generated for it by stc, and the VM does not see
it in its message lookup.
(i.e. setting a method to #ignored, and sending that selector,
leads to either the superclasses implementation to be called,
or a doesNotUnderstand exception to be raised)
Notice: this is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
-
isPrivate
-
return true, if this is a private method.
Execution of private methods is only allowed via self sends
from superclasses or the class itself.
If a private method is called by some other class, a runtime
error (PrivateMethodSignal) is raised.
Notice: method privacy is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
-
isProtected
-
return true, if this is a protected method.
Execution of protected methods is only allowed via self/super sends
from superclasses, the class itself or subclasse.
If a protected method is called by some other class, a runtime
error (PrivateMethodSignal) is raised.
Notice: method privacy is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
-
isPublic
-
return true, if this is a public method - I.e. can be executed via any send.
This is the default and how other smalltalk implementations treat all methods.
Notice: method privacy is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
-
isRestricted
-
return the flag bit stating that this method is restricted.
Execution of the receiver will only be allowed if the system is not in
'trap restricted mode' (-->ObjectMemory) otherise a runtime
error (PrivateMethodSignal) is raised.
Notice: method restriction is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
-
private primSetPrivacy: aSymbol
-
set the methods access rights (privacy) from a symbol;
Currently, this must be one of #private, #protected, #public or #ignored.
#setPrivacy: simply sets the attribute. When changing methods, that
have already been called, #privacy: should be used.
Notice: method privacy is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
If at all, use it for debugging purposes, to catch messagesends
which are not supposed to be sent by others.
(especially, if working in a team, while integrating other peoples work)
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
-
privacy
-
return a symbol describing the methods access rights (privacy);
Currently, this is one of #private, #protected, #public or #ignored.
Notice: method privacy is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
If at all, use it for debugging purposes, to catch messagesends
which are not supposed to be sent by others.
(especially, if working in a team, while integrating other peoples work)
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
-
privacy: aSymbol
-
set the method's access rights (privacy) from a symbol;
Currently, this must be one of #private, #protected, #public or #ignored.
Notice: method privacy is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
If at all, use it for debugging purposes, to catch message sends
which are not supposed to be sent by others.
(especially, if working in a team, while integrating other peoples work)
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
-
restricted: aBoolean
-
set or clear the flag bit stating that this method is restricted.
Execution of the receiver will only be allowed if the system is not in
'trap restricted mode' (-->ObjectMemory) otherise a runtime
error (PrivateMethodSignal) is raised.
Notice: method restriction is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
Usage example(s):
(ObjectMemory class compiledMethodAt:#compressingGarbageCollect) restricted:true
|
-
setPrivacy: aSymbol
-
set the method's access rights (privacy) from a symbol;
Currently, this must be one of #private, #protected, #public or #ignored.
#setPrivacy: simply sets the attribute.
When changing methods which have already been called, #privacy: should be used.
Notice: method privacy is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
If at all, use it for debugging purposes, to catch messagesends
which are not supposed to be sent by others.
(especially, if working in a team, while integrating other peoples work)
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
-
setPrivacy: aSymbol flushCaches: doFlush
-
set the method's access rights (privacy) from a symbol;
Currently, this must be one of #private, #protected, #public or #ignored.
#setPrivacy: simply sets the attribute. When changing methods, that
have already been called, #privacy: should be used.
Notice: method privacy is a nonstandard feature, not supported
by other Smalltalk implementations and not specified in the ANSI spec.
If at all, use it for debugging purposes, to catch message sends
which are not supposed to be sent by others.
(especially, if working in a team, while integrating other peoples work)
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
binary storage
-
asByteCodeMethod
-
if the receiver has no bytecodes, create & return a method having
the same semantics as the receiver, but uses interpreted bytecodes.
Otherwise, return the receiver. The new method is not installed in
the methodDictionary of any class - just returned.
If the method contains primitive code, this may return a method
without bytecode.
Can be used to obtain a bytecode version of a machine-code method,
for binary storage or dynamic recompilation (which is not yet finished)
or to compile lazy methods down to executable ones.
-
asByteCodeMethodWithSource: newSource
-
-
asExecutableMethod
-
if the receiver has neither bytecodes nor machinecode, create & return a
method having semantics as the receiver's source. This may be machine code,
if the system supports dynamic loading of object code and the source includes
primitive code. However, bytecode is preferred, since it compiles faster.
Otherwise, return the receiver. The new method is not installed in
the methodDictionary of any class - just returned.
Can be used to compile lazy methods down to executable ones.
-
asExecutableMethodWithSource: newSource
-
we have to sequentialize this using a lock-semaphore,
to make sure only one method is compiled at a time.
Otherwise, we might get into trouble, if (due to a timeout)
another recompile is forced while compiling this one ...
(happened when autoloading animation demos)
copying
-
copy
-
redefined to change a source ref into a real string
error handling
-
interpretWithReceiver: aReceiver arguments: anArray
-
this method must be redefined as stated in a superclass
-
invalidCodeObject
-
this method is triggered by the interpreter when a nil or non method
is about to be executed.
In this case, the VM sends this to the bad method (the receiver).
Also, the Compiler creates methods with their code/bytecode set to
this method if - after a class change - a method cannot be compiled
and is therefore no longer executable (for example, after an instvar
has been removed, and a method still tries to access this instvar)
Thus, we arrive here, when playing around in a classes methodArray,
or compiler/runtime system is broken :-(,
or you ignore the error messages during some recompile.
-
invalidCodeObjectWith: arg
-
When recompiling classes after a definition-change, all
uncompilable methods (with 2 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2
-
When recompiling classes after a definition-change, all
uncompilable methods (with 2 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2 with: arg3
-
When recompiling classes after a definition-change, all
uncompilable methods (with 3 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2 with: arg3 with: arg4
-
When recompiling classes after a definition-change, all
uncompilable methods (with 4 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2 with: arg3 with: arg4 with: arg5
-
When recompiling classes after a definition-change, all
uncompilable methods (with 5 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2 with: arg3 with: arg4 with: arg5 with: arg6
-
When recompiling classes after a definition-change, all
uncompilable methods (with 6 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2 with: arg3 with: arg4 with: arg5 with: arg6 with: arg7
-
When recompiling classes after a definition-change, all
uncompilable methods (with 7 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2 with: arg3 with: arg4 with: arg5 with: arg6 with: arg7 with: arg8
-
When recompiling classes after a definition-change, all
uncompilable methods (with 8 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2 with: arg3 with: arg4 with: arg5 with: arg6 with: arg7 with: arg8 with: arg9
-
When recompiling classes after a definition-change, all
uncompilable methods (with 9 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2 with: arg3 with: arg4 with: arg5 with: arg6 with: arg7 with: arg8 with: arg9 with: arg10
-
When recompiling classes after a definition-change, all
uncompilable methods (with 10 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2 with: arg3 with: arg4 with: arg5 with: arg6 with: arg7 with: arg8 with: arg9 with: arg10 with: arg11
-
When recompiling classes after a definition-change, all
uncompilable methods (with 11 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
invalidCodeObjectWith: arg with: arg2 with: arg3 with: arg4 with: arg5 with: arg6 with: arg7 with: arg8 with: arg9 with: arg10 with: arg11 with: arg12
-
When recompiling classes after a definition-change, all
uncompilable methods (with 12 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
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
-
When recompiling classes after a definition-change, all
uncompilable methods (with 13 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
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
-
When recompiling classes after a definition-change, all
uncompilable methods (with 14 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
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
-
When recompiling classes after a definition-change, all
uncompilable methods (with 15 args) will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
-
privateMethodCalled
-
this error is triggered, if a private or protected method is called.
If you continue in the debugger, the method will be called,
and further privacy exceptions will NOT be reported at this call location,
until any new method is compiled, or the privacy of any method changes,
or the caches are flushed.
(the reason is that after the continue, the method is entered into the
calling cache, for which method privacy is not checked.
Any of the above actions flushes this cache and a privacy check
is performed again.)
Future versions may not enter private methods into the cache, to fix this
(unobvious) behavior. However, then you will get an exception for EVERY
call to a private method ...
Notice: method privacy is a nonstandard feature, not supported
by other smalltalk implementations and not specified in the ANSI spec.
This is EXPERIMENTAL - and being evaluated for usability.
It may change or even vanish (if it shows to be not useful).
-
uncompiledCodeObject
-
this method is invoked by methods which contain primitive code,
but have not been compiled to machine code (either due to an error
when compiling, or simply because no stc is available.
For those methods, the compiler generated a method object consisting
of the original source code, but with this methods machine/byte code.
-
unloadedCodeObject
-
this method is invoked by methods which have been binary-unloaded
For those the source info consists
of the original source code, but with this methods machine/byte code.
inspecting
-
inspectorExtraAttributes
( an extension from the stx:libtool package )
-
extra (pseudo instvar) entries to be shown in an inspector.
Usage example(s):
(Method compiledMethodAt:#inspectorExtraAttributes) inspect
|
-
inspectorExtraMenuOperations
( an extension from the stx:libtool package )
-
extra (pseudo instvar) entries to be shown in an inspector.
printing & storing
-
printOn: aStream
-
put a printed representation of the receiver onto aStream.
Since methods do not store their class/selector, we have to search
for it here.
Usage example(s):
(Object compiledMethodAt:#at:) printOn:Transcript. Transcript cr.
(Object compiledMethodAt:#at:) copy printOn:Transcript. Transcript cr.
(Object compiledMethodAt:#at:) whoString printOn:Transcript. Transcript cr.
(Object compiledMethodAt:#at:) copy whoString printOn:Transcript. Transcript cr.
|
-
printStringForBrowserWithSelector: selector inClass: aClass
( an extension from the stx:libtool package )
-
return a printString to represent myself to the user in a browser.
Defined here to allow for browsers to deal with nonStandard pseudoMethods
-
selectorPrintStringInBrowserFor: selector
( an extension from the stx:libtool package )
-
-
selectorPrintStringInBrowserFor: selector class: aClass
( an extension from the stx:libtool package )
-
nsPart := selector copyFrom:2 to:idx-1.
ns := Smalltalk at:nsPart asSymbol.
-
whoString
-
return a string as className>>selector, if this is not an unbound
method.
Otherwise return 'unbound'. Used with debugging.
Usage example(s):
Method new whoString
(Method compiledMethodAt:#whoString) whoString
|
-
whoStringWith: sepString
-
return a string like className>>selector, where '>>' is replaced by sepString.
If this is an unbound method, return 'unbound'.
Used with debugging.
Usage example(s):
Method new whoStringWith:' >> '
(Method compiledMethodAt:#whoString) whoStringWith:' >> '
(Method compiledMethodAt:#whoString) whoStringWith:' ยป '
(Method compiledMethodAt:#whoString) whoStringWith:' -> '
|
private
-
annotationAtIndex: index
-
return the annotation at given index.
any raw annotation array (as generated by the stc compiler)
is lazily initialized from the 2-element format to real annotation instances here.
This is done to avoid the need for knowledge about annotation instances in the stc compiler.
-
annotationIndexOf: key
-
Returns the index of annotation with given key
or nil if there is no such annotation.
Handle both annotations as generated by STC (Arrays).
and Annotation objects.
-
cacheSourceStream: aStream
-
remember a (raw) source stream for later use
-
getAnnotations
-
-
getLookupObject
-
-
localSourceStream
-
try to open a stream from a local source file,
searching in standard places.
Returns either an open stream or nil
-
rawSourceStreamUsingCache: usingCacheBoolean
-
return an open sourceStream (needs positioning).
If usingCacheBoolean is true, cache the stream (but take care against concurrent access).
You have to close the stream, if usingCacheBoolean is false, and should not close it
if usingCacheBoolean is true.
-
setAnnotations: anObject
-
set the annotations (low level - do not use)
-
setLookupObject: lookup
-
set the lookupObject (low level - use lookupObject:)
-
sourceChunkFromStream: aStream
-
-
sourceStreamUsingCache: usingCacheBoolean
-
return an open sourceStream (needs positioning).
If usingCacheBoolean is true, cache the stream (but take care against concurrent access).
You have to close the stream, if usingCacheBoolean is false,
and should not close it if usingCacheBoolean is true.
private-compiler interface
-
hasPrimitiveCode
-
true if I have primitive code.
-
primitiveNumber
-
for stx rel >= 5.x only:
return the primitive number.
-
setPrimitiveNumber: aNumber
-
for stx rel >= 5.x only:
mark the method as having primitive code.
-
setResourceFlag
-
mark the method as having a <resource> definition in its
source. This flag can be used to find resource-flagged methods quicker.
queries
-
accessedInstVars
-
return a collection of instVarNames, which are accessed by
the receiver method
-
accessesField: instVarIndex
-
return true, if the instvar at instVarIndex is accessed by the receiver.
Uses parser (for now); could look at bytecode as well here...
-
accessesInstVar: instVarName
-
return true, if the named instvar is accessed by the receiver.
Uses parser (for now); could look at bytecode as well here...
-
containingClass
-
return the class I am defined in.
Notice, that the containingClass query returns nil, if a method is wrapped or no longer valid
due to an accept in a browser or debugger.
However, the mclass slot still contains a reference to the once valid class and can be fetched
via getMclass.
See comment in who.
Usage example(s):
(Object compiledMethodAt:#at:) containingClass
(Object class compiledMethodAt:#version) containingClass
|
-
evaluatorClass
-
-
externalLibraryFunction
-
if this is an externalLibraryFunction call, return the externalLibraryFunction.
Returns nil otherwise.
Usage example(s):
(IDispatchPointer compiledMethodAt:#'invokeGetTypeInfo:_:_:')
externalLibraryFunction
|
-
hasAnnotation
-
Return true iff the method has any annotation
-
hasAnnotation: key
-
Return true iff the method is annotated with the given key
-
hasAnyResource: aCollectionOfSymbols
-
return true if the method has a <resource> definition for any symbol in aCollectionOfSymbols
Usage example(s):
Method allInstancesDo:[:m |
(m hasAnyResource:#(image canvas)) ifTrue:[self halt]
].
|
-
hasPrimitiveCodeInSource
-
return true, if the method contains primitive code; false if not.
Uses Parser to parse methods source and get the information.
-
hasResource
-
return true if the method had a <resource> definition in its
source. This flag can be used to find resource-flagged methods quicker.
-
hasSource
-
answer true, if there is sourcecode present for the receiver
-
indexOfOLECall
-
return the vtable inedx, if the method contains an ole call; nil if not.
Uses Parser to parse methods source and get the information.
Usage example(s):
(Method compiledMethodAt:#hasPrimitiveCode) isOLECall
(Method compiledMethodAt:#hasPrimitiveCode) indexOfOLECall
(Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) isOLECall
(Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) indexOfOLECall
(Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) isExternalLibraryFunctionCall
(Win32OperatingSystem class compiledMethodAt:#primClosePrinter:) externalLibraryFunctionCall
(IUnknownPointer compiledMethodAt:#invokeAddRef) isExternalLibraryFunctionCall
(IUnknownPointer compiledMethodAt:#invokeAddRef) externalLibraryFunction
(IUnknownPointer compiledMethodAt:#invokeAddRef) isOLECall
(IUnknownPointer compiledMethodAt:#invokeAddRef) indexOfOLECall
|
-
isDocumentationMethod
-
Return true, if this is a documentation only (only a comment) method
(implies being a metaclass method)
-
isExplicitRequirement
-
to mark trait methods which are to be provided by the using class
-
isExtension
-
return true, if this method is an extension (i.e. package ~= classes' package)
-
isExternalLibraryFunctionCall
-
Return true, if this is an externalLibraryFunction call.
-
isForCompatibility
-
returns true, if this method only used for compatibility
and should use only when porting foreign code but not otherwise
-
isInvalid
-
return true, if this method is not executable due to
a (re)-compilation error. Since invalidation is by patching the
method's code-pointer to a trap function, check for that here.
(see comment in Method>>invalidCodeObject).
-
isOLECall
-
return true, if the method is an ole call; false if not.
-
isObsolete
-
returns true, if this method is obsolete and should not be used any longer.
Obsolete methods are marked by a:
<resource: #obsolete>
attribute.
Usage example(s):
SystemBrowser browseMethods:(Method allInstances select:#isObsolete)
|
-
isShadowingExtension
-
return true, if this method is an extension (i.e. package ~= classes' package)
which shadows an existing method from another package (i.e. a package conflict)
-
isSubclassResponsibility
-
ST/V code uses this
-
isSynthetic
-
a synthetic method does not really exist - it is only shown in a browser's list
-
isTaggedAs: tag
-
returns true, if this method has a <resource: tag> annotation
-
isVersionMethod
-
Return true, if this is a CVS, SVN or other version method.
Stupid: need to know all of them here; better add a pragma or
method attribute for that...
Usage example(s):
(Method class compiledMethodAt:#version) isVersionMethod
(Method class compiledMethodAt:#documentation) isVersionMethod
|
-
isVisualWorksTypedef
-
Return true, if this is a type-returning method (a visualWorks typedef)
-
messages
-
return a collection of message-selectors, sent by this method.
-
messagesDo: aBlock
-
evaluate aBlock for each message-selector sent by this method.
Uses Parser to parse methods source and extract the names.
-
messagesPossiblySent
-
return a collection with the message selectors possibly sent to by the receiver.
Uses Parser to parse methods source and extract the names.
The returned collection includes perform-like and possibly performed messages
Usage example(s):
(Method compiledMethodAt:#printOn:) messagesSent
(Point compiledMethodAt:#x:) messagesSent
(WindowEvent class compiledMethodAt:#focusInView:) messagesSent
(WindowEvent class compiledMethodAt:#focusInView:) messagesPossiblySent
(Method compiledMethodAt:#messagesPossiblySent) messagesSent
(Method compiledMethodAt:#messagesPossiblySent) messagesPossiblySent
|
-
messagesSent
-
return a set-like collection with the message selectors sent by the receiver.
Uses Parser to parse method's source and extract the names.
The returned collection includes all used message selectors
(i.e. including super-send messages)
Usage example(s):
(Method compiledMethodAt:#printOn:) messagesSent
(Point compiledMethodAt:#x:) messagesSent
|
-
messagesSentToSelf
-
return a collection with the message selectors sent to self by the receiver.
Uses Parser to parse methods source and extract the names.
-
messagesSentToSuper
-
return a collection with the message selectors sent to super by the receiver.
Uses Parser to parse methods source and extract the names.
-
methodArgAndVarNames
-
return a collection with the method's argument and variable names.
Uses Parser to parse the method's source and extract the names.
Returns an empty collection if the source is not available, or some other
syntax/parse error occurred.
For methods with no args and no vars, an empty collection is returned.
Usage example(s):
(Method compiledMethodAt:#printOn:) methodArgAndVarNames
|
-
methodArgAndVarNamesInContext: context
-
return a collection with the method's argument and variable names.
Uses Parser to parse methods source and extract the names.
Returns nil if the source is not available, or some other
syntax/parse error occurred. For methods with no args and no vars,
an empty collection is returned.
-
methodArgAndVarNamesInContextForInspector: context
-
return a collection with the method's argument and variable names.
Uses Parser to parse methods source and extract the names.
Returns nil if the source is not available, or some other
syntax/parse error occurred. For methods with no args and no vars,
an empty collection is returned.
-
methodArgNames
-
return a collection with the method's argument names.
Uses Parser to parse the method's source and extract the names.
Usage example(s):
(Method compiledMethodAt:#printOn:) methodArgNames
|
-
methodComment
-
return the method's first comment, nil if there is none.
This is a somewhat stupid implementation.
Usage example(s):
(Method compiledMethodAt:#methodComment) methodComment
|
-
methodDefinitionTemplate
-
return the string that defines the method and the arguments;
i.e. the methodSpec in the source.
If the source is available, correct argument names will be presented;
otherwise, synthetic names are generated
Usage example(s):
(self compiledMethodAt:#printOn:) methodDefinitionTemplate
(self compiledMethodAt:#printOn:) methodDefinitionTemplateForSelector:'newSel:'
|
-
methodDefinitionTemplateForSelector: aSelector
-
return the string that would define the method and the arguments,
iff the selected was aSelector; i.e. the methodSpec in the source.
If the source is available, correct argument names will be presented;
otherwise, synthetic names are generated
-
methodInvocationInfo
-
redefined by InstrumentedMethod, to return the collected info
-
methodVarNames
-
return a collection with the method's local-variable names.
Uses Parser to parse the method's source and extract the names.
Usage example(s):
(Method compiledMethodAt:#printOn:) methodVarNames
|
-
modificationTime
-
try to extract the modificationTime as a timeStamp from
the receiver's source. If there is no source or no history line,
we do not know the modification time, and nil is returned.
Usage example(s):
(Method compiledMethodAt:#modificationTime) modificationTime
(Method compiledMethodAt:#isMethod) modificationTime
|
-
modifiedInstVars
-
returns a collection of instance variables which are modified by this method.
Uses parser (for now); could look at bytecode as well here...
-
modifiesInstVar: instVarName
-
return true, if the named instvar is modiefied by the receiver.
Uses parser (for now); could look at bytecode as well here...
-
name
-
for compatibility with javaMethods
-
overwrites: aMethod
-
-
parse: parseSelector return: accessSelector or: valueIfNoSource
-
helper for methodArgNames, methodVarNames etc.
Get the source, let parser parse it using parseSelector,
return parser-info using accessSelector
Usage example(s):
(Method compiledMethodAt:#parse:return:or:)
parse:#'parseMethodSilent:' return:#sentMessages or:#()
|
-
parse: parseSelector with: arg2 return: accessSelector or: valueIfNoSource
-
helper for methodArgNames, methodVarNames etc.
Get the source, let parser parse it using parseSelector,
return parser-info using accessSelector
Usage example(s):
self flushParseTreeCache.
(Method compiledMethodAt:#parse:return:or:)
parse:#'parseMethodSilent:' return:#messagesSent or:#()
|
-
parseAnnotations
-
return the method's annotations.
-
parseResources
-
return the method's resource spec; either nil or a collection of symbols.
Resources are a special kind of annotation, of the form:
<resource: #symbol...>
and flags methods which depend on keyboard bindings or provide menus, specs or bitmap images
-
parseTree
( an extension from the stx:goodies/refactoryBrowser/parser package )
-
parse a method given a selector - return a parseTree
Usage example(s):
(Method compiledMethodAt:#parseTree) parseTree
|
-
possiblySends: aSelectorSymbol
-
return true, if this method contains an indirect message-send
(such as perform) with aSelectorSymbol as selector.
-
previousVersion
-
return the receiver's previous version's source code
Usage example(s):
previous := change previousVersion.
|
-
previousVersionCode
-
return the receiver's previous version's source code
-
previousVersions
-
return a collection of the receiver's previous versions (sources)
-
previousVersions: count
-
return a collection of the receiver's count previous versions (sources).
A nil count will retrieve all versions
Usage example(s):
(Method compiledMethodAt:#previousVersions:) previousVersions:nil
|
-
programmingLanguage
-
(comment from inherited method)
the following is correct, but might be too slow...
-
readsField: instVarIndex
-
return true, if the instvar at instVarIndex is read by the receiver.
Uses parser (for now); could look at bytecode as well here...
-
readsInstVar: instVarName
-
return true, if the named instvar is read by the receiver.
Uses parser (for now); could look at bytecode as well here...
-
refersToLiteral: anObject
-
redefined to also search in annotations
-
refersToLiteralMatching: aMatchString
-
redefined to also search in annotations
-
resourceType
-
ST-80 compatibility:
return the method's first resource specs key.
Returns either nil, or a single symbol.
For example, for an image-spec method, the resourceType
would be #image
-
resources
-
return the method's resource spec (i.e. resource-annotation);
either nil or a collection of symbols.
-
selector
-
return the selector under which I am found in my containingClasses
method-table.
See comment in who.
Usage example(s):
|m|
m := Object compiledMethodAt:#at:.
m selector
|
-
sends: selectorSymbol1 or: selectorSymbol2
-
return true, if this method contains a message-send
to either selectorSymbol1 or selectorSymbol2.
This is a hack, because calling sends: twice parses twice (should cache parse trees)
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
sendsAnySelector: aCollectionOfSelectorSymbols
-
return true, if this method contains a message-send
to any of aCollectionOfSelectorSymbols.
-
sendsMessageForWhich: aCheckBlock
-
return true, if this method contains a message-send
for which aCheckBlock returns true, when given the selector.
-
sendsSelector: aSelectorSymbol
-
return true, if this method contains a message-send
with aSelectorSymbol as selector.
-
shadowedMethod
-
Return the shadowed method if this method is an extension (i.e. package ~= classes' package)
AND it shadows (redefines) an existing method from the method's class.
If this method does not shadow any other method, return nil.
-
shouldBeSkippedInDebuggersWalkBack
-
return true, if this method thinks, it should be skipped in a walkback.
This is done by looking for a #skipInDebuggersWalkBack flag in the method's resources.
-
superMessages
-
return a collection of message-selectors, sent to super by this method.
-
usedGlobals
-
return a collection with the global names referred to by the receiver.
Uses Parser to parse methods source and extract them.
Usage example(s):
(Method compiledMethodAt:#resources) usedGlobals
|
-
usedSymbols
-
return a collection with the symbols referred to by the receiver.
Uses Parser to parse methods source and extract them.
This collection only includes implicit symbols references
(i.e. not messages sent)
Usage example(s):
(Method compiledMethodAt:#usedSymbols) usedSymbols
(Method compiledMethodAt:#usedSymbols) messagesSent
|
-
who
-
return the class and selector of where I am defined in;
nil is returned for unbound methods.
ST/X special notice:
returns an instance of MethodWhoInfo, which
responds to #methodClass and #methodSelector query messages.
For backward- (& ST-80) compatibility, the returned object also
responds to #at:1 and #at:2 messages.
Implementation notice:
To avoid an expensive search, the once valid containing class is kept and remembered
in the mclass slot. However, if a method gets recompiled or wrapped, the mclass field is
no longer valid and who on the old method returns nil (because the method is actually no longer
contained in that class). However, to allow easier unwrapping (and gathering of the corresponding
wrapper), the mclass field is never nilled. I.e. it still refers to the original class.
Therefore, a validation of the mclass slot is done here.
Usage example(s):
first, look in the class we found something the last time
this may often give a hit, when asking who repeatingly for
a context chain. (keep last by its name, to not keep classes from
being garbage collected)
|
Usage example(s):
because source might ask for who again...
|
Usage example(s):
|m|
m := Object compiledMethodAt:#copy.
m who
|
Usage example(s):
|m cls|
Object
subclass:#FunnyClass
instanceVariableNames:'foo'
classVariableNames:''
poolDictionaries:''
category:'testing'.
cls := Smalltalk at:#FunnyClass.
Smalltalk removeClass:cls.
cls compile:'testMethod1:arg foo:=arg'.
cls compile:'testMethod2 ^ foo'.
m := cls compiledMethodAt:#testMethod1:.
m who
|
-
wrapper
-
only for wrapped methods: return the wrapper.
That's the WrapperMethod which contains myself.
-
writesField: instVarIndex
-
return true, if the instvar at instVarIndex is written (modified) by the receiver.
Uses parser (for now); could look at bytecode as well here...
-
writesInstVar: instVarName
-
return true, if the named instvar is written (modified) by the receiver.
Uses parser (for now); could look at bytecode as well here...
source management
-
revisionInfo
-
cg: is this correct for extensions?
(shouldn't this be the revisionInfo from the extensions container?)
testing
-
isMethod
-
return true, if the receiver is some kind of method;
true returned here - the method is redefined from Object.
-
isMethodWithBreakpoints
-
only redefined in MethodWithBreakpoints
trap methods
-
makeInvalid
-
make the receiver an invalid method, which raises an invalidCodeObject
signal when executed. This is not for public use - it is required for
the objectFileLoader to invalidate methods whose code is unloaded.
-
makeUncompiled
-
make the receiver an uncompiled method, which raises an invalidCodeObject
signal when executed. This is not for public use - it is required for
the compiler to invalidate methods which cannot be compiled due to errors
after a class definition change (for example: instvars are no longer there).
-
makeUnloaded
-
make the receiver an unloaded method, which raises an invalidCodeObject
signal when executed. This is not for public use - it is required for
the objectFileLoader to invalidate methods for which a shared library has
been removed.
-
trapMethodForNumArgs: numArgs
-
MethodWhoInfo
ParseTreeCacheEntry
ParserCacheEntry
SkipSourcecodeManagerQuery
|