LKCompiler class documentation

Authors

Generated by builder

Contents -

  1. Software documentation for the LKCompiler class
  2. Software documentation for the LKCompiler(JTL) category
  3. Software documentation for the LKCompilerDelegate protocol
  4. Software documentation for the LKParser protocol
  5. LKCompiler types

Software documentation for the LKCompiler class

LKCompiler : NSObject

Declared in:
LKCompiler.h

Abstract class implementing a dynamic language compiler. Concrete subclasses provide implementations for specific languages.


Instance Variables

Method summary

addClassLoader: 

+ (void) addClassLoader: (LKClassLoader)aBlock;

Adds a new class loader. These will be called in the order that they appear.


compileLanguageKitBundle: output: 

+ (BOOL) compileLanguageKitBundle: (NSBundle*)bundle output: (NSString*)bitcode;

Loads a bundle containing an LKInfo.plist file. This should contain a Source key giving an array of source files in the order in which they should be compiled, a Frameworks key giving an array of frameworks and a Classes key for declaring classes being compile in other to resolve symbols correctly


compiler 

+ (LKCompiler*) compiler;

Returns a new autoreleased compiler for this language.


compilerClassForFileExtension: 

+ (Class) compilerClassForFileExtension: (NSString*)anExtension;

Returns the compiler for files with a given extension.


compilerForLanguage: 

+ (Class) compilerForLanguage: (NSString*)aLanguage;

Returns the compiler for a named language.


fileExtension 

+ (NSString*) fileExtension;
Subclasses must override this method.

Returns the extension used for scripts in this language.

Implemented by subclasses.


inDevMode 

+ (BOOL) inDevMode;

Returns whether we are in developer mode. In this mode, all unrecognised symbols are assumed to be classes.


languageName 

+ (NSString*) languageName;
Subclasses must override this method.

Returns the name of the language supported by this compiler.

Implemented by subclasses.


loadAllPlugInsForApplication 

+ (BOOL) loadAllPlugInsForApplication;

Loads all of the LanguageKit plugins for the current application.


loadAllScriptsForApplication 

+ (BOOL) loadAllScriptsForApplication;

Loads all scripts for all known languages from the application bundle.


loadApplicationScriptNamed: 

+ (BOOL) loadApplicationScriptNamed: (NSString*)fileName;

Compiles and loads a file from the application bundle. The file name extension will be used to select a suitable compiler.


loadFrameworkNamed: 

+ (BOOL) loadFrameworkNamed: (NSString*)framework;

Load a framework with the specified name.


loadHeader: 

+ (BOOL) loadHeader: (NSString*)aHeader;

Attempts to parse a C header. Returns YES on success, NO on failure. Failure can be caused by an inability to locate the header or by SourceCodeKit not being available.


loadLanguageKitBundle: 

+ (Class) loadLanguageKitBundle: (NSBundle*)bundle;

Loads a bundle containing an LKInfo.plist file. This should contain a Source key giving an array of source files in the order in which they should be compiled, a Frameworks key giving an array of frameworks, a Classes key for declaring classes being load in other to resolve symbols correctly and a PrincipalClass key for the class that should be instantiated when it is loaded.

Returns (Class)-1 in case of error, or the principal class if loading succeeds (Nil if no principal class is specified).


loadLibrary: 

+ (BOOL) loadLibrary: (NSString*)aLibrary;

Attempts to load a library from an absolute path or one of the standard library locations.


loadScriptNamed: fromBundle: 

+ (BOOL) loadScriptNamed: (NSString*)fileName fromBundle: (NSBundle*)bundle;

Compiles and loads a file from the specified bundle. The file name extension will be used to select a suitable compiler.


loadScriptsFromBundle: 

+ (BOOL) loadScriptsFromBundle: (NSBundle*)aBundle;

Loads all scripts for all known languages from the specified bundle.


parseScript: forFileExtension: 

+ (LKAST*) parseScript: (NSString*)script forFileExtension: (NSString*)extension;

Parse the specified string, using the correct parse.


parserClass 

+ (Class) parserClass;
Subclasses must override this method.

Returns the parser used by this language.


reportError: details: 

+ (BOOL) reportError: (NSString*)aWarning details: (NSDictionary*)info;

Reports the given error and returns YES if recovery should proceed.


reportWarning: details: 

+ (BOOL) reportWarning: (NSString*)aWarning details: (NSDictionary*)info;

Reports the given warning and returns YES if recovery should proceed.


setDebugMode: 

+ (void) setDebugMode: (LKDebuggingMode)aFlag;

Specifies whether the compiler should run in debug mode. Enabling this will spam stderr with a huge amount of debugging information. Note that this is a global setting and will apply to all compilers.


setDefaultDelegate: 

+ (void) setDefaultDelegate: (id<LKCompilerDelegate>)aDelegate;

