diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp | 88 |
1 files changed, 77 insertions, 11 deletions
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp b/contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp index a08a612..8f136a5 100644 --- a/contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp +++ b/contrib/llvm/tools/lldb/source/Interpreter/OptionValue.cpp @@ -222,6 +222,38 @@ OptionValue::GetAsFormat () const return nullptr; } +OptionValueLanguage * +OptionValue::GetAsLanguage () +{ + if (GetType () == OptionValue::eTypeLanguage) + return static_cast<OptionValueLanguage *>(this); + return NULL; +} + +const OptionValueLanguage * +OptionValue::GetAsLanguage () const +{ + if (GetType () == OptionValue::eTypeLanguage) + return static_cast<const OptionValueLanguage *>(this); + return NULL; +} + +OptionValueFormatEntity * +OptionValue::GetAsFormatEntity () +{ + if (GetType () == OptionValue::eTypeFormatEntity) + return static_cast<OptionValueFormatEntity *>(this); + return nullptr; +} + +const OptionValueFormatEntity * +OptionValue::GetAsFormatEntity () const +{ + if (GetType () == OptionValue::eTypeFormatEntity) + return static_cast<const OptionValueFormatEntity *>(this); + return nullptr; +} + OptionValuePathMappings * OptionValue::GetAsPathMappings () { @@ -452,6 +484,36 @@ OptionValue::SetFormatValue (lldb::Format new_value) return false; } +lldb::LanguageType +OptionValue::GetLanguageValue (lldb::LanguageType fail_value) const +{ + const OptionValueLanguage *option_value = GetAsLanguage (); + if (option_value) + return option_value->GetCurrentValue(); + return fail_value; +} + +bool +OptionValue::SetLanguageValue (lldb::LanguageType new_language) +{ + OptionValueLanguage *option_value = GetAsLanguage (); + if (option_value) + { + option_value->SetCurrentValue(new_language); + return true; + } + return false; +} + +const FormatEntity::Entry * +OptionValue::GetFormatEntity () const +{ + const OptionValueFormatEntity *option_value = GetAsFormatEntity(); + if (option_value) + return &option_value->GetCurrentValue(); + return nullptr; +} + const RegularExpression * OptionValue::GetRegexValue () const { @@ -563,6 +625,8 @@ OptionValue::GetBuiltinTypeAsCString (Type t) case eTypeFileSpec: return "file"; case eTypeFileSpecList: return "file-list"; case eTypeFormat: return "format"; + case eTypeFormatEntity: return "format-string"; + case eTypeLanguage: return "language"; case eTypePathMap: return "path-map"; case eTypeProperties: return "properties"; case eTypeRegex: return "regex"; @@ -583,19 +647,21 @@ OptionValue::CreateValueFromCStringForTypeMask (const char *value_cstr, uint32_t lldb::OptionValueSP value_sp; switch (type_mask) { - case 1u << eTypeArch: value_sp.reset(new OptionValueArch()); break; - case 1u << eTypeBoolean: value_sp.reset(new OptionValueBoolean(false)); break; - case 1u << eTypeChar: value_sp.reset(new OptionValueChar('\0')); break; - case 1u << eTypeFileSpec: value_sp.reset(new OptionValueFileSpec()); break; - case 1u << eTypeFormat: value_sp.reset(new OptionValueFormat(eFormatInvalid)); break; - case 1u << eTypeSInt64: value_sp.reset(new OptionValueSInt64()); break; - case 1u << eTypeString: value_sp.reset(new OptionValueString()); break; - case 1u << eTypeUInt64: value_sp.reset(new OptionValueUInt64()); break; - case 1u << eTypeUUID: value_sp.reset(new OptionValueUUID()); break; + case 1u << eTypeArch: value_sp.reset(new OptionValueArch()); break; + case 1u << eTypeBoolean: value_sp.reset(new OptionValueBoolean(false)); break; + case 1u << eTypeChar: value_sp.reset(new OptionValueChar('\0')); break; + case 1u << eTypeFileSpec: value_sp.reset(new OptionValueFileSpec()); break; + case 1u << eTypeFormat: value_sp.reset(new OptionValueFormat(eFormatInvalid)); break; + case 1u << eTypeFormatEntity: value_sp.reset(new OptionValueFormatEntity(NULL)); break; + case 1u << eTypeLanguage: value_sp.reset(new OptionValueLanguage(eLanguageTypeUnknown)); break; + case 1u << eTypeSInt64: value_sp.reset(new OptionValueSInt64()); break; + case 1u << eTypeString: value_sp.reset(new OptionValueString()); break; + case 1u << eTypeUInt64: value_sp.reset(new OptionValueUInt64()); break; + case 1u << eTypeUUID: value_sp.reset(new OptionValueUUID()); break; } if (value_sp) - error = value_sp->SetValueFromCString (value_cstr, eVarSetOperationAssign); + error = value_sp->SetValueFromString (value_cstr, eVarSetOperationAssign); else error.SetErrorString("unsupported type mask"); return value_sp; @@ -637,7 +703,7 @@ OptionValue::AutoComplete (CommandInterpreter &interpreter, } Error -OptionValue::SetValueFromCString (const char *value, VarSetOperationType op) +OptionValue::SetValueFromString (llvm::StringRef value, VarSetOperationType op) { Error error; switch (op) |