summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangPersistentVariables.cpp
blob: 49674a9d8ae05aab613dc1de44635a80bbcc8e58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//===-- ClangPersistentVariables.cpp ----------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "ClangPersistentVariables.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"

using namespace lldb_private;

ClangPersistentVariables::ClangPersistentVariables () :
    ClangExpressionVariableStore()
{
    m_result_counter = 0;
}

void
ClangPersistentVariables::GetNextResultName (std::string &name)
{
    StreamString s;
    s.Printf("$%llu", m_result_counter);
    
    m_result_counter++;
    
    name = s.GetString();
}

bool
ClangPersistentVariables::CreatePersistentVariable(const char *name,
                                                   TypeFromUser user_type)
{
    if (GetVariable(name))
            return false;

    ClangExpressionVariable &pvar (VariableAtIndex(CreateVariable()));

    pvar.m_name = name;
    pvar.m_user_type = user_type;
    // TODO: Sean, why do we need to call this?, we can just make it below
    // and we aren't checking the result or anything... Is this cruft left
    // over from an old code re-org?
    //pvar.EnableDataVars();
    pvar.m_data_sp.reset(new DataBufferHeap(pvar.Size(), 0));
    
    return true;
}
OpenPOWER on IntegriCloud