Move things from the LanguageRuntime that obviously belong in the new Language plugin instead.

llvm-svn: 246611
This commit is contained in:
Jim Ingham 2015-09-02 01:06:46 +00:00
parent bb0cef6e9c
commit 0e0984eebb
18 changed files with 201 additions and 189 deletions

View File

@ -42,6 +42,30 @@ namespace lldb_private {
virtual lldb::TypeCategoryImplSP
GetFormatters ();
// These are accessors for general information about the Languages lldb knows about:
static lldb::LanguageType
GetLanguageTypeFromString (const char *string);
static const char *
GetNameForLanguageType (lldb::LanguageType language);
static void
PrintAllLanguages (Stream &s, const char *prefix, const char *suffix);
static bool
LanguageIsCPlusPlus (lldb::LanguageType language);
static bool
LanguageIsObjC (lldb::LanguageType language);
static bool
LanguageIsC (lldb::LanguageType language);
static bool
LanguageIsPascal (lldb::LanguageType language);
protected:
//------------------------------------------------------------------
// Classes that inherit from Language can see and modify these

View File

@ -92,28 +92,6 @@ public:
CreateExceptionPrecondition (lldb::LanguageType language,
bool catch_bp,
bool throw_bp);
static lldb::LanguageType
GetLanguageTypeFromString (const char *string);
static const char *
GetNameForLanguageType (lldb::LanguageType language);
static void
PrintAllLanguages (Stream &s, const char *prefix, const char *suffix);
static bool
LanguageIsCPlusPlus (lldb::LanguageType language);
static bool
LanguageIsObjC (lldb::LanguageType language);
static bool
LanguageIsC (lldb::LanguageType language);
static bool
LanguageIsPascal (lldb::LanguageType language);
Process *
GetProcess()
{

View File

@ -421,7 +421,7 @@ namespace lldb {
eLanguageTypeFortran03 = 0x0022, ///< ISO Fortran 2003.
eLanguageTypeFortran08 = 0x0023, ///< ISO Fortran 2008.
// Vendor Extensions
// Note: LanguageRuntime::GetNameForLanguageType
// Note: Language::GetNameForLanguageType
// assumes these can be used as indexes into array language_names, and
// Language::SetLanguageFromCString and Language::AsCString
// assume these can be used as indexes into array g_languages.

View File

@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/API/SBLanguageRuntime.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Language.h"
using namespace lldb;
using namespace lldb_private;
@ -16,11 +16,11 @@ using namespace lldb_private;
lldb::LanguageType
SBLanguageRuntime::GetLanguageTypeFromString (const char *string)
{
return LanguageRuntime::GetLanguageTypeFromString(string);
return Language::GetLanguageTypeFromString(string);
}
const char *
SBLanguageRuntime::GetNameForLanguageType (lldb::LanguageType language)
{
return LanguageRuntime::GetNameForLanguageType(language);
return Language::GetNameForLanguageType(language);
}

View File

@ -52,6 +52,7 @@
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
@ -1133,7 +1134,7 @@ SBTarget::BreakpointCreateForException (lldb::LanguageType language,
if (log)
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: %s throw: %s) => SBBreakpoint(%p)",
static_cast<void*>(target_sp.get()),
LanguageRuntime::GetNameForLanguageType(language),
Language::GetNameForLanguageType(language),
catch_bp ? "on" : "off", throw_bp ? "on" : "off",
static_cast<void*>(sb_bp.get()));

View File

@ -26,7 +26,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Target/StackFrame.h"
@ -165,7 +165,7 @@ public:
case 'E':
{
LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
LanguageType language = Language::GetLanguageTypeFromString (option_arg);
switch (language)
{
@ -251,7 +251,7 @@ public:
}
case 'L':
m_language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
m_language = Language::GetLanguageTypeFromString (option_arg);
if (m_language == eLanguageTypeUnknown)
error.SetErrorStringWithFormat ("Unknown language type: '%s' for breakpoint", option_arg);
break;

View File

@ -25,6 +25,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Variable.h"
@ -86,7 +87,7 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int
switch (short_option)
{
case 'l':
language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
language = Language::GetLanguageTypeFromString (option_arg);
if (language == eLanguageTypeUnknown)
error.SetErrorStringWithFormat ("unknown language type: '%s' for expression", option_arg);
break;

View File

@ -14,6 +14,7 @@
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/LanguageRuntime.h"
using namespace lldb;
@ -36,7 +37,7 @@ CommandObjectLanguage::GenerateHelpText (Stream &output_stream) {
output_stream << "\nlanguage name can be one of the following:\n";
LanguageRuntime::PrintAllLanguages(output_stream, " ", "\n");
Language::PrintAllLanguages(output_stream, " ", "\n");
}
CommandObjectLanguage::~CommandObjectLanguage ()

View File

@ -31,7 +31,7 @@
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/SectionLoadList.h"
@ -1529,7 +1529,7 @@ FormatEntity::Format (const Entry &entry,
CompileUnit *cu = sc->comp_unit;
if (cu)
{
const char *lang_name = LanguageRuntime::GetNameForLanguageType(cu->GetLanguage());
const char *lang_name = Language::GetNameForLanguageType(cu->GetLanguage());
if (lang_name)
{
s.PutCString(lang_name);

View File

@ -29,6 +29,7 @@
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
@ -1783,17 +1784,17 @@ Module::PrepareForFunctionNameLookup (const ConstString &name,
if (CPPLanguageRuntime::IsCPPMangledName (name_cstr))
lookup_name_type_mask = eFunctionNameTypeFull;
else if ((language == eLanguageTypeUnknown ||
LanguageRuntime::LanguageIsObjC(language)) &&
Language::LanguageIsObjC(language)) &&
ObjCLanguageRuntime::IsPossibleObjCMethodName (name_cstr))
lookup_name_type_mask = eFunctionNameTypeFull;
else if (LanguageRuntime::LanguageIsC(language))
else if (Language::LanguageIsC(language))
{
lookup_name_type_mask = eFunctionNameTypeFull;
}
else
{
if ((language == eLanguageTypeUnknown ||
LanguageRuntime::LanguageIsObjC(language)) &&
Language::LanguageIsObjC(language)) &&
ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr))
lookup_name_type_mask |= eFunctionNameTypeSelector;

View File

@ -28,6 +28,8 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Language.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@ -848,7 +850,7 @@ LanguageTypeHelpTextCallback ()
StreamString sstr;
sstr << "One of the following languages:\n";
LanguageRuntime::PrintAllLanguages(sstr, " ", "\n");
Language::PrintAllLanguages(sstr, " ", "\n");
sstr.Flush();

View File

@ -16,7 +16,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Language.h"
using namespace lldb;
using namespace lldb_private;
@ -30,7 +30,7 @@ OptionValueLanguage::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, u
{
if (dump_mask & eDumpOptionType)
strm.PutCString (" = ");
strm.PutCString (LanguageRuntime::GetNameForLanguageType(m_current_value));
strm.PutCString (Language::GetNameForLanguageType(m_current_value));
}
}
@ -48,7 +48,7 @@ OptionValueLanguage::SetValueFromString (llvm::StringRef value, VarSetOperationT
case eVarSetOperationAssign:
{
ConstString lang_name(value.trim());
LanguageType new_type = LanguageRuntime::GetLanguageTypeFromString(lang_name.GetCString());
LanguageType new_type = Language::GetLanguageTypeFromString(lang_name.GetCString());
if (new_type)
{
m_value_was_set = true;
@ -59,7 +59,7 @@ OptionValueLanguage::SetValueFromString (llvm::StringRef value, VarSetOperationT
StreamString error_strm;
error_strm.Printf("invalid language type '%s', ", value.str().c_str());
error_strm.Printf("valid values are:\n");
LanguageRuntime::PrintAllLanguages(error_strm, " ", "\n");
Language::PrintAllLanguages(error_strm, " ", "\n");
error.SetErrorString(error_strm.GetData());
}
}

View File

@ -17,7 +17,7 @@
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionValues.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Language.h"
using namespace lldb;
using namespace lldb_private;
@ -129,7 +129,7 @@ Property::Property (const PropertyDefinition &definition) :
{
LanguageType new_lang = eLanguageTypeUnknown;
if (definition.default_cstr_value)
LanguageRuntime::GetLanguageTypeFromString(definition.default_cstr_value);
Language::GetLanguageTypeFromString(definition.default_cstr_value);
else
new_lang = (LanguageType)definition.default_uint_value;
m_value_sp.reset (new OptionValueLanguage(new_lang));

View File

@ -25,6 +25,7 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "clang/AST/DeclCXX.h"
@ -2252,7 +2253,7 @@ DWARFASTParserClang::ParseFunctionFromDWARF (const SymbolContext& sc,
if (mangled)
func_name.SetValue(ConstString(mangled), true);
else if (die.GetParent().Tag() == DW_TAG_compile_unit &&
LanguageRuntime::LanguageIsCPlusPlus(die.GetLanguage()) &&
Language::LanguageIsCPlusPlus(die.GetLanguage()) &&
name && strcmp(name, "main") != 0)
{
// If the mangled name is not present in the DWARF, generate the demangled name

View File

@ -57,6 +57,8 @@
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/Language.h"
#include "DWARFASTParser.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugAbbrev.h"
@ -3914,7 +3916,7 @@ SymbolFileDWARF::ParseVariableDIE
// "(int) A::B::j = 4". If the compiler does not emit a linkage name, we should be able
// to generate a fully qualified name from the declaration context.
if (parent_tag == DW_TAG_compile_unit &&
LanguageRuntime::LanguageIsCPlusPlus(die.GetLanguage()))
Language::LanguageIsCPlusPlus(die.GetLanguage()))
{
DWARFDeclContext decl_ctx;

View File

@ -12,7 +12,7 @@
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Language.h"
using namespace lldb;
using namespace lldb_private;
@ -87,7 +87,7 @@ CompileUnit::DumpSymbolContext(Stream *s)
void
CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const
{
const char* language = LanguageRuntime::GetNameForLanguageType(m_language);
const char* language = Language::GetNameForLanguageType(m_language);
*s << "id = " << (const UserID&)*this << ", file = \"" << (const FileSpec&)*this << "\", language = \"" << language << '"';
}
@ -101,7 +101,7 @@ CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const
void
CompileUnit::Dump(Stream *s, bool show_context) const
{
const char* language = LanguageRuntime::GetNameForLanguageType(m_language);
const char* language = Language::GetNameForLanguageType(m_language);
s->Printf("%p: ", static_cast<const void*>(this));
s->Indent();

View File

@ -15,6 +15,7 @@
#include "lldb/Host/Mutex.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Stream.h"
using namespace lldb;
using namespace lldb_private;
@ -93,6 +94,146 @@ Language::GetFormatters ()
return nullptr;
}
struct language_name_pair {
const char *name;
LanguageType type;
};
struct language_name_pair language_names[] =
{
// To allow GetNameForLanguageType to be a simple array lookup, the first
// part of this array must follow enum LanguageType exactly.
{ "unknown", eLanguageTypeUnknown },
{ "c89", eLanguageTypeC89 },
{ "c", eLanguageTypeC },
{ "ada83", eLanguageTypeAda83 },
{ "c++", eLanguageTypeC_plus_plus },
{ "cobol74", eLanguageTypeCobol74 },
{ "cobol85", eLanguageTypeCobol85 },
{ "fortran77", eLanguageTypeFortran77 },
{ "fortran90", eLanguageTypeFortran90 },
{ "pascal83", eLanguageTypePascal83 },
{ "modula2", eLanguageTypeModula2 },
{ "java", eLanguageTypeJava },
{ "c99", eLanguageTypeC99 },
{ "ada95", eLanguageTypeAda95 },
{ "fortran95", eLanguageTypeFortran95 },
{ "pli", eLanguageTypePLI },
{ "objective-c", eLanguageTypeObjC },
{ "objective-c++", eLanguageTypeObjC_plus_plus },
{ "upc", eLanguageTypeUPC },
{ "d", eLanguageTypeD },
{ "python", eLanguageTypePython },
{ "opencl", eLanguageTypeOpenCL },
{ "go", eLanguageTypeGo },
{ "modula3", eLanguageTypeModula3 },
{ "haskell", eLanguageTypeHaskell },
{ "c++03", eLanguageTypeC_plus_plus_03 },
{ "c++11", eLanguageTypeC_plus_plus_11 },
{ "ocaml", eLanguageTypeOCaml },
{ "rust", eLanguageTypeRust },
{ "c11", eLanguageTypeC11 },
{ "swift", eLanguageTypeSwift },
{ "julia", eLanguageTypeJulia },
{ "dylan", eLanguageTypeDylan },
{ "c++14", eLanguageTypeC_plus_plus_14 },
{ "fortran03", eLanguageTypeFortran03 },
{ "fortran08", eLanguageTypeFortran08 },
// Vendor Extensions
{ "mipsassem", eLanguageTypeMipsAssembler },
{ "renderscript", eLanguageTypeExtRenderScript},
// Now synonyms, in arbitrary order
{ "objc", eLanguageTypeObjC },
{ "objc++", eLanguageTypeObjC_plus_plus },
{ "pascal", eLanguageTypePascal83 }
};
static uint32_t num_languages = sizeof(language_names) / sizeof (struct language_name_pair);
LanguageType
Language::GetLanguageTypeFromString (const char *string)
{
for (uint32_t i = 0; i < num_languages; i++)
{
if (strcasecmp (language_names[i].name, string) == 0)
return (LanguageType) language_names[i].type;
}
return eLanguageTypeUnknown;
}
const char *
Language::GetNameForLanguageType (LanguageType language)
{
if (language < num_languages)
return language_names[language].name;
else
return language_names[eLanguageTypeUnknown].name;
}
void
Language::PrintAllLanguages (Stream &s, const char *prefix, const char *suffix)
{
for (uint32_t i = 1; i < num_languages; i++)
{
s.Printf("%s%s%s", prefix, language_names[i].name, suffix);
}
}
bool
Language::LanguageIsCPlusPlus (LanguageType language)
{
switch (language)
{
case eLanguageTypeC_plus_plus:
case eLanguageTypeC_plus_plus_03:
case eLanguageTypeC_plus_plus_11:
case eLanguageTypeC_plus_plus_14:
return true;
default:
return false;
}
}
bool
Language::LanguageIsObjC (LanguageType language)
{
switch (language)
{
case eLanguageTypeObjC:
case eLanguageTypeObjC_plus_plus:
return true;
default:
return false;
}
}
bool
Language::LanguageIsC (LanguageType language)
{
switch (language)
{
case eLanguageTypeC:
case eLanguageTypeC89:
case eLanguageTypeC99:
case eLanguageTypeC11:
return true;
default:
return false;
}
}
bool
Language::LanguageIsPascal (LanguageType language)
{
switch (language)
{
case eLanguageTypePascal83:
return true;
default:
return false;
}
}
//----------------------------------------------------------------------
// Constructor
//----------------------------------------------------------------------

View File

@ -321,146 +321,6 @@ LanguageRuntime::CreateExceptionBreakpoint (Target &target,
return exc_breakpt_sp;
}
struct language_name_pair {
const char *name;
LanguageType type;
};
struct language_name_pair language_names[] =
{
// To allow GetNameForLanguageType to be a simple array lookup, the first
// part of this array must follow enum LanguageType exactly.
{ "unknown", eLanguageTypeUnknown },
{ "c89", eLanguageTypeC89 },
{ "c", eLanguageTypeC },
{ "ada83", eLanguageTypeAda83 },
{ "c++", eLanguageTypeC_plus_plus },
{ "cobol74", eLanguageTypeCobol74 },
{ "cobol85", eLanguageTypeCobol85 },
{ "fortran77", eLanguageTypeFortran77 },
{ "fortran90", eLanguageTypeFortran90 },
{ "pascal83", eLanguageTypePascal83 },
{ "modula2", eLanguageTypeModula2 },
{ "java", eLanguageTypeJava },
{ "c99", eLanguageTypeC99 },
{ "ada95", eLanguageTypeAda95 },
{ "fortran95", eLanguageTypeFortran95 },
{ "pli", eLanguageTypePLI },
{ "objective-c", eLanguageTypeObjC },
{ "objective-c++", eLanguageTypeObjC_plus_plus },
{ "upc", eLanguageTypeUPC },
{ "d", eLanguageTypeD },
{ "python", eLanguageTypePython },
{ "opencl", eLanguageTypeOpenCL },
{ "go", eLanguageTypeGo },
{ "modula3", eLanguageTypeModula3 },
{ "haskell", eLanguageTypeHaskell },
{ "c++03", eLanguageTypeC_plus_plus_03 },
{ "c++11", eLanguageTypeC_plus_plus_11 },
{ "ocaml", eLanguageTypeOCaml },
{ "rust", eLanguageTypeRust },
{ "c11", eLanguageTypeC11 },
{ "swift", eLanguageTypeSwift },
{ "julia", eLanguageTypeJulia },
{ "dylan", eLanguageTypeDylan },
{ "c++14", eLanguageTypeC_plus_plus_14 },
{ "fortran03", eLanguageTypeFortran03 },
{ "fortran08", eLanguageTypeFortran08 },
// Vendor Extensions
{ "mipsassem", eLanguageTypeMipsAssembler },
{ "renderscript", eLanguageTypeExtRenderScript},
// Now synonyms, in arbitrary order
{ "objc", eLanguageTypeObjC },
{ "objc++", eLanguageTypeObjC_plus_plus },
{ "pascal", eLanguageTypePascal83 }
};
static uint32_t num_languages = sizeof(language_names) / sizeof (struct language_name_pair);
LanguageType
LanguageRuntime::GetLanguageTypeFromString (const char *string)
{
for (uint32_t i = 0; i < num_languages; i++)
{
if (strcasecmp (language_names[i].name, string) == 0)
return (LanguageType) language_names[i].type;
}
return eLanguageTypeUnknown;
}
const char *
LanguageRuntime::GetNameForLanguageType (LanguageType language)
{
if (language < num_languages)
return language_names[language].name;
else
return language_names[eLanguageTypeUnknown].name;
}
void
LanguageRuntime::PrintAllLanguages (Stream &s, const char *prefix, const char *suffix)
{
for (uint32_t i = 1; i < num_languages; i++)
{
s.Printf("%s%s%s", prefix, language_names[i].name, suffix);
}
}
bool
LanguageRuntime::LanguageIsCPlusPlus (LanguageType language)
{
switch (language)
{
case eLanguageTypeC_plus_plus:
case eLanguageTypeC_plus_plus_03:
case eLanguageTypeC_plus_plus_11:
case eLanguageTypeC_plus_plus_14:
return true;
default:
return false;
}
}
bool
LanguageRuntime::LanguageIsObjC (LanguageType language)
{
switch (language)
{
case eLanguageTypeObjC:
case eLanguageTypeObjC_plus_plus:
return true;
default:
return false;
}
}
bool
LanguageRuntime::LanguageIsC (LanguageType language)
{
switch (language)
{
case eLanguageTypeC:
case eLanguageTypeC89:
case eLanguageTypeC99:
case eLanguageTypeC11:
return true;
default:
return false;
}
}
bool
LanguageRuntime::LanguageIsPascal (LanguageType language)
{
switch (language)
{
case eLanguageTypePascal83:
return true;
default:
return false;
}
}
void
LanguageRuntime::InitializeCommands (CommandObject* parent)
{