diff --git a/src/Val.cc b/src/Val.cc index 94bdb9ec5e..36983bc21b 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -38,28 +38,23 @@ #include "threading/formatters/JSON.h" Val::Val(Func* f) - :val(f) + :val(f), type(f->FType()->Ref()) { ::Ref(val.func_val); - type = f->FType()->Ref(); -#ifdef DEBUG - bound_id = 0; -#endif } -Val::Val(BroFile* f) - :val(f) +static FileType *GetStringFileType() noexcept { static FileType* string_file_type = 0; if ( ! string_file_type ) string_file_type = new FileType(base_type(TYPE_STRING)); + return string_file_type; + } +Val::Val(BroFile* f) + :val(f), type(GetStringFileType()->Ref()) + { assert(f->FType()->Tag() == TYPE_STRING); - type = string_file_type->Ref(); - -#ifdef DEBUG - bound_id = 0; -#endif } Val::~Val() diff --git a/src/Val.h b/src/Val.h index 666e5fd824..dc32aab859 100644 --- a/src/Val.h +++ b/src/Val.h @@ -128,12 +128,8 @@ union BroValUnion { class Val : public BroObj { public: Val(double d, TypeTag t) - :val(d) + :val(d), type(base_type(t)) { - type = base_type(t); -#ifdef DEBUG - bound_id = 0; -#endif } explicit Val(Func* f); @@ -143,20 +139,13 @@ public: explicit Val(BroFile* f); Val(BroType* t, bool type_type) // Extra arg to differentiate from protected version. + :type(new TypeType(t->Ref())) { - type = new TypeType(t->Ref()); -#ifdef DEBUG - bound_id = 0; -#endif } Val() - :val(bro_int_t(0)) + :val(bro_int_t(0)), type(base_type(TYPE_ERROR)) { - type = base_type(TYPE_ERROR); -#ifdef DEBUG - bound_id = 0; -#endif } ~Val() override; @@ -364,30 +353,19 @@ protected: template Val(V &&v, TypeTag t) noexcept - :val(std::forward(v)) + :val(std::forward(v)), type(base_type(t)) { - type = base_type(t); -#ifdef DEBUG - bound_id = 0; -#endif } template Val(V &&v, BroType* t) noexcept - :val(std::forward(v)) + :val(std::forward(v)), type(t->Ref()) { - type = t->Ref(); -#ifdef DEBUG - bound_id = 0; -#endif } explicit Val(BroType* t) + :type(t->Ref()) { - type = t->Ref(); -#ifdef DEBUG - bound_id = 0; -#endif } ACCESSOR(TYPE_TABLE, PDict*, table_val, AsNonConstTable) @@ -415,7 +393,7 @@ protected: #ifdef DEBUG // For debugging, we keep the name of the ID to which a Val is bound. - const char* bound_id; + const char* bound_id = nullptr; #endif };