LKCompiler class documentation
LKCompiler : NSObjectOverview
Abstract class implementing a dynamic language compiler. Concrete subclasses provide implementations for specific languages.
Default
- + (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.
- - (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.
- + (void) addClassLoader: (LKClassLoader)aBlock
Adds a new class loader. These will be called in the order that they appear.
- + (LKCompiler *) compiler
Returns a new autoreleased compiler for this language.
- + (BOOL) inDevMode
Returns whether we are in developer mode. In this mode, all unrecognised symbols are assumed to be classes.
- + (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.
- - (LKAST *) compileString: (NSString *)source
Compiles and loads the specified source code. Returns the AST on success, nil on failure.
- - (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.
- - (BOOL) compileMethod: (NSString *)source onClassNamed: (NSString *)name
Compiles and loads a method on the class with the specified name.
- - (BOOL) compileMethod: (NSString *)source onClassNamed: (NSString *)name output: (NSString *)bitcode
Compiles a method to LLVM bitcode for the class with the specified name.
- - (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.
- + (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.
- - (BOOL) loadScriptNamed: (NSString *)name fromBundle: (NSBundle *)bundle
Compiles and loads a file from the specified bundle. Omit the extension in the name paramater.
- + (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.
- - (BOOL) loadApplicationScriptNamed: (NSString *)name
Compiles and loads a file from the application bundle. Omit the extension in the name paramater.
- + (BOOL) loadScriptsFromBundle: (NSBundle *)aBundle
Loads all scripts for all known languages from the specified bundle.
- - (BOOL) loadScriptsFromBundle: (NSBundle *)aBundle
Loads all scripts written in this language from the specified bundle.
- + (BOOL) loadAllScriptsForApplication
Loads all scripts for all known languages from the application bundle.
- - (BOOL) loadAllScriptsForApplication
Loads all scripts written in this language from the application bundle.
- + (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
- + (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).
- + (BOOL) loadAllPlugInsForApplication
Loads all of the LanguageKit plugins for the current application.
- + (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.
- + (BOOL) loadLibrary: (NSString *)aLibrary
Attempts to load a library from an absolute path or one of the standard library locations.
- + (NSString *) fileExtension
Returns the extension used for scripts in this language.
Implemented by subclasses.
- + (NSString *) languageName
Returns the name of the language supported by this compiler.
Implemented by subclasses.
- + (NSArray *) supportedLanguageNames
Returns the languages for which compilers are currently supported.
- + (Class) compilerClassForFileExtension: (NSString *)anExtension
Returns the compiler for files with a given extension.
- + (BOOL) reportWarning: (NSString *)aWarning details: (NSDictionary *)info
Reports the given warning and returns YES if recovery should proceed.
- + (BOOL) reportError: (NSString *)aWarning details: (NSDictionary *)info
Reports the given error and returns YES if recovery should proceed.
- + (LKAST *) parseScript: (NSString *)script forFileExtension: (NSString *)extension
Parse the specified string, using the correct parse.