diff --git a/src/DNS_Mgr.cc b/src/DNS_Mgr.cc index 5234ef6e35..dcde70659a 100644 --- a/src/DNS_Mgr.cc +++ b/src/DNS_Mgr.cc @@ -173,7 +173,7 @@ void DNS_Mgr_mapping_delete_func(void* v) static TableVal* empty_addr_set() { - IntrusivePtr addr_t{AdoptRef{}, base_type(TYPE_ADDR)}; + auto addr_t = base_type(TYPE_ADDR); auto set_index = make_intrusive(addr_t); set_index->Append(std::move(addr_t)); auto s = make_intrusive(std::move(set_index), nullptr); diff --git a/src/Expr.cc b/src/Expr.cc index 3382515847..f4a49b8bc2 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -134,7 +134,7 @@ bool Expr::IsError() const void Expr::SetError() { - SetType({AdoptRef{}, error_type()}); + SetType(error_type()); } void Expr::SetError(const char* msg) @@ -879,9 +879,9 @@ void BinaryExpr::PromoteType(TypeTag t, bool is_vector) PromoteOps(t); if ( is_vector) - SetType(make_intrusive(IntrusivePtr{AdoptRef{}, base_type(t)})); + SetType(make_intrusive(base_type(t))); else - SetType(IntrusivePtr{AdoptRef{}, base_type(t)}); + SetType(base_type(t)); } CloneExpr::CloneExpr(IntrusivePtr arg_op) @@ -1015,7 +1015,7 @@ ComplementExpr::ComplementExpr(IntrusivePtr arg_op) if ( bt != TYPE_COUNT ) ExprError("requires \"count\" operand"); else - SetType({AdoptRef{}, base_type(TYPE_COUNT)}); + SetType(base_type(TYPE_COUNT)); } IntrusivePtr ComplementExpr::Fold(Val* v) const @@ -1035,7 +1035,7 @@ NotExpr::NotExpr(IntrusivePtr arg_op) if ( ! IsIntegral(bt) && bt != TYPE_BOOL ) ExprError("requires an integral or boolean operand"); else - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); } IntrusivePtr NotExpr::Fold(Val* v) const @@ -1059,7 +1059,7 @@ PosExpr::PosExpr(IntrusivePtr arg_op) if ( IsIntegral(bt) ) // Promote count and counter to int. - base_result_type = {AdoptRef{}, base_type(TYPE_INT)}; + base_result_type = base_type(TYPE_INT); else if ( bt == TYPE_INTERVAL || bt == TYPE_DOUBLE ) base_result_type = {NewRef{}, t}; else @@ -1097,7 +1097,7 @@ NegExpr::NegExpr(IntrusivePtr arg_op) if ( IsIntegral(bt) ) // Promote count and counter to int. - base_result_type = {AdoptRef{}, base_type(TYPE_INT)}; + base_result_type = base_type(TYPE_INT); else if ( bt == TYPE_INTERVAL || bt == TYPE_DOUBLE ) base_result_type = {NewRef{}, t}; else @@ -1126,9 +1126,9 @@ SizeExpr::SizeExpr(IntrusivePtr arg_op) return; if ( op->Type()->InternalType() == TYPE_INTERNAL_DOUBLE ) - SetType({AdoptRef{}, base_type(TYPE_DOUBLE)}); + SetType(base_type(TYPE_DOUBLE)); else - SetType({AdoptRef{}, base_type(TYPE_COUNT)}); + SetType(base_type(TYPE_COUNT)); } IntrusivePtr SizeExpr::Eval(Frame* f) const @@ -1165,15 +1165,15 @@ AddExpr::AddExpr(IntrusivePtr arg_op1, IntrusivePtr arg_op2) IntrusivePtr base_result_type; if ( bt1 == TYPE_TIME && bt2 == TYPE_INTERVAL ) - base_result_type = {AdoptRef{}, base_type(bt1)}; + base_result_type = base_type(bt1); else if ( bt2 == TYPE_TIME && bt1 == TYPE_INTERVAL ) - base_result_type = {AdoptRef{}, base_type(bt2)}; + base_result_type = base_type(bt2); else if ( bt1 == TYPE_INTERVAL && bt2 == TYPE_INTERVAL ) - base_result_type = {AdoptRef{}, base_type(bt1)}; + base_result_type = base_type(bt1); else if ( BothArithmetic(bt1, bt2) ) PromoteType(max_type(bt1, bt2), is_vector(op1.get()) || is_vector(op2.get())); else if ( BothString(bt1, bt2) ) - base_result_type = {AdoptRef{}, base_type(bt1)}; + base_result_type = base_type(bt1); else ExprError("requires arithmetic operands"); @@ -1209,9 +1209,9 @@ AddToExpr::AddToExpr(IntrusivePtr arg_op1, IntrusivePtr arg_op2) if ( BothArithmetic(bt1, bt2) ) PromoteType(max_type(bt1, bt2), is_vector(op1.get()) || is_vector(op2.get())); else if ( BothString(bt1, bt2) ) - SetType({AdoptRef{}, base_type(bt1)}); + SetType(base_type(bt1)); else if ( BothInterval(bt1, bt2) ) - SetType({AdoptRef{}, base_type(bt1)}); + SetType(base_type(bt1)); else if ( IsVector(bt1) ) { @@ -1296,13 +1296,13 @@ SubExpr::SubExpr(IntrusivePtr arg_op1, IntrusivePtr arg_op2) IntrusivePtr base_result_type; if ( bt1 == TYPE_TIME && bt2 == TYPE_INTERVAL ) - base_result_type = {AdoptRef{}, base_type(bt1)}; + base_result_type = base_type(bt1); else if ( bt1 == TYPE_TIME && bt2 == TYPE_TIME ) - SetType({AdoptRef{}, base_type(TYPE_INTERVAL)}); + SetType(base_type(TYPE_INTERVAL)); else if ( bt1 == TYPE_INTERVAL && bt2 == TYPE_INTERVAL ) - base_result_type = {AdoptRef{}, base_type(bt1)}; + base_result_type = base_type(bt1); else if ( t1->IsSet() && t2->IsSet() ) { @@ -1340,7 +1340,7 @@ RemoveFromExpr::RemoveFromExpr(IntrusivePtr arg_op1, if ( BothArithmetic(bt1, bt2) ) PromoteType(max_type(bt1, bt2), is_vector(op1.get()) || is_vector(op2.get())); else if ( BothInterval(bt1, bt2) ) - SetType({AdoptRef{}, base_type(bt1)}); + SetType(base_type(bt1)); else ExprError("requires two arithmetic operands"); } @@ -1430,9 +1430,9 @@ DivideExpr::DivideExpr(IntrusivePtr arg_op1, else if ( bt1 == TYPE_INTERVAL && bt2 == TYPE_INTERVAL ) { if ( is_vector(op1.get()) || is_vector(op2.get()) ) - SetType(make_intrusive(IntrusivePtr{AdoptRef{}, base_type(TYPE_DOUBLE)})); + SetType(make_intrusive(base_type(TYPE_DOUBLE))); else - SetType({AdoptRef{}, base_type(TYPE_DOUBLE)}); + SetType(base_type(TYPE_DOUBLE)); } else ExprError("division of interval requires arithmetic operand"); @@ -1443,7 +1443,7 @@ DivideExpr::DivideExpr(IntrusivePtr arg_op1, else if ( bt1 == TYPE_ADDR && ! is_vector(op2.get()) && (bt2 == TYPE_COUNT || bt2 == TYPE_INT) ) - SetType({AdoptRef{}, base_type(TYPE_SUBNET)}); + SetType(base_type(TYPE_SUBNET)); else ExprError("requires arithmetic operands"); @@ -1519,10 +1519,10 @@ BoolExpr::BoolExpr(BroExprTag arg_tag, { if ( ! (is_vector(op1.get()) && is_vector(op2.get())) ) reporter->Warning("mixing vector and scalar operands is deprecated"); - SetType(make_intrusive(IntrusivePtr{AdoptRef{}, base_type(TYPE_BOOL)})); + SetType(make_intrusive(base_type(TYPE_BOOL))); } else - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); } else ExprError("requires boolean operands"); @@ -1669,9 +1669,9 @@ BitExpr::BitExpr(BroExprTag arg_tag, if ( bt1 == TYPE_COUNTER && bt2 == TYPE_COUNTER ) ExprError("cannot apply a bitwise operator to two \"counter\" operands"); else if ( is_vector(op1.get()) || is_vector(op2.get()) ) - SetType(make_intrusive(IntrusivePtr{AdoptRef{}, base_type(TYPE_COUNT)})); + SetType(make_intrusive(base_type(TYPE_COUNT))); else - SetType({AdoptRef{}, base_type(TYPE_COUNT)}); + SetType(base_type(TYPE_COUNT)); } else if ( bt1 == TYPE_PATTERN ) @@ -1681,7 +1681,7 @@ BitExpr::BitExpr(BroExprTag arg_tag, else if ( tag == EXPR_XOR ) ExprError("'^' operator does not apply to patterns"); else - SetType({AdoptRef{}, base_type(TYPE_PATTERN)}); + SetType(base_type(TYPE_PATTERN)); } else if ( t1->IsSet() && t2->IsSet() ) @@ -1717,9 +1717,9 @@ EqExpr::EqExpr(BroExprTag arg_tag, bt2 = t2->AsVectorType()->YieldType()->Tag(); if ( is_vector(op1.get()) || is_vector(op2.get()) ) - SetType(make_intrusive(IntrusivePtr{AdoptRef{}, base_type(TYPE_BOOL)})); + SetType(make_intrusive(base_type(TYPE_BOOL))); else - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); if ( BothArithmetic(bt1, bt2) ) PromoteOps(max_type(bt1, bt2)); @@ -1819,9 +1819,9 @@ RelExpr::RelExpr(BroExprTag arg_tag, bt2 = t2->AsVectorType()->YieldType()->Tag(); if ( is_vector(op1.get()) || is_vector(op2.get()) ) - SetType(make_intrusive(IntrusivePtr{AdoptRef{}, base_type(TYPE_BOOL)})); + SetType(make_intrusive(base_type(TYPE_BOOL))); else - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); if ( BothArithmetic(bt1, bt2) ) PromoteOps(max_type(bt1, bt2)); @@ -1899,9 +1899,9 @@ CondExpr::CondExpr(IntrusivePtr arg_op1, IntrusivePtr arg_op2, op3 = make_intrusive(std::move(op3), t); if ( is_vector(op2.get()) ) - SetType(make_intrusive(IntrusivePtr{AdoptRef{}, base_type(t)})); + SetType(make_intrusive(base_type(t))); else - SetType({AdoptRef{}, base_type(t)}); + SetType(base_type(t)); } else if ( bt2 != bt3 ) @@ -2511,13 +2511,13 @@ IndexExpr::IndexExpr(IntrusivePtr arg_op1, else if ( ! op1->Type()->YieldType() ) { if ( IsString(op1->Type()->Tag()) && match_type == MATCHES_INDEX_SCALAR ) - SetType({AdoptRef{}, base_type(TYPE_STRING)}); + SetType(base_type(TYPE_STRING)); else // It's a set - so indexing it yields void. We don't // directly generate an error message, though, since this // expression might be part of an add/delete statement, // rather than yielding a value. - SetType({AdoptRef{}, base_type(TYPE_VOID)}); + SetType(base_type(TYPE_VOID)); } else if ( match_type == MATCHES_INDEX_SCALAR ) @@ -2982,7 +2982,7 @@ HasFieldExpr::HasFieldExpr(IntrusivePtr arg_op, else if ( rt->IsFieldDeprecated(field) ) reporter->Warning("%s", rt->GetFieldDeprecationWarning(field, true).c_str()); - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); } } @@ -3109,7 +3109,7 @@ TableConstructorExpr::TableConstructorExpr(IntrusivePtr constructor_li else { if ( op->AsListExpr()->Exprs().empty() ) - SetType(make_intrusive(make_intrusive(IntrusivePtr{AdoptRef{}, base_type(TYPE_ANY)}), nullptr)); + SetType(make_intrusive(make_intrusive(base_type(TYPE_ANY)), nullptr)); else { SetType(init_type(op.get())); @@ -3223,7 +3223,7 @@ SetConstructorExpr::SetConstructorExpr(IntrusivePtr constructor_list, else { if ( op->AsListExpr()->Exprs().empty() ) - SetType(make_intrusive<::SetType>(make_intrusive(IntrusivePtr{AdoptRef{}, base_type(TYPE_ANY)}), nullptr)); + SetType(make_intrusive<::SetType>(make_intrusive(base_type(TYPE_ANY)), nullptr)); else SetType(init_type(op.get())); } @@ -3343,7 +3343,7 @@ VectorConstructorExpr::VectorConstructorExpr(IntrusivePtr constructor_ // vector(). // By default, assign VOID type here. A vector with // void type set is seen as an unspecified vector. - SetType(make_intrusive<::VectorType>(IntrusivePtr{AdoptRef{}, base_type(TYPE_VOID)})); + SetType(make_intrusive<::VectorType>(base_type(TYPE_VOID))); return; } @@ -3479,11 +3479,11 @@ ArithCoerceExpr::ArithCoerceExpr(IntrusivePtr arg_op, TypeTag t) if ( IsVector(bt) ) { - SetType(make_intrusive(IntrusivePtr{AdoptRef{}, base_type(t)})); + SetType(make_intrusive(base_type(t))); vbt = op->Type()->AsVectorType()->YieldType()->Tag(); } else - SetType({AdoptRef{}, base_type(t)}); + SetType(base_type(t)); if ( (bt == TYPE_ENUM) != (t == TYPE_ENUM) ) ExprError("can't convert to/from enumerated type"); @@ -3903,7 +3903,7 @@ ScheduleExpr::ScheduleExpr(IntrusivePtr arg_when, if ( bt != TYPE_TIME && bt != TYPE_INTERVAL ) ExprError("schedule expression requires a time or time interval"); else - SetType({AdoptRef{}, base_type(TYPE_TIMER)}); + SetType(base_type(TYPE_TIMER)); } bool ScheduleExpr::IsPure() const @@ -3990,7 +3990,7 @@ InExpr::InExpr(IntrusivePtr arg_op1, IntrusivePtr arg_op2) SetError(); } else - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); } else if ( op1->Type()->Tag() == TYPE_RECORD ) @@ -4013,13 +4013,13 @@ InExpr::InExpr(IntrusivePtr arg_op1, IntrusivePtr arg_op2) SetError(); } else - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); } } else if ( op1->Type()->Tag() == TYPE_STRING && op2->Type()->Tag() == TYPE_STRING ) - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); else { @@ -4030,14 +4030,14 @@ InExpr::InExpr(IntrusivePtr arg_op1, IntrusivePtr arg_op2) { if ( op2->Type()->Tag() == TYPE_SUBNET ) { - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); return; } if ( op2->Type()->Tag() == TYPE_TABLE && op2->Type()->AsTableType()->IsSubNetIndex() ) { - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); return; } } @@ -4050,7 +4050,7 @@ InExpr::InExpr(IntrusivePtr arg_op1, IntrusivePtr arg_op2) if ( ! op2->Type()->MatchesIndex(lop1) ) SetError("not an index type"); else - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); } } @@ -4935,7 +4935,7 @@ void CastExpr::ExprDescribe(ODesc* d) const IsExpr::IsExpr(IntrusivePtr arg_op, IntrusivePtr arg_t) : UnaryExpr(EXPR_IS, std::move(arg_op)), t(std::move(arg_t)) { - SetType({AdoptRef{}, base_type(TYPE_BOOL)}); + SetType(base_type(TYPE_BOOL)); } IntrusivePtr IsExpr::Fold(Val* v) const diff --git a/src/File.cc b/src/File.cc index 8ac36350ae..a94d3662b7 100644 --- a/src/File.cc +++ b/src/File.cc @@ -57,7 +57,7 @@ BroFile::BroFile(FILE* arg_f) Init(); f = arg_f; name = access = 0; - t = base_type(TYPE_STRING); + t = base_type(TYPE_STRING).release(); is_open = (f != 0); } @@ -67,7 +67,7 @@ BroFile::BroFile(FILE* arg_f, const char* arg_name, const char* arg_access) f = arg_f; name = copy_string(arg_name); access = copy_string(arg_access); - t = base_type(TYPE_STRING); + t = base_type(TYPE_STRING).release(); is_open = (f != 0); } @@ -77,7 +77,7 @@ BroFile::BroFile(const char* arg_name, const char* arg_access, BroType* arg_t) f = 0; name = copy_string(arg_name); access = copy_string(arg_access); - t = arg_t ? arg_t : base_type(TYPE_STRING); + t = arg_t ? arg_t : base_type(TYPE_STRING).release(); if ( streq(name, "/dev/stdin") ) f = stdin; diff --git a/src/ID.cc b/src/ID.cc index 41e839c440..db76fdb325 100644 --- a/src/ID.cc +++ b/src/ID.cc @@ -314,7 +314,7 @@ TraversalCode ID::Traverse(TraversalCallback* cb) const void ID::Error(const char* msg, const BroObj* o2) { BroObj::Error(msg, o2, 1); - SetType({AdoptRef{}, error_type()}); + SetType(error_type()); } void ID::Describe(ODesc* d) const diff --git a/src/OpaqueVal.cc b/src/OpaqueVal.cc index b0ed446e6f..42d2515b3b 100644 --- a/src/OpaqueVal.cc +++ b/src/OpaqueVal.cc @@ -143,7 +143,7 @@ BroType* OpaqueVal::UnserializeType(const broker::data& data) if ( ! tag ) return nullptr; - return base_type(static_cast(*tag)); + return base_type(static_cast(*tag)).release(); } IntrusivePtr OpaqueVal::DoClone(CloneState* state) diff --git a/src/RuleCondition.cc b/src/RuleCondition.cc index 35a25b201c..281cbace3c 100644 --- a/src/RuleCondition.cc +++ b/src/RuleCondition.cc @@ -146,7 +146,7 @@ RuleConditionEval::RuleConditionEval(const char* func) TypeList tl; tl.Append({NewRef{}, internal_type("signature_state")}); - tl.Append({AdoptRef{}, base_type(TYPE_STRING)}); + tl.Append(base_type(TYPE_STRING)); if ( ! f->CheckArgs(tl.Types()) ) rules_error("eval function parameters must be a 'signature_state' " diff --git a/src/Stmt.cc b/src/Stmt.cc index a45b0198a7..5628535edc 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -1114,7 +1114,7 @@ ForStmt::ForStmt(id_list* arg_loop_vars, IntrusivePtr loop_expr) BroType* t = (*loop_vars)[0]->Type(); if ( ! t ) - add_local({NewRef{}, (*loop_vars)[0]}, {AdoptRef{}, base_type(TYPE_COUNT)}, + add_local({NewRef{}, (*loop_vars)[0]}, base_type(TYPE_COUNT), INIT_NONE, 0, 0, VAR_REGULAR); else if ( ! IsIntegral(t->Tag()) ) @@ -1135,7 +1135,7 @@ ForStmt::ForStmt(id_list* arg_loop_vars, IntrusivePtr loop_expr) BroType* t = (*loop_vars)[0]->Type(); if ( ! t ) add_local({NewRef{}, (*loop_vars)[0]}, - {AdoptRef{}, base_type(TYPE_STRING)}, + base_type(TYPE_STRING), INIT_NONE, 0, 0, VAR_REGULAR); else if ( t->Tag() != TYPE_STRING ) diff --git a/src/Type.cc b/src/Type.cc index b59a8ffc8f..e090a9a626 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -100,7 +100,7 @@ int BroType::MatchesIndex(ListExpr* const index) const if ( index->Exprs().length() != 1 && index->Exprs().length() != 2 ) return DOES_NOT_MATCH_INDEX; - if ( check_and_promote_exprs_to_type(index, ::base_type(TYPE_INT)) ) + if ( check_and_promote_exprs_to_type(index, ::base_type(TYPE_INT).get()) ) return MATCHES_INDEX_SCALAR; } @@ -1307,10 +1307,10 @@ BroType* VectorType::YieldType() // comparisions. if ( IsUnspecifiedVector() ) { - BroType* ret = ::base_type(TYPE_ANY); - Unref(ret); // unref, because this won't be held by anyone. + auto ret = ::base_type(TYPE_ANY); assert(ret); - return ret; + // release, because this won't be held by anyone. + return ret.release(); } return yield_type.get(); @@ -1324,10 +1324,10 @@ const BroType* VectorType::YieldType() const // comparisions. if ( IsUnspecifiedVector() ) { - BroType* ret = ::base_type(TYPE_ANY); - Unref(ret); // unref, because this won't be held by anyone. + auto ret = ::base_type(TYPE_ANY); assert(ret); - return ret; + // release, because this won't be held by anyone. + return ret.release(); } return yield_type.get(); @@ -1711,7 +1711,7 @@ IntrusivePtr merge_types(const BroType* t1, const BroType* t2) TypeTag tg2 = t2->Tag(); if ( BothArithmetic(tg1, tg2) ) - return {AdoptRef{}, base_type(max_type(tg1, tg2))}; + return base_type(max_type(tg1, tg2)); if ( tg1 != tg2 ) { @@ -1731,7 +1731,7 @@ IntrusivePtr merge_types(const BroType* t1, const BroType* t2) case TYPE_BOOL: case TYPE_ANY: case TYPE_ERROR: - return {AdoptRef{}, base_type(tg1)}; + return base_type(tg1); case TYPE_ENUM: { diff --git a/src/Type.h b/src/Type.h index 7075d3565e..e74ab77d4c 100644 --- a/src/Type.h +++ b/src/Type.h @@ -687,11 +687,11 @@ BroType* base_type_no_ref(TypeTag tag); // Returns the basic (non-parameterized) type with the given type. // The caller assumes responsibility for a reference to the type. -inline BroType* base_type(TypeTag tag) - { return base_type_no_ref(tag)->Ref(); } +inline IntrusivePtr base_type(TypeTag tag) + { return {NewRef{}, base_type_no_ref(tag)}; } // Returns the basic error type. -inline BroType* error_type() { return base_type(TYPE_ERROR); } +inline IntrusivePtr error_type() { return base_type(TYPE_ERROR); } // 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 diff --git a/src/Val.cc b/src/Val.cc index 4c3ae7fd0c..4eab5bd98d 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -49,7 +49,7 @@ static FileType* GetStringFileType() noexcept { static FileType* string_file_type = 0; if ( ! string_file_type ) - string_file_type = new FileType({AdoptRef{}, base_type(TYPE_STRING)}); + string_file_type = new FileType(base_type(TYPE_STRING)); return string_file_type; } @@ -1125,7 +1125,7 @@ IntrusivePtr StringVal::DoClone(CloneState* state) val.string_val->Len(), 1))); } -PatternVal::PatternVal(RE_Matcher* re) : Val(base_type(TYPE_PATTERN)) +PatternVal::PatternVal(RE_Matcher* re) : Val(base_type(TYPE_PATTERN).release()) { val.re_val = re; } @@ -1185,7 +1185,7 @@ IntrusivePtr PatternVal::DoClone(CloneState* state) } ListVal::ListVal(TypeTag t) -: Val(new TypeList({NewRef{}, t == TYPE_ANY ? 0 : base_type_no_ref(t)})) +: Val(new TypeList(t == TYPE_ANY ? nullptr : base_type(t))) { tag = t; } @@ -1235,7 +1235,7 @@ TableVal* ListVal::ConvertToSet() const Internal("conversion of heterogeneous list to set"); auto set_index = make_intrusive(IntrusivePtr{NewRef{}, type->AsTypeList()->PureType()}); - set_index->Append({AdoptRef{}, base_type(tag)}); + set_index->Append(base_type(tag)); auto s = make_intrusive(std::move(set_index), nullptr); TableVal* t = new TableVal(std::move(s)); diff --git a/src/Val.h b/src/Val.h index 56adccf3a8..f785943547 100644 --- a/src/Val.h +++ b/src/Val.h @@ -129,7 +129,7 @@ union BroValUnion { class Val : public BroObj { public: Val(double d, TypeTag t) - : val(d), type(base_type(t)) + : val(d), type(base_type(t).release()) { } @@ -146,7 +146,7 @@ public: } Val() - : val(bro_int_t(0)), type(base_type(TYPE_ERROR)) + : val(bro_int_t(0)), type(base_type(TYPE_ERROR).release()) { } @@ -355,7 +355,7 @@ protected: template Val(V &&v, TypeTag t) noexcept - : val(std::forward(v)), type(base_type(t)) + : val(std::forward(v)), type(base_type(t).release()) { } diff --git a/src/Var.cc b/src/Var.cc index 888f1bd788..37f0755258 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -106,7 +106,7 @@ static void make_var(ID* id, IntrusivePtr t, init_class c, t = init_type(init.get()); if ( ! t ) { - id->SetType({AdoptRef{}, error_type()}); + id->SetType(error_type()); return; } } diff --git a/src/analyzer/protocol/modbus/modbus-analyzer.pac b/src/analyzer/protocol/modbus/modbus-analyzer.pac index 40e6197375..e30b5e3867 100644 --- a/src/analyzer/protocol/modbus/modbus-analyzer.pac +++ b/src/analyzer/protocol/modbus/modbus-analyzer.pac @@ -38,7 +38,7 @@ VectorVal* create_vector_of_count() { - VectorType* vt = new VectorType({AdoptRef{}, base_type(TYPE_COUNT)}); + VectorType* vt = new VectorType(base_type(TYPE_COUNT)); VectorVal* vv = new VectorVal(vt); Unref(vt); return vv; diff --git a/src/analyzer/protocol/rpc/MOUNT.cc b/src/analyzer/protocol/rpc/MOUNT.cc index 4b5a5a23f8..7265001fe3 100644 --- a/src/analyzer/protocol/rpc/MOUNT.cc +++ b/src/analyzer/protocol/rpc/MOUNT.cc @@ -271,7 +271,7 @@ RecordVal* MOUNT_Interp::mount3_mnt_reply(const u_char*& buf, int& n, auth_flavors_count = max_auth_flavors; } - VectorType* enum_vector = new VectorType({AdoptRef{}, base_type(TYPE_ENUM)}); + VectorType* enum_vector = new VectorType(base_type(TYPE_ENUM)); VectorVal* auth_flavors = new VectorVal(enum_vector); Unref(enum_vector); diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 37f618124a..c9f12bd778 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -2555,7 +2555,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) co index_type = {NewRef{}, enum_id->Type()->AsEnumType()}; } else - index_type = {NewRef{}, base_type_no_ref(stag)}; + index_type = base_type(stag); set_index = make_intrusive(index_type); set_index->Append(std::move(index_type)); @@ -2579,14 +2579,14 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, bool& have_error) co BroType* type; if ( val->val.vector_val.size == 0 && val->subtype == TYPE_VOID ) // don't know type - unspecified table. - type = base_type(TYPE_ANY); + type = base_type(TYPE_ANY).release(); else { // all entries have to have the same type... if ( val->subtype == TYPE_VOID ) - type = base_type(val->val.vector_val.vals[0]->type); + type = base_type(val->val.vector_val.vals[0]->type).release(); else - type = base_type(val->subtype); + type = base_type(val->subtype).release(); } VectorType* vt = new VectorType({NewRef{}, type}); diff --git a/src/parse.y b/src/parse.y index cc657765b5..82a53899eb 100644 --- a/src/parse.y +++ b/src/parse.y @@ -702,7 +702,7 @@ expr: if ( ! id->Type() ) { id->Error("undeclared variable"); - id->SetType({AdoptRef{}, error_type()}); + id->SetType(error_type()); $$ = new NameExpr(std::move(id)); } @@ -844,72 +844,72 @@ enum_body_elem: type: TOK_BOOL { set_location(@1); - $$ = base_type(TYPE_BOOL); + $$ = base_type(TYPE_BOOL).release(); } | TOK_INT { set_location(@1); - $$ = base_type(TYPE_INT); + $$ = base_type(TYPE_INT).release(); } | TOK_COUNT { set_location(@1); - $$ = base_type(TYPE_COUNT); + $$ = base_type(TYPE_COUNT).release(); } | TOK_COUNTER { set_location(@1); - $$ = base_type(TYPE_COUNTER); + $$ = base_type(TYPE_COUNTER).release(); } | TOK_DOUBLE { set_location(@1); - $$ = base_type(TYPE_DOUBLE); + $$ = base_type(TYPE_DOUBLE).release(); } | TOK_TIME { set_location(@1); - $$ = base_type(TYPE_TIME); + $$ = base_type(TYPE_TIME).release(); } | TOK_INTERVAL { set_location(@1); - $$ = base_type(TYPE_INTERVAL); + $$ = base_type(TYPE_INTERVAL).release(); } | TOK_STRING { set_location(@1); - $$ = base_type(TYPE_STRING); + $$ = base_type(TYPE_STRING).release(); } | TOK_PATTERN { set_location(@1); - $$ = base_type(TYPE_PATTERN); + $$ = base_type(TYPE_PATTERN).release(); } | TOK_TIMER { set_location(@1); - $$ = base_type(TYPE_TIMER); + $$ = base_type(TYPE_TIMER).release(); } | TOK_PORT { set_location(@1); - $$ = base_type(TYPE_PORT); + $$ = base_type(TYPE_PORT).release(); } | TOK_ADDR { set_location(@1); - $$ = base_type(TYPE_ADDR); + $$ = base_type(TYPE_ADDR).release(); } | TOK_SUBNET { set_location(@1); - $$ = base_type(TYPE_SUBNET); + $$ = base_type(TYPE_SUBNET).release(); } | TOK_ANY { set_location(@1); - $$ = base_type(TYPE_ANY); + $$ = base_type(TYPE_ANY).release(); } | TOK_TABLE '[' type_list ']' TOK_OF type @@ -985,7 +985,7 @@ type: | TOK_HOOK '(' formal_args ')' { set_location(@1, @3); - $$ = new FuncType({AdoptRef{}, $3}, {AdoptRef{}, base_type(TYPE_BOOL)}, FUNC_FLAVOR_HOOK); + $$ = new FuncType({AdoptRef{}, $3}, base_type(TYPE_BOOL), FUNC_FLAVOR_HOOK); } | TOK_FILE TOK_OF type @@ -997,7 +997,7 @@ type: | TOK_FILE { set_location(@1); - $$ = new FileType({AdoptRef{}, base_type(TYPE_STRING)}); + $$ = new FileType(base_type(TYPE_STRING)); } | TOK_OPAQUE TOK_OF TOK_ID @@ -1013,7 +1013,7 @@ type: NullStmt here; if ( $1 ) $1->Error("not a Zeek type", &here); - $$ = error_type(); + $$ = error_type().release(); } else { @@ -1204,7 +1204,7 @@ func_hdr: | TOK_HOOK def_global_id func_params opt_attr { $3->ClearYieldType(FUNC_FLAVOR_HOOK); - $3->SetYieldType({AdoptRef{}, base_type(TYPE_BOOL)}); + $3->SetYieldType(base_type(TYPE_BOOL)); begin_func($2, current_module.c_str(), FUNC_FLAVOR_HOOK, 0, {NewRef{}, $3}, $4); $$ = $3; @@ -1280,7 +1280,7 @@ func_params: '(' formal_args ')' ':' type { $$ = new FuncType({AdoptRef{}, $2}, {AdoptRef{}, $5}, FUNC_FLAVOR_FUNCTION); } | '(' formal_args ')' - { $$ = new FuncType({AdoptRef{}, $2}, {AdoptRef{}, base_type(TYPE_VOID)}, FUNC_FLAVOR_FUNCTION); } + { $$ = new FuncType({AdoptRef{}, $2}, base_type(TYPE_VOID), FUNC_FLAVOR_FUNCTION); } ; opt_type: