mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
enum types track whether they've had values added via "redef"
This commit is contained in:
parent
45004872e8
commit
341c284de9
2 changed files with 9 additions and 0 deletions
|
@ -1341,6 +1341,9 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name,
|
||||||
bro_int_t val, bool is_export, detail::Expr* deprecation,
|
bro_int_t val, bool is_export, detail::Expr* deprecation,
|
||||||
bool from_redef)
|
bool from_redef)
|
||||||
{
|
{
|
||||||
|
if ( from_redef )
|
||||||
|
has_redefs = true;
|
||||||
|
|
||||||
if ( Lookup(val) )
|
if ( Lookup(val) )
|
||||||
{
|
{
|
||||||
reporter->Error("enumerator value in enumerated type definition already exists");
|
reporter->Error("enumerator value in enumerated type definition already exists");
|
||||||
|
|
|
@ -722,12 +722,15 @@ public:
|
||||||
|
|
||||||
// -1 indicates not found.
|
// -1 indicates not found.
|
||||||
bro_int_t Lookup(const std::string& module_name, const char* name) const;
|
bro_int_t Lookup(const std::string& module_name, const char* name) const;
|
||||||
|
|
||||||
const char* Lookup(bro_int_t value) const; // Returns 0 if not found
|
const char* Lookup(bro_int_t value) const; // Returns 0 if not found
|
||||||
|
|
||||||
// Returns the list of defined names with their values. The names
|
// Returns the list of defined names with their values. The names
|
||||||
// will be fully qualified with their module name.
|
// will be fully qualified with their module name.
|
||||||
enum_name_list Names() const;
|
enum_name_list Names() const;
|
||||||
|
|
||||||
|
bool HasRedefs() const { return has_redefs; }
|
||||||
|
|
||||||
void Describe(ODesc* d) const override;
|
void Describe(ODesc* d) const override;
|
||||||
void DescribeReST(ODesc* d, bool roles_only = false) const override;
|
void DescribeReST(ODesc* d, bool roles_only = false) const override;
|
||||||
|
|
||||||
|
@ -747,6 +750,9 @@ protected:
|
||||||
typedef std::map<std::string, bro_int_t> NameMap;
|
typedef std::map<std::string, bro_int_t> NameMap;
|
||||||
NameMap names;
|
NameMap names;
|
||||||
|
|
||||||
|
// Whether any of the elements of the enum were added via redef's.
|
||||||
|
bool has_redefs = false;
|
||||||
|
|
||||||
using ValMap = std::unordered_map<bro_int_t, EnumValPtr>;
|
using ValMap = std::unordered_map<bro_int_t, EnumValPtr>;
|
||||||
ValMap vals;
|
ValMap vals;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue