blob: f014811fb17f57496d3c10f4bba514b208b8b016 [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
36ClangPersistentVariables::CreatePersistentVariable(const char *name,
37 TypeFromUser user_type)
38{
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;
46
47 pvar.EnableDataVars();
48
49 pvar.m_data_vars->m_data = new DataBufferHeap(pvar.Size(), 0);
50
51 return true;
52}