mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Restore the SetType constructor and destructor
This commit is contained in:
parent
d6c7a479e2
commit
210737f36e
1 changed files with 44 additions and 0 deletions
44
src/Type.cc
44
src/Type.cc
|
@ -569,6 +569,50 @@ bool TableType::DoExpireCheck(const detail::AttrPtr& attr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetType::SetType(TypeListPtr ind, detail::ListExprPtr arg_elements)
|
||||||
|
: TableType(std::move(ind), nullptr), elements(std::move(arg_elements)) {
|
||||||
|
if ( elements ) {
|
||||||
|
if ( indices ) { // We already have a type.
|
||||||
|
if ( ! check_and_promote_exprs(elements.get(), indices) )
|
||||||
|
SetError();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeList* tl_type = elements->GetType()->AsTypeList();
|
||||||
|
const auto& tl = tl_type->GetTypes();
|
||||||
|
|
||||||
|
if ( tl.size() < 1 ) {
|
||||||
|
Error("no type given for set");
|
||||||
|
SetError();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ( tl.size() == 1 ) {
|
||||||
|
TypePtr ft{NewRef{}, flatten_type(tl[0].get())};
|
||||||
|
indices = make_intrusive<TypeList>(ft);
|
||||||
|
indices->Append(std::move(ft));
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
auto t = merge_types(tl[0], tl[1]);
|
||||||
|
|
||||||
|
for ( size_t i = 2; t && i < tl.size(); ++i )
|
||||||
|
t = merge_types(t, tl[i]);
|
||||||
|
|
||||||
|
if ( ! t ) {
|
||||||
|
Error("bad set type");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
indices = make_intrusive<TypeList>(t);
|
||||||
|
indices->Append(std::move(t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TypePtr SetType::ShallowClone() { return make_intrusive<SetType>(indices, elements); }
|
||||||
|
|
||||||
|
SetType::~SetType() = default;
|
||||||
|
|
||||||
FuncType::Capture::Capture(detail::IDPtr _id, bool _deep_copy) : id(std::move(_id)), deep_copy(_deep_copy) {
|
FuncType::Capture::Capture(detail::IDPtr _id, bool _deep_copy) : id(std::move(_id)), deep_copy(_deep_copy) {
|
||||||
is_managed = id ? ZVal::IsManagedType(id->GetType()) : false;
|
is_managed = id ? ZVal::IsManagedType(id->GetType()) : false;
|
||||||
if ( ! is_managed )
|
if ( ! is_managed )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue