mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 02:58:20 +00:00
Two small infrastructure extensions for passing information into the
logging framework. - To enable passing a type into a bif, there's now a new BroType-derived class TypeType and a corresponding TYPE_TYPE tag. With that, a Val can now have a type as its value. This is experimental for now. - RecordVal's get a new method CoerceTo() to coerce their value into a another record type with the usual semantics. Most of the code in there was previously in RecordContructorExpr::InitVal(), which is now calling the new CoerceTo() method.
This commit is contained in:
parent
ffa494e428
commit
9d407d882c
5 changed files with 119 additions and 40 deletions
28
src/Type.h
28
src/Type.h
|
@ -31,6 +31,7 @@ typedef enum {
|
|||
TYPE_FUNC,
|
||||
TYPE_FILE,
|
||||
TYPE_VECTOR,
|
||||
TYPE_TYPE,
|
||||
TYPE_ERROR
|
||||
#define NUM_TYPES (int(TYPE_ERROR) + 1)
|
||||
} TypeTag;
|
||||
|
@ -59,6 +60,7 @@ class ListExpr;
|
|||
class EnumType;
|
||||
class Serializer;
|
||||
class VectorType;
|
||||
class TypeType;
|
||||
|
||||
const int DOES_NOT_MATCH_INDEX = 0;
|
||||
const int MATCHES_INDEX_SCALAR = 1;
|
||||
|
@ -151,6 +153,7 @@ public:
|
|||
CHECK_TYPE_TAG(TYPE_SUBNET, "BroType::AsSubNetType");
|
||||
return (const SubNetType*) this;
|
||||
}
|
||||
|
||||
SubNetType* AsSubNetType()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_SUBNET, "BroType::AsSubNetType");
|
||||
|
@ -192,6 +195,18 @@ public:
|
|||
return (VectorType*) this;
|
||||
}
|
||||
|
||||
const TypeType* AsTypeType() const
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_TYPE, "BroType::AsTypeType");
|
||||
return (TypeType*) this;
|
||||
}
|
||||
|
||||
TypeType* AsTypeType()
|
||||
{
|
||||
CHECK_TYPE_TAG(TYPE_TYPE, "BroType::AsTypeType");
|
||||
return (TypeType*) this;
|
||||
}
|
||||
|
||||
int IsSet() const
|
||||
{
|
||||
return tag == TYPE_TABLE && (YieldType() == 0);
|
||||
|
@ -359,6 +374,19 @@ protected:
|
|||
ID* return_value;
|
||||
};
|
||||
|
||||
class TypeType : public BroType {
|
||||
public:
|
||||
TypeType(BroType* t) : BroType(TYPE_TYPE) { type = t->Ref(); }
|
||||
~TypeType() { Unref(type); }
|
||||
|
||||
BroType* Type() { return type; }
|
||||
|
||||
protected:
|
||||
TypeType() {}
|
||||
|
||||
BroType* type;
|
||||
};
|
||||
|
||||
class TypeDecl {
|
||||
public:
|
||||
TypeDecl(BroType* t, const char* i, attr_list* attrs = 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue