Back: CompiledCode-translation Up: Base classes Forward: CompiledMethod class-c call-outs   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.39 CompiledMethod

Defined in namespace Smalltalk
Superclass: CompiledCode
Category: Language-Implementation
I represent methods that have been compiled. I can recompile methods from their source code, I can invoke Emacs to edit the source code for one of my instances, and I know how to access components of my instances.

1.39.1 CompiledMethod class: c call-outs  (class)
1.39.2 CompiledMethod class: instance creation  (class)
1.39.3 CompiledMethod class: lean images  (class)
1.39.4 CompiledMethod: accessing  (instance)
1.39.5 CompiledMethod: attributes  (instance)
1.39.6 CompiledMethod: basic  (instance)
1.39.7 CompiledMethod: c call-outs  (instance)
1.39.8 CompiledMethod: compiling  (instance)
1.39.9 CompiledMethod: invoking  (instance)
1.39.10 CompiledMethod: printing  (instance)
1.39.11 CompiledMethod: saving and loading  (instance)
1.39.12 CompiledMethod: source code  (instance)
1.39.13 CompiledMethod: testing  (instance)


1.39.1 CompiledMethod class: c call-outs

pragma
asyncCCall: descr numArgs: numArgs attributes: attributesArray
Return a CompiledMethod corresponding to a #asyncCCall:args: pragma with the given arguments.

pragma

cCall: descr numArgs: numArgs attributes: attributesArray
Return a CompiledMethod corresponding to a #cCall:returning:args: pragma with the given arguments.


1.39.2 CompiledMethod class: instance creation

literals: lits numArgs: numArg numTemps: numTemp attributes: attrArray bytecodes: bytecodes depth: depth
Answer a full fledged CompiledMethod. Construct the method header from the parameters, and set the literals and bytecodes to the provided ones. Also, the bytecodes are optimized and any embedded CompiledBlocks modified to refer to these literals and to the newly created CompiledMethod.

numArgs: args
Create a user-defined method (one that is sent #valueWithReceiver:withArguments: when it is invoked) with numArgs arguments. This only makes sense when called for a subclass of CompiledMethod.


1.39.3 CompiledMethod class: lean images

stripSourceCode
Remove all the references to method source code from the system


1.39.4 CompiledMethod: accessing

allBlocksDo: aBlock
Evaluate aBlock, passing to it all the CompiledBlocks it holds

allLiterals
Answer the literals referred to by the receiver and all the blocks in it

flags
Private - Answer the optimization flags for the receiver

isOldSyntax
Answer whether the method was written with the old (chunk-format) syntax

methodCategory
Answer the method category

methodCategory: aCategory
Set the method category to the given string

methodClass
Answer the class in which the receiver is installed.

methodClass: methodClass
Set the receiver's class instance variable

noteOldSyntax
Remember that the method is written with the old (chunk-format) syntax

numArgs
Answer the number of arguments for the receiver

numTemps
Answer the number of temporaries for the receiver

primitive
Answer the primitive called by the receiver

selector
Answer the selector through which the method is called

selector: aSymbol
Set the selector through which the method is called

sourceCodeLinesDelta
Answer the delta from the numbers in LINE_NUMBER bytecodes to source code line numbers.

stackDepth
Answer the number of stack slots needed for the receiver

withAllBlocksDo: aBlock
Evaluate aBlock, passing the receiver and all the CompiledBlocks it holds

withNewMethodClass: class
Answer either the receiver or a copy of it, with the method class set to class

withNewMethodClass: class selector: selector
Answer either the receiver or a copy of it, with the method class set to class


1.39.5 CompiledMethod: attributes

attributeAt: aSymbol
Return a Message for the first attribute named aSymbol defined by the receiver, or answer an error if none was found.

attributeAt: aSymbol ifAbsent: aBlock
Return a Message for the first attribute named aSymbol defined by the receiver, or evaluate aBlock is none was found.

attributes
Return an Array of Messages, one for each attribute defined by the receiver.

attributesDo: aBlock
Evaluate aBlock once for each attribute defined by the receiver, passing a Message each time.

isAnnotated
If the receiver has any attributes, answer true.

primitiveAttribute
If the receiver defines a primitive, return a Message resembling the attribute that was used to define it.


1.39.6 CompiledMethod: basic

= aMethod
Answer whether the receiver and aMethod are equal

hash
Answer an hash value for the receiver


1.39.7 CompiledMethod: c call-outs

isValidCCall
Answer whether I appear to have the valid flags, information, and ops to invoke a C function and answer its result.

rewriteAsAsyncCCall: func args: argsArray
Not commented.

rewriteAsCCall: funcOrDescr for: aClass
Not commented.

rewriteAsCCall: func returning: returnType args: argsArray
Not commented.


1.39.8 CompiledMethod: compiling

methodFormattedSourceString
Answer the method source code as a string, formatted using the RBFormatter. Requires package Parser.

methodParseNode
Answer the parse tree for the receiver, or nil if there is an error. Requires package Parser.

parserClass
Answer a parser class, similar to Behavior>>parserClass, that can parse my source code. Requires package Parser.

recompile
Recompile the method in the scope of the class where it leaves.

recompileNotifying: aNotifier
Recompile the method in the scope of the class where it leaves, notifying errors to aNotifier by sending it #error:.


1.39.9 CompiledMethod: invoking

valueWithReceiver: anObject withArguments: args
Execute the method within anObject, passing the elements of the args Array as parameters. The method need not reside on the hierarchy from the receiver's class to Object -- it need not reside at all in a MethodDictionary, in fact -- but doing bad things will compromise stability of the Smalltalk virtual machine (and don't blame anybody but yourself).

If the flags field of the method header is 6, this method instead provides a hook from which the virtual machine can call back whenever execution of the method is requested. In this case, invoking the method would cause an infinite loop (the VM asks the method to run, the method asks the VM to invoke it, and so on), so this method fails with a #subclassResponsibility error.


1.39.10 CompiledMethod: printing

printOn: aStream
Print the receiver's class and selector on aStream

storeOn: aStream
Print code to create the receiver on aStream


1.39.11 CompiledMethod: saving and loading

to
binaryRepresentationObject
This method is implemented to allow for a PluggableProxy to be used with CompiledMethods. Answer a DirectedMessage which sends #>> to the class object containing the receiver.


1.39.12 CompiledMethod: source code

methodRecompilationSourceString
Answer the method source code as a string, ensuring that it is in new syntax (it has brackets).

methodSourceCode
Answer the method source code (a FileSegment or String or nil)

methodSourceFile
Answer the file where the method source code is stored

methodSourcePos
Answer the location where the method source code is stored in the methodSourceFile

methodSourceString
Answer the method source code as a string


1.39.13 CompiledMethod: testing

accesses: instVarIndex
Answer whether the receiver or the blocks it contains accesses the instance variable with the given index

assigns: instVarIndex
Answer whether the receiver or the blocks it contains writes to the instance variable with the given index

isAbstract
Answer whether the receiver is abstract.

reads: instVarIndex
Answer whether the receiver or the blocks it contains reads to the instance variable with the given index

sendsToSuper
Answer whether the receiver or the blocks it contains have sends to super



Back: CompiledMethod-source code Up: CompiledMethod Forward: ContextPart   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document


This document was generated on July, 23 2009 using texi2html