LKCodeGenLoader class documentation

Authors

Generated by builder

Contents -

  1. Software documentation for the LKCodeGenLoader class
  2. Software documentation for the LKCodeGenerator protocol
  3. Software documentation for the LKStaticCodeGenerator protocol
  4. LKCodeGen functions

Software documentation for the LKCodeGenLoader class

LKCodeGenLoader : NSObject

Declared in:
LKCodeGen.h

Class used to instantiate the default code generators. Lazily loads the code generator components the first time it receives a message.

Method summary

defaultJIT 

+ (id<LKCodeGenerator>) defaultJIT;

Returns the default code generator for JIT compilation.


defaultStaticCompilerWithFile: 

+ (id<LKStaticCodeGenerator>) defaultStaticCompilerWithFile: (NSString*)outFile;

Returns the default code generator for static compilation, outputting to the file specified in the argument.


Software documentation for the LKCodeGenerator protocol

LKCodeGenerator

Declared in:
LKCodeGen.h
Conforms to:
NSObject

Code generator protocol. Each AST node calls methods in a class conforming to this protocol. Methods which return a value return a pointer to a generator-specific type, which can then be passed in to the generator later when it expects a value.

Method summary

basicBlockForLabel: 

- (void*) basicBlockForLabel: (NSString*)aLabel;

Returns the basic block associated with the specified label.


beginBlockWithArgs: locals: externals: signature: 

- (void) beginBlockWithArgs: (NSArray*)args locals: (NSArray*)locals externals: (NSArray*)externals signature: (NSString*)signature;

Begin generating a block expression with the specified number of arguments and locals. The bound variables are pointers to variables declared outside the block's scope.


beginClassMethod: withTypeEncoding: arguments: locals: 

- (void) beginClassMethod: (NSString*)aName withTypeEncoding: (NSString*)typeEncoding arguments: (NSArray*)arguments locals: (NSArray*)locals;

Begin a class method with the specified type encoding and number of local variables. Local variables and arguments are indexed by number, the symbol table information is just for debugging.


beginFunction: withTypeEncoding: arguments: locals: 

- (void) beginFunction: (NSString*)aName withTypeEncoding: (NSString*)typeEncoding arguments: (NSArray*)arguments locals: (NSArray*)locals;

Begins compiling a free-standing function.


beginInstanceMethod: withTypeEncoding: arguments: locals: 

- (void) beginInstanceMethod: (NSString*)aName withTypeEncoding: (NSString*)typeEncoding arguments: (NSArray*)arguments locals: (NSArray*)locals;

Begin an instance method with the specified type encoding and number of local variables. Local variables and arguments are indexed by number, the symbol table information is just for debugging.


blockReturn: 

- (void) blockReturn: (void*)aValue;

Specify the return value for a block. For Smalltalk, this is the result of the last statement in a block.


branchOnCondition: true: false: 

- (void) branchOnCondition: (void*)aCondition true: (void*)trueBlock false: (void*)falseBlock;

Compares aCondition to the SmallInt value for NO (1) and executes the first block if it matches, the second if it doesn't.


callFunction: typeEncoding: arguments: count: 

- (void*) callFunction: (NSString*)functionName typeEncoding: (NSString*)typeEncoding arguments: (void**)arguments count: (int)count;

Calls a C function, with the specified type encoding.


comparePointer: to: 

- (void*) comparePointer: (void*)lhs to: (void*)rhs;

Compares two pointers.


createCategoryWithName: onClassNamed: 

- (void) createCategoryWithName: (NSString*)aCategory onClassNamed: (NSString*)aClass;

Create a new category with the specified name on the named class.


createSubclassWithName: superclassNamed: withSymbolTable: 

- (void) createSubclassWithName: (NSString*)aClass superclassNamed: (NSString*)aSuperclass withSymbolTable: (LKSymbolTable*)symbolTable;

Create a new class, with the specified superclass. The symbol table should define all of the new instance and class variables.


currentBasicBlock 

- (void*) currentBasicBlock;

Returns a pointer to the current basic block.


endBlock 

- (void*) endBlock;

End the current block. Subsequent calls will insert instructions into the containing scope (the method, or another block).


endCategory 

- (void) endCategory;

