OptionValueArch.cpp revision 254721
1254721Semaste//===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===//
2254721Semaste//
3254721Semaste//                     The LLVM Compiler Infrastructure
4254721Semaste//
5254721Semaste// This file is distributed under the University of Illinois Open Source
6254721Semaste// License. See LICENSE.TXT for details.
7254721Semaste//
8254721Semaste//===----------------------------------------------------------------------===//
9254721Semaste
10254721Semaste#include "lldb/lldb-python.h"
11254721Semaste
12254721Semaste#include "lldb/Interpreter/OptionValueArch.h"
13254721Semaste
14254721Semaste// C Includes
15254721Semaste// C++ Includes
16254721Semaste// Other libraries and framework includes
17254721Semaste// Project includes
18254721Semaste#include "lldb/Core/State.h"
19254721Semaste#include "lldb/DataFormatters/FormatManager.h"
20254721Semaste#include "lldb/Interpreter/Args.h"
21254721Semaste#include "lldb/Interpreter/CommandCompletions.h"
22254721Semaste
23254721Semasteusing namespace lldb;
24254721Semasteusing namespace lldb_private;
25254721Semaste
26254721Semastevoid
27254721SemasteOptionValueArch::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
28254721Semaste{
29254721Semaste    if (dump_mask & eDumpOptionType)
30254721Semaste        strm.Printf ("(%s)", GetTypeAsCString ());
31254721Semaste    if (dump_mask & eDumpOptionValue)
32254721Semaste    {
33254721Semaste        if (dump_mask & eDumpOptionType)
34254721Semaste            strm.PutCString (" = ");
35254721Semaste
36254721Semaste        if (m_current_value.IsValid())
37254721Semaste        {
38254721Semaste            const char *arch_name = m_current_value.GetArchitectureName();
39254721Semaste            if (arch_name)
40254721Semaste                strm.PutCString (arch_name);
41254721Semaste        }
42254721Semaste    }
43254721Semaste}
44254721Semaste
45254721SemasteError
46254721SemasteOptionValueArch::SetValueFromCString (const char *value_cstr, VarSetOperationType op)
47254721Semaste{
48254721Semaste    Error error;
49254721Semaste    switch (op)
50254721Semaste    {
51254721Semaste    case eVarSetOperationClear:
52254721Semaste        Clear();
53254721Semaste        break;
54254721Semaste
55254721Semaste    case eVarSetOperationReplace:
56254721Semaste    case eVarSetOperationAssign:
57254721Semaste        if (value_cstr && value_cstr[0])
58254721Semaste        {
59254721Semaste            if (m_current_value.SetTriple (value_cstr))
60254721Semaste                m_value_was_set = true;
61254721Semaste            else
62254721Semaste                error.SetErrorStringWithFormat("unsupported architecture '%s'", value_cstr);
63254721Semaste        }
64254721Semaste        else
65254721Semaste        {
66254721Semaste            error.SetErrorString("invalid value string");
67254721Semaste        }
68254721Semaste        break;
69254721Semaste
70254721Semaste    case eVarSetOperationInsertBefore:
71254721Semaste    case eVarSetOperationInsertAfter:
72254721Semaste    case eVarSetOperationRemove:
73254721Semaste    case eVarSetOperationAppend:
74254721Semaste    case eVarSetOperationInvalid:
75254721Semaste        error = OptionValue::SetValueFromCString (value_cstr, op);
76254721Semaste        break;
77254721Semaste    }
78254721Semaste    return error;
79254721Semaste}
80254721Semaste
81254721Semastelldb::OptionValueSP
82254721SemasteOptionValueArch::DeepCopy () const
83254721Semaste{
84254721Semaste    return OptionValueSP(new OptionValueArch(*this));
85254721Semaste}
86254721Semaste
87254721Semaste
88254721Semastesize_t
89254721SemasteOptionValueArch::AutoComplete (CommandInterpreter &interpreter,
90254721Semaste                                   const char *s,
91254721Semaste                                   int match_start_point,
92254721Semaste                                   int max_return_elements,
93254721Semaste                                   bool &word_complete,
94254721Semaste                                   StringList &matches)
95254721Semaste{
96254721Semaste    word_complete = false;
97254721Semaste    matches.Clear();
98254721Semaste    CommandCompletions::InvokeCommonCompletionCallbacks (interpreter,
99254721Semaste                                                         CommandCompletions::eArchitectureCompletion,
100254721Semaste                                                         s,
101254721Semaste                                                         match_start_point,
102254721Semaste                                                         max_return_elements,
103254721Semaste                                                         NULL,
104254721Semaste                                                         word_complete,
105254721Semaste                                                         matches);
106254721Semaste    return matches.GetSize();
107254721Semaste}
108254721Semaste
109254721Semaste
110254721Semaste
111254721Semaste
112