mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +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,
|
||||
bool from_redef)
|
||||
{
|
||||
if ( from_redef )
|
||||
has_redefs = true;
|
||||
|
||||
if ( Lookup(val) )
|
||||
{
|
||||
reporter->Error("enumerator value in enumerated type definition already exists");
|
||||
|
|
|
@ -722,12 +722,15 @@ public:
|
|||
|
||||
// -1 indicates not found.
|
||||
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
|
||||
|
||||
// Returns the list of defined names with their values. The names
|
||||
// will be fully qualified with their module name.
|
||||
enum_name_list Names() const;
|
||||
|
||||
bool HasRedefs() const { return has_redefs; }
|
||||
|
||||
void Describe(ODesc* d) 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;
|
||||
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>;
|
||||
ValMap vals;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue