1 //===-- OptionValueArch.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/OptionValueArch.h"
11 
12 // C Includes
13 // C++ Includes
14 // Other libraries and framework includes
15 // Project includes
16 #include "lldb/Core/FormatManager.h"
17 #include "lldb/Core/State.h"
18 #include "lldb/Interpreter/Args.h"
19 #include "lldb/Interpreter/CommandCompletions.h"
20 
21 using namespace lldb;
22 using namespace lldb_private;
23 
24 void
25 OptionValueArch::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 
34         if (m_current_value.IsValid())
35         {
36             const char *arch_name = m_current_value.GetArchitectureName();
37             if (arch_name)
38                 strm.PutCString (arch_name);
39         }
40     }
41 }
42 
43 Error
44 OptionValueArch::SetValueFromCString (const char *value_cstr, VarSetOperationType op)
45 {
46     Error error;
47     switch (op)
48     {
49     case eVarSetOperationClear:
50         Clear();
51         break;
52 
53     case eVarSetOperationReplace:
54     case eVarSetOperationAssign:
55         if (value_cstr && value_cstr[0])
56         {
57             if (m_current_value.SetTriple (value_cstr))
58                 m_value_was_set = true;
59             else
60                 error.SetErrorStringWithFormat("unsupported architecture '%s'", value_cstr);
61         }
62         else
63         {
64             error.SetErrorString("invalid value string");
65         }
66         break;
67 
68     case eVarSetOperationInsertBefore:
69     case eVarSetOperationInsertAfter:
70     case eVarSetOperationRemove:
71     case eVarSetOperationAppend:
72     case eVarSetOperationInvalid:
73         error = OptionValue::SetValueFromCString (value_cstr, op);
74         break;
75     }
76     return error;
77 }
78 
79 lldb::OptionValueSP
80 OptionValueArch::DeepCopy () const
81 {
82     return OptionValueSP(new OptionValueArch(*this));
83 }
84 
85 
86 size_t
87 OptionValueArch::AutoComplete (CommandInterpreter &interpreter,
88                                    const char *s,
89                                    int match_start_point,
90                                    int max_return_elements,
91                                    bool &word_complete,
92                                    StringList &matches)
93 {
94     word_complete = false;
95     matches.Clear();
96     CommandCompletions::InvokeCommonCompletionCallbacks (interpreter,
97                                                          CommandCompletions::eArchitectureCompletion,
98                                                          s,
99                                                          match_start_point,
100                                                          max_return_elements,
101                                                          NULL,
102                                                          word_complete,
103                                                          matches);
104     return matches.GetSize();
105 }
106 
107 
108 
109 
110