eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Method':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Method


Inheritance:

   Object
   |
   +--ExecutableFunction
      |
      +--CompiledCode
         |
         +--Method
            |
            +--InstrumentedMethod
            |
            +--JavaScriptFunction
            |
            +--LazyMethod
            |
            +--MethodWithBreakpoints
            |
            +--SmalltalkShareClient::RemoteMethod
            |
            +--Tools::MethodCategoryList::MissingMethod
            |
            +--WrappedMethod

Package:
stx:libbasic
Category:
Kernel-Methods
Version:
rev: 1.521 date: 2019/07/18 05:50:55
user: cg
file: Method.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


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


Class protocol:

Signal constants
o  privateMethodSignal
return the signal raised when a private/protected method is called
by some other object (i.e. not a self- or super send)

cleanup
o  lowSpaceCleanup
cleanup in low-memory situations

initialization
o  initialize
create signals

o  lastMethodSourcesLock

queries
o  binarySelectorCharacters
return a collection of characters which are allowed in binary selectors

o  isBuiltInClass
return true if this class is known by the run-time-system.
Here, true is returned for myself, false for subclasses.

o  maxBinarySelectorSize
in ST/X, binops are allowed with up-to 3 characters;
for example:
<->
<=>
+++
:=:
etc. are valid binOps here

o  methodDefinitionTemplateForSelector: aSelector
given a selector, return a prototype definition string

usage example(s):

     Method methodDefinitionTemplateForSelector:#foo
     Method methodDefinitionTemplateForSelector:#+
     Method methodDefinitionTemplateForSelector:#foo:bar:baz:

o  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')

o  methodPrivacySupported
return true, if the system was compiled to support methodPrivacy.
You should not depend on that feature being available.

o  resourceTypes
get the types of resources for which a spec definition and corresponding editor exist

special
o  flushParseTreeCache
used by lint and the compiler

usage example(s):

     Method flushParseTreeCache

o  flushSourceStreamCache
Method flushSourceStreamCache

trap methods
o  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


Instance protocol:

Compatibility-Squeak
o  isCompiledMethod
(comment from inherited method)
same as isMethod - for squeak compatibility

o  numTemps
( an extension from the stx:libcompat package )

o  pragmaAt: aKey

o  pragmas
for squeak compatibility, we only present real pragmas

o  propertyValueAt: aKey
for now - no properties

o  sourceCode

o  timeStamp
( an extension from the stx:libcompat package )

Compatibility-VW
o  attributeAt: aSymbol ifAbsent: exceptionValue

o  attributeMessages

o  classIsMeta
return true, if this method is a class method

RefactoringBrowser
o  equivalentTo: aCompiledMethod
( an extension from the stx:goodies/refactoryBrowser/parser package )

accessing
o  category
return the method's category or nil

o  category: aStringOrSymbol
set the method's category

o  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

o  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

o  getPackage
return the package-ID of the method

o  getSource
low-level access to the source instance-variable.
For internal (compiler) use only.
This is NOT always the method's source string

o  getSourcePosition
low-level access to the sourcePosition instance-variable.
For internal (compiler) use only.
This is NOT always the method's sourcePosition

o  localSourceFilename: aFileName 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.

o  lookupObject
lookupObject isNil ifTrue:[^ BuiltinLookup instance "Lookup builtin"].

o  lookupObject: anObject

o  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.

o  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.

o  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

o  nameSpace: aNameSpace

o  nameSpaceName

o  originalMethodIfWrapped
return the method the receiver is wrapping - none here

o  overriddenMethod

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  overriddenMethod: aMethod

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  overwrittenMethod
Answers overridden method or nil.

o  overwrittenMethod: aMethod
Set overridden method to aMethod

o  package
return the package-symbol of the method (nil is translated to noProject here)

o  package: aSymbol
set the package-symbol

o  setCategory: aStringOrSymbol
set the method's category (without change notification)

o  setPackage: aSymbol
set the package-symbol (low level - use package:)

o  source
return the sourcestring for the receiver

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):

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

o  source: aString
set the method's sourcestring

o  sourceFilename
return the sourcefilename if source is extern; nil otherwise

o  sourceFilename: aFileName position: aNumber
set the method's sourcefile/position

o  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.

o  sourcePosition
return the sourceposition if source is extern; nil otherwise

accessing-annotations
o  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:

o  annotationAt: key
(Object >> #yourself) annotationAt: #namespace:

o  annotations
return (a copy) of the annotations array

o  annotations: anObject
set the annotations

o  annotationsAt: key

o  annotationsAt: key do: block

o  annotationsAt: key1 orAt: key2

o  annotationsAt: key1 orAt: key2 do: block

o  annotationsDo: aBlock

accessing-visibility
o  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).

o  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).

o  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).

o  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).

o  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).

o  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).

o  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).

o  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).

o  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

o  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).

o  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
o  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.

o  asByteCodeMethodWithSource: newSource

o  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.

o  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
o  copy
redefined to change a source ref into a real string

error handling
o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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.

o  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).

o  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.

o  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
o  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

printing & storing
o  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.

o  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

o  selectorPrintStringInBrowserFor: selector
( an extension from the stx:libtool package )

o  selectorPrintStringInBrowserFor: selector class: aClass
( an extension from the stx:libtool package )
nsPart := selector copyFrom:2 to:idx-1.
ns := Smalltalk at:nsPart asSymbol.

o  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

