blob: 4919922a401766a1533bab67f02ac47968d35542 [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
Greg Clayton8de27c72010-10-15 22:48:33 +000025ClangPersistentVariables::GetNextResultName (ConstString &name)
Sean Callanan82b74c82010-08-12 01:56:52 +000026{
Greg Clayton8de27c72010-10-15 22:48:33 +000027 char result_name[256];
28 ::snprintf (result_name, sizeof(result_name), "$%llu", m_result_counter++);
29 name.SetCString(result_name);
Sean Callanan82b74c82010-08-12 01:56:52 +000030}
Sean Callanana6223432010-08-20 01:02:30 +000031
32bool
Greg Clayton8de27c72010-10-15 22:48:33 +000033ClangPersistentVariables::CreatePersistentVariable (const ConstString &name,
34 TypeFromUser user_type)
Sean Callanana6223432010-08-20 01:02:30 +000035{
36 if (GetVariable(name))
37 return false;
38
39 ClangExpressionVariable &pvar (VariableAtIndex(CreateVariable()));
40
41 pvar.m_name = name;
42 pvar.m_user_type = user_type;
Greg Clayton66ed2fb2010-10-05 00:00:42 +000043 // TODO: Sean, why do we need to call this?, we can just make it below
44 // and we aren't checking the result or anything... Is this cruft left
45 // over from an old code re-org?
46 //pvar.EnableDataVars();
47 pvar.m_data_sp.reset(new DataBufferHeap(pvar.Size(), 0));
Sean Callanana6223432010-08-20 01:02:30 +000048
49 return true;
50}