mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Func: Add SetCapturesVec()
Add an API to directly set captures_vec for use by C++ compilation. The current code keys off or asserts on ZAM stmts, making it difficult to leverage captures_vec in other contexts.
This commit is contained in:
parent
5e35334281
commit
5e36709905
2 changed files with 12 additions and 4 deletions
15
src/Func.h
15
src/Func.h
|
@ -211,6 +211,15 @@ public:
|
||||||
return *captures_vec;
|
return *captures_vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the set of ZVal's used for captures.
|
||||||
|
*
|
||||||
|
* Used for script optimization purposes.
|
||||||
|
*
|
||||||
|
* @param cv The value used for captures_vec.
|
||||||
|
*/
|
||||||
|
void SetCapturesVec(std::unique_ptr<std::vector<ZVal>> cv) { captures_vec = std::move(cv); }
|
||||||
|
|
||||||
// Same definition as in Frame.h.
|
// Same definition as in Frame.h.
|
||||||
using OffsetMap = std::unordered_map<std::string, int>;
|
using OffsetMap = std::unordered_map<std::string, int>;
|
||||||
|
|
||||||
|
@ -291,9 +300,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SetCaptures(Frame* f);
|
virtual void SetCaptures(Frame* f);
|
||||||
|
|
||||||
// Captures when using ZVal block instead of a Frame.
|
|
||||||
std::unique_ptr<std::vector<ZVal>> captures_vec;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t frame_size = 0;
|
size_t frame_size = 0;
|
||||||
|
|
||||||
|
@ -307,6 +313,9 @@ private:
|
||||||
|
|
||||||
OffsetMap* captures_offset_mapping = nullptr;
|
OffsetMap* captures_offset_mapping = nullptr;
|
||||||
|
|
||||||
|
// Captures when using ZVal block instead of a Frame.
|
||||||
|
std::unique_ptr<std::vector<ZVal>> captures_vec;
|
||||||
|
|
||||||
// The most recently added/updated body ...
|
// The most recently added/updated body ...
|
||||||
StmtPtr current_body;
|
StmtPtr current_body;
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,6 @@ protected:
|
||||||
// Methods related to sending lambdas via Broker.
|
// Methods related to sending lambdas via Broker.
|
||||||
std::optional<BrokerData> SerializeCaptures() const override;
|
std::optional<BrokerData> SerializeCaptures() const override;
|
||||||
void SetCaptures(Frame* f) override;
|
void SetCaptures(Frame* f) override;
|
||||||
void SetCapturesVec(std::unique_ptr<std::vector<ZVal>> _captures_vec) { captures_vec = std::move(_captures_vec); }
|
|
||||||
|
|
||||||
FuncPtr DoClone() override;
|
FuncPtr DoClone() override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue