LLVM API Documentation
00001 //===- SourceLanguage.h - Interact with source languages --------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the abstract SourceLanguage interface, which is used by the 00011 // LLVM debugger to parse source-language expressions and render program objects 00012 // into a human readable string. In general, these classes perform all of the 00013 // analysis and interpretation of the language-specific debugger information. 00014 // 00015 // This interface is designed to be completely stateless, so all methods are 00016 // const. 00017 // 00018 //===----------------------------------------------------------------------===// 00019 00020 #ifndef LLVM_DEBUGGER_SOURCELANGUAGE_H 00021 #define LLVM_DEBUGGER_SOURCELANGUAGE_H 00022 00023 #include <string> 00024 00025 namespace llvm { 00026 class GlobalVariable; 00027 class SourceFileInfo; 00028 class SourceFunctionInfo; 00029 class ProgramInfo; 00030 class RuntimeInfo; 00031 00032 struct SourceLanguage { 00033 virtual ~SourceLanguage() {} 00034 00035 /// getSourceLanguageName - This method is used to implement the 'show 00036 /// language' command in the debugger. 00037 virtual const char *getSourceLanguageName() const = 0; 00038 00039 //===------------------------------------------------------------------===// 00040 // Methods used to implement debugger hooks. 00041 // 00042 00043 /// printInfo - Implementing this method allows the debugger to use 00044 /// language-specific 'info' extensions, e.g., 'info selectors' for objc. 00045 /// This method should return true if the specified string is recognized. 00046 /// 00047 virtual bool printInfo(const std::string &What) const { 00048 return false; 00049 } 00050 00051 /// lookupFunction - Given a textual function name, return the 00052 /// SourceFunctionInfo descriptor for that function, or null if it cannot be 00053 /// found. If the program is currently running, the RuntimeInfo object 00054 /// provides information about the current evaluation context, otherwise it 00055 /// will be null. 00056 /// 00057 virtual SourceFunctionInfo *lookupFunction(const std::string &FunctionName, 00058 ProgramInfo &PI, 00059 RuntimeInfo *RI = 0) const { 00060 return 0; 00061 } 00062 00063 00064 //===------------------------------------------------------------------===// 00065 // Methods used to parse various pieces of program information. 00066 // 00067 00068 /// createSourceFileInfo - This method can be implemented by the front-end 00069 /// if it needs to keep track of information beyond what the debugger 00070 /// requires. 00071 virtual SourceFileInfo * 00072 createSourceFileInfo(const GlobalVariable *Desc, ProgramInfo &PI) const; 00073 00074 /// createSourceFunctionInfo - This method can be implemented by the derived 00075 /// SourceLanguage if it needs to keep track of more information than the 00076 /// SourceFunctionInfo has. 00077 virtual SourceFunctionInfo * 00078 createSourceFunctionInfo(const GlobalVariable *Desc, ProgramInfo &PI) const; 00079 00080 00081 //===------------------------------------------------------------------===// 00082 // Static methods used to get instances of various source languages. 00083 // 00084 00085 /// get - This method returns a source-language instance for the specified 00086 /// Dwarf 3 language identifier. If the language is unknown, an object is 00087 /// returned that can support some minimal operations, but is not terribly 00088 /// bright. 00089 static const SourceLanguage &get(unsigned ID); 00090 00091 /// get*Instance() - These methods return specific instances of languages. 00092 /// 00093 static const SourceLanguage &getCFamilyInstance(); 00094 static const SourceLanguage &getCPlusPlusInstance(); 00095 static const SourceLanguage &getUnknownLanguageInstance(); 00096 }; 00097 } 00098 00099 #endif