Finish the current category.


endClass 

- (void) endClass;

Finish the current class.


endMethod 

- (void) endMethod;

End the current method.


endModule 

- (void) endModule;

Finish generating a module.


floatConstant: 

- (void*) floatConstant: (NSString*)aString;

Return a constant representing the passed string.


generateConstantSymbol: 

- (void*) generateConstantSymbol: (NSString*)aSymbol;

Generates a constant symbol (a boxed selector).


goToBasicBlock: 

- (void) goToBasicBlock: (void*)aBasicBlock;

Ends the current basic block with an unconditional jump to the specified basic block


goToLabelledBasicBlock: 

- (void) goToLabelledBasicBlock: (NSString*)aLabel;

Ends the current basic block with an unconditional jump to the basic block that has been associated with the specified label.


intConstant: 

- (void*) intConstant: (NSString*)aString;

Returns a constant representing the string as an integer (either a SmallInt or a BigInt).


loadBlockContext 

- (void*) loadBlockContext;

Returns the block object for the current closure. Calling this when not in a block has undefined behaviour.


loadClassNamed: 

- (void*) loadClassNamed: (NSString*)aClass;

Load a pointer to the named class.


loadSelf 

- (void*) loadSelf;

Returns 'self' in the current method.


loadVariable: 

- (void*) loadVariable: (LKSymbol*)aVariable;

Load the value of the specified local variable.


moveInsertPointToBasicBlock: 

- (void) moveInsertPointToBasicBlock: (void*)aBasicBlock;

Sets the current insert point to the specified basic block.


nilConstant 

- (void*) nilConstant;

Returns nil as a constant.


sendMessage: types: to: withArgs: count: 

- (void*) sendMessage: (NSString*)aMessage types: (NSArray*)types to: (void*)receiver withArgs: (void**)argv count: (unsigned int)argc;

Sends a message to a receiver which may be a SmallInt (a boxed Smalltalk integer contained within an object pointer).


sendMessage: types: toObject: withArgs: count: 

- (void*) sendMessage: (NSString*)aMessage types: (NSArray*)types toObject: (void*)receiver withArgs: (void**)argv count: (unsigned int)argc;

Sends a message to an object. Similar to sendMessage:type:to:withargs:count: but requires that receiver be an Objective-C object, not a small integer.


sendSuperMessage: types: withArgs: count: 

- (void*) sendSuperMessage: (NSString*)sel types: (NSString*)seltypes withArgs: (void**)argv count: (unsigned int)argc;

Sends a message to the superclass.


setBasicBlock: forLabel: 

- (void) setBasicBlock: (void*)aBasicBlock forLabel: (NSString*)aLabel;

Associate a basic block with the specified label for later retrieval.


setReturn: 

- (void) setReturn: (void*)aValue;

Set the return value for a method.


startBasicBlock: 

- (void*) startBasicBlock: (NSString*)aName;

Starts a new basic block and returns a pointer to the basic block.


startModule: 

- (void) startModule: (NSString*)fileName;

Begin generating a module. A module is a set of classes and categories which are compiled and optimised at once.


storeValue: inVariable: 

- (void) storeValue: (void*)aVal inVariable: (LKSymbol*)aVariable;

Stores a value in the specified variable.


stringConstant: 

- (void*) stringConstant: (NSString*)aString;

Return a constant representing the passed string.


Software documentation for the LKStaticCodeGenerator protocol

LKStaticCodeGenerator

Declared in:
LKCodeGen.h
Conforms to:
LKCodeGenerator

Protocol for static code generators.

Method summary

initWithFile: 

- (id<LKStaticCodeGenerator>) initWithFile: (NSString*)outFile;

Initializes the code generator with the specified file.


LKCodeGen functions

defaultJIT

id<LKCodeGenerator> defaultJIT();

Returns the default code generator for JIT compilation.

Deprecated. Use [LKCodeGenLoader defaultJIT] in new code.


defaultStaticCompilterWithFile

id<LKCodeGenerator> defaultStaticCompilterWithFile(NSString* );

Returns the default code generator for static compilation, outputting to the file specified in the argument.

Deprecated. Use [LKCodeGenLoader defaultStaticCompilerWithFile:] in new code.