mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Rename BroType to Type
This commit is contained in:
parent
c04d9cae45
commit
137e416a03
34 changed files with 367 additions and 359 deletions
|
@ -146,7 +146,7 @@ void Attr::AddTag(ODesc* d) const
|
|||
d->Add(attr_name(Tag()));
|
||||
}
|
||||
|
||||
Attributes::Attributes(attr_list* a, IntrusivePtr<BroType> t, bool arg_in_record, bool is_global)
|
||||
Attributes::Attributes(attr_list* a, IntrusivePtr<Type> t, bool arg_in_record, bool is_global)
|
||||
{
|
||||
attrs.reserve(a->length());
|
||||
in_record = arg_in_record;
|
||||
|
@ -164,14 +164,14 @@ Attributes::Attributes(attr_list* a, IntrusivePtr<BroType> t, bool arg_in_record
|
|||
delete a;
|
||||
}
|
||||
|
||||
Attributes::Attributes(IntrusivePtr<BroType> t,
|
||||
Attributes::Attributes(IntrusivePtr<Type> t,
|
||||
bool arg_in_record, bool is_global)
|
||||
: Attributes(std::vector<IntrusivePtr<Attr>>{}, std::move(t),
|
||||
arg_in_record, is_global)
|
||||
{}
|
||||
|
||||
Attributes::Attributes(std::vector<IntrusivePtr<Attr>> a,
|
||||
IntrusivePtr<BroType> t,
|
||||
IntrusivePtr<Type> t,
|
||||
bool arg_in_record, bool is_global)
|
||||
: type(std::move(t))
|
||||
{
|
||||
|
|
|
@ -112,11 +112,11 @@ protected:
|
|||
class Attributes final : public BroObj {
|
||||
public:
|
||||
[[deprecated("Remove in v4.1. Construct using IntrusivePtrs instead.")]]
|
||||
Attributes(attr_list* a, IntrusivePtr<BroType> t, bool in_record, bool is_global);
|
||||
Attributes(attr_list* a, IntrusivePtr<Type> t, bool in_record, bool is_global);
|
||||
|
||||
Attributes(std::vector<IntrusivePtr<Attr>> a, IntrusivePtr<BroType> t,
|
||||
Attributes(std::vector<IntrusivePtr<Attr>> a, IntrusivePtr<Type> t,
|
||||
bool in_record, bool is_global);
|
||||
Attributes(IntrusivePtr<BroType> t, bool in_record, bool is_global);
|
||||
Attributes(IntrusivePtr<Type> t, bool in_record, bool is_global);
|
||||
|
||||
void AddAttr(IntrusivePtr<Attr> a);
|
||||
|
||||
|
@ -147,7 +147,7 @@ public:
|
|||
protected:
|
||||
void CheckAttr(Attr* attr);
|
||||
|
||||
IntrusivePtr<BroType> type;
|
||||
IntrusivePtr<Type> type;
|
||||
std::vector<IntrusivePtr<Attr>> attrs;
|
||||
bool in_record;
|
||||
bool global_var;
|
||||
|
|
|
@ -16,8 +16,9 @@ using id_list = PList<zeek::detail::ID>;
|
|||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||
using stmt_list = PList<zeek::detail::Stmt>;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(BroType, zeek);
|
||||
using type_list = PList<zeek::BroType>;
|
||||
namespace zeek { class Type; }
|
||||
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||
using type_list = PList<zeek::Type>;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail);
|
||||
using attr_list = PList<zeek::detail::Attr>;
|
||||
|
|
|
@ -71,7 +71,7 @@ CompositeHash::~CompositeHash()
|
|||
|
||||
// Computes the piece of the hash for Val*, returning the new kp.
|
||||
char* CompositeHash::SingleValHash(bool type_check, char* kp0,
|
||||
zeek::BroType* bt, Val* v, bool optional) const
|
||||
zeek::Type* bt, Val* v, bool optional) const
|
||||
{
|
||||
char* kp1 = nullptr;
|
||||
zeek::InternalTypeTag t = bt->InternalType();
|
||||
|
@ -449,7 +449,7 @@ std::unique_ptr<HashKey> CompositeHash::ComputeSingletonHash(const Val* v, bool
|
|||
}
|
||||
}
|
||||
|
||||
int CompositeHash::SingleTypeKeySize(zeek::BroType* bt, const Val* v,
|
||||
int CompositeHash::SingleTypeKeySize(zeek::Type* bt, const Val* v,
|
||||
bool type_check, int sz, bool optional,
|
||||
bool calc_static_size) const
|
||||
{
|
||||
|
@ -730,7 +730,7 @@ IntrusivePtr<ListVal> CompositeHash::RecoverVals(const HashKey& k) const
|
|||
}
|
||||
|
||||
const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
||||
const char* const k_end, zeek::BroType* t,
|
||||
const char* const k_end, zeek::Type* t,
|
||||
IntrusivePtr<Val>* pval, bool optional) const
|
||||
{
|
||||
// k->Size() == 0 for a single empty string.
|
||||
|
@ -1010,7 +1010,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey& k, const char* kp0,
|
|||
for ( int i = 0; i < n; ++i )
|
||||
{
|
||||
IntrusivePtr<Val> v;
|
||||
zeek::BroType* it = tl->Types()[i].get();
|
||||
zeek::Type* it = tl->Types()[i].get();
|
||||
kp1 = RecoverOneVal(k, kp1, k_end, it, &v, false);
|
||||
lv->Append(std::move(v));
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ protected:
|
|||
|
||||
// Computes the piece of the hash for Val*, returning the new kp.
|
||||
// Used as a helper for ComputeHash in the non-singleton case.
|
||||
char* SingleValHash(bool type_check, char* kp, zeek::BroType* bt, Val* v,
|
||||
char* SingleValHash(bool type_check, char* kp, zeek::Type* bt, Val* v,
|
||||
bool optional) const;
|
||||
|
||||
// Recovers just one Val of possibly many; called from RecoverVals.
|
||||
|
@ -46,7 +46,7 @@ protected:
|
|||
// upon errors, so there is no return value for invalid input.
|
||||
const char* RecoverOneVal(const HashKey& k,
|
||||
const char* kp, const char* const k_end,
|
||||
zeek::BroType* t, IntrusivePtr<Val>* pval, bool optional) const;
|
||||
zeek::Type* t, IntrusivePtr<Val>* pval, bool optional) const;
|
||||
|
||||
// Rounds the given pointer up to the nearest multiple of the
|
||||
// given size, if not already a multiple.
|
||||
|
@ -85,7 +85,7 @@ protected:
|
|||
int ComputeKeySize(const Val* v, bool type_check,
|
||||
bool calc_static_size) const;
|
||||
|
||||
int SingleTypeKeySize(zeek::BroType*, const Val*,
|
||||
int SingleTypeKeySize(zeek::Type*, const Val*,
|
||||
bool type_check, int sz, bool optional,
|
||||
bool calc_static_size) const;
|
||||
|
||||
|
|
|
@ -403,19 +403,19 @@ void ODesc::Clear()
|
|||
}
|
||||
}
|
||||
|
||||
bool ODesc::PushType(const zeek::BroType* type)
|
||||
bool ODesc::PushType(const zeek::Type* type)
|
||||
{
|
||||
auto res = encountered_types.insert(type);
|
||||
return std::get<1>(res);
|
||||
}
|
||||
|
||||
bool ODesc::PopType(const zeek::BroType* type)
|
||||
bool ODesc::PopType(const zeek::Type* type)
|
||||
{
|
||||
size_t res = encountered_types.erase(type);
|
||||
return (res == 1);
|
||||
}
|
||||
|
||||
bool ODesc::FindType(const zeek::BroType* type)
|
||||
bool ODesc::FindType(const zeek::Type* type)
|
||||
{
|
||||
auto res = encountered_types.find(type);
|
||||
|
||||
|
|
12
src/Desc.h
12
src/Desc.h
|
@ -25,7 +25,9 @@ typedef enum {
|
|||
class BroFile;
|
||||
class IPAddr;
|
||||
class IPPrefix;
|
||||
FORWARD_DECLARE_NAMESPACED(BroType, zeek);
|
||||
|
||||
namespace zeek { class Type; }
|
||||
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||
|
||||
class ODesc {
|
||||
public:
|
||||
|
@ -146,9 +148,9 @@ public:
|
|||
|
||||
// Used to determine recursive types. Records push their types on here;
|
||||
// if the same type (by address) is re-encountered, processing aborts.
|
||||
bool PushType(const zeek::BroType* type);
|
||||
bool PopType(const zeek::BroType* type);
|
||||
bool FindType(const zeek::BroType* type);
|
||||
bool PushType(const zeek::Type* type);
|
||||
bool PopType(const zeek::Type* type);
|
||||
bool FindType(const zeek::Type* type);
|
||||
|
||||
protected:
|
||||
void Indent();
|
||||
|
@ -204,5 +206,5 @@ protected:
|
|||
bool do_flush;
|
||||
bool include_stats;
|
||||
|
||||
std::set<const zeek::BroType*> encountered_types;
|
||||
std::set<const zeek::Type*> encountered_types;
|
||||
};
|
||||
|
|
62
src/Expr.cc
62
src/Expr.cc
|
@ -90,7 +90,7 @@ IntrusivePtr<Expr> Expr::MakeLvalue()
|
|||
return {NewRef{}, this};
|
||||
}
|
||||
|
||||
void Expr::EvalIntoAggregate(const BroType* /* t */, Val* /* aggr */,
|
||||
void Expr::EvalIntoAggregate(const zeek::Type* /* t */, Val* /* aggr */,
|
||||
Frame* /* f */) const
|
||||
{
|
||||
Internal("Expr::EvalIntoAggregate called");
|
||||
|
@ -101,7 +101,7 @@ void Expr::Assign(Frame* /* f */, IntrusivePtr<Val> /* v */)
|
|||
Internal("Expr::Assign called");
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> Expr::InitType() const
|
||||
IntrusivePtr<zeek::Type> Expr::InitType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ bool Expr::IsPure() const
|
|||
return true;
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> Expr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) const
|
||||
IntrusivePtr<Val> Expr::InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const
|
||||
{
|
||||
if ( aggr )
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ void Expr::Canonicize()
|
|||
{
|
||||
}
|
||||
|
||||
void Expr::SetType(IntrusivePtr<BroType> t)
|
||||
void Expr::SetType(IntrusivePtr<zeek::Type> t)
|
||||
{
|
||||
if ( ! type || type->Tag() != zeek::TYPE_ERROR )
|
||||
type = std::move(t);
|
||||
|
@ -1047,7 +1047,7 @@ PosExpr::PosExpr(IntrusivePtr<Expr> arg_op)
|
|||
const auto& t = IsVector(op->GetType()->Tag()) ? op->GetType()->Yield() : op->GetType();
|
||||
|
||||
TypeTag bt = t->Tag();
|
||||
IntrusivePtr<BroType> base_result_type;
|
||||
IntrusivePtr<zeek::Type> base_result_type;
|
||||
|
||||
if ( IsIntegral(bt) )
|
||||
// Promote count and counter to int.
|
||||
|
@ -1082,7 +1082,7 @@ NegExpr::NegExpr(IntrusivePtr<Expr> arg_op)
|
|||
const auto& t = IsVector(op->GetType()->Tag()) ? op->GetType()->Yield() : op->GetType();
|
||||
|
||||
TypeTag bt = t->Tag();
|
||||
IntrusivePtr<BroType> base_result_type;
|
||||
IntrusivePtr<zeek::Type> base_result_type;
|
||||
|
||||
if ( IsIntegral(bt) )
|
||||
// Promote count and counter to int.
|
||||
|
@ -1151,7 +1151,7 @@ AddExpr::AddExpr(IntrusivePtr<Expr> arg_op1, IntrusivePtr<Expr> arg_op2)
|
|||
if ( IsVector(bt2) )
|
||||
bt2 = op2->GetType()->AsVectorType()->Yield()->Tag();
|
||||
|
||||
IntrusivePtr<BroType> base_result_type;
|
||||
IntrusivePtr<zeek::Type> base_result_type;
|
||||
|
||||
if ( bt2 == zeek::TYPE_INTERVAL && ( bt1 == zeek::TYPE_TIME || bt1 == zeek::TYPE_INTERVAL ) )
|
||||
base_result_type = base_type(bt1);
|
||||
|
@ -1276,7 +1276,7 @@ SubExpr::SubExpr(IntrusivePtr<Expr> arg_op1, IntrusivePtr<Expr> arg_op2)
|
|||
if ( IsVector(bt2) )
|
||||
bt2 = t2->AsVectorType()->Yield()->Tag();
|
||||
|
||||
IntrusivePtr<BroType> base_result_type;
|
||||
IntrusivePtr<zeek::Type> base_result_type;
|
||||
|
||||
if ( bt2 == zeek::TYPE_INTERVAL && ( bt1 == zeek::TYPE_TIME || bt1 == zeek::TYPE_INTERVAL ) )
|
||||
base_result_type = base_type(bt1);
|
||||
|
@ -2262,7 +2262,7 @@ IntrusivePtr<Val> AssignExpr::Eval(Frame* f) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> AssignExpr::InitType() const
|
||||
IntrusivePtr<zeek::Type> AssignExpr::InitType() const
|
||||
{
|
||||
if ( op1->Tag() != EXPR_LIST )
|
||||
{
|
||||
|
@ -2278,7 +2278,7 @@ IntrusivePtr<BroType> AssignExpr::InitType() const
|
|||
op2->GetType());
|
||||
}
|
||||
|
||||
void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
|
||||
void AssignExpr::EvalIntoAggregate(const zeek::Type* t, Val* aggr, Frame* f) const
|
||||
{
|
||||
if ( IsError() )
|
||||
return;
|
||||
|
@ -2327,7 +2327,7 @@ void AssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const
|
|||
RuntimeError("type clash in table assignment");
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> AssignExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) const
|
||||
IntrusivePtr<Val> AssignExpr::InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const
|
||||
{
|
||||
if ( ! aggr )
|
||||
{
|
||||
|
@ -3004,14 +3004,14 @@ RecordConstructorExpr::~RecordConstructorExpr()
|
|||
{
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> RecordConstructorExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) const
|
||||
IntrusivePtr<Val> RecordConstructorExpr::InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const
|
||||
{
|
||||
auto v = Eval(nullptr);
|
||||
|
||||
if ( v )
|
||||
{
|
||||
RecordVal* rv = v->AsRecordVal();
|
||||
auto bt = const_cast<BroType*>(t);
|
||||
auto bt = const_cast<zeek::Type*>(t);
|
||||
IntrusivePtr<RecordType> rt{NewRef{}, bt->AsRecordType()};
|
||||
auto aggr_rec = cast_intrusive<RecordVal>(std::move(aggr));
|
||||
auto ar = rv->CoerceTo(std::move(rt), std::move(aggr_rec));
|
||||
|
@ -3049,7 +3049,7 @@ void RecordConstructorExpr::ExprDescribe(ODesc* d) const
|
|||
|
||||
TableConstructorExpr::TableConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> arg_attrs,
|
||||
IntrusivePtr<BroType> arg_type)
|
||||
IntrusivePtr<zeek::Type> arg_type)
|
||||
: UnaryExpr(EXPR_TABLE_CONSTRUCTOR, std::move(constructor_list))
|
||||
{
|
||||
if ( IsError() )
|
||||
|
@ -3143,7 +3143,7 @@ IntrusivePtr<Val> TableConstructorExpr::Eval(Frame* f) const
|
|||
return aggr;
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> TableConstructorExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) const
|
||||
IntrusivePtr<Val> TableConstructorExpr::InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const
|
||||
{
|
||||
if ( IsError() )
|
||||
return nullptr;
|
||||
|
@ -3170,7 +3170,7 @@ void TableConstructorExpr::ExprDescribe(ODesc* d) const
|
|||
|
||||
SetConstructorExpr::SetConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> arg_attrs,
|
||||
IntrusivePtr<BroType> arg_type)
|
||||
IntrusivePtr<zeek::Type> arg_type)
|
||||
: UnaryExpr(EXPR_SET_CONSTRUCTOR, std::move(constructor_list))
|
||||
{
|
||||
if ( IsError() )
|
||||
|
@ -3254,7 +3254,7 @@ IntrusivePtr<Val> SetConstructorExpr::Eval(Frame* f) const
|
|||
return aggr;
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> SetConstructorExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) const
|
||||
IntrusivePtr<Val> SetConstructorExpr::InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const
|
||||
{
|
||||
if ( IsError() )
|
||||
return nullptr;
|
||||
|
@ -3288,7 +3288,7 @@ void SetConstructorExpr::ExprDescribe(ODesc* d) const
|
|||
}
|
||||
|
||||
VectorConstructorExpr::VectorConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
||||
IntrusivePtr<BroType> arg_type)
|
||||
IntrusivePtr<zeek::Type> arg_type)
|
||||
: UnaryExpr(EXPR_VECTOR_CONSTRUCTOR, std::move(constructor_list))
|
||||
{
|
||||
if ( IsError() )
|
||||
|
@ -3352,7 +3352,7 @@ IntrusivePtr<Val> VectorConstructorExpr::Eval(Frame* f) const
|
|||
return vec;
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> VectorConstructorExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) const
|
||||
IntrusivePtr<Val> VectorConstructorExpr::InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const
|
||||
{
|
||||
if ( IsError() )
|
||||
return nullptr;
|
||||
|
@ -3392,7 +3392,7 @@ FieldAssignExpr::FieldAssignExpr(const char* arg_field_name,
|
|||
SetType(op->GetType());
|
||||
}
|
||||
|
||||
void FieldAssignExpr::EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f)
|
||||
void FieldAssignExpr::EvalIntoAggregate(const zeek::Type* t, Val* aggr, Frame* f)
|
||||
const
|
||||
{
|
||||
if ( IsError() )
|
||||
|
@ -3553,7 +3553,7 @@ RecordCoerceExpr::RecordCoerceExpr(IntrusivePtr<Expr> arg_op,
|
|||
|
||||
if ( ! same_type(sup_t_i, sub_t_i) )
|
||||
{
|
||||
auto is_arithmetic_promotable = [](BroType* sup, BroType* sub) -> bool
|
||||
auto is_arithmetic_promotable = [](zeek::Type* sup, zeek::Type* sub) -> bool
|
||||
{
|
||||
auto sup_tag = sup->Tag();
|
||||
auto sub_tag = sub->Tag();
|
||||
|
@ -3570,7 +3570,7 @@ RecordCoerceExpr::RecordCoerceExpr(IntrusivePtr<Expr> arg_op,
|
|||
return true;
|
||||
};
|
||||
|
||||
auto is_record_promotable = [](BroType* sup, BroType* sub) -> bool
|
||||
auto is_record_promotable = [](zeek::Type* sup, zeek::Type* sub) -> bool
|
||||
{
|
||||
if ( sup->Tag() != zeek::TYPE_RECORD )
|
||||
return false;
|
||||
|
@ -3623,12 +3623,12 @@ RecordCoerceExpr::~RecordCoerceExpr()
|
|||
delete [] map;
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> RecordCoerceExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) const
|
||||
IntrusivePtr<Val> RecordCoerceExpr::InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const
|
||||
{
|
||||
if ( auto v = Eval(nullptr) )
|
||||
{
|
||||
RecordVal* rv = v->AsRecordVal();
|
||||
auto bt = const_cast<BroType*>(t);
|
||||
auto bt = const_cast<zeek::Type*>(t);
|
||||
IntrusivePtr<RecordType> rt{NewRef{}, bt->AsRecordType()};
|
||||
auto aggr_rec = cast_intrusive<RecordVal>(std::move(aggr));
|
||||
|
||||
|
@ -4399,7 +4399,7 @@ IntrusivePtr<Val> ListExpr::Eval(Frame* f) const
|
|||
return v;
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> ListExpr::InitType() const
|
||||
IntrusivePtr<zeek::Type> ListExpr::InitType() const
|
||||
{
|
||||
if ( exprs.empty() )
|
||||
{
|
||||
|
@ -4457,7 +4457,7 @@ IntrusivePtr<BroType> ListExpr::InitType() const
|
|||
}
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> ListExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) const
|
||||
IntrusivePtr<Val> ListExpr::InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const
|
||||
{
|
||||
// While fairly similar to the EvalIntoAggregate() code,
|
||||
// we keep this separate since it also deals with initialization
|
||||
|
@ -4601,7 +4601,7 @@ IntrusivePtr<Val> ListExpr::InitVal(const BroType* t, IntrusivePtr<Val> aggr) co
|
|||
return aggr;
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> ListExpr::AddSetInit(const BroType* t, IntrusivePtr<Val> aggr) const
|
||||
IntrusivePtr<Val> ListExpr::AddSetInit(const zeek::Type* t, IntrusivePtr<Val> aggr) const
|
||||
{
|
||||
if ( aggr->GetType()->Tag() != zeek::TYPE_TABLE )
|
||||
Internal("bad aggregate in ListExpr::InitVal");
|
||||
|
@ -4764,7 +4764,7 @@ RecordAssignExpr::RecordAssignExpr(const IntrusivePtr<Expr>& record,
|
|||
}
|
||||
}
|
||||
|
||||
CastExpr::CastExpr(IntrusivePtr<Expr> arg_op, IntrusivePtr<BroType> t)
|
||||
CastExpr::CastExpr(IntrusivePtr<Expr> arg_op, IntrusivePtr<zeek::Type> t)
|
||||
: UnaryExpr(EXPR_CAST, std::move(arg_op))
|
||||
{
|
||||
auto stype = Op()->GetType();
|
||||
|
@ -4812,7 +4812,7 @@ void CastExpr::ExprDescribe(ODesc* d) const
|
|||
GetType()->Describe(d);
|
||||
}
|
||||
|
||||
IsExpr::IsExpr(IntrusivePtr<Expr> arg_op, IntrusivePtr<BroType> arg_t)
|
||||
IsExpr::IsExpr(IntrusivePtr<Expr> arg_op, IntrusivePtr<zeek::Type> arg_t)
|
||||
: UnaryExpr(EXPR_IS, std::move(arg_op)), t(std::move(arg_t))
|
||||
{
|
||||
SetType(zeek::base_type(zeek::TYPE_BOOL));
|
||||
|
@ -4850,7 +4850,7 @@ IntrusivePtr<Expr> get_assign_expr(IntrusivePtr<Expr> op1,
|
|||
is_init);
|
||||
}
|
||||
|
||||
IntrusivePtr<Expr> check_and_promote_expr(Expr* const e, BroType* t)
|
||||
IntrusivePtr<Expr> check_and_promote_expr(Expr* const e, zeek::Type* t)
|
||||
{
|
||||
const auto& et = e->GetType();
|
||||
TypeTag e_tag = et->Tag();
|
||||
|
@ -5006,7 +5006,7 @@ bool check_and_promote_args(ListExpr* const args, RecordType* types)
|
|||
return rval;
|
||||
}
|
||||
|
||||
bool check_and_promote_exprs_to_type(ListExpr* const elements, BroType* type)
|
||||
bool check_and_promote_exprs_to_type(ListExpr* const elements, zeek::Type* type)
|
||||
{
|
||||
expr_list& el = elements->Exprs();
|
||||
|
||||
|
|
54
src/Expr.h
54
src/Expr.h
|
@ -76,9 +76,9 @@ class Stmt;
|
|||
class Expr : public BroObj {
|
||||
public:
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
BroType* Type() const { return type.get(); }
|
||||
zeek::Type* Type() const { return type.get(); }
|
||||
|
||||
const IntrusivePtr<BroType>& GetType() const
|
||||
const IntrusivePtr<zeek::Type>& GetType() const
|
||||
{ return type; }
|
||||
|
||||
template <class T>
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
// into the given aggregate of the given type. Note that
|
||||
// return type is void since it's updating an existing
|
||||
// value, rather than creating a new one.
|
||||
virtual void EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f)
|
||||
virtual void EvalIntoAggregate(const zeek::Type* t, Val* aggr, Frame* f)
|
||||
const;
|
||||
|
||||
// Assign to the given value, if appropriate.
|
||||
|
@ -105,7 +105,7 @@ public:
|
|||
|
||||
// Returns the type corresponding to this expression interpreted
|
||||
// as an initialization. Returns nil if the initialization is illegal.
|
||||
virtual IntrusivePtr<BroType> InitType() const;
|
||||
virtual IntrusivePtr<zeek::Type> InitType() const;
|
||||
|
||||
// Returns true if this expression, interpreted as an initialization,
|
||||
// constitutes a record element, false otherwise. If the TypeDecl*
|
||||
|
@ -118,7 +118,7 @@ public:
|
|||
// with the given type. If "aggr" is non-nil, then this expression
|
||||
// is an element of the given aggregate, and it is added to it
|
||||
// accordingly.
|
||||
virtual IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const;
|
||||
virtual IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const;
|
||||
|
||||
// True if the expression has no side effects, false otherwise.
|
||||
virtual bool IsPure() const;
|
||||
|
@ -223,7 +223,7 @@ protected:
|
|||
// Puts the expression in canonical form.
|
||||
virtual void Canonicize();
|
||||
|
||||
void SetType(IntrusivePtr<BroType> t);
|
||||
void SetType(IntrusivePtr<zeek::Type> t);
|
||||
|
||||
// Reports the given error and sets the expression's type to
|
||||
// TYPE_ERROR.
|
||||
|
@ -235,7 +235,7 @@ protected:
|
|||
[[noreturn]] void RuntimeErrorWithCallStack(const std::string& msg) const;
|
||||
|
||||
BroExprTag tag;
|
||||
IntrusivePtr<BroType> type;
|
||||
IntrusivePtr<zeek::Type> type;
|
||||
bool paren;
|
||||
};
|
||||
|
||||
|
@ -524,10 +524,10 @@ public:
|
|||
const IntrusivePtr<Attributes>& attrs = nullptr);
|
||||
|
||||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||
void EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const override;
|
||||
IntrusivePtr<BroType> InitType() const override;
|
||||
void EvalIntoAggregate(const zeek::Type* t, Val* aggr, Frame* f) const override;
|
||||
IntrusivePtr<zeek::Type> InitType() const override;
|
||||
bool IsRecordElement(TypeDecl* td) const override;
|
||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
||||
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||
bool IsPure() const override;
|
||||
|
||||
protected:
|
||||
|
@ -624,7 +624,7 @@ public:
|
|||
~RecordConstructorExpr() override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
||||
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||
IntrusivePtr<Val> Fold(Val* v) const override;
|
||||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
@ -634,7 +634,7 @@ class TableConstructorExpr final : public UnaryExpr {
|
|||
public:
|
||||
TableConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs,
|
||||
IntrusivePtr<BroType> arg_type = nullptr);
|
||||
IntrusivePtr<zeek::Type> arg_type = nullptr);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetAttrs().")]]
|
||||
Attributes* Attrs() { return attrs.get(); }
|
||||
|
@ -645,7 +645,7 @@ public:
|
|||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
||||
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
|
@ -656,7 +656,7 @@ class SetConstructorExpr final : public UnaryExpr {
|
|||
public:
|
||||
SetConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs,
|
||||
IntrusivePtr<BroType> arg_type = nullptr);
|
||||
IntrusivePtr<zeek::Type> arg_type = nullptr);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetAttrs().")]]
|
||||
Attributes* Attrs() { return attrs.get(); }
|
||||
|
@ -667,7 +667,7 @@ public:
|
|||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
||||
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
|
@ -677,12 +677,12 @@ protected:
|
|||
class VectorConstructorExpr final : public UnaryExpr {
|
||||
public:
|
||||
explicit VectorConstructorExpr(IntrusivePtr<ListExpr> constructor_list,
|
||||
IntrusivePtr<BroType> arg_type = nullptr);
|
||||
IntrusivePtr<zeek::Type> arg_type = nullptr);
|
||||
|
||||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
||||
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
};
|
||||
|
@ -693,7 +693,7 @@ public:
|
|||
|
||||
const char* FieldName() const { return field_name.c_str(); }
|
||||
|
||||
void EvalIntoAggregate(const BroType* t, Val* aggr, Frame* f) const override;
|
||||
void EvalIntoAggregate(const zeek::Type* t, Val* aggr, Frame* f) const override;
|
||||
bool IsRecordElement(TypeDecl* td) const override;
|
||||
|
||||
protected:
|
||||
|
@ -717,7 +717,7 @@ public:
|
|||
~RecordCoerceExpr() override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
||||
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||
IntrusivePtr<Val> Fold(Val* v) const override;
|
||||
|
||||
// For each super-record slot, gives subrecord slot with which to
|
||||
|
@ -868,15 +868,15 @@ public:
|
|||
|
||||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||
|
||||
IntrusivePtr<BroType> InitType() const override;
|
||||
IntrusivePtr<Val> InitVal(const BroType* t, IntrusivePtr<Val> aggr) const override;
|
||||
IntrusivePtr<zeek::Type> InitType() const override;
|
||||
IntrusivePtr<Val> InitVal(const zeek::Type* t, IntrusivePtr<Val> aggr) const override;
|
||||
IntrusivePtr<Expr> MakeLvalue() override;
|
||||
void Assign(Frame* f, IntrusivePtr<Val> v) override;
|
||||
|
||||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> AddSetInit(const BroType* t, IntrusivePtr<Val> aggr) const;
|
||||
IntrusivePtr<Val> AddSetInit(const zeek::Type* t, IntrusivePtr<Val> aggr) const;
|
||||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
|
@ -891,7 +891,7 @@ public:
|
|||
|
||||
class CastExpr final : public UnaryExpr {
|
||||
public:
|
||||
CastExpr(IntrusivePtr<Expr> op, IntrusivePtr<BroType> t);
|
||||
CastExpr(IntrusivePtr<Expr> op, IntrusivePtr<zeek::Type> t);
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> Eval(Frame* f) const override;
|
||||
|
@ -900,14 +900,14 @@ protected:
|
|||
|
||||
class IsExpr final : public UnaryExpr {
|
||||
public:
|
||||
IsExpr(IntrusivePtr<Expr> op, IntrusivePtr<BroType> t);
|
||||
IsExpr(IntrusivePtr<Expr> op, IntrusivePtr<zeek::Type> t);
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> Fold(Val* v) const override;
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
private:
|
||||
IntrusivePtr<BroType> t;
|
||||
IntrusivePtr<zeek::Type> t;
|
||||
};
|
||||
|
||||
inline Val* Expr::ExprVal() const
|
||||
|
@ -936,11 +936,11 @@ IntrusivePtr<Expr> get_assign_expr(IntrusivePtr<Expr> op1,
|
|||
* Returns nullptr if the expression cannot match or a promoted
|
||||
* expression.
|
||||
*/
|
||||
extern IntrusivePtr<Expr> check_and_promote_expr(Expr* e, BroType* t);
|
||||
extern IntrusivePtr<Expr> check_and_promote_expr(Expr* e, Type* t);
|
||||
|
||||
extern bool check_and_promote_exprs(ListExpr* elements, TypeList* types);
|
||||
extern bool check_and_promote_args(ListExpr* args, RecordType* types);
|
||||
extern bool check_and_promote_exprs_to_type(ListExpr* elements, BroType* type);
|
||||
extern bool check_and_promote_exprs_to_type(ListExpr* elements, Type* type);
|
||||
|
||||
// Returns a ListExpr simplified down to a list a values, or nil
|
||||
// if they couldn't all be reduced.
|
||||
|
|
10
src/File.h
10
src/File.h
|
@ -18,7 +18,9 @@
|
|||
|
||||
class RecordVal;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(BroType, zeek);
|
||||
namespace zeek { class Type; }
|
||||
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(PrintStmt, zeek::detail);
|
||||
FORWARD_DECLARE_NAMESPACED(Attributes, zeek::detail);
|
||||
|
||||
|
@ -41,9 +43,9 @@ public:
|
|||
void SetBuf(bool buffered); // false=line buffered, true=fully buffered
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
zeek::BroType* FType() const { return t.get(); }
|
||||
zeek::Type* FType() const { return t.get(); }
|
||||
|
||||
const IntrusivePtr<zeek::BroType>& GetType() const
|
||||
const IntrusivePtr<zeek::Type>& GetType() const
|
||||
{ return t; }
|
||||
|
||||
// Whether the file is open in a general sense; it might
|
||||
|
@ -104,7 +106,7 @@ protected:
|
|||
void RaiseOpenEvent();
|
||||
|
||||
FILE* f;
|
||||
IntrusivePtr<zeek::BroType> t;
|
||||
IntrusivePtr<zeek::Type> t;
|
||||
char* name;
|
||||
char* access;
|
||||
zeek::detail::Attributes* attrs;
|
||||
|
|
|
@ -460,7 +460,7 @@ std::pair<bool, IntrusivePtr<Frame>> Frame::Unserialize(const broker::vector& da
|
|||
return std::make_pair(false, nullptr);
|
||||
|
||||
broker::integer g = *has_type;
|
||||
zeek::BroType t( static_cast<zeek::TypeTag>(g) );
|
||||
zeek::Type t( static_cast<zeek::TypeTag>(g) );
|
||||
|
||||
auto val = bro_broker::data_to_val(std::move(val_tuple[0]), &t);
|
||||
if ( ! val )
|
||||
|
|
|
@ -36,7 +36,7 @@ const IntrusivePtr<zeek::detail::ID>& zeek::id::find(std::string_view name)
|
|||
return global_scope()->Find(name);
|
||||
}
|
||||
|
||||
const IntrusivePtr<zeek::BroType>& zeek::id::find_type(std::string_view name)
|
||||
const IntrusivePtr<zeek::Type>& zeek::id::find_type(std::string_view name)
|
||||
{
|
||||
auto id = global_scope()->Find(name);
|
||||
|
||||
|
@ -133,7 +133,7 @@ std::string ID::ModuleName() const
|
|||
return extract_module_name(name);
|
||||
}
|
||||
|
||||
void ID::SetType(IntrusivePtr<zeek::BroType> t)
|
||||
void ID::SetType(IntrusivePtr<zeek::Type> t)
|
||||
{
|
||||
type = std::move(t);
|
||||
}
|
||||
|
|
20
src/ID.h
20
src/ID.h
|
@ -16,7 +16,9 @@
|
|||
class Val;
|
||||
class Func;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(BroType, zeek);
|
||||
namespace zeek { class Type; }
|
||||
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(RecordType, zeek);
|
||||
FORWARD_DECLARE_NAMESPACED(TableType, zeek);
|
||||
FORWARD_DECLARE_NAMESPACED(VectorType, zeek);
|
||||
|
@ -54,14 +56,14 @@ public:
|
|||
|
||||
std::string ModuleName() const;
|
||||
|
||||
void SetType(IntrusivePtr<BroType> t);
|
||||
void SetType(IntrusivePtr<Type> t);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
BroType* Type() { return type.get(); }
|
||||
zeek::Type* Type() { return type.get(); }
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
const BroType* Type() const { return type.get(); }
|
||||
const zeek::Type* Type() const { return type.get(); }
|
||||
|
||||
const IntrusivePtr<BroType>& GetType() const
|
||||
const IntrusivePtr<zeek::Type>& GetType() const
|
||||
{ return type; }
|
||||
|
||||
template <class T>
|
||||
|
@ -69,9 +71,9 @@ public:
|
|||
{ return cast_intrusive<T>(type); }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use IsType() and GetType().")]]
|
||||
BroType* AsType() { return is_type ? GetType().get() : nullptr; }
|
||||
zeek::Type* AsType() { return is_type ? GetType().get() : nullptr; }
|
||||
[[deprecated("Remove in v4.1. Use IsType() and GetType().")]]
|
||||
const BroType* AsType() const { return is_type ? GetType().get() : nullptr; }
|
||||
const zeek::Type* AsType() const { return is_type ? GetType().get() : nullptr; }
|
||||
|
||||
bool IsType() const
|
||||
{ return is_type; }
|
||||
|
@ -172,7 +174,7 @@ protected:
|
|||
IDScope scope;
|
||||
bool is_export;
|
||||
bool infer_return_type;
|
||||
IntrusivePtr<BroType> type;
|
||||
IntrusivePtr<zeek::Type> type;
|
||||
bool is_const, is_enum_const, is_type, is_option;
|
||||
int offset;
|
||||
IntrusivePtr<Val> val;
|
||||
|
@ -202,7 +204,7 @@ const IntrusivePtr<zeek::detail::ID>& find(std::string_view name);
|
|||
* @param name The identifier name to lookup
|
||||
* @return The type of the identifier.
|
||||
*/
|
||||
const IntrusivePtr<zeek::BroType>& find_type(std::string_view name);
|
||||
const IntrusivePtr<zeek::Type>& find_type(std::string_view name);
|
||||
|
||||
/**
|
||||
* Lookup an ID by its name and return its type (as cast to @c T).
|
||||
|
|
|
@ -96,7 +96,7 @@ IntrusivePtr<OpaqueVal> OpaqueVal::Unserialize(const broker::data& data)
|
|||
return val;
|
||||
}
|
||||
|
||||
broker::expected<broker::data> OpaqueVal::SerializeType(const IntrusivePtr<zeek::BroType>& t)
|
||||
broker::expected<broker::data> OpaqueVal::SerializeType(const IntrusivePtr<zeek::Type>& t)
|
||||
{
|
||||
if ( t->InternalType() == zeek::TYPE_INTERNAL_ERROR )
|
||||
return broker::ec::invalid_data;
|
||||
|
@ -112,7 +112,7 @@ broker::expected<broker::data> OpaqueVal::SerializeType(const IntrusivePtr<zeek:
|
|||
return {broker::vector{false, static_cast<uint64_t>(t->Tag())}};
|
||||
}
|
||||
|
||||
IntrusivePtr<zeek::BroType> OpaqueVal::UnserializeType(const broker::data& data)
|
||||
IntrusivePtr<zeek::Type> OpaqueVal::UnserializeType(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
if ( ! (v && v->size() == 2) )
|
||||
|
@ -723,7 +723,7 @@ IntrusivePtr<Val> BloomFilterVal::DoClone(CloneState* state)
|
|||
return state->NewClone(this, make_intrusive<BloomFilterVal>());
|
||||
}
|
||||
|
||||
bool BloomFilterVal::Typify(IntrusivePtr<zeek::BroType> arg_type)
|
||||
bool BloomFilterVal::Typify(IntrusivePtr<zeek::Type> arg_type)
|
||||
{
|
||||
if ( type )
|
||||
return false;
|
||||
|
@ -882,7 +882,7 @@ IntrusivePtr<Val> CardinalityVal::DoClone(CloneState* state)
|
|||
make_intrusive<CardinalityVal>(new probabilistic::CardinalityCounter(*c)));
|
||||
}
|
||||
|
||||
bool CardinalityVal::Typify(IntrusivePtr<zeek::BroType> arg_type)
|
||||
bool CardinalityVal::Typify(IntrusivePtr<zeek::Type> arg_type)
|
||||
{
|
||||
if ( type )
|
||||
return false;
|
||||
|
|
|
@ -148,13 +148,13 @@ protected:
|
|||
* Helper function for derived class that need to record a type
|
||||
* during serialization.
|
||||
*/
|
||||
static broker::expected<broker::data> SerializeType(const IntrusivePtr<zeek::BroType>& t);
|
||||
static broker::expected<broker::data> SerializeType(const IntrusivePtr<zeek::Type>& t);
|
||||
|
||||
/**
|
||||
* Helper function for derived class that need to restore a type
|
||||
* during unserialization. Returns the type at reference count +1.
|
||||
*/
|
||||
static IntrusivePtr<zeek::BroType> UnserializeType(const broker::data& data);
|
||||
static IntrusivePtr<zeek::Type> UnserializeType(const broker::data& data);
|
||||
};
|
||||
|
||||
namespace probabilistic {
|
||||
|
@ -304,10 +304,10 @@ public:
|
|||
|
||||
IntrusivePtr<Val> DoClone(CloneState* state) override;
|
||||
|
||||
const IntrusivePtr<zeek::BroType>& Type() const
|
||||
const IntrusivePtr<zeek::Type>& Type() const
|
||||
{ return type; }
|
||||
|
||||
bool Typify(IntrusivePtr<zeek::BroType> type);
|
||||
bool Typify(IntrusivePtr<zeek::Type> type);
|
||||
|
||||
void Add(const Val* val);
|
||||
size_t Count(const Val* val) const;
|
||||
|
@ -328,7 +328,7 @@ private:
|
|||
BloomFilterVal(const BloomFilterVal&);
|
||||
BloomFilterVal& operator=(const BloomFilterVal&);
|
||||
|
||||
IntrusivePtr<zeek::BroType> type;
|
||||
IntrusivePtr<zeek::Type> type;
|
||||
CompositeHash* hash;
|
||||
probabilistic::BloomFilter* bloom_filter;
|
||||
};
|
||||
|
@ -343,10 +343,10 @@ public:
|
|||
|
||||
void Add(const Val* val);
|
||||
|
||||
const IntrusivePtr<zeek::BroType>& Type() const
|
||||
const IntrusivePtr<zeek::Type>& Type() const
|
||||
{ return type; }
|
||||
|
||||
bool Typify(IntrusivePtr<zeek::BroType> type);
|
||||
bool Typify(IntrusivePtr<zeek::Type> type);
|
||||
|
||||
probabilistic::CardinalityCounter* Get() { return c; };
|
||||
|
||||
|
@ -355,7 +355,7 @@ protected:
|
|||
|
||||
DECLARE_OPAQUE_VALUE(CardinalityVal)
|
||||
private:
|
||||
IntrusivePtr<zeek::BroType> type;
|
||||
IntrusivePtr<zeek::Type> type;
|
||||
CompositeHash* hash;
|
||||
probabilistic::CardinalityCounter* c;
|
||||
};
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
template <class T> class IntrusivePtr;
|
||||
class ListVal;
|
||||
|
||||
FORWARD_DECLARE_NAMESPACED(BroType, zeek);
|
||||
namespace zeek { class Type; }
|
||||
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||
FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||
|
||||
class Scope : public BroObj {
|
||||
|
@ -45,9 +46,9 @@ public:
|
|||
{ return attrs; }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetReturnTrype().")]]
|
||||
zeek::BroType* ReturnType() const { return return_type.get(); }
|
||||
zeek::Type* ReturnType() const { return return_type.get(); }
|
||||
|
||||
const IntrusivePtr<zeek::BroType>& GetReturnType() const
|
||||
const IntrusivePtr<zeek::Type>& GetReturnType() const
|
||||
{ return return_type; }
|
||||
|
||||
size_t Length() const { return local.size(); }
|
||||
|
@ -70,7 +71,7 @@ public:
|
|||
protected:
|
||||
IntrusivePtr<zeek::detail::ID> scope_id;
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs;
|
||||
IntrusivePtr<zeek::BroType> return_type;
|
||||
IntrusivePtr<zeek::Type> return_type;
|
||||
std::map<std::string, IntrusivePtr<zeek::detail::ID>, std::less<>> local;
|
||||
std::vector<IntrusivePtr<zeek::detail::ID>> inits;
|
||||
};
|
||||
|
|
124
src/Type.cc
124
src/Type.cc
|
@ -24,7 +24,7 @@ using namespace std;
|
|||
|
||||
namespace zeek {
|
||||
|
||||
BroType::TypeAliasMap BroType::type_aliases;
|
||||
Type::TypeAliasMap Type::type_aliases;
|
||||
|
||||
// Note: This function must be thread-safe.
|
||||
const char* type_name(zeek::TypeTag t)
|
||||
|
@ -64,14 +64,14 @@ const char* type_name(zeek::TypeTag t)
|
|||
return type_names[int(t)];
|
||||
}
|
||||
|
||||
BroType::BroType(zeek::TypeTag t, bool arg_base_type)
|
||||
Type::Type(zeek::TypeTag t, bool arg_base_type)
|
||||
: tag(t), internal_tag(to_internal_type_tag(tag)),
|
||||
is_network_order(zeek::is_network_order(t)),
|
||||
base_type(arg_base_type)
|
||||
{
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> BroType::ShallowClone()
|
||||
IntrusivePtr<Type> Type::ShallowClone()
|
||||
{
|
||||
switch ( tag ) {
|
||||
case TYPE_VOID:
|
||||
|
@ -89,15 +89,15 @@ IntrusivePtr<BroType> BroType::ShallowClone()
|
|||
case TYPE_ADDR:
|
||||
case TYPE_SUBNET:
|
||||
case TYPE_ANY:
|
||||
return make_intrusive<BroType>(tag, base_type);
|
||||
return make_intrusive<Type>(tag, base_type);
|
||||
|
||||
default:
|
||||
reporter->InternalError("cloning illegal base BroType");
|
||||
reporter->InternalError("cloning illegal base Type");
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int BroType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
||||
int Type::MatchesIndex(zeek::detail::ListExpr* const index) const
|
||||
{
|
||||
if ( Tag() == TYPE_STRING )
|
||||
{
|
||||
|
@ -111,22 +111,22 @@ int BroType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
|||
return DOES_NOT_MATCH_INDEX;
|
||||
}
|
||||
|
||||
const IntrusivePtr<BroType>& BroType::Yield() const
|
||||
const IntrusivePtr<Type>& Type::Yield() const
|
||||
{
|
||||
return BroType::nil;
|
||||
return Type::nil;
|
||||
}
|
||||
|
||||
bool BroType::HasField(const char* /* field */) const
|
||||
bool Type::HasField(const char* /* field */) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
BroType* BroType::FieldType(const char* /* field */) const
|
||||
Type* Type::FieldType(const char* /* field */) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BroType::Describe(ODesc* d) const
|
||||
void Type::Describe(ODesc* d) const
|
||||
{
|
||||
if ( d->IsBinary() )
|
||||
d->Add(int(Tag()));
|
||||
|
@ -140,22 +140,22 @@ void BroType::Describe(ODesc* d) const
|
|||
}
|
||||
}
|
||||
|
||||
void BroType::DescribeReST(ODesc* d, bool roles_only) const
|
||||
void Type::DescribeReST(ODesc* d, bool roles_only) const
|
||||
{
|
||||
d->Add(fmt(":zeek:type:`%s`", type_name(Tag())));
|
||||
}
|
||||
|
||||
void BroType::SetError()
|
||||
void Type::SetError()
|
||||
{
|
||||
tag = TYPE_ERROR;
|
||||
}
|
||||
|
||||
unsigned int BroType::MemoryAllocation() const
|
||||
unsigned int Type::MemoryAllocation() const
|
||||
{
|
||||
return padded_sizeof(*this);
|
||||
}
|
||||
|
||||
bool TypeList::AllMatch(const BroType* t, bool is_init) const
|
||||
bool TypeList::AllMatch(const Type* t, bool is_init) const
|
||||
{
|
||||
for ( const auto& type : types )
|
||||
if ( ! same_type(type, t, is_init) )
|
||||
|
@ -163,7 +163,7 @@ bool TypeList::AllMatch(const BroType* t, bool is_init) const
|
|||
return true;
|
||||
}
|
||||
|
||||
void TypeList::Append(IntrusivePtr<BroType> t)
|
||||
void TypeList::Append(IntrusivePtr<Type> t)
|
||||
{
|
||||
if ( pure_type && ! same_type(t, pure_type) )
|
||||
reporter->InternalError("pure type-list violation");
|
||||
|
@ -171,7 +171,7 @@ void TypeList::Append(IntrusivePtr<BroType> t)
|
|||
types.emplace_back(std::move(t));
|
||||
}
|
||||
|
||||
void TypeList::AppendEvenIfNotPure(IntrusivePtr<BroType> t)
|
||||
void TypeList::AppendEvenIfNotPure(IntrusivePtr<Type> t)
|
||||
{
|
||||
if ( pure_type && ! same_type(t, pure_type) )
|
||||
pure_type = nullptr;
|
||||
|
@ -215,8 +215,8 @@ unsigned int TypeList::MemoryAllocation() const
|
|||
|
||||
size += pad_size(types.capacity() * sizeof(decltype(types)::value_type));
|
||||
|
||||
return BroType::MemoryAllocation()
|
||||
+ padded_sizeof(*this) - padded_sizeof(BroType)
|
||||
return Type::MemoryAllocation()
|
||||
+ padded_sizeof(*this) - padded_sizeof(Type)
|
||||
+ size;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ int IndexType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
|||
|
||||
void IndexType::Describe(ODesc* d) const
|
||||
{
|
||||
BroType::Describe(d);
|
||||
Type::Describe(d);
|
||||
if ( ! d->IsBinary() )
|
||||
d->Add("[");
|
||||
|
||||
|
@ -317,7 +317,7 @@ bool IndexType::IsSubNetIndex() const
|
|||
return false;
|
||||
}
|
||||
|
||||
TableType::TableType(IntrusivePtr<TypeList> ind, IntrusivePtr<BroType> yield)
|
||||
TableType::TableType(IntrusivePtr<TypeList> ind, IntrusivePtr<Type> yield)
|
||||
: IndexType(TYPE_TABLE, std::move(ind), std::move(yield))
|
||||
{
|
||||
if ( ! indices )
|
||||
|
@ -344,7 +344,7 @@ TableType::TableType(IntrusivePtr<TypeList> ind, IntrusivePtr<BroType> yield)
|
|||
}
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> TableType::ShallowClone()
|
||||
IntrusivePtr<Type> TableType::ShallowClone()
|
||||
{
|
||||
return make_intrusive<TableType>(indices, yield_type);
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ SetType::SetType(IntrusivePtr<TypeList> ind, IntrusivePtr<zeek::detail::ListExpr
|
|||
|
||||
else if ( tl.size() == 1 )
|
||||
{
|
||||
IntrusivePtr<BroType> ft{NewRef{}, flatten_type(tl[0].get())};
|
||||
IntrusivePtr<Type> ft{NewRef{}, flatten_type(tl[0].get())};
|
||||
indices = make_intrusive<TypeList>(ft);
|
||||
indices->Append(std::move(ft));
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ SetType::SetType(IntrusivePtr<TypeList> ind, IntrusivePtr<zeek::detail::ListExpr
|
|||
}
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> SetType::ShallowClone()
|
||||
IntrusivePtr<Type> SetType::ShallowClone()
|
||||
{
|
||||
return make_intrusive<SetType>(indices, elements);
|
||||
}
|
||||
|
@ -411,8 +411,8 @@ IntrusivePtr<BroType> SetType::ShallowClone()
|
|||
SetType::~SetType() = default;
|
||||
|
||||
FuncType::FuncType(IntrusivePtr<RecordType> arg_args,
|
||||
IntrusivePtr<BroType> arg_yield, FunctionFlavor arg_flavor)
|
||||
: BroType(TYPE_FUNC), args(std::move(arg_args)),
|
||||
IntrusivePtr<Type> arg_yield, FunctionFlavor arg_flavor)
|
||||
: Type(TYPE_FUNC), args(std::move(arg_args)),
|
||||
arg_types(make_intrusive<TypeList>()), yield(std::move(arg_yield))
|
||||
{
|
||||
flavor = arg_flavor;
|
||||
|
@ -441,7 +441,7 @@ FuncType::FuncType(IntrusivePtr<RecordType> arg_args,
|
|||
prototypes.emplace_back(Prototype{false, args, std::move(offsets)});
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> FuncType::ShallowClone()
|
||||
IntrusivePtr<Type> FuncType::ShallowClone()
|
||||
{
|
||||
auto f = make_intrusive<FuncType>();
|
||||
f->args = args;
|
||||
|
@ -481,7 +481,7 @@ int FuncType::MatchesIndex(zeek::detail::ListExpr* const index) const
|
|||
|
||||
bool FuncType::CheckArgs(const type_list* args, bool is_init) const
|
||||
{
|
||||
std::vector<IntrusivePtr<BroType>> as;
|
||||
std::vector<IntrusivePtr<Type>> as;
|
||||
as.reserve(args->length());
|
||||
|
||||
for ( auto a : *args )
|
||||
|
@ -490,7 +490,7 @@ bool FuncType::CheckArgs(const type_list* args, bool is_init) const
|
|||
return CheckArgs(as, is_init);
|
||||
}
|
||||
|
||||
bool FuncType::CheckArgs(const std::vector<IntrusivePtr<BroType>>& args,
|
||||
bool FuncType::CheckArgs(const std::vector<IntrusivePtr<Type>>& args,
|
||||
bool is_init) const
|
||||
{
|
||||
const auto& my_args = arg_types->Types();
|
||||
|
@ -609,7 +609,7 @@ std::optional<FuncType::Prototype> FuncType::FindPrototype(const RecordType& arg
|
|||
return {};
|
||||
}
|
||||
|
||||
TypeDecl::TypeDecl(const char* i, IntrusivePtr<BroType> t,
|
||||
TypeDecl::TypeDecl(const char* i, IntrusivePtr<Type> t,
|
||||
IntrusivePtr<zeek::detail::Attributes> arg_attrs)
|
||||
: type(std::move(t)),
|
||||
attrs(std::move(arg_attrs)),
|
||||
|
@ -650,7 +650,7 @@ void TypeDecl::DescribeReST(ODesc* d, bool roles_only) const
|
|||
}
|
||||
}
|
||||
|
||||
RecordType::RecordType(type_decl_list* arg_types) : BroType(TYPE_RECORD)
|
||||
RecordType::RecordType(type_decl_list* arg_types) : Type(TYPE_RECORD)
|
||||
{
|
||||
types = arg_types;
|
||||
num_fields = types ? types->length() : 0;
|
||||
|
@ -658,7 +658,7 @@ RecordType::RecordType(type_decl_list* arg_types) : BroType(TYPE_RECORD)
|
|||
|
||||
// in this case the clone is actually not so shallow, since
|
||||
// it gets modified by everyone.
|
||||
IntrusivePtr<BroType> RecordType::ShallowClone()
|
||||
IntrusivePtr<Type> RecordType::ShallowClone()
|
||||
{
|
||||
auto pass = new type_decl_list();
|
||||
for ( const auto& type : *types )
|
||||
|
@ -760,7 +760,7 @@ void RecordType::DescribeReST(ODesc* d, bool roles_only) const
|
|||
d->PopType(this);
|
||||
}
|
||||
|
||||
static string container_type_name(const BroType* ft)
|
||||
static string container_type_name(const Type* ft)
|
||||
{
|
||||
string s;
|
||||
if ( ft->Tag() == TYPE_RECORD )
|
||||
|
@ -1016,7 +1016,7 @@ string RecordType::GetFieldDeprecationWarning(int field, bool has_check) const
|
|||
return "";
|
||||
}
|
||||
|
||||
SubNetType::SubNetType() : BroType(TYPE_SUBNET)
|
||||
SubNetType::SubNetType() : Type(TYPE_SUBNET)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1028,8 +1028,8 @@ void SubNetType::Describe(ODesc* d) const
|
|||
d->Add(int(Tag()));
|
||||
}
|
||||
|
||||
FileType::FileType(IntrusivePtr<BroType> yield_type)
|
||||
: BroType(TYPE_FILE), yield(std::move(yield_type))
|
||||
FileType::FileType(IntrusivePtr<Type> yield_type)
|
||||
: Type(TYPE_FILE), yield(std::move(yield_type))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1049,7 +1049,7 @@ void FileType::Describe(ODesc* d) const
|
|||
}
|
||||
}
|
||||
|
||||
OpaqueType::OpaqueType(const string& arg_name) : BroType(TYPE_OPAQUE)
|
||||
OpaqueType::OpaqueType(const string& arg_name) : Type(TYPE_OPAQUE)
|
||||
{
|
||||
name = arg_name;
|
||||
}
|
||||
|
@ -1070,20 +1070,20 @@ void OpaqueType::DescribeReST(ODesc* d, bool roles_only) const
|
|||
}
|
||||
|
||||
EnumType::EnumType(const string& name)
|
||||
: BroType(TYPE_ENUM)
|
||||
: Type(TYPE_ENUM)
|
||||
{
|
||||
counter = 0;
|
||||
SetName(name);
|
||||
}
|
||||
|
||||
EnumType::EnumType(const EnumType* e)
|
||||
: BroType(TYPE_ENUM), names(e->names), vals(e->vals)
|
||||
: Type(TYPE_ENUM), names(e->names), vals(e->vals)
|
||||
{
|
||||
counter = e->counter;
|
||||
SetName(e->GetName());
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> EnumType::ShallowClone()
|
||||
IntrusivePtr<Type> EnumType::ShallowClone()
|
||||
{
|
||||
if ( counter == 0 )
|
||||
return make_intrusive<EnumType>(GetName());
|
||||
|
@ -1166,8 +1166,8 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name,
|
|||
if ( vals.find(val) == vals.end() )
|
||||
vals[val] = make_intrusive<EnumVal>(IntrusivePtr{NewRef{}, this}, val);
|
||||
|
||||
set<BroType*> types = BroType::GetAliases(GetName());
|
||||
set<BroType*>::const_iterator it;
|
||||
set<Type*> types = Type::GetAliases(GetName());
|
||||
set<Type*>::const_iterator it;
|
||||
|
||||
for ( it = types.begin(); it != types.end(); ++it )
|
||||
if ( *it != this )
|
||||
|
@ -1303,19 +1303,19 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const
|
|||
}
|
||||
}
|
||||
|
||||
VectorType::VectorType(IntrusivePtr<BroType> element_type)
|
||||
: BroType(TYPE_VECTOR), yield_type(std::move(element_type))
|
||||
VectorType::VectorType(IntrusivePtr<Type> element_type)
|
||||
: Type(TYPE_VECTOR), yield_type(std::move(element_type))
|
||||
{
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> VectorType::ShallowClone()
|
||||
IntrusivePtr<Type> VectorType::ShallowClone()
|
||||
{
|
||||
return make_intrusive<VectorType>(yield_type);
|
||||
}
|
||||
|
||||
VectorType::~VectorType() = default;
|
||||
|
||||
const IntrusivePtr<BroType>& VectorType::Yield() const
|
||||
const IntrusivePtr<Type>& VectorType::Yield() const
|
||||
{
|
||||
// Work around the fact that we use void internally to mark a vector
|
||||
// as being unspecified. When looking at its yield type, we need to
|
||||
|
@ -1376,7 +1376,7 @@ void VectorType::DescribeReST(ODesc* d, bool roles_only) const
|
|||
// false otherwise. Assumes that t1's tag is different from t2's. Note
|
||||
// that the test is in only one direction - we don't check whether t2 is
|
||||
// initialization-compatible with t1.
|
||||
static bool is_init_compat(const BroType& t1, const BroType& t2)
|
||||
static bool is_init_compat(const Type& t1, const Type& t2)
|
||||
{
|
||||
if ( t1.Tag() == TYPE_LIST )
|
||||
{
|
||||
|
@ -1392,7 +1392,7 @@ static bool is_init_compat(const BroType& t1, const BroType& t2)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool same_type(const BroType& arg_t1, const BroType& arg_t2,
|
||||
bool same_type(const Type& arg_t1, const Type& arg_t2,
|
||||
bool is_init, bool match_record_field_names)
|
||||
{
|
||||
if ( &arg_t1 == &arg_t2 ||
|
||||
|
@ -1587,7 +1587,7 @@ bool record_promotion_compatible(const RecordType* super_rec,
|
|||
return true;
|
||||
}
|
||||
|
||||
const BroType* flatten_type(const BroType* t)
|
||||
const Type* flatten_type(const Type* t)
|
||||
{
|
||||
if ( t->Tag() != TYPE_LIST )
|
||||
return t;
|
||||
|
@ -1610,9 +1610,9 @@ const BroType* flatten_type(const BroType* t)
|
|||
return t;
|
||||
}
|
||||
|
||||
BroType* flatten_type(BroType* t)
|
||||
Type* flatten_type(Type* t)
|
||||
{
|
||||
return (BroType*) flatten_type((const BroType*) t);
|
||||
return (Type*) flatten_type((const Type*) t);
|
||||
}
|
||||
|
||||
bool is_assignable(TypeTag t)
|
||||
|
@ -1684,8 +1684,8 @@ TypeTag max_type(TypeTag t1, TypeTag t2)
|
|||
}
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> merge_types(const IntrusivePtr<BroType>& arg_t1,
|
||||
const IntrusivePtr<BroType>& arg_t2)
|
||||
IntrusivePtr<Type> merge_types(const IntrusivePtr<Type>& arg_t1,
|
||||
const IntrusivePtr<Type>& arg_t2)
|
||||
{
|
||||
auto t1 = arg_t1.get();
|
||||
auto t2 = arg_t2.get();
|
||||
|
@ -1779,7 +1779,7 @@ IntrusivePtr<BroType> merge_types(const IntrusivePtr<BroType>& arg_t1,
|
|||
|
||||
const auto& y1 = t1->Yield();
|
||||
const auto& y2 = t2->Yield();
|
||||
IntrusivePtr<BroType> y3;
|
||||
IntrusivePtr<Type> y3;
|
||||
|
||||
if ( y1 || y2 )
|
||||
{
|
||||
|
@ -1924,7 +1924,7 @@ IntrusivePtr<BroType> merge_types(const IntrusivePtr<BroType>& arg_t1,
|
|||
}
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> merge_type_list(zeek::detail::ListExpr* elements)
|
||||
IntrusivePtr<Type> merge_type_list(zeek::detail::ListExpr* elements)
|
||||
{
|
||||
TypeList* tl_type = elements->GetType()->AsTypeList();
|
||||
const auto& tl = tl_type->Types();
|
||||
|
@ -1950,7 +1950,7 @@ IntrusivePtr<BroType> merge_type_list(zeek::detail::ListExpr* elements)
|
|||
}
|
||||
|
||||
// Reduces an aggregate type.
|
||||
static BroType* reduce_type(BroType* t)
|
||||
static Type* reduce_type(Type* t)
|
||||
{
|
||||
if ( t->Tag() == TYPE_LIST )
|
||||
return flatten_type(t);
|
||||
|
@ -1969,7 +1969,7 @@ static BroType* reduce_type(BroType* t)
|
|||
return t;
|
||||
}
|
||||
|
||||
IntrusivePtr<BroType> init_type(zeek::detail::Expr* init)
|
||||
IntrusivePtr<Type> init_type(zeek::detail::Expr* init)
|
||||
{
|
||||
if ( init->Tag() != zeek::detail::EXPR_LIST )
|
||||
{
|
||||
|
@ -2016,7 +2016,7 @@ IntrusivePtr<BroType> init_type(zeek::detail::Expr* init)
|
|||
for ( int i = 1; t && i < el.length(); ++i )
|
||||
{
|
||||
auto el_t = el[i]->InitType();
|
||||
IntrusivePtr<BroType> ti;
|
||||
IntrusivePtr<Type> ti;
|
||||
|
||||
if ( el_t )
|
||||
ti = {NewRef{}, reduce_type(el_t.get())};
|
||||
|
@ -2053,7 +2053,7 @@ IntrusivePtr<BroType> init_type(zeek::detail::Expr* init)
|
|||
nullptr);
|
||||
}
|
||||
|
||||
bool is_atomic_type(const BroType& t)
|
||||
bool is_atomic_type(const Type& t)
|
||||
{
|
||||
switch ( t.InternalType() ) {
|
||||
case TYPE_INTERNAL_INT:
|
||||
|
@ -2068,14 +2068,14 @@ bool is_atomic_type(const BroType& t)
|
|||
}
|
||||
}
|
||||
|
||||
const IntrusivePtr<BroType>& base_type(zeek::TypeTag tag)
|
||||
const IntrusivePtr<Type>& base_type(zeek::TypeTag tag)
|
||||
{
|
||||
static IntrusivePtr<BroType> base_types[NUM_TYPES];
|
||||
static IntrusivePtr<Type> base_types[NUM_TYPES];
|
||||
|
||||
// We could check here that "tag" actually corresponds to a basic type.
|
||||
if ( ! base_types[tag] )
|
||||
{
|
||||
base_types[tag] = make_intrusive<BroType>(tag, true);
|
||||
base_types[tag] = make_intrusive<Type>(tag, true);
|
||||
// Give the base types a pseudo-location for easier identification.
|
||||
Location l(type_name(tag), 0, 0, 0, 0);
|
||||
base_types[tag]->SetLocationInfo(&l);
|
||||
|
|
236
src/Type.h
236
src/Type.h
|
@ -185,14 +185,14 @@ constexpr int DOES_NOT_MATCH_INDEX = 0;
|
|||
constexpr int MATCHES_INDEX_SCALAR = 1;
|
||||
constexpr int MATCHES_INDEX_VECTOR = 2;
|
||||
|
||||
class BroType : public BroObj {
|
||||
class Type : public BroObj {
|
||||
public:
|
||||
static inline const IntrusivePtr<BroType> nil;
|
||||
static inline const IntrusivePtr<Type> nil;
|
||||
|
||||
explicit BroType(zeek::TypeTag tag, bool base_type = false);
|
||||
explicit Type(zeek::TypeTag tag, bool base_type = false);
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek::TypeTag instead.")]]
|
||||
explicit BroType(::TypeTag tag, bool base_type = false)
|
||||
: BroType(static_cast<zeek::TypeTag>(tag), base_type)
|
||||
explicit Type(::TypeTag tag, bool base_type = false)
|
||||
: Type(static_cast<zeek::TypeTag>(tag), base_type)
|
||||
{}
|
||||
|
||||
// Performs a shallow clone operation of the Bro type.
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
// Clone operations will mostly be implemented in the derived classes;
|
||||
// in addition cloning will be limited to classes that can be reached by
|
||||
// the script-level.
|
||||
virtual IntrusivePtr<BroType> ShallowClone();
|
||||
virtual IntrusivePtr<Type> ShallowClone();
|
||||
|
||||
TypeTag Tag() const { return tag; }
|
||||
InternalTypeTag InternalType() const { return internal_tag; }
|
||||
|
@ -223,13 +223,13 @@ public:
|
|||
// Returns the type yielded by this type. For example, if
|
||||
// this type is a table[string] of port, then returns the "port"
|
||||
// type. Returns nil if this is not an index type.
|
||||
virtual const IntrusivePtr<BroType>& Yield() const;
|
||||
virtual const IntrusivePtr<Type>& Yield() const;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use Yield() instead.")]]
|
||||
virtual BroType* YieldType()
|
||||
virtual Type* YieldType()
|
||||
{ return Yield().get(); }
|
||||
[[deprecated("Remove in v4.1. Use Yield() instead.")]]
|
||||
virtual const BroType* YieldType() const
|
||||
virtual const Type* YieldType() const
|
||||
{ return Yield().get(); }
|
||||
|
||||
// Returns true if this type is a record and contains the
|
||||
|
@ -239,126 +239,126 @@ public:
|
|||
|
||||
// Returns the type of the given field, or nil if no such field.
|
||||
[[deprecated("Remove in v4.1. Use RecordType::GetFieldType() directly.")]]
|
||||
virtual BroType* FieldType(const char* field) const;
|
||||
virtual Type* FieldType(const char* field) const;
|
||||
|
||||
#define CHECK_TYPE_TAG(tag_type, func_name) \
|
||||
CHECK_TAG(tag, tag_type, func_name, type_name)
|
||||
|
||||
const TypeList* AsTypeList() const
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_LIST, "BroType::AsTypeList");
|
||||
CHECK_TYPE_TAG(TYPE_LIST, "Type::AsTypeList");
|
||||
return (const TypeList*) this;
|
||||
}
|
||||
TypeList* AsTypeList()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_LIST, "BroType::AsTypeList");
|
||||
CHECK_TYPE_TAG(TYPE_LIST, "Type::AsTypeList");
|
||||
return (TypeList*) this;
|
||||
}
|
||||
|
||||
const TableType* AsTableType() const
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_TABLE, "BroType::AsTableType");
|
||||
CHECK_TYPE_TAG(TYPE_TABLE, "Type::AsTableType");
|
||||
return (const TableType*) this;
|
||||
}
|
||||
TableType* AsTableType()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_TABLE, "BroType::AsTableType");
|
||||
CHECK_TYPE_TAG(TYPE_TABLE, "Type::AsTableType");
|
||||
return (TableType*) this;
|
||||
}
|
||||
|
||||
SetType* AsSetType()
|
||||
{
|
||||
if ( ! IsSet() )
|
||||
BadTag("BroType::AsSetType", type_name(tag));
|
||||
BadTag("Type::AsSetType", type_name(tag));
|
||||
return (SetType*) this;
|
||||
}
|
||||
const SetType* AsSetType() const
|
||||
{
|
||||
if ( ! IsSet() )
|
||||
BadTag("BroType::AsSetType", type_name(tag));
|
||||
BadTag("Type::AsSetType", type_name(tag));
|
||||
return (const SetType*) this;
|
||||
}
|
||||
|
||||
const RecordType* AsRecordType() const
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_RECORD, "BroType::AsRecordType");
|
||||
CHECK_TYPE_TAG(TYPE_RECORD, "Type::AsRecordType");
|
||||
return (const RecordType*) this;
|
||||
}
|
||||
RecordType* AsRecordType()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_RECORD, "BroType::AsRecordType");
|
||||
CHECK_TYPE_TAG(TYPE_RECORD, "Type::AsRecordType");
|
||||
return (RecordType*) this;
|
||||
}
|
||||
|
||||
const SubNetType* AsSubNetType() const
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_SUBNET, "BroType::AsSubNetType");
|
||||
CHECK_TYPE_TAG(TYPE_SUBNET, "Type::AsSubNetType");
|
||||
return (const SubNetType*) this;
|
||||
}
|
||||
|
||||
SubNetType* AsSubNetType()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_SUBNET, "BroType::AsSubNetType");
|
||||
CHECK_TYPE_TAG(TYPE_SUBNET, "Type::AsSubNetType");
|
||||
return (SubNetType*) this;
|
||||
}
|
||||
|
||||
const FuncType* AsFuncType() const
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_FUNC, "BroType::AsFuncType");
|
||||
CHECK_TYPE_TAG(TYPE_FUNC, "Type::AsFuncType");
|
||||
return (const FuncType*) this;
|
||||
}
|
||||
|
||||
FuncType* AsFuncType()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_FUNC, "BroType::AsFuncType");
|
||||
CHECK_TYPE_TAG(TYPE_FUNC, "Type::AsFuncType");
|
||||
return (FuncType*) this;
|
||||
}
|
||||
|
||||
const EnumType* AsEnumType() const
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_ENUM, "BroType::AsEnumType");
|
||||
CHECK_TYPE_TAG(TYPE_ENUM, "Type::AsEnumType");
|
||||
return (EnumType*) this;
|
||||
}
|
||||
|
||||
EnumType* AsEnumType()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_ENUM, "BroType::AsEnumType");
|
||||
CHECK_TYPE_TAG(TYPE_ENUM, "Type::AsEnumType");
|
||||
return (EnumType*) this;
|
||||
}
|
||||
|
||||
const VectorType* AsVectorType() const
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_VECTOR, "BroType::AsVectorType");
|
||||
CHECK_TYPE_TAG(TYPE_VECTOR, "Type::AsVectorType");
|
||||
return (VectorType*) this;
|
||||
}
|
||||
|
||||
OpaqueType* AsOpaqueType()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_OPAQUE, "BroType::AsOpaqueType");
|
||||
CHECK_TYPE_TAG(TYPE_OPAQUE, "Type::AsOpaqueType");
|
||||
return (OpaqueType*) this;
|
||||
}
|
||||
|
||||
const OpaqueType* AsOpaqueType() const
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_OPAQUE, "BroType::AsOpaqueType");
|
||||
CHECK_TYPE_TAG(TYPE_OPAQUE, "Type::AsOpaqueType");
|
||||
return (OpaqueType*) this;
|
||||
}
|
||||
|
||||
VectorType* AsVectorType()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_VECTOR, "BroType::AsVectorType");
|
||||
CHECK_TYPE_TAG(TYPE_VECTOR, "Type::AsVectorType");
|
||||
return (VectorType*) this;
|
||||
}
|
||||
|
||||
const TypeType* AsTypeType() const
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_TYPE, "BroType::AsTypeType");
|
||||
CHECK_TYPE_TAG(TYPE_TYPE, "Type::AsTypeType");
|
||||
return (TypeType*) this;
|
||||
}
|
||||
|
||||
TypeType* AsTypeType()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_TYPE, "BroType::AsTypeType");
|
||||
CHECK_TYPE_TAG(TYPE_TYPE, "Type::AsTypeType");
|
||||
return (TypeType*) this;
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ public:
|
|||
return tag == TYPE_TABLE && Yield();
|
||||
}
|
||||
|
||||
BroType* Ref() { ::Ref(this); return this; }
|
||||
Type* Ref() { ::Ref(this); return this; }
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
virtual void DescribeReST(ODesc* d, bool roles_only = false) const;
|
||||
|
@ -382,16 +382,16 @@ public:
|
|||
void SetName(const std::string& arg_name) { name = arg_name; }
|
||||
const std::string& GetName() const { return name; }
|
||||
|
||||
typedef std::map<std::string, std::set<BroType*> > TypeAliasMap;
|
||||
typedef std::map<std::string, std::set<Type*> > TypeAliasMap;
|
||||
|
||||
static std::set<BroType*> GetAliases(const std::string& type_name)
|
||||
{ return BroType::type_aliases[type_name]; }
|
||||
static std::set<Type*> GetAliases(const std::string& type_name)
|
||||
{ return Type::type_aliases[type_name]; }
|
||||
|
||||
static void AddAlias(const std::string &type_name, BroType* type)
|
||||
{ BroType::type_aliases[type_name].insert(type); }
|
||||
static void AddAlias(const std::string &type_name, Type* type)
|
||||
{ Type::type_aliases[type_name].insert(type); }
|
||||
|
||||
protected:
|
||||
BroType() { }
|
||||
Type() = default;
|
||||
|
||||
void SetError();
|
||||
|
||||
|
@ -405,48 +405,48 @@ private:
|
|||
static TypeAliasMap type_aliases;
|
||||
};
|
||||
|
||||
class TypeList final : public BroType {
|
||||
class TypeList final : public Type {
|
||||
public:
|
||||
explicit TypeList(IntrusivePtr<BroType> arg_pure_type = nullptr)
|
||||
: BroType(TYPE_LIST), pure_type(std::move(arg_pure_type))
|
||||
explicit TypeList(IntrusivePtr<Type> arg_pure_type = nullptr)
|
||||
: Type(TYPE_LIST), pure_type(std::move(arg_pure_type))
|
||||
{
|
||||
}
|
||||
|
||||
const std::vector<IntrusivePtr<BroType>>& Types() const
|
||||
const std::vector<IntrusivePtr<Type>>& Types() const
|
||||
{ return types; }
|
||||
|
||||
bool IsPure() const { return pure_type != nullptr; }
|
||||
|
||||
// Returns the underlying pure type, or nil if the list
|
||||
// is not pure or is empty.
|
||||
const IntrusivePtr<BroType>& GetPureType() const
|
||||
const IntrusivePtr<Type>& GetPureType() const
|
||||
{ return pure_type; }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetPureType() instead.")]]
|
||||
BroType* PureType() { return pure_type.get(); }
|
||||
Type* PureType() { return pure_type.get(); }
|
||||
[[deprecated("Remove in v4.1. Use GetPureType() instead.")]]
|
||||
const BroType* PureType() const { return pure_type.get(); }
|
||||
const Type* PureType() const { return pure_type.get(); }
|
||||
|
||||
// True if all of the types match t, false otherwise. If
|
||||
// is_init is true, then the matching is done in the context
|
||||
// of an initialization.
|
||||
bool AllMatch(const BroType* t, bool is_init) const;
|
||||
bool AllMatch(const IntrusivePtr<BroType>& t, bool is_init) const
|
||||
bool AllMatch(const Type* t, bool is_init) const;
|
||||
bool AllMatch(const IntrusivePtr<Type>& t, bool is_init) const
|
||||
{ return AllMatch(t.get(), is_init); }
|
||||
|
||||
void Append(IntrusivePtr<BroType> t);
|
||||
void AppendEvenIfNotPure(IntrusivePtr<BroType> t);
|
||||
void Append(IntrusivePtr<Type> t);
|
||||
void AppendEvenIfNotPure(IntrusivePtr<Type> t);
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
||||
unsigned int MemoryAllocation() const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<BroType> pure_type;
|
||||
std::vector<IntrusivePtr<BroType>> types;
|
||||
IntrusivePtr<Type> pure_type;
|
||||
std::vector<IntrusivePtr<Type>> types;
|
||||
};
|
||||
|
||||
class IndexType : public BroType {
|
||||
class IndexType : public Type {
|
||||
public:
|
||||
int MatchesIndex(zeek::detail::ListExpr* index) const override;
|
||||
|
||||
|
@ -456,10 +456,10 @@ public:
|
|||
[[deprecated("Remove in v4.1. Use GetIndices().")]]
|
||||
TypeList* Indices() const { return indices.get(); }
|
||||
|
||||
const std::vector<IntrusivePtr<BroType>>& IndexTypes() const
|
||||
const std::vector<IntrusivePtr<Type>>& IndexTypes() const
|
||||
{ return indices->Types(); }
|
||||
|
||||
const IntrusivePtr<BroType>& Yield() const override
|
||||
const IntrusivePtr<Type>& Yield() const override
|
||||
{ return yield_type; }
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
@ -470,8 +470,8 @@ public:
|
|||
|
||||
protected:
|
||||
IndexType(TypeTag t, IntrusivePtr<TypeList> arg_indices,
|
||||
IntrusivePtr<BroType> arg_yield_type)
|
||||
: BroType(t), indices(std::move(arg_indices)),
|
||||
IntrusivePtr<Type> arg_yield_type)
|
||||
: Type(t), indices(std::move(arg_indices)),
|
||||
yield_type(std::move(arg_yield_type))
|
||||
{
|
||||
}
|
||||
|
@ -479,14 +479,14 @@ protected:
|
|||
~IndexType() override;
|
||||
|
||||
IntrusivePtr<TypeList> indices;
|
||||
IntrusivePtr<BroType> yield_type;
|
||||
IntrusivePtr<Type> yield_type;
|
||||
};
|
||||
|
||||
class TableType : public IndexType {
|
||||
public:
|
||||
TableType(IntrusivePtr<TypeList> ind, IntrusivePtr<BroType> yield);
|
||||
TableType(IntrusivePtr<TypeList> ind, IntrusivePtr<Type> yield);
|
||||
|
||||
IntrusivePtr<BroType> ShallowClone() override;
|
||||
IntrusivePtr<Type> ShallowClone() override;
|
||||
|
||||
// Returns true if this table type is "unspecified", which is
|
||||
// what one gets using an empty "set()" or "table()" constructor.
|
||||
|
@ -498,7 +498,7 @@ public:
|
|||
SetType(IntrusivePtr<TypeList> ind, IntrusivePtr<zeek::detail::ListExpr> arg_elements);
|
||||
~SetType() override;
|
||||
|
||||
IntrusivePtr<BroType> ShallowClone() override;
|
||||
IntrusivePtr<Type> ShallowClone() override;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use Elements() isntead.")]]
|
||||
zeek::detail::ListExpr* SetElements() const { return elements.get(); }
|
||||
|
@ -510,7 +510,7 @@ protected:
|
|||
IntrusivePtr<zeek::detail::ListExpr> elements;
|
||||
};
|
||||
|
||||
class FuncType final : public BroType {
|
||||
class FuncType final : public Type {
|
||||
public:
|
||||
static inline const IntrusivePtr<FuncType> nil;
|
||||
|
||||
|
@ -525,15 +525,15 @@ public:
|
|||
std::map<int, int> offsets;
|
||||
};
|
||||
|
||||
FuncType(IntrusivePtr<RecordType> args, IntrusivePtr<BroType> yield,
|
||||
FuncType(IntrusivePtr<RecordType> args, IntrusivePtr<Type> yield,
|
||||
FunctionFlavor f);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use the version that takes zeek::FunctionFlavor instead.")]]
|
||||
FuncType(IntrusivePtr<RecordType> args, IntrusivePtr<BroType> yield, ::function_flavor f)
|
||||
FuncType(IntrusivePtr<RecordType> args, IntrusivePtr<Type> yield, ::function_flavor f)
|
||||
: FuncType(args, yield, static_cast<FunctionFlavor>(f))
|
||||
{}
|
||||
|
||||
IntrusivePtr<BroType> ShallowClone() override;
|
||||
IntrusivePtr<Type> ShallowClone() override;
|
||||
|
||||
~FuncType() override;
|
||||
|
||||
|
@ -543,10 +543,10 @@ public:
|
|||
const IntrusivePtr<RecordType>& Params() const
|
||||
{ return args; }
|
||||
|
||||
const IntrusivePtr<BroType>& Yield() const override
|
||||
const IntrusivePtr<Type>& Yield() const override
|
||||
{ return yield; }
|
||||
|
||||
void SetYieldType(IntrusivePtr<BroType> arg_yield) { yield = std::move(arg_yield); }
|
||||
void SetYieldType(IntrusivePtr<Type> arg_yield) { yield = std::move(arg_yield); }
|
||||
FunctionFlavor Flavor() const { return flavor; }
|
||||
std::string FlavorString() const;
|
||||
|
||||
|
@ -560,7 +560,7 @@ public:
|
|||
|
||||
int MatchesIndex(zeek::detail::ListExpr* index) const override;
|
||||
bool CheckArgs(const type_list* args, bool is_init = false) const;
|
||||
bool CheckArgs(const std::vector<IntrusivePtr<BroType>>& args,
|
||||
bool CheckArgs(const std::vector<IntrusivePtr<Type>>& args,
|
||||
bool is_init = false) const;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use ParamList().")]]
|
||||
|
@ -591,20 +591,20 @@ public:
|
|||
protected:
|
||||
friend IntrusivePtr<FuncType> make_intrusive<FuncType>();
|
||||
|
||||
FuncType() : BroType(TYPE_FUNC) { flavor = FUNC_FLAVOR_FUNCTION; }
|
||||
FuncType() : Type(TYPE_FUNC) { flavor = FUNC_FLAVOR_FUNCTION; }
|
||||
IntrusivePtr<RecordType> args;
|
||||
IntrusivePtr<TypeList> arg_types;
|
||||
IntrusivePtr<BroType> yield;
|
||||
IntrusivePtr<Type> yield;
|
||||
FunctionFlavor flavor;
|
||||
std::vector<Prototype> prototypes;
|
||||
};
|
||||
|
||||
class TypeType final : public BroType {
|
||||
class TypeType final : public Type {
|
||||
public:
|
||||
explicit TypeType(IntrusivePtr<BroType> t) : BroType(TYPE_TYPE), type(std::move(t)) {}
|
||||
IntrusivePtr<BroType> ShallowClone() override { return make_intrusive<TypeType>(type); }
|
||||
explicit TypeType(IntrusivePtr<Type> t) : zeek::Type(TYPE_TYPE), type(std::move(t)) {}
|
||||
IntrusivePtr<Type> ShallowClone() override { return make_intrusive<TypeType>(type); }
|
||||
|
||||
const IntrusivePtr<BroType>& GetType() const
|
||||
const IntrusivePtr<Type>& GetType() const
|
||||
{ return type; }
|
||||
|
||||
template <class T>
|
||||
|
@ -612,18 +612,18 @@ public:
|
|||
{ return cast_intrusive<T>(type); }
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
BroType* Type() { return type.get(); }
|
||||
zeek::Type* Type() { return type.get(); }
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
const BroType* Type() const { return type.get(); }
|
||||
const zeek::Type* Type() const { return type.get(); }
|
||||
|
||||
protected:
|
||||
IntrusivePtr<BroType> type;
|
||||
IntrusivePtr<zeek::Type> type;
|
||||
};
|
||||
|
||||
class TypeDecl final {
|
||||
public:
|
||||
TypeDecl() = default;
|
||||
TypeDecl(const char* i, IntrusivePtr<BroType> t,
|
||||
TypeDecl(const char* i, IntrusivePtr<Type> t,
|
||||
IntrusivePtr<zeek::detail::Attributes> attrs = nullptr);
|
||||
TypeDecl(const TypeDecl& other);
|
||||
~TypeDecl();
|
||||
|
@ -637,38 +637,38 @@ public:
|
|||
|
||||
void DescribeReST(ODesc* d, bool roles_only = false) const;
|
||||
|
||||
IntrusivePtr<BroType> type;
|
||||
IntrusivePtr<Type> type;
|
||||
IntrusivePtr<zeek::detail::Attributes> attrs;
|
||||
const char* id = nullptr;
|
||||
};
|
||||
|
||||
using type_decl_list = PList<TypeDecl>;
|
||||
|
||||
class RecordType final : public BroType {
|
||||
class RecordType final : public Type {
|
||||
public:
|
||||
explicit RecordType(type_decl_list* types);
|
||||
IntrusivePtr<BroType> ShallowClone() override;
|
||||
IntrusivePtr<Type> ShallowClone() override;
|
||||
|
||||
~RecordType() override;
|
||||
|
||||
bool HasField(const char* field) const override;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetFieldType() instead (note it doesn't check for invalid names).")]]
|
||||
BroType* FieldType(const char* field) const override
|
||||
Type* FieldType(const char* field) const override
|
||||
{
|
||||
auto offset = FieldOffset(field);
|
||||
return offset >= 0 ? GetFieldType(offset).get() : nullptr;
|
||||
}
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetFieldType() instead.")]]
|
||||
BroType* FieldType(int field) const
|
||||
Type* FieldType(int field) const
|
||||
{ return GetFieldType(field).get(); }
|
||||
|
||||
/**
|
||||
* Looks up a field by name and returns its type. No check for invalid
|
||||
* field name is performed.
|
||||
*/
|
||||
const IntrusivePtr<BroType>& GetFieldType(const char* field_name) const
|
||||
const IntrusivePtr<Type>& GetFieldType(const char* field_name) const
|
||||
{ return GetFieldType(FieldOffset(field_name)); }
|
||||
|
||||
/**
|
||||
|
@ -683,7 +683,7 @@ public:
|
|||
* Looks up a field by its index and returns its type. No check for
|
||||
* invalid field offset is performed.
|
||||
*/
|
||||
const IntrusivePtr<BroType>& GetFieldType(int field_index) const
|
||||
const IntrusivePtr<Type>& GetFieldType(int field_index) const
|
||||
{ return (*types)[field_index]->type; }
|
||||
|
||||
/**
|
||||
|
@ -753,31 +753,31 @@ protected:
|
|||
type_decl_list* types;
|
||||
};
|
||||
|
||||
class SubNetType final : public BroType {
|
||||
class SubNetType final : public Type {
|
||||
public:
|
||||
SubNetType();
|
||||
void Describe(ODesc* d) const override;
|
||||
};
|
||||
|
||||
class FileType final : public BroType {
|
||||
class FileType final : public Type {
|
||||
public:
|
||||
explicit FileType(IntrusivePtr<BroType> yield_type);
|
||||
IntrusivePtr<BroType> ShallowClone() override { return make_intrusive<FileType>(yield); }
|
||||
explicit FileType(IntrusivePtr<Type> yield_type);
|
||||
IntrusivePtr<Type> ShallowClone() override { return make_intrusive<FileType>(yield); }
|
||||
~FileType() override;
|
||||
|
||||
const IntrusivePtr<BroType>& Yield() const override
|
||||
const IntrusivePtr<Type>& Yield() const override
|
||||
{ return yield; }
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<BroType> yield;
|
||||
IntrusivePtr<Type> yield;
|
||||
};
|
||||
|
||||
class OpaqueType final : public BroType {
|
||||
class OpaqueType final : public Type {
|
||||
public:
|
||||
explicit OpaqueType(const std::string& name);
|
||||
IntrusivePtr<BroType> ShallowClone() override { return make_intrusive<OpaqueType>(name); }
|
||||
IntrusivePtr<Type> ShallowClone() override { return make_intrusive<OpaqueType>(name); }
|
||||
~OpaqueType() override { };
|
||||
|
||||
const std::string& Name() const { return name; }
|
||||
|
@ -791,13 +791,13 @@ protected:
|
|||
std::string name;
|
||||
};
|
||||
|
||||
class EnumType final : public BroType {
|
||||
class EnumType final : public Type {
|
||||
public:
|
||||
typedef std::list<std::pair<std::string, bro_int_t> > enum_name_list;
|
||||
|
||||
explicit EnumType(const EnumType* e);
|
||||
explicit EnumType(const std::string& arg_name);
|
||||
IntrusivePtr<BroType> ShallowClone() override;
|
||||
IntrusivePtr<Type> ShallowClone() override;
|
||||
~EnumType() override;
|
||||
|
||||
// The value of this name is next internal counter value, starting
|
||||
|
@ -844,13 +844,13 @@ protected:
|
|||
bro_int_t counter;
|
||||
};
|
||||
|
||||
class VectorType final : public BroType {
|
||||
class VectorType final : public Type {
|
||||
public:
|
||||
explicit VectorType(IntrusivePtr<BroType> t);
|
||||
IntrusivePtr<BroType> ShallowClone() override;
|
||||
explicit VectorType(IntrusivePtr<Type> t);
|
||||
IntrusivePtr<Type> ShallowClone() override;
|
||||
~VectorType() override;
|
||||
|
||||
const IntrusivePtr<BroType>& Yield() const override;
|
||||
const IntrusivePtr<Type>& Yield() const override;
|
||||
|
||||
int MatchesIndex(zeek::detail::ListExpr* index) const override;
|
||||
|
||||
|
@ -862,24 +862,24 @@ public:
|
|||
void DescribeReST(ODesc* d, bool roles_only = false) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<BroType> yield_type;
|
||||
IntrusivePtr<Type> yield_type;
|
||||
};
|
||||
|
||||
// True if the two types are equivalent. If is_init is true then the test is
|
||||
// done in the context of an initialization. If match_record_field_names is
|
||||
// true then for record types the field names have to match, too.
|
||||
extern bool same_type(const BroType& t1, const BroType& t2,
|
||||
extern bool same_type(const Type& t1, const Type& t2,
|
||||
bool is_init=false, bool match_record_field_names=true);
|
||||
inline bool same_type(const IntrusivePtr<BroType>& t1, const IntrusivePtr<BroType>& t2,
|
||||
inline bool same_type(const IntrusivePtr<Type>& t1, const IntrusivePtr<Type>& t2,
|
||||
bool is_init=false, bool match_record_field_names=true)
|
||||
{ return same_type(*t1, *t2, is_init, match_record_field_names); }
|
||||
inline bool same_type(const BroType* t1, const BroType* t2,
|
||||
inline bool same_type(const Type* t1, const Type* t2,
|
||||
bool is_init=false, bool match_record_field_names=true)
|
||||
{ return same_type(*t1, *t2, is_init, match_record_field_names); }
|
||||
inline bool same_type(const IntrusivePtr<BroType>& t1, const BroType* t2,
|
||||
inline bool same_type(const IntrusivePtr<Type>& t1, const Type* t2,
|
||||
bool is_init=false, bool match_record_field_names=true)
|
||||
{ return same_type(*t1, *t2, is_init, match_record_field_names); }
|
||||
inline bool same_type(const BroType* t1, const IntrusivePtr<BroType>& t2,
|
||||
inline bool same_type(const Type* t1, const IntrusivePtr<Type>& t2,
|
||||
bool is_init=false, bool match_record_field_names=true)
|
||||
{ return same_type(*t1, *t2, is_init, match_record_field_names); }
|
||||
|
||||
|
@ -891,10 +891,10 @@ extern bool same_attrs(const zeek::detail::Attributes* a1, const zeek::detail::A
|
|||
extern bool record_promotion_compatible(const RecordType* super_rec,
|
||||
const RecordType* sub_rec);
|
||||
|
||||
// If the given BroType is a TypeList with just one element, returns
|
||||
// If the given Type is a TypeList with just one element, returns
|
||||
// that element, otherwise returns the type.
|
||||
extern const BroType* flatten_type(const BroType* t);
|
||||
extern BroType* flatten_type(BroType* t);
|
||||
extern const Type* flatten_type(const Type* t);
|
||||
extern Type* flatten_type(Type* t);
|
||||
|
||||
// Returns the "maximum" of two type tags, in a type-promotion sense.
|
||||
extern TypeTag max_type(TypeTag t1, TypeTag t2);
|
||||
|
@ -902,27 +902,27 @@ extern TypeTag max_type(TypeTag t1, TypeTag t2);
|
|||
// Given two types, returns the "merge", in which promotable types
|
||||
// are promoted to the maximum of the two. Returns nil (and generates
|
||||
// an error message) if the types are incompatible.
|
||||
IntrusivePtr<BroType> merge_types(const IntrusivePtr<BroType>& t1,
|
||||
const IntrusivePtr<BroType>& t2);
|
||||
IntrusivePtr<Type> merge_types(const IntrusivePtr<Type>& t1,
|
||||
const IntrusivePtr<Type>& t2);
|
||||
|
||||
// Given a list of expressions, returns a (ref'd) type reflecting
|
||||
// a merged type consistent across all of them, or nil if this
|
||||
// cannot be done.
|
||||
IntrusivePtr<BroType> merge_type_list(zeek::detail::ListExpr* elements);
|
||||
IntrusivePtr<Type> merge_type_list(zeek::detail::ListExpr* elements);
|
||||
|
||||
// Given an expression, infer its type when used for an initialization.
|
||||
IntrusivePtr<BroType> init_type(zeek::detail::Expr* init);
|
||||
IntrusivePtr<Type> init_type(zeek::detail::Expr* init);
|
||||
|
||||
// Returns true if argument is an atomic type.
|
||||
bool is_atomic_type(const BroType& t);
|
||||
inline bool is_atomic_type(const BroType* t)
|
||||
bool is_atomic_type(const Type& t);
|
||||
inline bool is_atomic_type(const Type* t)
|
||||
{ return is_atomic_type(*t); }
|
||||
inline bool is_atomic_type(const IntrusivePtr<BroType>& t)
|
||||
inline bool is_atomic_type(const IntrusivePtr<Type>& t)
|
||||
{ return is_atomic_type(*t); }
|
||||
|
||||
// True if the given type tag corresponds to type that can be assigned to.
|
||||
extern bool is_assignable(TypeTag t);
|
||||
inline bool is_assignable(BroType* t)
|
||||
inline bool is_assignable(Type* t)
|
||||
{ return zeek::is_assignable(t->Tag()); }
|
||||
|
||||
// True if the given type tag corresponds to an integral type.
|
||||
|
@ -974,17 +974,17 @@ inline bool BothString(TypeTag t1, TypeTag t2) { return (IsString(t1) && IsStrin
|
|||
inline bool EitherError(TypeTag t1, TypeTag t2) { return (IsErrorType(t1) || IsErrorType(t2)); }
|
||||
|
||||
// Returns the basic (non-parameterized) type with the given type.
|
||||
const IntrusivePtr<zeek::BroType>& base_type(zeek::TypeTag tag);
|
||||
const IntrusivePtr<zeek::Type>& base_type(zeek::TypeTag tag);
|
||||
|
||||
// Returns the basic error type.
|
||||
inline const IntrusivePtr<zeek::BroType>& error_type() { return base_type(TYPE_ERROR); }
|
||||
inline const IntrusivePtr<zeek::Type>& error_type() { return base_type(TYPE_ERROR); }
|
||||
|
||||
} // namespace zeek
|
||||
|
||||
// Returns the basic (non-parameterized) type with the given type.
|
||||
// The reference count of the type is not increased.
|
||||
[[deprecated("Remove in v4.1. Use zeek::base_type() instead")]]
|
||||
inline zeek::BroType* base_type_no_ref(TypeTag tag)
|
||||
inline zeek::Type* base_type_no_ref(TypeTag tag)
|
||||
{ return zeek::base_type(static_cast<zeek::TypeTag>(tag)).get(); }
|
||||
|
||||
extern IntrusivePtr<zeek::OpaqueType> md5_type;
|
||||
|
@ -998,7 +998,7 @@ extern IntrusivePtr<zeek::OpaqueType> x509_opaque_type;
|
|||
extern IntrusivePtr<zeek::OpaqueType> ocsp_resp_opaque_type;
|
||||
extern IntrusivePtr<zeek::OpaqueType> paraglob_type;
|
||||
|
||||
using BroType [[deprecated("Remove in v4.1. Use zeek::BroType instead.")]] = zeek::BroType;
|
||||
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
|
||||
using TypeList [[deprecated("Remove in v4.1. Use zeek::TypeList instead.")]] = zeek::TypeList;
|
||||
using IndexType [[deprecated("Remove in v4.1. Use zeek::IndexType instead.")]] = zeek::IndexType;
|
||||
using TableType [[deprecated("Remove in v4.1. Use zeek::TableType instead.")]] = zeek::TableType;
|
||||
|
|
14
src/Val.cc
14
src/Val.cc
|
@ -391,7 +391,7 @@ void Val::SetID(zeek::detail::ID* id)
|
|||
}
|
||||
#endif
|
||||
|
||||
bool Val::WouldOverflow(const zeek::BroType* from_type, const zeek::BroType* to_type, const Val* val)
|
||||
bool Val::WouldOverflow(const zeek::Type* from_type, const zeek::Type* to_type, const Val* val)
|
||||
{
|
||||
if ( !to_type || !from_type )
|
||||
return true;
|
||||
|
@ -1337,7 +1337,7 @@ static void table_entry_val_delete_func(void* val)
|
|||
delete tv;
|
||||
}
|
||||
|
||||
static void find_nested_record_types(const IntrusivePtr<zeek::BroType>& t, std::set<zeek::RecordType*>* found)
|
||||
static void find_nested_record_types(const IntrusivePtr<zeek::Type>& t, std::set<zeek::RecordType*>* found)
|
||||
{
|
||||
if ( ! t )
|
||||
return;
|
||||
|
@ -3188,14 +3188,14 @@ void VectorVal::ValDescribe(ODesc* d) const
|
|||
d->Add("]");
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> check_and_promote(IntrusivePtr<Val> v, const zeek::BroType* t,
|
||||
IntrusivePtr<Val> check_and_promote(IntrusivePtr<Val> v, const zeek::Type* t,
|
||||
bool is_init,
|
||||
const Location* expr_location)
|
||||
{
|
||||
if ( ! v )
|
||||
return nullptr;
|
||||
|
||||
zeek::BroType* vt = flatten_type(v->GetType().get());
|
||||
zeek::Type* vt = flatten_type(v->GetType().get());
|
||||
t = flatten_type(t);
|
||||
|
||||
zeek::TypeTag t_tag = t->Tag();
|
||||
|
@ -3392,7 +3392,7 @@ void delete_vals(val_list* vals)
|
|||
}
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> cast_value_to_type(Val* v, zeek::BroType* t)
|
||||
IntrusivePtr<Val> cast_value_to_type(Val* v, zeek::Type* t)
|
||||
{
|
||||
// Note: when changing this function, adapt all three of
|
||||
// cast_value_to_type()/can_cast_value_to_type()/can_cast_value_to_type().
|
||||
|
@ -3418,7 +3418,7 @@ IntrusivePtr<Val> cast_value_to_type(Val* v, zeek::BroType* t)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool can_cast_value_to_type(const Val* v, zeek::BroType* t)
|
||||
bool can_cast_value_to_type(const Val* v, zeek::Type* t)
|
||||
{
|
||||
// Note: when changing this function, adapt all three of
|
||||
// cast_value_to_type()/can_cast_value_to_type()/can_cast_value_to_type().
|
||||
|
@ -3444,7 +3444,7 @@ bool can_cast_value_to_type(const Val* v, zeek::BroType* t)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool can_cast_value_to_type(const zeek::BroType* s, zeek::BroType* t)
|
||||
bool can_cast_value_to_type(const zeek::Type* s, zeek::Type* t)
|
||||
{
|
||||
// Note: when changing this function, adapt all three of
|
||||
// cast_value_to_type()/can_cast_value_to_type()/can_cast_value_to_type().
|
||||
|
|
28
src/Val.h
28
src/Val.h
|
@ -140,12 +140,12 @@ public:
|
|||
explicit Val(IntrusivePtr<BroFile> f);
|
||||
|
||||
// Extra arg to differentiate from protected version.
|
||||
Val(IntrusivePtr<zeek::BroType> t, bool type_type)
|
||||
Val(IntrusivePtr<zeek::Type> t, bool type_type)
|
||||
: type(make_intrusive<zeek::TypeType>(std::move(t)))
|
||||
{}
|
||||
|
||||
[[deprecated("Remove in v4.1. Construct from IntrusivePtr instead.")]]
|
||||
Val(zeek::BroType* t, bool type_type) : Val({NewRef{}, t}, type_type)
|
||||
Val(zeek::Type* t, bool type_type) : Val({NewRef{}, t}, type_type)
|
||||
{}
|
||||
|
||||
Val()
|
||||
|
@ -185,11 +185,11 @@ public:
|
|||
virtual bool RemoveFrom(Val* v) const;
|
||||
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
zeek::BroType* Type() { return type.get(); }
|
||||
zeek::Type* Type() { return type.get(); }
|
||||
[[deprecated("Remove in v4.1. Use GetType().")]]
|
||||
const zeek::BroType* Type() const { return type.get(); }
|
||||
const zeek::Type* Type() const { return type.get(); }
|
||||
|
||||
const IntrusivePtr<zeek::BroType>& GetType() const
|
||||
const IntrusivePtr<zeek::Type>& GetType() const
|
||||
{ return type; }
|
||||
|
||||
template <class T>
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
return *val.subnet_val;
|
||||
}
|
||||
|
||||
zeek::BroType* AsType() const
|
||||
zeek::Type* AsType() const
|
||||
{
|
||||
CHECK_TAG(type->Tag(), zeek::TYPE_TYPE, "Val::Type", zeek::type_name)
|
||||
return type.get();
|
||||
|
@ -333,7 +333,7 @@ public:
|
|||
void SetID(zeek::detail::ID* id);
|
||||
#endif
|
||||
|
||||
static bool WouldOverflow(const zeek::BroType* from_type, const zeek::BroType* to_type, const Val* val);
|
||||
static bool WouldOverflow(const zeek::Type* from_type, const zeek::Type* to_type, const Val* val);
|
||||
|
||||
IntrusivePtr<TableVal> GetRecordFields();
|
||||
|
||||
|
@ -361,11 +361,11 @@ protected:
|
|||
{}
|
||||
|
||||
template<typename V>
|
||||
Val(V&& v, IntrusivePtr<zeek::BroType> t) noexcept
|
||||
Val(V&& v, IntrusivePtr<zeek::Type> t) noexcept
|
||||
: val(std::forward<V>(v)), type(std::move(t))
|
||||
{}
|
||||
|
||||
explicit Val(IntrusivePtr<zeek::BroType> t) noexcept
|
||||
explicit Val(IntrusivePtr<zeek::Type> t) noexcept
|
||||
: type(std::move(t))
|
||||
{}
|
||||
|
||||
|
@ -386,7 +386,7 @@ protected:
|
|||
virtual IntrusivePtr<Val> DoClone(CloneState* state);
|
||||
|
||||
BroValUnion val;
|
||||
IntrusivePtr<zeek::BroType> type;
|
||||
IntrusivePtr<zeek::Type> type;
|
||||
|
||||
#ifdef DEBUG
|
||||
// For debugging, we keep the name of the ID to which a Val is bound.
|
||||
|
@ -1372,7 +1372,7 @@ protected:
|
|||
// If not a match, generates an error message and return nil. If is_init is
|
||||
// true, then the checking is done in the context of an initialization.
|
||||
extern IntrusivePtr<Val> check_and_promote(IntrusivePtr<Val> v,
|
||||
const zeek::BroType* t, bool is_init,
|
||||
const zeek::Type* t, bool is_init,
|
||||
const Location* expr_location = nullptr);
|
||||
|
||||
extern bool same_val(const Val* v1, const Val* v2);
|
||||
|
@ -1390,16 +1390,16 @@ inline bool is_vector(const IntrusivePtr<Val>& v) { return is_vector(v.get()); }
|
|||
// Returns v casted to type T if the type supports that. Returns null if not.
|
||||
//
|
||||
// Note: This implements the script-level cast operator.
|
||||
extern IntrusivePtr<Val> cast_value_to_type(Val* v, zeek::BroType* t);
|
||||
extern IntrusivePtr<Val> cast_value_to_type(Val* v, zeek::Type* t);
|
||||
|
||||
// Returns true if v can be casted to type T. If so, check_and_cast() will
|
||||
// succeed as well.
|
||||
//
|
||||
// Note: This implements the script-level type comparision operator.
|
||||
extern bool can_cast_value_to_type(const Val* v, zeek::BroType* t);
|
||||
extern bool can_cast_value_to_type(const Val* v, zeek::Type* t);
|
||||
|
||||
// Returns true if values of type s may support casting to type t. This is
|
||||
// purely static check to weed out cases early on that will never succeed.
|
||||
// However, even this function returns true, casting may still fail for a
|
||||
// specific instance later.
|
||||
extern bool can_cast_value_to_type(const zeek::BroType* s, zeek::BroType* t);
|
||||
extern bool can_cast_value_to_type(const zeek::Type* s, zeek::Type* t);
|
||||
|
|
20
src/Var.cc
20
src/Var.cc
|
@ -19,7 +19,7 @@
|
|||
|
||||
using namespace zeek::detail;
|
||||
|
||||
static IntrusivePtr<Val> init_val(zeek::detail::Expr* init, const zeek::BroType* t,
|
||||
static IntrusivePtr<Val> init_val(zeek::detail::Expr* init, const zeek::Type* t,
|
||||
IntrusivePtr<Val> aggr)
|
||||
{
|
||||
try
|
||||
|
@ -32,7 +32,7 @@ static IntrusivePtr<Val> init_val(zeek::detail::Expr* init, const zeek::BroType*
|
|||
}
|
||||
}
|
||||
|
||||
static bool add_prototype(const IntrusivePtr<zeek::detail::ID>& id, zeek::BroType* t,
|
||||
static bool add_prototype(const IntrusivePtr<zeek::detail::ID>& id, zeek::Type* t,
|
||||
std::vector<IntrusivePtr<zeek::detail::Attr>>* attrs,
|
||||
const IntrusivePtr<zeek::detail::Expr>& init)
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ static bool add_prototype(const IntrusivePtr<zeek::detail::ID>& id, zeek::BroTyp
|
|||
return true;
|
||||
}
|
||||
|
||||
static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<zeek::BroType> t,
|
||||
static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<zeek::Type> t,
|
||||
zeek::detail::init_class c,
|
||||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
|
@ -310,7 +310,7 @@ static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<zeek
|
|||
}
|
||||
}
|
||||
|
||||
void add_global(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<zeek::BroType> t,
|
||||
void add_global(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<zeek::Type> t,
|
||||
zeek::detail::init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
decl_type dt)
|
||||
|
@ -318,7 +318,7 @@ void add_global(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<zeek::Bro
|
|||
make_var(id, std::move(t), c, std::move(init), std::move(attr), dt, true);
|
||||
}
|
||||
|
||||
IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id, IntrusivePtr<zeek::BroType> t,
|
||||
IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id, IntrusivePtr<zeek::Type> t,
|
||||
zeek::detail::init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
decl_type dt)
|
||||
|
@ -360,12 +360,12 @@ extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<zeek::
|
|||
false, std::move(val));
|
||||
}
|
||||
|
||||
void add_type(zeek::detail::ID* id, IntrusivePtr<zeek::BroType> t,
|
||||
void add_type(zeek::detail::ID* id, IntrusivePtr<zeek::Type> t,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr)
|
||||
{
|
||||
std::string new_type_name = id->Name();
|
||||
std::string old_type_name = t->GetName();
|
||||
IntrusivePtr<zeek::BroType> tnew;
|
||||
IntrusivePtr<zeek::Type> tnew;
|
||||
|
||||
if ( (t->Tag() == zeek::TYPE_RECORD || t->Tag() == zeek::TYPE_ENUM) &&
|
||||
old_type_name.empty() )
|
||||
|
@ -375,10 +375,10 @@ void add_type(zeek::detail::ID* id, IntrusivePtr<zeek::BroType> t,
|
|||
// Clone the type to preserve type name aliasing.
|
||||
tnew = t->ShallowClone();
|
||||
|
||||
zeek::BroType::AddAlias(new_type_name, tnew.get());
|
||||
zeek::Type::AddAlias(new_type_name, tnew.get());
|
||||
|
||||
if ( new_type_name != old_type_name && ! old_type_name.empty() )
|
||||
zeek::BroType::AddAlias(old_type_name, tnew.get());
|
||||
zeek::Type::AddAlias(old_type_name, tnew.get());
|
||||
|
||||
tnew->SetName(id->Name());
|
||||
|
||||
|
@ -769,7 +769,7 @@ ListVal* internal_list_val(const char* name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
zeek::BroType* internal_type(const char* name)
|
||||
zeek::Type* internal_type(const char* name)
|
||||
{
|
||||
return zeek::id::find_type(name).get();
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@ FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
|||
typedef enum { VAR_REGULAR, VAR_CONST, VAR_REDEF, VAR_OPTION, } decl_type;
|
||||
|
||||
extern void add_global(const IntrusivePtr<zeek::detail::ID>& id,
|
||||
IntrusivePtr<zeek::BroType> t,
|
||||
IntrusivePtr<zeek::Type> t,
|
||||
zeek::detail::init_class c,
|
||||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
decl_type dt);
|
||||
|
||||
extern IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id,
|
||||
IntrusivePtr<zeek::BroType> t,
|
||||
IntrusivePtr<zeek::Type> t,
|
||||
zeek::detail::init_class c,
|
||||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr,
|
||||
|
@ -36,7 +36,7 @@ extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<zeek::
|
|||
IntrusivePtr<zeek::detail::Expr> init,
|
||||
IntrusivePtr<Val> val = nullptr);
|
||||
|
||||
extern void add_type(zeek::detail::ID* id, IntrusivePtr<zeek::BroType> t,
|
||||
extern void add_type(zeek::detail::ID* id, IntrusivePtr<zeek::Type> t,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attr);
|
||||
|
||||
extern void begin_func(IntrusivePtr<zeek::detail::ID> id, const char* module_name,
|
||||
|
@ -77,7 +77,7 @@ extern TableVal* opt_internal_table(const char* name); // nil if not defined
|
|||
extern ListVal* internal_list_val(const char* name);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use zeek::id::find_type().")]]
|
||||
extern zeek::BroType* internal_type(const char* name);
|
||||
extern zeek::Type* internal_type(const char* name);
|
||||
|
||||
[[deprecated("Remove in v4.1. Use zeek::id::find_func().")]]
|
||||
extern Func* internal_func(const char* name);
|
||||
|
|
|
@ -20,7 +20,7 @@ IntrusivePtr<zeek::OpaqueType> bro_broker::opaque_of_table_iterator;
|
|||
IntrusivePtr<zeek::OpaqueType> bro_broker::opaque_of_vector_iterator;
|
||||
IntrusivePtr<zeek::OpaqueType> bro_broker::opaque_of_record_iterator;
|
||||
|
||||
static bool data_type_check(const broker::data& d, zeek::BroType* t);
|
||||
static bool data_type_check(const broker::data& d, zeek::Type* t);
|
||||
|
||||
static broker::port::protocol to_broker_port_proto(TransportProto tp)
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ TEST_CASE("converting Broker to Zeek protocol constants")
|
|||
struct val_converter {
|
||||
using result_type = IntrusivePtr<Val>;
|
||||
|
||||
zeek::BroType* type;
|
||||
zeek::Type* type;
|
||||
|
||||
result_type operator()(broker::none)
|
||||
{
|
||||
|
@ -445,7 +445,7 @@ struct val_converter {
|
|||
struct type_checker {
|
||||
using result_type = bool;
|
||||
|
||||
zeek::BroType* type;
|
||||
zeek::Type* type;
|
||||
|
||||
result_type operator()(broker::none)
|
||||
{
|
||||
|
@ -771,7 +771,7 @@ struct type_checker {
|
|||
}
|
||||
};
|
||||
|
||||
static bool data_type_check(const broker::data& d, zeek::BroType* t)
|
||||
static bool data_type_check(const broker::data& d, zeek::Type* t)
|
||||
{
|
||||
if ( t->Tag() == zeek::TYPE_ANY )
|
||||
return true;
|
||||
|
@ -779,7 +779,7 @@ static bool data_type_check(const broker::data& d, zeek::BroType* t)
|
|||
return caf::visit(type_checker{t}, d);
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> bro_broker::data_to_val(broker::data d, zeek::BroType* type)
|
||||
IntrusivePtr<Val> bro_broker::data_to_val(broker::data d, zeek::Type* type)
|
||||
{
|
||||
if ( type->Tag() == zeek::TYPE_ANY )
|
||||
return bro_broker::make_data_val(move(d));
|
||||
|
@ -1137,17 +1137,17 @@ void bro_broker::DataVal::ValDescribe(ODesc* d) const
|
|||
d->Add("}");
|
||||
}
|
||||
|
||||
bool bro_broker::DataVal::canCastTo(zeek::BroType* t) const
|
||||
bool bro_broker::DataVal::canCastTo(zeek::Type* t) const
|
||||
{
|
||||
return data_type_check(data, t);
|
||||
}
|
||||
|
||||
IntrusivePtr<Val> bro_broker::DataVal::castTo(zeek::BroType* t)
|
||||
IntrusivePtr<Val> bro_broker::DataVal::castTo(zeek::Type* t)
|
||||
{
|
||||
return data_to_val(data, t);
|
||||
}
|
||||
|
||||
const IntrusivePtr<zeek::BroType>& bro_broker::DataVal::ScriptDataType()
|
||||
const IntrusivePtr<zeek::Type>& bro_broker::DataVal::ScriptDataType()
|
||||
{
|
||||
static auto script_data_type = zeek::id::find_type("Broker::Data");
|
||||
return script_data_type;
|
||||
|
|
|
@ -65,7 +65,7 @@ broker::expected<broker::data> val_to_data(const Val* v);
|
|||
* @return a pointer to a new Bro value or a nullptr if the conversion was not
|
||||
* possible.
|
||||
*/
|
||||
IntrusivePtr<Val> data_to_val(broker::data d, zeek::BroType* type);
|
||||
IntrusivePtr<Val> data_to_val(broker::data d, zeek::Type* type);
|
||||
|
||||
/**
|
||||
* Convert a Bro threading::Value to a Broker data value.
|
||||
|
@ -109,13 +109,13 @@ public:
|
|||
|
||||
void ValDescribe(ODesc* d) const override;
|
||||
|
||||
IntrusivePtr<Val> castTo(zeek::BroType* t);
|
||||
bool canCastTo(zeek::BroType* t) const;
|
||||
IntrusivePtr<Val> castTo(zeek::Type* t);
|
||||
bool canCastTo(zeek::Type* t) const;
|
||||
|
||||
// Returns the Bro type that scripts use to represent a Broker data
|
||||
// instance. This may be wrapping the opaque value inside another
|
||||
// type.
|
||||
static const IntrusivePtr<zeek::BroType>& ScriptDataType();
|
||||
static const IntrusivePtr<zeek::Type>& ScriptDataType();
|
||||
|
||||
broker::data data;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <set>
|
||||
#include <string>
|
||||
|
||||
static bool is_string_set(const zeek::BroType* type)
|
||||
static bool is_string_set(const zeek::Type* type)
|
||||
{
|
||||
if ( ! type->IsSet() )
|
||||
return false;
|
||||
|
|
|
@ -774,7 +774,7 @@ bool Manager::CreateAnalysisStream(RecordVal* fval)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Manager::IsCompatibleType(zeek::BroType* t, bool atomic_only)
|
||||
bool Manager::IsCompatibleType(zeek::Type* t, bool atomic_only)
|
||||
{
|
||||
if ( ! t )
|
||||
return false;
|
||||
|
@ -2159,7 +2159,7 @@ HashKey* Manager::HashValues(const int num_elements, const Value* const *vals) c
|
|||
// have_error is a reference to a boolean which is set to true as soon as an error occurs.
|
||||
// When have_error is set to true at the beginning of the function, it is assumed that
|
||||
// an error already occurred in the past and processing is aborted.
|
||||
Val* Manager::ValueToVal(const Stream* i, const Value* val, zeek::BroType* request_type, bool& have_error) const
|
||||
Val* Manager::ValueToVal(const Stream* i, const Value* val, zeek::Type* request_type, bool& have_error) const
|
||||
{
|
||||
if ( have_error )
|
||||
return nullptr;
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
*
|
||||
* @return True if the type is compatible with the input framework.
|
||||
*/
|
||||
static bool IsCompatibleType(zeek::BroType* t, bool atomic_only=false);
|
||||
static bool IsCompatibleType(zeek::Type* t, bool atomic_only=false);
|
||||
|
||||
protected:
|
||||
friend class ReaderFrontend;
|
||||
|
@ -222,7 +222,7 @@ private:
|
|||
int CopyValue(char *data, const int startpos, const threading::Value* val) const;
|
||||
|
||||
// Convert Threading::Value to an internal Bro Type (works with Records).
|
||||
Val* ValueToVal(const Stream* i, const threading::Value* val, zeek::BroType* request_type, bool& have_error) const;
|
||||
Val* ValueToVal(const Stream* i, const threading::Value* val, zeek::Type* request_type, bool& have_error) const;
|
||||
|
||||
// Convert Threading::Value to an internal Bro list type.
|
||||
Val* ValueToIndexVal(const Stream* i, int num_fields, const zeek::RecordType* type, const threading::Value* const *vals, bool& have_error) const;
|
||||
|
|
|
@ -913,7 +913,7 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
|
|||
return true;
|
||||
}
|
||||
|
||||
threading::Value* Manager::ValToLogVal(Val* val, zeek::BroType* ty)
|
||||
threading::Value* Manager::ValToLogVal(Val* val, zeek::Type* ty)
|
||||
{
|
||||
if ( ! ty )
|
||||
ty = val->GetType().get();
|
||||
|
|
|
@ -261,7 +261,7 @@ private:
|
|||
threading::Value** RecordToFilterVals(Stream* stream, Filter* filter,
|
||||
RecordVal* columns);
|
||||
|
||||
threading::Value* ValToLogVal(Val* val, zeek::BroType* ty = nullptr);
|
||||
threading::Value* ValToLogVal(Val* val, zeek::Type* ty = nullptr);
|
||||
Stream* FindStream(EnumVal* id);
|
||||
void RemoveDisabledWriters(Stream* stream);
|
||||
void InstallRotationTimer(WriterInfo* winfo);
|
||||
|
|
|
@ -169,7 +169,7 @@ static void parser_redef_enum (zeek::detail::ID *id)
|
|||
static void extend_record(zeek::detail::ID* id, std::unique_ptr<zeek::type_decl_list> fields,
|
||||
std::unique_ptr<std::vector<IntrusivePtr<zeek::detail::Attr>>> attrs)
|
||||
{
|
||||
std::set<zeek::BroType*> types = zeek::BroType::GetAliases(id->Name());
|
||||
std::set<zeek::Type*> types = zeek::Type::GetAliases(id->Name());
|
||||
|
||||
if ( types.empty() )
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ static void extend_record(zeek::detail::ID* id, std::unique_ptr<zeek::type_decl_
|
|||
|
||||
static IntrusivePtr<zeek::detail::Attributes>
|
||||
make_attributes(std::vector<IntrusivePtr<zeek::detail::Attr>>* attrs,
|
||||
IntrusivePtr<zeek::BroType> t, bool in_record, bool is_global)
|
||||
IntrusivePtr<zeek::Type> t, bool in_record, bool is_global)
|
||||
{
|
||||
if ( ! attrs )
|
||||
return nullptr;
|
||||
|
@ -241,7 +241,7 @@ static bool expr_is_table_type_name(const zeek::detail::Expr* expr)
|
|||
zeek::detail::EventExpr* event_expr;
|
||||
zeek::detail::Stmt* stmt;
|
||||
zeek::detail::ListExpr* list;
|
||||
zeek::BroType* type;
|
||||
zeek::Type* type;
|
||||
zeek::RecordType* record;
|
||||
zeek::FuncType* func_type;
|
||||
zeek::TypeList* type_l;
|
||||
|
@ -1667,7 +1667,7 @@ case_type:
|
|||
| TOK_TYPE type TOK_AS TOK_ID
|
||||
{
|
||||
const char* name = $4;
|
||||
IntrusivePtr<zeek::BroType> type{AdoptRef{}, $2};
|
||||
IntrusivePtr<zeek::Type> type{AdoptRef{}, $2};
|
||||
auto case_var = lookup_ID(name, current_module.c_str());
|
||||
|
||||
if ( case_var && case_var->IsGlobal() )
|
||||
|
|
|
@ -18,7 +18,7 @@ static void topk_element_hash_delete_func(void* val)
|
|||
delete e;
|
||||
}
|
||||
|
||||
void TopkVal::Typify(IntrusivePtr<zeek::BroType> t)
|
||||
void TopkVal::Typify(IntrusivePtr<zeek::Type> t)
|
||||
{
|
||||
assert(!hash && !type);
|
||||
type = std::move(t);
|
||||
|
|
|
@ -161,9 +161,9 @@ private:
|
|||
*
|
||||
* @param t type that is tracked
|
||||
*/
|
||||
void Typify(IntrusivePtr<zeek::BroType> t);
|
||||
void Typify(IntrusivePtr<zeek::Type> t);
|
||||
|
||||
IntrusivePtr<zeek::BroType> type;
|
||||
IntrusivePtr<zeek::Type> type;
|
||||
CompositeHash* hash;
|
||||
std::list<Bucket*> buckets;
|
||||
PDict<Element>* elementDict;
|
||||
|
|
|
@ -122,7 +122,7 @@ Value::~Value()
|
|||
}
|
||||
}
|
||||
|
||||
bool Value::IsCompatibleType(zeek::BroType* t, bool atomic_only)
|
||||
bool Value::IsCompatibleType(zeek::Type* t, bool atomic_only)
|
||||
{
|
||||
if ( ! t )
|
||||
return false;
|
||||
|
@ -535,7 +535,7 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
|
|||
if ( stag == zeek::TYPE_VOID )
|
||||
stag = val->val.set_val.vals[0]->type;
|
||||
|
||||
IntrusivePtr<zeek::BroType> index_type;
|
||||
IntrusivePtr<zeek::Type> index_type;
|
||||
|
||||
if ( stag == zeek::TYPE_ENUM )
|
||||
{
|
||||
|
@ -575,7 +575,7 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
|
|||
|
||||
case zeek::TYPE_VECTOR:
|
||||
{
|
||||
IntrusivePtr<zeek::BroType> type;
|
||||
IntrusivePtr<zeek::Type> type;
|
||||
|
||||
if ( val->val.vector_val.size == 0 && val->subtype == zeek::TYPE_VOID )
|
||||
// don't know type - unspecified table.
|
||||
|
|
|
@ -202,7 +202,7 @@ struct Value {
|
|||
* Returns true if the type can be represented by a Value. If
|
||||
* `atomic_only` is true, will not permit composite types. This
|
||||
* method is thread-safe. */
|
||||
static bool IsCompatibleType(zeek::BroType* t, bool atomic_only=false);
|
||||
static bool IsCompatibleType(zeek::Type* t, bool atomic_only=false);
|
||||
|
||||
/**
|
||||
* Convenience function to delete an array of value pointers.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue