From 2494940d95f2963b052205748703b76070feed7d Mon Sep 17 00:00:00 2001 From: Matthias Vallentin Date: Wed, 5 Dec 2012 18:52:52 -1000 Subject: [PATCH] Implement equivalence relation for opaque types. --- src/Type.cc | 7 +++++-- src/Type.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Type.cc b/src/Type.cc index 8b4cfca88c..0baff8b2ee 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1754,8 +1754,11 @@ int same_type(const BroType* t1, const BroType* t2, int is_init) return same_type(t1->YieldType(), t2->YieldType(), is_init); case TYPE_OPAQUE: - // FIXME: Should we downcast here and compare the opaque type names? - return 1; + { + const OpaqueType* ot1 = (const OpaqueType*) t1; + const OpaqueType* ot2 = (const OpaqueType*) t2; + return ot1->Name() == ot2->Name() ? 1 : 0; + } case TYPE_TYPE: return same_type(t1, t2, is_init); diff --git a/src/Type.h b/src/Type.h index 0f356dca31..0f48684675 100644 --- a/src/Type.h +++ b/src/Type.h @@ -505,7 +505,7 @@ public: OpaqueType(const string& name); virtual ~OpaqueType() { }; - const string& Name() { return name; } + const string& Name() const { return name; } void Describe(ODesc* d) const;