2016-09-07 04:57:50 +08:00
|
|
|
//===-- FormatClasses.cpp ----------------------------------------*- C++
|
|
|
|
//-*-===//
|
2013-01-29 07:47:25 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
<rdar://problem/15530080>
Rework data formatters matching algorithm
What happens now is that, for each category, the FormatNavigator generates all possible matches, and checks them one by one
Since the possible matches do not actually depend on the category (whether a match is accepted or not does, but that check can be shifted at a more convenient time),
it is actually feasible to generate every possible match upfront and then let individual categories just scan through those
This commit changes things by introducing a notion of formatters match candidate, and shifting responsibility for generating all of them given a (ValueObject,DynamicValueType) pair
from the FormatNavigator back to the FormatManager
A list of these candidates is then passed down to each category for matching
Candidates also need to remember whether they were generated by stripping pointers, references, typedefs, since this is something that individual formatters can choose to reject
This check, however, is conveniently only done once a "textual" match has been found, so that the list of candidates is truly category-independent
While the performance benefit is small (mostly, due to caching), this is much cleaner from a design perspective
llvm-svn: 195395
2013-11-22 08:02:13 +08:00
|
|
|
#include "lldb/DataFormatters/FormatClasses.h"
|
2013-01-29 07:47:25 +08:00
|
|
|
|
2015-10-06 09:02:47 +08:00
|
|
|
#include "lldb/DataFormatters/FormatManager.h"
|
|
|
|
|
2013-01-29 07:47:25 +08:00
|
|
|
// C Includes
|
|
|
|
|
|
|
|
// C++ Includes
|
|
|
|
|
|
|
|
// Other libraries and framework includes
|
|
|
|
|
|
|
|
// Project includes
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
FormattersMatchData::FormattersMatchData(ValueObject &valobj,
|
|
|
|
lldb::DynamicValueType use_dynamic)
|
|
|
|
: m_valobj(valobj), m_dynamic_value_type(use_dynamic),
|
|
|
|
m_formatters_match_vector({}, false), m_type_for_cache(),
|
|
|
|
m_candidate_languages() {
|
|
|
|
m_type_for_cache = FormatManager::GetTypeForCache(valobj, use_dynamic);
|
|
|
|
m_candidate_languages = FormatManager::GetCandidateLanguages(valobj);
|
2015-10-06 09:02:47 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
FormattersMatchVector FormattersMatchData::GetMatchesVector() {
|
|
|
|
if (!m_formatters_match_vector.second) {
|
|
|
|
m_formatters_match_vector.second = true;
|
|
|
|
m_formatters_match_vector.first =
|
|
|
|
FormatManager::GetPossibleMatches(m_valobj, m_dynamic_value_type);
|
|
|
|
}
|
|
|
|
return m_formatters_match_vector.first;
|
2015-10-06 09:02:47 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ConstString FormattersMatchData::GetTypeForCache() { return m_type_for_cache; }
|
2015-10-06 09:02:47 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
CandidateLanguagesVector FormattersMatchData::GetCandidateLanguages() {
|
|
|
|
return m_candidate_languages;
|
2015-10-06 09:02:47 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
ValueObject &FormattersMatchData::GetValueObject() { return m_valobj; }
|
2015-10-06 09:02:47 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::DynamicValueType FormattersMatchData::GetDynamicValueType() {
|
|
|
|
return m_dynamic_value_type;
|
2015-10-06 09:02:47 +08:00
|
|
|
}
|