Documentation

LKCodeGenLoader class documentation

LKCodeGenerator <NSObject>

AuthorsGenerated by builder
Declared inLKCodeGen.h

Overview

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.


Default

- (void) startModule: (NSString *)fileName

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

    - (void) endModule

    Finish generating a module.

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

        - (void) endClass

        Finish the current class.

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

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

            - (void) endCategory

            Finish the current category.

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

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

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

                  Begins compiling a free-standing function.

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

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

                      Sends a message to the superclass.

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

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

                          Calls a C function, with the specified type encoding.

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

                              - (void*) loadSelf

                              Returns 'self' in the current method.

                                - (void*) loadBlockContext

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

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

                                  Load a pointer to the named class.

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

                                    Stores a value in the specified variable.

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

                                      Load the value of the specified local variable.

                                        - (void) endMethod

                                        End the current method.

                                          - (void*) endBlock

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

                                            - (void) blockReturn: (void*)aValue

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

                                              - (void) setReturn: (void*)aValue

                                              Set the return value for a method.

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

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

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

                                                  Return a constant representing the passed string.

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

                                                    Return a constant representing the passed string.

                                                      - (void*) nilConstant

                                                      Returns nil as a constant.

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

                                                        Compares two pointers.

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

                                                          Generates a constant symbol (a boxed selector).

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

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

                                                              - (void*) currentBasicBlock

                                                              Returns a pointer to the current basic block.

                                                                - (void) moveInsertPointToBasicBlock: (void*)aBasicBlock

                                                                Sets the current insert point to the specified basic block.

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

                                                                    - (void) goToBasicBlock: (void*)aBasicBlock

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

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

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

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

                                                                        Returns the basic block associated with the specified label.

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