streamlining of constructing script-level tables

This commit is contained in:
Vern Paxson 2023-12-14 15:12:17 -08:00 committed by Arne Welzel
parent d1d9b9a1be
commit a11ee9038b
4 changed files with 52 additions and 27 deletions

View file

@ -10,6 +10,7 @@
#include <unordered_set>
#include "zeek/Attr.h"
#include "zeek/CompHash.h"
#include "zeek/Desc.h"
#include "zeek/Expr.h"
#include "zeek/Reporter.h"
@ -478,8 +479,13 @@ TableType::TableType(TypeListPtr ind, TypePtr yield) : IndexType(TYPE_TABLE, std
break;
}
}
if ( Tag() != TYPE_ERROR )
RegenerateHash();
}
TableType::~TableType() { delete table_hash; }
bool TableType::CheckExpireFuncCompatibility(const detail::AttrPtr& attr) {
if ( reported_error )
return false;
@ -493,6 +499,11 @@ bool TableType::CheckExpireFuncCompatibility(const detail::AttrPtr& attr) {
TypePtr TableType::ShallowClone() { return make_intrusive<TableType>(indices, yield_type); }
void TableType::RegenerateHash() {
delete table_hash;
table_hash = new detail::CompositeHash(GetIndices());
}
bool TableType::IsUnspecifiedTable() const {
// Unspecified types have an empty list of indices.
return indices->GetTypes().empty();