forked from OSchip/llvm-project
Added support for enumerating the languages that actually support TypeSystems
and expressions. Also wired that into the OptionValue infrastructure, although it isn't used for tab-completion yet. llvm-svn: 249769
This commit is contained in:
parent
46e642f8c5
commit
fe38c8506f
|
@ -425,7 +425,8 @@ public:
|
||||||
static bool
|
static bool
|
||||||
RegisterPlugin (const ConstString &name,
|
RegisterPlugin (const ConstString &name,
|
||||||
const char *description,
|
const char *description,
|
||||||
TypeSystemCreateInstance create_callback);
|
TypeSystemCreateInstance create_callback,
|
||||||
|
TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
UnregisterPlugin (TypeSystemCreateInstance create_callback);
|
UnregisterPlugin (TypeSystemCreateInstance create_callback);
|
||||||
|
@ -436,6 +437,12 @@ public:
|
||||||
static TypeSystemCreateInstance
|
static TypeSystemCreateInstance
|
||||||
GetTypeSystemCreateCallbackForPluginName (const ConstString &name);
|
GetTypeSystemCreateCallbackForPluginName (const ConstString &name);
|
||||||
|
|
||||||
|
static TypeSystemEnumerateSupportedLanguages
|
||||||
|
GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx);
|
||||||
|
|
||||||
|
static TypeSystemEnumerateSupportedLanguages
|
||||||
|
GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name);
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Some plug-ins might register a DebuggerInitializeCallback
|
// Some plug-ins might register a DebuggerInitializeCallback
|
||||||
// callback when registering the plug-in. After a new Debugger
|
// callback when registering the plug-in. After a new Debugger
|
||||||
|
|
|
@ -72,6 +72,9 @@ public:
|
||||||
|
|
||||||
static lldb::TypeSystemSP
|
static lldb::TypeSystemSP
|
||||||
CreateInstance (lldb::LanguageType language, Module *module, Target *target);
|
CreateInstance (lldb::LanguageType language, Module *module, Target *target);
|
||||||
|
|
||||||
|
static void
|
||||||
|
EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Initialize ();
|
Initialize ();
|
||||||
|
|
|
@ -41,6 +41,9 @@ class GoASTContext : public TypeSystem
|
||||||
|
|
||||||
static lldb::TypeSystemSP
|
static lldb::TypeSystemSP
|
||||||
CreateInstance (lldb::LanguageType language, Module *module, Target *target);
|
CreateInstance (lldb::LanguageType language, Module *module, Target *target);
|
||||||
|
|
||||||
|
static void
|
||||||
|
EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Initialize ();
|
Initialize ();
|
||||||
|
|
|
@ -139,7 +139,11 @@ public:
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
LanguageIsPascal (lldb::LanguageType language);
|
LanguageIsPascal (lldb::LanguageType language);
|
||||||
|
|
||||||
|
static void
|
||||||
|
GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
|
||||||
|
std::set<lldb::LanguageType> &languages_for_expressions);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Classes that inherit from Language can see and modify these
|
// Classes that inherit from Language can see and modify these
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include "lldb/lldb-private.h"
|
#include "lldb/lldb-private.h"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
namespace lldb_private
|
namespace lldb_private
|
||||||
{
|
{
|
||||||
typedef lldb::ABISP (*ABICreateInstance) (const ArchSpec &arch);
|
typedef lldb::ABISP (*ABICreateInstance) (const ArchSpec &arch);
|
||||||
|
@ -47,6 +49,7 @@ namespace lldb_private
|
||||||
typedef lldb::InstrumentationRuntimeType (*InstrumentationRuntimeGetType) ();
|
typedef lldb::InstrumentationRuntimeType (*InstrumentationRuntimeGetType) ();
|
||||||
typedef lldb::InstrumentationRuntimeSP (*InstrumentationRuntimeCreateInstance) (const lldb::ProcessSP &process_sp);
|
typedef lldb::InstrumentationRuntimeSP (*InstrumentationRuntimeCreateInstance) (const lldb::ProcessSP &process_sp);
|
||||||
typedef lldb::TypeSystemSP (*TypeSystemCreateInstance) (lldb::LanguageType language, Module *module, Target *target);
|
typedef lldb::TypeSystemSP (*TypeSystemCreateInstance) (lldb::LanguageType language, Module *module, Target *target);
|
||||||
|
typedef void (*TypeSystemEnumerateSupportedLanguages) (std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
|
||||||
typedef int (*ComparisonFunction)(const void *, const void *);
|
typedef int (*ComparisonFunction)(const void *, const void *);
|
||||||
typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
|
typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
|
||||||
|
|
||||||
|
|
|
@ -2531,6 +2531,7 @@ struct TypeSystemInstance
|
||||||
ConstString name;
|
ConstString name;
|
||||||
std::string description;
|
std::string description;
|
||||||
TypeSystemCreateInstance create_callback;
|
TypeSystemCreateInstance create_callback;
|
||||||
|
TypeSystemEnumerateSupportedLanguages enumerate_callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<TypeSystemInstance> TypeSystemInstances;
|
typedef std::vector<TypeSystemInstance> TypeSystemInstances;
|
||||||
|
@ -2552,7 +2553,8 @@ GetTypeSystemInstances ()
|
||||||
bool
|
bool
|
||||||
PluginManager::RegisterPlugin (const ConstString &name,
|
PluginManager::RegisterPlugin (const ConstString &name,
|
||||||
const char *description,
|
const char *description,
|
||||||
TypeSystemCreateInstance create_callback)
|
TypeSystemCreateInstance create_callback,
|
||||||
|
TypeSystemEnumerateSupportedLanguages enumerate_supported_languages_callback)
|
||||||
{
|
{
|
||||||
if (create_callback)
|
if (create_callback)
|
||||||
{
|
{
|
||||||
|
@ -2617,6 +2619,33 @@ PluginManager::GetTypeSystemCreateCallbackForPluginName (const ConstString &name
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TypeSystemEnumerateSupportedLanguages
|
||||||
|
PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx)
|
||||||
|
{
|
||||||
|
Mutex::Locker locker (GetTypeSystemMutex ());
|
||||||
|
TypeSystemInstances &instances = GetTypeSystemInstances ();
|
||||||
|
if (idx < instances.size())
|
||||||
|
return instances[idx].enumerate_callback;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeSystemEnumerateSupportedLanguages
|
||||||
|
PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name)
|
||||||
|
{
|
||||||
|
if (name)
|
||||||
|
{
|
||||||
|
Mutex::Locker locker (GetTypeSystemMutex ());
|
||||||
|
TypeSystemInstances &instances = GetTypeSystemInstances ();
|
||||||
|
|
||||||
|
TypeSystemInstances::iterator pos, end = instances.end();
|
||||||
|
for (pos = instances.begin(); pos != end; ++ pos)
|
||||||
|
{
|
||||||
|
if (name == pos->name)
|
||||||
|
return pos->enumerate_callback;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark PluginManager
|
#pragma mark PluginManager
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,12 @@ OptionValueLanguage::SetValueFromString (llvm::StringRef value, VarSetOperationT
|
||||||
case eVarSetOperationAssign:
|
case eVarSetOperationAssign:
|
||||||
{
|
{
|
||||||
ConstString lang_name(value.trim());
|
ConstString lang_name(value.trim());
|
||||||
|
std::set<lldb::LanguageType> languages_for_types;
|
||||||
|
std::set<lldb::LanguageType> languages_for_expressions;
|
||||||
|
Language::GetLanguagesSupportingTypeSystems(languages_for_types, languages_for_expressions);
|
||||||
|
|
||||||
LanguageType new_type = Language::GetLanguageTypeFromString(lang_name.GetCString());
|
LanguageType new_type = Language::GetLanguageTypeFromString(lang_name.GetCString());
|
||||||
if (new_type)
|
if (new_type && languages_for_types.count(new_type))
|
||||||
{
|
{
|
||||||
m_value_was_set = true;
|
m_value_was_set = true;
|
||||||
m_current_value = new_type;
|
m_current_value = new_type;
|
||||||
|
@ -59,7 +63,10 @@ OptionValueLanguage::SetValueFromString (llvm::StringRef value, VarSetOperationT
|
||||||
StreamString error_strm;
|
StreamString error_strm;
|
||||||
error_strm.Printf("invalid language type '%s', ", value.str().c_str());
|
error_strm.Printf("invalid language type '%s', ", value.str().c_str());
|
||||||
error_strm.Printf("valid values are:\n");
|
error_strm.Printf("valid values are:\n");
|
||||||
Language::PrintAllLanguages(error_strm, " ", "\n");
|
for (lldb::LanguageType language : languages_for_types)
|
||||||
|
{
|
||||||
|
error_strm.Printf("%s%s%s", " ", Language::GetNameForLanguageType(language), "\n");
|
||||||
|
}
|
||||||
error.SetErrorString(error_strm.GetData());
|
error.SetErrorString(error_strm.GetData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
// C++ Includes
|
// C++ Includes
|
||||||
#include <mutex> // std::once
|
#include <mutex> // std::once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// Other libraries and framework includes
|
// Other libraries and framework includes
|
||||||
|
|
||||||
|
@ -424,13 +425,41 @@ ClangASTContext::CreateInstance (lldb::LanguageType language, Module *module, Ta
|
||||||
return lldb::TypeSystemSP();
|
return lldb::TypeSystemSP();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClangASTContext::EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions)
|
||||||
|
{
|
||||||
|
static std::vector<lldb::LanguageType> s_supported_languages_for_types({
|
||||||
|
lldb::eLanguageTypeC89,
|
||||||
|
lldb::eLanguageTypeC,
|
||||||
|
lldb::eLanguageTypeC11,
|
||||||
|
lldb::eLanguageTypeC_plus_plus,
|
||||||
|
lldb::eLanguageTypeC99,
|
||||||
|
lldb::eLanguageTypeObjC,
|
||||||
|
lldb::eLanguageTypeObjC_plus_plus,
|
||||||
|
lldb::eLanguageTypeC_plus_plus_03,
|
||||||
|
lldb::eLanguageTypeC_plus_plus_11,
|
||||||
|
lldb::eLanguageTypeC11,
|
||||||
|
lldb::eLanguageTypeC_plus_plus_14});
|
||||||
|
|
||||||
|
static std::vector<lldb::LanguageType> s_supported_languages_for_expressions({
|
||||||
|
lldb::eLanguageTypeC_plus_plus,
|
||||||
|
lldb::eLanguageTypeObjC_plus_plus,
|
||||||
|
lldb::eLanguageTypeC_plus_plus_03,
|
||||||
|
lldb::eLanguageTypeC_plus_plus_11,
|
||||||
|
lldb::eLanguageTypeC_plus_plus_14});
|
||||||
|
|
||||||
|
languages_for_types.insert(s_supported_languages_for_types.begin(), s_supported_languages_for_types.end());
|
||||||
|
languages_for_expressions.insert(s_supported_languages_for_expressions.begin(), s_supported_languages_for_expressions.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ClangASTContext::Initialize()
|
ClangASTContext::Initialize()
|
||||||
{
|
{
|
||||||
PluginManager::RegisterPlugin (GetPluginNameStatic(),
|
PluginManager::RegisterPlugin (GetPluginNameStatic(),
|
||||||
"clang base AST context plug-in",
|
"clang base AST context plug-in",
|
||||||
CreateInstance);
|
CreateInstance,
|
||||||
|
EnumerateSupportedLanguages);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -342,13 +342,26 @@ GoASTContext::CreateInstance (lldb::LanguageType language, Module *module, Targe
|
||||||
return lldb::TypeSystemSP();
|
return lldb::TypeSystemSP();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GoASTContext::EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions)
|
||||||
|
{
|
||||||
|
static std::vector<lldb::LanguageType> s_supported_languages_for_types({
|
||||||
|
lldb::eLanguageTypeGo});
|
||||||
|
|
||||||
|
static std::vector<lldb::LanguageType> s_supported_languages_for_expressions({});
|
||||||
|
|
||||||
|
languages_for_types.insert(s_supported_languages_for_types.begin(), s_supported_languages_for_types.end());
|
||||||
|
languages_for_expressions.insert(s_supported_languages_for_expressions.begin(), s_supported_languages_for_expressions.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GoASTContext::Initialize()
|
GoASTContext::Initialize()
|
||||||
{
|
{
|
||||||
PluginManager::RegisterPlugin (GetPluginNameStatic(),
|
PluginManager::RegisterPlugin (GetPluginNameStatic(),
|
||||||
"AST context plug-in",
|
"AST context plug-in",
|
||||||
CreateInstance);
|
CreateInstance,
|
||||||
|
EnumerateSupportedLanguages);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -287,6 +287,18 @@ Language::LanguageIsPascal (LanguageType language)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Language::GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
|
||||||
|
std::set<lldb::LanguageType> &languages_for_expressions)
|
||||||
|
{
|
||||||
|
uint32_t idx = 0;
|
||||||
|
|
||||||
|
while (TypeSystemEnumerateSupportedLanguages enumerate = PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(idx++))
|
||||||
|
{
|
||||||
|
(*enumerate)(languages, languages_for_expressions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<Language::TypeScavenger>
|
std::unique_ptr<Language::TypeScavenger>
|
||||||
Language::GetTypeScavenger ()
|
Language::GetTypeScavenger ()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue