1 //===- SourceLanguage.h - Interact with source languages --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the abstract SourceLanguage interface, which is used by the
11 // LLVM debugger to parse source-language expressions and render program objects
12 // into a human readable string. In general, these classes perform all of the
13 // analysis and interpretation of the language-specific debugger information.
15 // This interface is designed to be completely stateless, so all methods are
18 //===----------------------------------------------------------------------===//
20 #ifndef LLVM_DEBUGGER_SOURCELANGUAGE_H
21 #define LLVM_DEBUGGER_SOURCELANGUAGE_H
28 class SourceFunctionInfo;
32 struct SourceLanguage {
33 virtual ~SourceLanguage() {}
35 /// getSourceLanguageName - This method is used to implement the 'show
36 /// language' command in the debugger.
37 virtual const char *getSourceLanguageName() const = 0;
39 //===------------------------------------------------------------------===//
40 // Methods used to implement debugger hooks.
43 /// printInfo - Implementing this method allows the debugger to use
44 /// language-specific 'info' extensions, e.g., 'info selectors' for objc.
45 /// This method should return true if the specified string is recognized.
47 virtual bool printInfo(const std::string &What) const {
51 /// lookupFunction - Given a textual function name, return the
52 /// SourceFunctionInfo descriptor for that function, or null if it cannot be
53 /// found. If the program is currently running, the RuntimeInfo object
54 /// provides information about the current evaluation context, otherwise it
57 virtual SourceFunctionInfo *lookupFunction(const std::string &FunctionName,
59 RuntimeInfo *RI = 0) const {
64 //===------------------------------------------------------------------===//
65 // Methods used to parse various pieces of program information.
68 /// createSourceFileInfo - This method can be implemented by the front-end
69 /// if it needs to keep track of information beyond what the debugger
71 virtual SourceFileInfo *
72 createSourceFileInfo(const GlobalVariable *Desc, ProgramInfo &PI) const;
74 /// createSourceFunctionInfo - This method can be implemented by the derived
75 /// SourceLanguage if it needs to keep track of more information than the
76 /// SourceFunctionInfo has.
77 virtual SourceFunctionInfo *
78 createSourceFunctionInfo(const GlobalVariable *Desc, ProgramInfo &PI) const;
81 //===------------------------------------------------------------------===//
82 // Static methods used to get instances of various source languages.
85 /// get - This method returns a source-language instance for the specified
86 /// Dwarf 3 language identifier. If the language is unknown, an object is
87 /// returned that can support some minimal operations, but is not terribly
89 static const SourceLanguage &get(unsigned ID);
91 /// get*Instance() - These methods return specific instances of languages.
93 static const SourceLanguage &getCFamilyInstance();
94 static const SourceLanguage &getCPlusPlusInstance();
95 static const SourceLanguage &getUnknownLanguageInstance();