1 //===-- Language.h ---------------------------------------------------*- 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 #ifndef liblldb_Language_h_
11 #define liblldb_Language_h_
20 // Other libraries and framework includes
22 #include "lldb/lldb-public.h"
23 #include "lldb/lldb-private.h"
24 #include "lldb/Core/PluginInterface.h"
25 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
26 #include "lldb/DataFormatters/FormatClasses.h"
27 #include "lldb/DataFormatters/StringPrinter.h"
29 namespace lldb_private {
32 public PluginInterface
45 DumpToStream (Stream& stream,
46 bool print_help_if_available) = 0;
48 virtual ~Result() = default;
51 typedef std::set<std::unique_ptr<Result>> ResultSet;
53 virtual ~TypeScavenger () = default;
56 Find (ExecutionContextScope *exe_scope,
62 TypeScavenger () = default;
65 Find_Impl (ExecutionContextScope *exe_scope,
67 ResultSet &results) = 0;
70 enum class FunctionNameRepresentation
80 FindPlugin (lldb::LanguageType language);
82 // return false from callback to stop iterating
84 ForEach (std::function<bool(Language*)> callback);
86 virtual lldb::LanguageType
87 GetLanguageType () const = 0;
90 IsTopLevelFunction (Function& function);
92 virtual lldb::TypeCategoryImplSP
95 virtual HardcodedFormatters::HardcodedFormatFinder
96 GetHardcodedFormats ();
98 virtual HardcodedFormatters::HardcodedSummaryFinder
99 GetHardcodedSummaries ();
101 virtual HardcodedFormatters::HardcodedSyntheticFinder
102 GetHardcodedSynthetics ();
104 virtual HardcodedFormatters::HardcodedValidatorFinder
105 GetHardcodedValidators ();
107 virtual std::vector<ConstString>
108 GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic);
110 virtual lldb_private::formatters::StringPrinter::EscapingHelper
111 GetStringPrinterEscapingHelper (lldb_private::formatters::StringPrinter::GetPrintableElementType);
113 virtual std::unique_ptr<TypeScavenger>
116 // if an individual data formatter can apply to several types and cross a language boundary
117 // it makes sense for individual languages to want to customize the printing of values of that
118 // type by appending proper prefix/suffix information in language-specific ways
120 GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint,
121 std::string& prefix, std::string& suffix);
123 // if a language has a custom format for printing variable declarations that it wants LLDB to honor
124 // it should return an appropriate closure here
125 virtual DumpValueObjectOptions::DeclPrintingHelper
126 GetDeclPrintingHelper ();
129 IsLogicalTrue (ValueObject& valobj,
132 // for a ValueObject of some "reference type", if the value points to the
133 // nil/null object, this method returns true
135 IsNilReference (ValueObject& valobj);
137 // for a ValueObject of some "reference type", if the language provides a technique
138 // to decide whether the reference has ever been assigned to some object, this method
139 // will return true if such detection is possible, and if the reference has never been assigned
141 IsUninitializedReference (ValueObject& valobj);
144 GetFunctionDisplayName (const SymbolContext *sc,
145 const ExecutionContext *exe_ctx,
146 FunctionNameRepresentation representation,
150 GetExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s);
153 GetDefaultExceptionResolverDescription(bool catch_on, bool throw_on, Stream &s);
155 // These are accessors for general information about the Languages lldb knows about:
157 static lldb::LanguageType
158 GetLanguageTypeFromString (const char *string);
161 GetNameForLanguageType (lldb::LanguageType language);
164 PrintAllLanguages (Stream &s, const char *prefix, const char *suffix);
166 // return false from callback to stop iterating
168 ForAllLanguages (std::function<bool(lldb::LanguageType)> callback);
171 LanguageIsCPlusPlus (lldb::LanguageType language);
174 LanguageIsObjC (lldb::LanguageType language);
177 LanguageIsC (lldb::LanguageType language);
180 LanguageIsPascal (lldb::LanguageType language);
182 // return the primary language, so if LanguageIsC(l), return eLanguageTypeC, etc.
183 static lldb::LanguageType
184 GetPrimaryLanguage (lldb::LanguageType language);
187 GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
188 std::set<lldb::LanguageType> &languages_for_expressions);
191 GetLanguagesSupportingREPLs (std::set<lldb::LanguageType> &languages);
194 //------------------------------------------------------------------
195 // Classes that inherit from Language can see and modify these
196 //------------------------------------------------------------------
201 DISALLOW_COPY_AND_ASSIGN (Language);
204 } // namespace lldb_private
206 #endif // liblldb_Language_h_