From 863f02744e74e701c609e529e61a6385a41abfbd Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Thu, 21 May 2020 23:00:02 -0700 Subject: [PATCH] Add is_assignable() overload taking TypeTag --- src/Expr.cc | 2 +- src/Type.cc | 4 ++-- src/Type.h | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Expr.cc b/src/Expr.cc index e652a3d09a..4aa6bd0f30 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -1984,7 +1984,7 @@ RefExpr::RefExpr(IntrusivePtr arg_op) if ( IsError() ) return; - if ( ! ::is_assignable(op->GetType().get()) ) + if ( ! ::is_assignable(op->GetType()->Tag()) ) ExprError("illegal assignment target"); else SetType(op->GetType()); diff --git a/src/Type.cc b/src/Type.cc index 158c8b0ccf..7260c4194c 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1644,9 +1644,9 @@ BroType* flatten_type(BroType* t) return (BroType*) flatten_type((const BroType*) t); } -bool is_assignable(BroType* t) +bool is_assignable(TypeTag t) { - switch ( t->Tag() ) { + switch ( t ) { case TYPE_BOOL: case TYPE_INT: case TYPE_COUNT: diff --git a/src/Type.h b/src/Type.h index 92bd2c5ef2..8e30e705cb 100644 --- a/src/Type.h +++ b/src/Type.h @@ -867,7 +867,9 @@ inline bool is_atomic_type(const IntrusivePtr& t) { return is_atomic_type(*t); } // True if the given type tag corresponds to type that can be assigned to. -extern bool is_assignable(BroType* t); +extern bool is_assignable(TypeTag t); +inline bool is_assignable(BroType* t) + { return ::is_assignable(t->Tag()); } // True if the given type tag corresponds to an integral type. inline bool IsIntegral(TypeTag t) { return (t == TYPE_INT || t == TYPE_COUNT || t == TYPE_COUNTER); }