xref: /src/contrib/llvm-project/lldb/source/DataFormatters/FormatClasses.cpp (revision 5ffd83dbcc34f10e07f6d3e968ae6365869615f4)
1cfca06d7SDimitry Andric //===-- FormatClasses.cpp -------------------------------------------------===//
2f034231aSEd Maste //
35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f034231aSEd Maste //
7f034231aSEd Maste //===----------------------------------------------------------------------===//
8f034231aSEd Maste 
986758c71SEd Maste #include "lldb/DataFormatters/FormatClasses.h"
10f034231aSEd Maste 
11e81d9d49SDimitry Andric #include "lldb/DataFormatters/FormatManager.h"
12e81d9d49SDimitry Andric 
13f034231aSEd Maste 
14f034231aSEd Maste 
15f034231aSEd Maste 
16f034231aSEd Maste 
17f034231aSEd Maste using namespace lldb;
18f034231aSEd Maste using namespace lldb_private;
19f034231aSEd Maste 
FormattersMatchData(ValueObject & valobj,lldb::DynamicValueType use_dynamic)2014f1b3e8SDimitry Andric FormattersMatchData::FormattersMatchData(ValueObject &valobj,
2114f1b3e8SDimitry Andric                                          lldb::DynamicValueType use_dynamic)
2214f1b3e8SDimitry Andric     : m_valobj(valobj), m_dynamic_value_type(use_dynamic),
2314f1b3e8SDimitry Andric       m_formatters_match_vector({}, false), m_type_for_cache(),
2414f1b3e8SDimitry Andric       m_candidate_languages() {
25e81d9d49SDimitry Andric   m_type_for_cache = FormatManager::GetTypeForCache(valobj, use_dynamic);
26706b4fc4SDimitry Andric   m_candidate_languages =
27706b4fc4SDimitry Andric       FormatManager::GetCandidateLanguages(valobj.GetObjectRuntimeLanguage());
28e81d9d49SDimitry Andric }
29e81d9d49SDimitry Andric 
GetMatchesVector()3014f1b3e8SDimitry Andric FormattersMatchVector FormattersMatchData::GetMatchesVector() {
3114f1b3e8SDimitry Andric   if (!m_formatters_match_vector.second) {
32e81d9d49SDimitry Andric     m_formatters_match_vector.second = true;
3314f1b3e8SDimitry Andric     m_formatters_match_vector.first =
3414f1b3e8SDimitry Andric         FormatManager::GetPossibleMatches(m_valobj, m_dynamic_value_type);
35e81d9d49SDimitry Andric   }
36e81d9d49SDimitry Andric   return m_formatters_match_vector.first;
37e81d9d49SDimitry Andric }
38e81d9d49SDimitry Andric 
GetTypeForCache()3914f1b3e8SDimitry Andric ConstString FormattersMatchData::GetTypeForCache() { return m_type_for_cache; }
40e81d9d49SDimitry Andric 
GetCandidateLanguages()4114f1b3e8SDimitry Andric CandidateLanguagesVector FormattersMatchData::GetCandidateLanguages() {
42e81d9d49SDimitry Andric   return m_candidate_languages;
43e81d9d49SDimitry Andric }
44e81d9d49SDimitry Andric 
GetValueObject()4514f1b3e8SDimitry Andric ValueObject &FormattersMatchData::GetValueObject() { return m_valobj; }
46e81d9d49SDimitry Andric 
GetDynamicValueType()4714f1b3e8SDimitry Andric lldb::DynamicValueType FormattersMatchData::GetDynamicValueType() {
48e81d9d49SDimitry Andric   return m_dynamic_value_type;
49e81d9d49SDimitry Andric }
50