06f4381be0ad2e4c32c88accbfa07e26e332e902
[oota-llvm.git] / include / llvm / Debugger / SourceLanguage.h
1 //===- SourceLanguage.h - Interact with source languages --------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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.
14 //
15 // This interface is designed to be completely stateless, so all methods are
16 // const.
17 //
18 //===----------------------------------------------------------------------===//
19
20 #ifndef LLVM_DEBUGGER_SOURCELANGUAGE_H
21 #define LLVM_DEBUGGER_SOURCELANGUAGE_H
22
23 #include <string>
24
25 namespace llvm {
26   class GlobalVariable;
27   class SourceFileInfo;
28   class SourceFunctionInfo;
29   class ProgramInfo;
30   class RuntimeInfo;
31
32   struct SourceLanguage {
33     virtual ~SourceLanguage() {}
34
35     /// getSourceLanguageName - This method is used to implement the 'show
36     /// language' command in the debugger.
37     virtual const char *getSourceLanguageName() const = 0;
38
39     //===------------------------------------------------------------------===//
40     // Methods used to implement debugger hooks.
41     //
42
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.
46     ///
47     virtual bool printInfo(const std::string &What) const {
48       return false;
49     }
50
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
55     /// will be null.
56     ///
57     virtual SourceFunctionInfo *lookupFunction(const std::string &FunctionName,
58                                                ProgramInfo &PI,
59                                                RuntimeInfo *RI = 0) const {
60       return 0;
61     }
62
63
64     //===------------------------------------------------------------------===//
65     // Methods used to parse various pieces of program information.
66     //
67
68     /// createSourceFileInfo - This method can be implemented by the front-end
69     /// if it needs to keep track of information beyond what the debugger
70     /// requires.
71     virtual SourceFileInfo *
72     createSourceFileInfo(const GlobalVariable *Desc, ProgramInfo &PI) const;
73
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;
79
80
81     //===------------------------------------------------------------------===//
82     // Static methods used to get instances of various source languages.
83     //
84
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
88     /// bright.
89     static const SourceLanguage &get(unsigned ID);
90
91     /// get*Instance() - These methods return specific instances of languages.
92     ///
93     static const SourceLanguage &getCFamilyInstance();
94     static const SourceLanguage &getCPlusPlusInstance();
95     static const SourceLanguage &getUnknownLanguageInstance();
96   };
97 }
98
99 #endif