mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Add is_atomic_type() overloads for IntrusivePtr
This commit is contained in:
parent
6a1c312451
commit
457c08f531
4 changed files with 10 additions and 6 deletions
|
@ -606,10 +606,10 @@ SwitchStmt::SwitchStmt(IntrusivePtr<Expr> index, case_list* arg_cases)
|
||||||
{
|
{
|
||||||
have_exprs = true;
|
have_exprs = true;
|
||||||
|
|
||||||
if ( ! is_atomic_type(e->GetType().get()) )
|
if ( ! is_atomic_type(e->GetType()) )
|
||||||
e->Error("switch expression must be of an atomic type when cases are expressions");
|
e->Error("switch expression must be of an atomic type when cases are expressions");
|
||||||
|
|
||||||
if ( ! le->GetType()->AsTypeList()->AllMatch(e->GetType().get(), false) )
|
if ( ! le->GetType()->AsTypeList()->AllMatch(e->GetType(), false) )
|
||||||
{
|
{
|
||||||
le->Error("case expression type differs from switch type", e.get());
|
le->Error("case expression type differs from switch type", e.get());
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -2082,9 +2082,9 @@ IntrusivePtr<BroType> init_type(Expr* init)
|
||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_atomic_type(const BroType* t)
|
bool is_atomic_type(const BroType& t)
|
||||||
{
|
{
|
||||||
switch ( t->InternalType() ) {
|
switch ( t.InternalType() ) {
|
||||||
case TYPE_INTERNAL_INT:
|
case TYPE_INTERNAL_INT:
|
||||||
case TYPE_INTERNAL_UNSIGNED:
|
case TYPE_INTERNAL_UNSIGNED:
|
||||||
case TYPE_INTERNAL_DOUBLE:
|
case TYPE_INTERNAL_DOUBLE:
|
||||||
|
|
|
@ -860,7 +860,11 @@ IntrusivePtr<BroType> merge_type_list(ListExpr* elements);
|
||||||
IntrusivePtr<BroType> init_type(Expr* init);
|
IntrusivePtr<BroType> init_type(Expr* init);
|
||||||
|
|
||||||
// Returns true if argument is an atomic type.
|
// Returns true if argument is an atomic type.
|
||||||
bool is_atomic_type(const BroType* t);
|
bool is_atomic_type(const BroType& t);
|
||||||
|
inline bool is_atomic_type(const BroType* t)
|
||||||
|
{ return is_atomic_type(*t); }
|
||||||
|
inline bool is_atomic_type(const IntrusivePtr<BroType>& t)
|
||||||
|
{ return is_atomic_type(*t); }
|
||||||
|
|
||||||
// True if the given type tag corresponds to type that can be assigned to.
|
// True if the given type tag corresponds to type that can be assigned to.
|
||||||
extern bool is_assignable(BroType* t);
|
extern bool is_assignable(BroType* t);
|
||||||
|
|
|
@ -3305,7 +3305,7 @@ bool same_val(const Val* /* v1 */, const Val* /* v2 */)
|
||||||
|
|
||||||
bool is_atomic_val(const Val* v)
|
bool is_atomic_val(const Val* v)
|
||||||
{
|
{
|
||||||
return is_atomic_type(v->GetType().get());
|
return is_atomic_type(v->GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool same_atomic_val(const Val* v1, const Val* v2)
|
bool same_atomic_val(const Val* v1, const Val* v2)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue