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