#include <string>#include <map>#include "Obj.h"#include "Attr.h"#include "BroList.h"#include "Dict.h"Include dependency graph for Type.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| class | BroType |
| class | EnumType |
| class | FileType |
| class | FuncType |
| class | IndexType |
| class | RecordField |
| class | RecordType |
| class | SetType |
| class | SubNetType |
| class | TableType |
| class | TypeDecl |
| class | TypeList |
| class | VectorType |
Defines | |
| #define | NUM_TYPES (int(TYPE_ERROR) + 1) |
| #define | IsIntegral(t) (t == TYPE_INT || t == TYPE_COUNT || t == TYPE_COUNTER) |
| #define | IsArithmetic(t) (IsIntegral(t) || t == TYPE_DOUBLE) |
| #define | IsBool(t) (t == TYPE_BOOL) |
| #define | IsRecord(t) (t == TYPE_RECORD || t == TYPE_UNION) |
| #define | IsFunc(t) (t == TYPE_FUNC) |
| #define | IsMutable(t) (t == TYPE_RECORD || t == TYPE_TABLE) |
| #define | IsVector(t) (t == TYPE_VECTOR) |
| #define | IsErrorType(t) (t == TYPE_ERROR) |
| #define | BothIntegral(t1, t2) (IsIntegral(t1) && IsIntegral(t2)) |
| #define | BothArithmetic(t1, t2) (IsArithmetic(t1) && IsArithmetic(t2)) |
| #define | EitherArithmetic(t1, t2) (IsArithmetic(t1) || IsArithmetic(t2)) |
| #define | BothBool(t1, t2) (IsBool(t1) && IsBool(t2)) |
| #define | EitherError(t1, t2) (IsErrorType(t1) || IsErrorType(t2)) |
Enumerations | |
| enum | TypeTag { TYPE_VOID, TYPE_BOOL, TYPE_INT, TYPE_COUNT, TYPE_COUNTER, TYPE_DOUBLE, TYPE_TIME, TYPE_INTERVAL, TYPE_STRING, TYPE_PATTERN, TYPE_ENUM, TYPE_TIMER, TYPE_PORT, TYPE_ADDR, TYPE_NET, TYPE_SUBNET, TYPE_ANY, TYPE_TABLE, TYPE_UNION, TYPE_RECORD, TYPE_LIST, TYPE_FUNC, TYPE_FILE, TYPE_VECTOR, NUM_TYPES } |
| enum | function_flavor { FUNC_FLAVOR_FUNCTION, FUNC_FLAVOR_EVENT } |
| enum | InternalTypeTag { TYPE_INTERNAL_VOID, TYPE_INTERNAL_INT, TYPE_INTERNAL_UNSIGNED, TYPE_INTERNAL_DOUBLE, TYPE_INTERNAL_STRING, TYPE_INTERNAL_ADDR, TYPE_INTERNAL_SUBNET, TYPE_INTERNAL_OTHER, TYPE_INTERNAL_ERROR } |
Functions | |
| declare (PDict, RecordField) | |
| const char * | type_name (TypeTag t) |
| BroType * | refine_type (TypeList *base, type_decl_list *refinements) |
| BroType * | base_type (TypeTag tag) |
| BroType * | error_type () |
| int | same_type (const BroType *t1, const BroType *t2, int is_init=0) |
| int | record_promotion_compatible (const RecordType *super_rec, const RecordType *sub_rec) |
| const BroType * | flatten_type (const BroType *t) |
| BroType * | flatten_type (BroType *t) |
| TypeTag | max_type (TypeTag t1, TypeTag t2) |
| BroType * | merge_types (const BroType *t1, const BroType *t2) |
| int | is_assignable (BroType *t) |
Variables | |
| bool | in_global_attr_decl |
| RecordType * | global_attributes_type |
| const int | DOES_NOT_MATCH_INDEX = 0 |
| const int | MATCHES_INDEX_SCALAR = 1 |
| const int | MATCHES_INDEX_VECTOR = 2 |
|
|
Definition at line 596 of file Type.h. Referenced by AddExpr::AddExpr(), check_and_promote(), check_and_promote_expr(), CondExpr::CondExpr(), DivideExpr::DivideExpr(), EqExpr::EqExpr(), max_type(), merge_types(), RelExpr::RelExpr(), SubExpr::SubExpr(), and TimesExpr::TimesExpr(). |
|
|
Definition at line 602 of file Type.h. Referenced by BoolExpr::BoolExpr(). |
|
|
Definition at line 593 of file Type.h. Referenced by ModExpr::ModExpr(). |
|
|
Definition at line 599 of file Type.h. Referenced by check_and_promote(), check_and_promote_expr(), and EqExpr::EqExpr(). |
|
|
|
|
|
Definition at line 569 of file Type.h. Referenced by ArithCoerceExpr::ArithCoerceExpr(), AssignExpr::AssignExpr(), check_and_promote(), DivideExpr::DivideExpr(), RecordMatchExpr::RecordMatchExpr(), and TimesExpr::TimesExpr(). |
|
|
Definition at line 572 of file Type.h. Referenced by ArithCoerceExpr::ArithCoerceExpr(), IndexExpr::Eval(), DbgBreakpoint::HasHit(), IfStmt::IfStmt(), and VectorType::MatchesIndex(). |
|
|
|
|
|
Definition at line 578 of file Type.h. Referenced by CallExpr::CallExpr(), and ID::Traverse(). |
|
|
Definition at line 566 of file Type.h. Referenced by DbgBreakpoint::HasHit(), IncrExpr::IncrExpr(), VectorType::MatchesIndex(), NegExpr::NegExpr(), NotExpr::NotExpr(), PosExpr::PosExpr(), and StateAccess::Replay(). |
|
|
Definition at line 581 of file Type.h. Referenced by Val::IsMutableVal(). |
|
|
Definition at line 575 of file Type.h. Referenced by FieldExpr::FieldExpr(), and HasFieldExpr::HasFieldExpr(). |
|
|
|
Referenced by base_type(), and type_name(). |
|
|
Definition at line 55 of file Type.h.
00055 { FUNC_FLAVOR_FUNCTION, FUNC_FLAVOR_EVENT } function_flavor;
|
|
|
Definition at line 57 of file Type.h. Referenced by check_and_promote(), ArithCoerceExpr::DoSimplify(), ArithCoerceExpr::Fold(), BinaryExpr::Fold(), BroType::InternalType(), recover_val(), CompositeHash::RecoverOneVal(), CompositeHash::SingleTypeKeySize(), CompositeHash::SingleValHash(), and TableType::TableType().
00057 {
00058 TYPE_INTERNAL_VOID,
00059 TYPE_INTERNAL_INT, TYPE_INTERNAL_UNSIGNED, TYPE_INTERNAL_DOUBLE,
00060 TYPE_INTERNAL_STRING, TYPE_INTERNAL_ADDR, TYPE_INTERNAL_SUBNET,
00061 TYPE_INTERNAL_OTHER, TYPE_INTERNAL_ERROR
00062 } InternalTypeTag;
|
|
|
|
Definition at line 1253 of file Type.cc. References int, NUM_TYPES, BroType::Ref(), BroObj::SetLocationInfo(), and type_name(). Referenced by AddExpr::AddExpr(), ArithCoerceExpr::ArithCoerceExpr(), BoolExpr::BoolExpr(), BroFile::BroFile(), CondExpr::CondExpr(), ListVal::ConvertToSet(), DivideExpr::DivideExpr(), empty_addr_set(), EqExpr::EqExpr(), HasFieldExpr::HasFieldExpr(), IndexExpr::IndexExpr(), InExpr::InExpr(), ListVal::ListVal(), merge_types(), NegExpr::NegExpr(), NetSessions::NetSessions(), NotExpr::NotExpr(), PatternVal::PatternVal(), PosExpr::PosExpr(), BinaryExpr::PromoteType(), RelExpr::RelExpr(), ScheduleExpr::ScheduleExpr(), SubExpr::SubExpr(), Val::Val(), and yyparse().
01254 {
01255 static BroType* base_types[NUM_TYPES];
01256
01257 // We could check here that "tag" actually corresponds to a BRO
01258 // basic type.
01259
01260 int t = int(tag);
01261 if ( ! base_types[t] )
01262 {
01263 base_types[t] = new BroType(tag, true);
01264 // Give the base types a pseudo-location for easier identification.
01265 Location* l = new Location(type_name(tag), 0, 0, 0, 0);
01266 base_types[t]->SetLocationInfo(l);
01267 }
01268
01269 return base_types[t]->Ref();
01270 }
|
|
||||||||||||
|
|
|
|
Definition at line 541 of file Type.h. Referenced by ID::Error(), make_var(), Expr::SetError(), and yyparse().
00545 { return base_type(TYPE_ERROR); }
|
|
|
Definition at line 1467 of file Type.cc. Referenced by check_and_promote(), merge_types(), reduce_type(), same_type(), and SetType::SetType().
01468 {
01469 return (BroType*) flatten_type((const BroType*) t);
01470 }
|
|
|
Definition at line 1445 of file Type.cc. References TypeList::AllMatch(), BroType::AsTypeList(), internal_error(), TypeList::IsPure(), TypeList::PureType(), BroType::Tag(), TYPE_LIST, and TypeList::Types().
01446 {
01447 if ( t->Tag() != TYPE_LIST )
01448 return t;
01449
01450 const TypeList* tl = t->AsTypeList();
01451
01452 if ( tl->IsPure() )
01453 return tl->PureType();
01454
01455 const type_list* types = tl->Types();
01456
01457 if ( types->length() == 0 )
01458 internal_error("empty type list in flatten_type");
01459
01460 const BroType* ft = (*types)[0];
01461 if ( types->length() == 1 || tl->AllMatch(ft, 0) )
01462 return ft;
01463
01464 return t;
01465 }
|
|
|
Definition at line 1472 of file Type.cc. References error(), BroType::Tag(), TYPE_ADDR, TYPE_ANY, TYPE_BOOL, TYPE_COUNT, TYPE_COUNTER, TYPE_DOUBLE, TYPE_ENUM, TYPE_ERROR, TYPE_FILE, TYPE_FUNC, TYPE_INT, TYPE_INTERVAL, TYPE_LIST, TYPE_NET, TYPE_PATTERN, TYPE_PORT, TYPE_RECORD, TYPE_STRING, TYPE_SUBNET, TYPE_TABLE, TYPE_TIME, TYPE_TIMER, TYPE_UNION, TYPE_VECTOR, and TYPE_VOID. Referenced by RefExpr::RefExpr().
01473 {
01474 switch ( t->Tag() ) {
01475 case TYPE_BOOL:
01476 case TYPE_INT:
01477 case TYPE_COUNT:
01478 case TYPE_COUNTER:
01479 case TYPE_DOUBLE:
01480 case TYPE_TIME:
01481 case TYPE_INTERVAL:
01482 case TYPE_STRING:
01483 case TYPE_PATTERN:
01484 case TYPE_ENUM:
01485 case TYPE_TIMER:
01486 case TYPE_PORT:
01487 case TYPE_ADDR:
01488 case TYPE_NET:
01489 case TYPE_SUBNET:
01490 case TYPE_RECORD:
01491 case TYPE_FUNC:
01492 case TYPE_ANY:
01493 case TYPE_ERROR:
01494 case TYPE_LIST:
01495 return 1;
01496
01497 case TYPE_VECTOR:
01498 case TYPE_FILE:
01499 case TYPE_TABLE:
01500 return 1;
01501
01502 case TYPE_VOID:
01503 return 0;
01504
01505 case TYPE_UNION:
01506 error("union type in is_assignable()");
01507 }
01508
01509 return 0;
01510 }
|
|
||||||||||||
|
Definition at line 1512 of file Type.cc. References BothArithmetic, CHECK_TYPE, internal_error(), TYPE_COUNT, TYPE_DOUBLE, TYPE_ERROR, TYPE_INT, TYPE_INTERVAL, TYPE_TIME, and TypeTag. Referenced by AddExpr::AddExpr(), check_and_promote(), check_and_promote_expr(), CondExpr::CondExpr(), DivideExpr::DivideExpr(), EqExpr::EqExpr(), merge_types(), ModExpr::ModExpr(), RelExpr::RelExpr(), SubExpr::SubExpr(), and TimesExpr::TimesExpr().
01513 {
01514 if ( t1 == TYPE_INTERVAL || t1 == TYPE_TIME )
01515 t1 = TYPE_DOUBLE;
01516 if ( t2 == TYPE_INTERVAL || t2 == TYPE_TIME )
01517 t2 = TYPE_DOUBLE;
01518
01519 if ( BothArithmetic(t1, t2) )
01520 {
01521 #define CHECK_TYPE(t) \
01522 if ( t1 == t || t2 == t ) \
01523 return t;
01524
01525 CHECK_TYPE(TYPE_DOUBLE);
01526 CHECK_TYPE(TYPE_INT);
01527 CHECK_TYPE(TYPE_COUNT);
01528
01529 // Note - mixing two TYPE_COUNTER's still promotes to
01530 // a TYPE_COUNT.
01531 return TYPE_COUNT;
01532 }
01533 else
01534 {
01535 internal_error("non-arithmetic tags in max_type()");
01536 return TYPE_ERROR;
01537 }
01538 }
|
|
||||||||||||
|
Definition at line 1540 of file Type.cc. References TypeList::Append(), FuncType::Args(), args, BroType::AsTypeList(), base_type(), BothArithmetic, copy_string(), BroObj::Error(), RecordType::FieldDecl(), flatten_type(), TypeDecl::id, IndexType::IndexTypes(), internal_error(), FuncType::IsEvent(), TypeList::IsPure(), BroType::IsSet(), loop_over_list, max_type(), RecordType::NumFields(), same_type(), streq(), BroType::Tag(), TypeDecl::type, TYPE_ADDR, TYPE_ANY, TYPE_ERROR, TYPE_FILE, TYPE_FUNC, TYPE_INTERVAL, TYPE_LIST, TYPE_NET, TYPE_PATTERN, TYPE_PORT, TYPE_RECORD, TYPE_STRING, TYPE_SUBNET, TYPE_TABLE, TYPE_TIME, TYPE_TIMER, TYPE_UNION, TYPE_VECTOR, TypeList::Types(), TypeTag, Unref(), and BroType::YieldType(). Referenced by init_type(), and SetType::SetType().
01541 {
01542 t1 = flatten_type(t1);
01543 t2 = flatten_type(t2);
01544
01545 TypeTag tg1 = t1->Tag();
01546 TypeTag tg2 = t2->Tag();
01547
01548 if ( BothArithmetic(tg1, tg2) )
01549 return base_type(max_type(tg1, tg2));
01550
01551 if ( tg1 != tg2 )
01552 {
01553 t1->Error("incompatible types", t2);
01554 return 0;
01555 }
01556
01557 switch ( tg1 ) {
01558 case TYPE_TIME:
01559 case TYPE_INTERVAL:
01560 case TYPE_STRING:
01561 case TYPE_PATTERN:
01562 case TYPE_TIMER:
01563 case TYPE_PORT:
01564 case TYPE_ADDR:
01565 case TYPE_NET:
01566 case TYPE_SUBNET:
01567 case TYPE_ANY:
01568 case TYPE_ERROR:
01569 return base_type(tg1);
01570
01571 case TYPE_TABLE:
01572 {
01573 const IndexType* it1 = (const IndexType*) t1;
01574 const IndexType* it2 = (const IndexType*) t2;
01575
01576 const type_list* tl1 = it1->IndexTypes();
01577 const type_list* tl2 = it2->IndexTypes();
01578 TypeList* tl3 = 0;
01579
01580 if ( tl1 || tl2 )
01581 {
01582 if ( ! tl1 || ! tl2 || tl1->length() != tl2->length() )
01583 {
01584 t1->Error("incompatible types", t2);
01585 return 0;
01586 }
01587
01588 tl3 = new TypeList();
01589
01590 loop_over_list(*tl1, i)
01591 {
01592 BroType* tl3_i = merge_types((*tl1)[i], (*tl2)[i]);
01593 if ( ! tl3_i )
01594 {
01595 Unref(tl3);
01596 return 0;
01597 }
01598
01599 tl3->Append(tl3_i);
01600 }
01601 }
01602
01603 const BroType* y1 = t1->YieldType();
01604 const BroType* y2 = t2->YieldType();
01605 BroType* y3 = 0;
01606
01607 if ( y1 || y2 )
01608 {
01609 if ( ! y1 || ! y2 )
01610 {
01611 t1->Error("incompatible types", t2);
01612 return 0;
01613 }
01614
01615 y3 = merge_types(y1, y2);
01616 if ( ! y3 )
01617 {
01618 Unref(tl3);
01619 return 0;
01620 }
01621 }
01622
01623 if ( t1->IsSet() )
01624 return new SetType(tl3, 0);
01625 else if ( tg1 == TYPE_TABLE )
01626 return new TableType(tl3, y3);
01627 else
01628 {
01629 internal_error("bad tag in merge_types");
01630 return 0;
01631 }
01632 }
01633
01634 case TYPE_FUNC:
01635 {
01636 if ( ! same_type(t1, t2) )
01637 {
01638 t1->Error("incompatible types", t2);
01639 return 0;
01640 }
01641
01642 const FuncType* ft1 = (const FuncType*) t1;
01643 const FuncType* ft2 = (const FuncType*) t1;
01644 BroType* args = merge_types(ft1->Args(), ft2->Args());
01645 BroType* yield = t1->YieldType() ?
01646 merge_types(t1->YieldType(), t2->YieldType()) : 0;
01647
01648 return new FuncType(args->AsRecordType(), yield, ft1->IsEvent());
01649 }
01650
01651 case TYPE_RECORD:
01652 {
01653 const RecordType* rt1 = (const RecordType*) t1;
01654 const RecordType* rt2 = (const RecordType*) t2;
01655
01656 if ( rt1->NumFields() != rt2->NumFields() )
01657 return 0;
01658
01659 type_decl_list* tdl3 = new type_decl_list;
01660
01661 for ( int i = 0; i < rt1->NumFields(); ++i )
01662 {
01663 const TypeDecl* td1 = rt1->FieldDecl(i);
01664 const TypeDecl* td2 = rt2->FieldDecl(i);
01665 BroType* tdl3_i = merge_types(td1->type, td2->type);
01666
01667 if ( ! streq(td1->id, td2->id) || ! tdl3_i )
01668 {
01669 t1->Error("incompatible record fields", t2);
01670 delete tdl3;
01671 Unref(tdl3_i);
01672 return 0;
01673 }
01674
01675 tdl3->append(new TypeDecl(tdl3_i, copy_string(td1->id)));
01676 }
01677
01678 return new RecordType(tdl3);
01679 }
01680
01681 case TYPE_LIST:
01682 {
01683 const TypeList* tl1 = t1->AsTypeList();
01684 const TypeList* tl2 = t2->AsTypeList();
01685
01686 if ( tl1->IsPure() != tl2->IsPure() )
01687 {
01688 tl1->Error("incompatible lists", tl2);
01689 return 0;
01690 }
01691
01692 const type_list* l1 = tl1->Types();
01693 const type_list* l2 = tl2->Types();
01694
01695 if ( l1->length() == 0 || l2->length() == 0 )
01696 {
01697 if ( l1->length() == 0 )
01698 tl1->Error("empty list");
01699 else
01700 tl2->Error("empty list");
01701 return 0;
01702 }
01703
01704 if ( tl1->IsPure() )
01705 {
01706 // We will be expanding the pure list when converting
01707 // the initialization expression into a set of values.
01708 // So the merge type of the list is the type of one
01709 // of the elements, providing they're consistent.
01710 return merge_types((*l1)[0], (*l2)[0]);
01711 }
01712
01713 // Impure lists - must have the same size and match element
01714 // by element.
01715 if ( l1->length() != l2->length() )
01716 {
01717 tl1->Error("different number of indices", tl2);
01718 return 0;
01719 }
01720
01721 TypeList* tl3 = new TypeList();
01722 loop_over_list(*l1, i)
01723 tl3->Append(merge_types((*l1)[i], (*l2)[i]));
01724
01725 return tl3;
01726 }
01727
01728 case TYPE_VECTOR:
01729 if ( ! same_type(t1->YieldType(), t2->YieldType()) )
01730 {
01731 t1->Error("incompatible types", t2);
01732 return 0;
01733 }
01734
01735 return new VectorType(merge_types(t1->YieldType(), t2->YieldType()));
01736
01737 case TYPE_FILE:
01738 if ( ! same_type(t1->YieldType(), t2->YieldType()) )
01739 {
01740 t1->Error("incompatible types", t2);
01741 return 0;
01742 }
01743
01744 return new FileType(merge_types(t1->YieldType(), t2->YieldType()));
01745
01746 case TYPE_UNION:
01747 internal_error("union type in merge_types()");
01748 return 0;
01749
01750 default:
01751 internal_error("bad type in merge_types()");
01752 return 0;
01753 }
01754 }
|
|
||||||||||||
|
Definition at line 1429 of file Type.cc. Referenced by check_and_promote_expr(), and RecordConstructorExpr::InitVal().
|
|
||||||||||||
|
Definition at line 1238 of file Type.cc. References TypeList::Types(), and Unref(). Referenced by BroType::SetAttributesType(), and yyparse().
01239 {
01240 type_list* t = base->Types();
01241
01242 if ( t->length() == 1 && ! refinements )
01243 { // Just a direct reference to a single type.
01244 BroType* rt = (*t)[0]->Ref();
01245 Unref(base);
01246 return rt;
01247 }
01248
01249 return new RecordType(base, refinements);
01250 }
|
|
||||||||||||||||
|
Definition at line 1294 of file Type.cc. References FuncType::Args(), BroType::AsTypeList(), error(), RecordType::FieldDecl(), flatten_type(), TypeDecl::id, IndexType::Indices(), is_init_compat(), FuncType::IsEvent(), loop_over_list, RecordType::NumFields(), streq(), BroType::Tag(), TypeDecl::type, TYPE_ADDR, TYPE_ANY, TYPE_BOOL, TYPE_COUNT, TYPE_COUNTER, TYPE_DOUBLE, TYPE_ENUM, TYPE_ERROR, TYPE_FILE, TYPE_FUNC, TYPE_INT, TYPE_INTERVAL, TYPE_LIST, TYPE_NET, TYPE_PATTERN, TYPE_PORT, TYPE_RECORD, TYPE_STRING, TYPE_SUBNET, TYPE_TABLE, TYPE_TIME, TYPE_TIMER, TYPE_UNION, TYPE_VECTOR, TYPE_VOID, TypeList::Types(), and BroType::YieldType(). Referenced by ListExpr::AddSetInit(), TableVal::AddTo(), TypeList::AllMatch(), TypeList::Append(), TypeList::AppendEvenIfNotPure(), VectorVal::Assign(), AssignExpr::AssignExpr(), begin_func(), check_and_promote(), check_and_promote_expr(), FuncType::CheckArgs(), Attributes::CheckAttr(), EqExpr::EqExpr(), ForStmt::ForStmt(), InExpr::InExpr(), init_type(), ListExpr::InitVal(), is_init_compat(), TableVal::Lookup(), make_var(), merge_types(), RecordAssignExpr::RecordAssignExpr(), RecordCoerceExpr::RecordCoerceExpr(), recover_val(), TableVal::RemoveFrom(), same_expr(), and ID::Unserialize().
01295 {
01296 if ( t1 == t2 )
01297 return 1;
01298
01299 t1 = flatten_type(t1);
01300 t2 = flatten_type(t2);
01301 if ( t1 == t2 )
01302 return 1;
01303
01304 if ( t1->Tag() != t2->Tag() )
01305 {
01306 if ( is_init )
01307 return is_init_compat(t1, t2) || is_init_compat(t2, t1);
01308
01309 return 0;
01310 }
01311
01312 switch ( t1->Tag() ) {
01313 case TYPE_VOID:
01314 case TYPE_BOOL:
01315 case TYPE_INT:
01316 case TYPE_COUNT:
01317 case TYPE_COUNTER:
01318 case TYPE_DOUBLE:
01319 case TYPE_TIME:
01320 case TYPE_INTERVAL:
01321 case TYPE_STRING:
01322 case TYPE_PATTERN:
01323 case TYPE_TIMER:
01324 case TYPE_PORT:
01325 case TYPE_ADDR:
01326 case TYPE_NET:
01327 case TYPE_SUBNET:
01328 case TYPE_ANY:
01329 case TYPE_ERROR:
01330 return 1;
01331
01332 case TYPE_ENUM:
01333 // We should probably check to see whether all of the
01334 // enumerations are present and in the same location.
01335 // FIXME: Yes, but perhaps we should better return
01336 // true per default?
01337 return 1;
01338
01339 case TYPE_TABLE:
01340 {
01341 const IndexType* it1 = (const IndexType*) t1;
01342 const IndexType* it2 = (const IndexType*) t2;
01343
01344 TypeList* tl1 = it1->Indices();
01345 TypeList* tl2 = it2->Indices();
01346
01347 if ( tl1 || tl2 )
01348 {
01349 if ( ! tl1 || ! tl2 || ! same_type(tl1, tl2, is_init) )
01350 return 0;
01351 }
01352
01353 const BroType* y1 = t1->YieldType();
01354 const BroType* y2 = t2->YieldType();
01355
01356 if ( y1 || y2 )
01357 {
01358 if ( ! y1 || ! y2 || ! same_type(y1, y2, is_init) )
01359 return 0;
01360 }
01361
01362 return 1;
01363 }
01364
01365 case TYPE_FUNC:
01366 {
01367 const FuncType* ft1 = (const FuncType*) t1;
01368 const FuncType* ft2 = (const FuncType*) t2;
01369
01370 if ( ft1->IsEvent() != ft2->IsEvent() )
01371 return 0;
01372
01373 if ( t1->YieldType() || t2->YieldType() )
01374 {
01375 if ( ! t1->YieldType() || ! t2->YieldType() ||
01376 ! same_type(t1->YieldType(), t2->YieldType(), is_init) )
01377 return 0;
01378 }
01379
01380 return same_type(ft1->Args(), ft2->Args(), is_init);
01381 }
01382
01383 case TYPE_RECORD:
01384 {
01385 const RecordType* rt1 = (const RecordType*) t1;
01386 const RecordType* rt2 = (const RecordType*) t2;
01387
01388 if ( rt1->NumFields() != rt2->NumFields() )
01389 return 0;
01390
01391 for ( int i = 0; i < rt1->NumFields(); ++i )
01392 {
01393 const TypeDecl* td1 = rt1->FieldDecl(i);
01394 const TypeDecl* td2 = rt2->FieldDecl(i);
01395
01396 if ( ! streq(td1->id, td2->id) ||
01397 ! same_type(td1->type, td2->type, is_init) )
01398 return 0;
01399 }
01400
01401 return 1;
01402 }
01403
01404 case TYPE_LIST:
01405 {
01406 const type_list* tl1 = t1->AsTypeList()->Types();
01407 const type_list* tl2 = t2->AsTypeList()->Types();
01408
01409 if ( tl1->length() != tl2->length() )
01410 return 0;
01411
01412 loop_over_list(*tl1, i)
01413 if ( ! same_type((*tl1)[i], (*tl2)[i], is_init) )
01414 return 0;
01415
01416 return 1;
01417 }
01418
01419 case TYPE_VECTOR:
01420 case TYPE_FILE:
01421 return same_type(t1->YieldType(), t2->YieldType(), is_init);
01422
01423 case TYPE_UNION:
01424 error("union type in same_type()");
01425 }
01426 return 0;
01427 }
|
|
|
Definition at line 43 of file Type.cc. References int, and NUM_TYPES. Referenced by base_type(), and BroType::Describe().
00044 {
00045 static const char* type_names[int(NUM_TYPES)] = {
00046 "void",
00047 "bool", "int", "count", "counter",
00048 "double", "time", "interval",
00049 "string", "pattern",
00050 "enum",
00051 "timer",
00052 "port", "addr", "net", "subnet",
00053 "any",
00054 "table", "union", "record", "types",
00055 "func",
00056 "file",
00057 "vector",
00058 "error",
00059 };
00060
00061 return type_names[int(t)];
00062 }
|
|
|
Definition at line 80 of file Type.h. Referenced by IndexExpr::IndexExpr(), VectorType::MatchesIndex(), FuncType::MatchesIndex(), IndexType::MatchesIndex(), and BroType::MatchesIndex(). |
|
|
Definition at line 78 of file Type.h. Referenced by BroType::AttributesType(), BroType::BroType(), BroType::SetAttributesType(), BroType::Unserialize(), and yyparse(). |
|
|
Definition at line 77 of file Type.h. Referenced by BroType::BroType(), init_global_attrs(), TypeDecl::TypeDecl(), and yyparse(). |
|
|
Definition at line 81 of file Type.h. Referenced by IndexExpr::IndexExpr(), VectorType::MatchesIndex(), FuncType::MatchesIndex(), and IndexType::MatchesIndex(). |
|
|
Definition at line 82 of file Type.h. Referenced by IndexExpr::IndexExpr(), and VectorType::MatchesIndex(). |
1.3.5