mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Make CompHash computation/recovery for functions deterministic
Functions are now assigned a unique integer on construction which CompositeHash can base hashes on. Recovery then just involves looking up the function pointer associated with that unique number.
This commit is contained in:
parent
3ecd872291
commit
1cc675e30f
6 changed files with 64 additions and 27 deletions
11
src/Func.h
11
src/Func.h
|
@ -20,8 +20,7 @@ public:
|
|||
|
||||
enum Kind { BRO_FUNC, BUILTIN_FUNC };
|
||||
|
||||
Func(Kind arg_kind)
|
||||
{ scope = 0; kind = arg_kind; id = 0; return_value = 0; }
|
||||
Func(Kind arg_kind);
|
||||
|
||||
virtual ~Func();
|
||||
|
||||
|
@ -68,8 +67,12 @@ public:
|
|||
ID* GetReturnValueID() const;
|
||||
virtual TraversalCode Traverse(TraversalCallback* cb) const;
|
||||
|
||||
uint32 GetUniqueFuncID() const { return unique_id; }
|
||||
static Func* GetFuncPtr(size_t id)
|
||||
{ return id >= unique_ids.size() ? 0 : unique_ids[id]; }
|
||||
|
||||
protected:
|
||||
Func() { scope = 0; id = 0; return_value = 0; }
|
||||
Func();
|
||||
|
||||
DECLARE_ABSTRACT_SERIAL(Func);
|
||||
|
||||
|
@ -78,6 +81,8 @@ protected:
|
|||
Kind kind;
|
||||
ID* id;
|
||||
ID* return_value;
|
||||
uint32 unique_id;
|
||||
static vector<Func*> unique_ids;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue