1 //===-- OptionValueFormat.cpp -----------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Interpreter/OptionValueLanguage.h" 11 12 // C Includes 13 // C++ Includes 14 // Other libraries and framework includes 15 // Project includes 16 #include "lldb/Core/Stream.h" 17 #include "lldb/DataFormatters/FormatManager.h" 18 #include "lldb/Interpreter/Args.h" 19 #include "lldb/Target/LanguageRuntime.h" 20 21 using namespace lldb; 22 using namespace lldb_private; 23 24 void 25 OptionValueLanguage::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) 26 { 27 if (dump_mask & eDumpOptionType) 28 strm.Printf ("(%s)", GetTypeAsCString ()); 29 if (dump_mask & eDumpOptionValue) 30 { 31 if (dump_mask & eDumpOptionType) 32 strm.PutCString (" = "); 33 strm.PutCString (LanguageRuntime::GetNameForLanguageType(m_current_value)); 34 } 35 } 36 37 Error 38 OptionValueLanguage::SetValueFromString (llvm::StringRef value, VarSetOperationType op) 39 { 40 Error error; 41 switch (op) 42 { 43 case eVarSetOperationClear: 44 Clear(); 45 break; 46 47 case eVarSetOperationReplace: 48 case eVarSetOperationAssign: 49 { 50 LanguageType new_type = LanguageRuntime::GetLanguageTypeFromString(value.data()); 51 m_value_was_set = true; 52 m_current_value = new_type; 53 } 54 break; 55 56 case eVarSetOperationInsertBefore: 57 case eVarSetOperationInsertAfter: 58 case eVarSetOperationRemove: 59 case eVarSetOperationAppend: 60 case eVarSetOperationInvalid: 61 error = OptionValue::SetValueFromString(value, op); 62 break; 63 } 64 return error; 65 } 66 67 68 lldb::OptionValueSP 69 OptionValueLanguage::DeepCopy () const 70 { 71 return OptionValueSP(new OptionValueLanguage(*this)); 72 } 73 74