Sets the default delegate that will be used by new compiler instances. If this is not called then a default delegate will be installed that just logs errors and warnings to the console.


supportedLanguageNames 

+ (NSArray*) supportedLanguageNames;

Returns the languages for which compilers are currently supported.


compileMethod: onClassNamed: 

- (BOOL) compileMethod: (NSString*)source onClassNamed: (NSString*)name;

Compiles and loads a method on the class with the specified name.


compileMethod: onClassNamed: output: 

- (BOOL) compileMethod: (NSString*)source onClassNamed: (NSString*)name output: (NSString*)bitcode;

Compiles a method to LLVM bitcode for the class with the specified name.


compileMethod: onClassNamed: withGenerator: 

- (BOOL) compileMethod: (NSString*)source onClassNamed: (NSString*)name withGenerator: (id<LKCodeGenerator>)cg;

Compiles a method on the class with the specified name using the given code generator.


compileString: 

- (LKAST*) compileString: (NSString*)source;

Compiles and loads the specified source code. Returns the AST on success, nil on failure.


compileString: withGenerator: 

- (LKAST*) compileString: (NSString*)source withGenerator: (id<LKCodeGenerator>)cg;

Compiles the specified source code to LLVM bitcode. This can then be optimised with the LLVM opt utility and converted to object code with llc. Returns the AST on success, nil on failure.

Compiles the specified source code using the given code generator. Returns the AST on success, nil on failure.


loadAllScriptsForApplication 

- (BOOL) loadAllScriptsForApplication;

Loads all scripts written in this language from the application bundle.


loadApplicationScriptNamed: 

- (BOOL) loadApplicationScriptNamed: (NSString*)name;

Compiles and loads a file from the application bundle. Omit the extension in the name paramater.


loadScriptNamed: fromBundle: 

- (BOOL) loadScriptNamed: (NSString*)name fromBundle: (NSBundle*)bundle;

Compiles and loads a file from the specified bundle. Omit the extension in the name paramater.


loadScriptsFromBundle: 

- (BOOL) loadScriptsFromBundle: (NSBundle*)aBundle;

Loads all scripts written in this language from the specified bundle.


setDelegate: 

- (void) setDelegate: (id<LKCompilerDelegate>)aDelegate;

Sets the delegate for this compiler. The delegate is responsible for handling errors and warnings that occur during the semantic analysis of the program.




Instance Variables for LKCompiler Class

delegate

@protected id delegate;
Description forthcoming.




Software documentation for the LKCompiler(JTL) category

LKCompiler(JTL)

Declared in:
LKCompiler.h
Description forthcoming.
Method summary

justTooLateCompileBundle: 

+ (void) justTooLateCompileBundle: (NSBundle*)aBundle;
Description forthcoming.

linkBitcodeFiles: outputDir: outputFile: 

+ (NSString*) linkBitcodeFiles: (NSMutableArray*)files outputDir: (NSString*)dir outputFile: (NSString*)fileName;

Link LKModule into a library.


Software documentation for the LKCompilerDelegate protocol

LKCompilerDelegate

Declared in:
LKCompiler.h
Conforms to:
NSObject
Description forthcoming.
Method summary

compiler: generatedError: details: 

- (BOOL) compiler: (LKCompiler*)aCompiler generatedError: (NSString*)anError details: (NSDictionary*)info;

Indicates that the specified compiler has encountered an unrecoverable problem. Extra information about this error may be found in the info dictionary. All errors must contain a human readable description identified by the key kLKHumanReadableDescription, specific errors may contain other information. See the LKCompilerErrors.h file for more information.

In normal circumstances, errors are unrecoverable. A delegate may perform some manipulation on the AST to eliminate the error, however. In this case, the delegate should return YES, causing the semantic analysis to be retried.


compiler: generatedWarning: details: 

- (BOOL) compiler: (LKCompiler*)aCompiler generatedWarning: (NSString*)aWarning details: (NSDictionary*)info;

Indicates that the specified compiler has encountered a recoverable problem. The delegate should return YES if the compiler should attempt to continue. Extra information about this warning may be found in the info dictionary. All warnings must contain a human readable description identified by the key kLKHumanReadableDesciption, specific warnings may contain other information. See the LKCompilerErrors.h file for more information.


Software documentation for the LKParser protocol

LKParser

Declared in:
LKCompiler.h
Conforms to:
NSObject

All languages must use a parser conforming to this protocol.

Method summary

parseMethod: 

- (LKMethod*) parseMethod: (NSString*)source;

Returns a method AST constructed by parsing the specified source, or nil if parsing failed or method parsing is not supported by this language.


parseString: 

- (LKModule*) parseString: (NSString*)source;

Returns a module AST constructed by parsing the specified source. The result is nil if parsing failed.


LKCompiler types

LKDebuggingMode

typedef enum ... LKDebuggingMode;
Description forthcoming.