blob: 49674a9d8ae05aab613dc1de44635a80bbcc8e58 [file] [log] [blame]
Sean Callanana48fe162010-08-11 03:57:18 +00001//===-- ClangPersistentVariables.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 "ClangPersistentVariables.h"
Sean Callanan82b74c82010-08-12 01:56:52 +000011#include "lldb/Core/DataExtractor.h"
Sean Callanana48fe162010-08-11 03:57:18 +000012#include "lldb/Core/Log.h"
13#include "lldb/Core/StreamString.h"
Sean Callanan82b74c82010-08-12 01:56:52 +000014#include "lldb/Core/Value.h"
Sean Callanana48fe162010-08-11 03:57:18 +000015
16using namespace lldb_private;
Sean Callanan82b74c82010-08-12 01:56:52 +000017
Sean Callanana48fe162010-08-11 03:57:18 +000018ClangPersistentVariables::ClangPersistentVariables () :
Sean Callanana6223432010-08-20 01:02:30 +000019 ClangExpressionVariableStore()
Sean Callanana48fe162010-08-11 03:57:18 +000020{
Sean Callanana6223432010-08-20 01:02:30 +000021 m_result_counter = 0;
Sean Callanana48fe162010-08-11 03:57:18 +000022}
Sean Callanan82b74c82010-08-12 01:56:52 +000023
24void
25ClangPersistentVariables::GetNextResultName (std::string &name)
26{
27 StreamString s;
28 s.Printf("$%llu", m_result_counter);
29
30 m_result_counter++;
31
32 name = s.GetString();
33}
Sean Callanana6223432010-08-20 01:02:30 +000034
35bool
Greg Clayton66ed2fb2010-10-05 00:00:42 +000036ClangPersistentVariables::CreatePersistentVariable(const char *name,
37 TypeFromUser user_type)
Sean Callanana6223432010-08-20 01:02:30 +000038{
39 if (GetVariable(name))
40 return false;
41
42 ClangExpressionVariable &pvar (VariableAtIndex(CreateVariable()));
43
44 pvar.m_name = name;
45 pvar.m_user_type = user_type;
Greg Clayton66ed2fb2010-10-05 00:00:42 +000046 // TODO: Sean, why do we need to call this?, we can just make it below
47 // and we aren't checking the result or anything... Is this cruft left
48 // over from an old code re-org?
49 //pvar.EnableDataVars();
50 pvar.m_data_sp.reset(new DataBufferHeap(pvar.Size(), 0));
Sean Callanana6223432010-08-20 01:02:30 +000051
52 return true;
53}