o  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
o  annotationAtIndex: index
return the annotation at given index.
any raw annotation array (as generated by the 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.

o  annotationIndexOf: key
Returns the index of annotation with given key
or nil if there is no such annotation

o  cacheSourceStream: aStream
remember a (raw) source stream for later use

o  getAnnotations

o  getLookupObject

o  localSourceStream
try to open a stream from a local source file,
searching in standard places.

o  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.

o  setAnnotations: anObject
set the annotations (low level - do not use)

o  setLookupObject: lookup
set the lookupObject (low level - use lookupObject:)

o  sourceChunkFromStream: aStream

o  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
o  hasPrimitiveCode
true if I have primitive code.

o  primitiveNumber
for stx rel >= 5.x only:
return the primitive number.

o  setPrimitiveNumber: aNumber
for stx rel >= 5.x only:
mark the method as having primitive code.

o  setResourceFlag
mark the method as having a <resource> definition in its
source. This flag can be used to find resource-flagged methods quicker.

queries
o  accessedInstVars
return a collection of instVarNames, which are accessed by
the receiver method

o  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...

o  accessesInstVar: instVarName
return true, if the named instvar is accessed by the receiver.
Uses parser (for now); could look at bytecode as well here...

o  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

o  externalLibraryFunction
if this is an externalLibraryFunction call, return the externalLibraryFunction.
Returns nil otherwise.

usage example(s):

     (IDispatchPointer compiledMethodAt:#'invokeGetTypeInfo:_:_:')
        externalLibraryFunction

o  hasAnnotation
Return true iff the method has any annotation

o  hasAnnotation: key
Return true iff the method is annotated with the given key

o  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]
     ].

o  hasPrimitiveCodeInSource
return true, if the method contains primitive code; false if not.
Uses Parser to parse methods source and get the information.

o  hasResource
return true if the method had a <resource> definition in its
source. This flag can be used to find resource-flagged methods quicker.

o  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

o  isDocumentationMethod
Return true, if this is a documentation only (only a comment) method
(implies being a metaclass method)

o  isExtension
return true, if this method is an extension (i.e. package ~= classes' package)

o  isExternalLibraryFunctionCall
Return true, if this is an externalLibraryFunction call.

o  isForCompatibility
returns true, if this method only used for compatibility
and should use only when porting foreign code but not otherwise

o  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).

o  isMethod
return true, if the receiver is some kind of method;
true returned here - the method is redefined from Object.

o  isOLECall
return true, if the method is an ole call; false if not.

o  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)  

o  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)

o  isSubclassResponsibility
ST/V code uses this

o  isSynthetic
a synthetic method does not really exist - it is only shown in a browser's list

o  isTaggedAs: tag
returns true, if this method has a <resource: tag> annotation

o  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

o  isVisualWorksTypedef
Return true, if this is a type-returning method (a visualWorks typedef)

o  mclass
return the class in which the receiver is currently 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 and can be fetched
via getMclass.
Same as #containingClass, for ST80 compatibility.

o  messages
return a collection of message-selectors, sent by this method.

o  messagesDo: aBlock
evaluate aBlock for each message-selector sent by this method.
Uses Parser to parse methods source and extract the names.

o  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

o  messagesSent
return a set-like collection with the message selectors sent by the receiver.
Uses Parser to parse methods 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

o  messagesSentToSelf
return a collection with the message selectors sent to self by the receiver.
Uses Parser to parse methods source and extract the names.

o  messagesSentToSuper
return a collection with the message selectors sent to super by the receiver.
Uses Parser to parse methods source and extract the names.

o  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

o  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.

o  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

o  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

o  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:'

o  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

o  methodInvocationInfo
redefined by InstrumentedMethod, to return the collected info

o  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

o  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

o  modifiedInstVars
returns a collection of instance variables which are modified by this method.
Uses parser (for now); could look at bytecode as well here...

o  name
for compatibility with javaMethods

o  overwrites: aMethod

o  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:#()

o  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):

     LastParseTreeCache removeAll.

     (Method compiledMethodAt:#parse:return:or:)
        parse:#'parseMethodSilent:' return:#sentMessages or:#()

o  parseAnnotations
return the method's annotations.

o  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

o  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

o  possiblySends: aSelectorSymbol
return true, if this method contains an indirect message-send
(such as perform) with aSelectorSymbol as selector.

o  previousVersion
return the receiver's previous version's source code

usage example(s):

previous := change previousVersion.

o  previousVersionCode
return the receiver's previous version's source code

o  previousVersions
return a collection of the receiver's previous versions (sources)

o  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

o  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...

o  readsInstVar: instVarName
return true, if the named instvar is read by the receiver.
Uses parser (for now); could look at bytecode as well here...

o  refersToLiteral: anObject
redefined to search in annotations

o  refersToLiteralMatching: aMatchString
self halt.

o  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

o  resources
return the method's resource spec (i.e. resource-annotation);
either nil or a collection of symbols.

o  selector
return the selector under which I am found in my containingClasses
method-table.
See comment in who.

o  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) **

o  sendsAnySelector: aCollectionOfSelectorSymbols
return true, if this method contains a message-send
to any of aCollectionOfSelectorSymbols.

o  sendsMessageForWhich: aCheckBlock
return true, if this method contains a message-send
for which aCheckBlock returns true, when given the selector.

o  sendsSelector: aSelectorSymbol
return true, if this method contains a message-send
with aSelectorSymbol as selector.

o  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.

o  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.

o  superMessages
return a collection of message-selectors, sent to super by this method.

o  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

o  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

o  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)

o  wrapper
only for wrapped methods: return the wrapper.
That's the WrapperMethod which contains myself.

o  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...

o  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
o  revisionInfo
cg: is this correct for extensions?
(shouldn't this be the revisionInfo from the extensions container?)

testing
o  isMethodWithBreakpoints
only redefined in MethodWithBreakpoints

trap methods
o  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.

o  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).

o  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.

o  trapMethodForNumArgs: numArgs


Private classes:

    MethodWhoInfo
    ParseTreeCacheEntry
    ParserCacheEntry


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 29 Mar 2024 13:44:15 GMT