mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00

This largely copies over Spicy's `.clang-format` configuration file. The one place where we deviate is header include order since Zeek depends on headers being included in a certain order.
60 lines
1.3 KiB
C++
60 lines
1.3 KiB
C++
// See the file "COPYING" in the main distribution directory for copyright.
|
|
|
|
#include "zeek/script_opt/CPP/Tracker.h"
|
|
|
|
#include "zeek/Desc.h"
|
|
#include "zeek/script_opt/CPP/Util.h"
|
|
#include "zeek/script_opt/ProfileFunc.h"
|
|
|
|
namespace zeek::detail {
|
|
|
|
using namespace std;
|
|
|
|
template<class T>
|
|
void CPPTracker<T>::AddKey(IntrusivePtr<T> key, p_hash_type h) {
|
|
if ( HasKey(key) )
|
|
return;
|
|
|
|
if ( map2.count(h) == 0 ) {
|
|
auto index = keys.size();
|
|
keys.push_back(key);
|
|
|
|
map2[h] = index;
|
|
reps[h] = key.get();
|
|
}
|
|
|
|
ASSERT(h != 0); // check for hash botches
|
|
|
|
map[key.get()] = h;
|
|
}
|
|
|
|
template<class T>
|
|
string CPPTracker<T>::KeyName(const T* key) {
|
|
ASSERT(HasKey(key));
|
|
|
|
auto hash = map[key];
|
|
ASSERT(hash != 0);
|
|
|
|
auto rep = reps[hash];
|
|
auto gi = gi_s.find(rep);
|
|
if ( gi != gi_s.end() )
|
|
return gi->second->Name();
|
|
|
|
auto index = map2[hash];
|
|
string ind = Fmt(index);
|
|
string full_name;
|
|
|
|
if ( single_global )
|
|
full_name = base_name + "__CPP[" + ind + "]";
|
|
else
|
|
full_name = base_name + "_" + ind + "__CPP";
|
|
|
|
return full_name;
|
|
}
|
|
|
|
// Instantiate the templates we'll need.
|
|
template class CPPTracker<Type>;
|
|
template class CPPTracker<Attributes>;
|
|
template class CPPTracker<Expr>;
|
|
|
|
} // namespace zeek::detail
|