From 5e36709905f3e61866b33b9e23bfbd985c89f31e Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Thu, 15 Aug 2024 10:08:47 +0200 Subject: [PATCH] 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. --- src/Func.h | 15 ++++++++++++--- src/script_opt/CPP/Func.h | 1 - 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Func.h b/src/Func.h index f6808484d5..d22a8cc716 100644 --- a/src/Func.h +++ b/src/Func.h @@ -211,6 +211,15 @@ public: 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> cv) { captures_vec = std::move(cv); } + // Same definition as in Frame.h. using OffsetMap = std::unordered_map; @@ -291,9 +300,6 @@ protected: */ virtual void SetCaptures(Frame* f); - // Captures when using ZVal block instead of a Frame. - std::unique_ptr> captures_vec; - private: size_t frame_size = 0; @@ -307,6 +313,9 @@ private: OffsetMap* captures_offset_mapping = nullptr; + // Captures when using ZVal block instead of a Frame. + std::unique_ptr> captures_vec; + // The most recently added/updated body ... StmtPtr current_body; diff --git a/src/script_opt/CPP/Func.h b/src/script_opt/CPP/Func.h index 9a12cb2921..4642c2fdaa 100644 --- a/src/script_opt/CPP/Func.h +++ b/src/script_opt/CPP/Func.h @@ -77,7 +77,6 @@ protected: // Methods related to sending lambdas via Broker. std::optional SerializeCaptures() const override; void SetCaptures(Frame* f) override; - void SetCapturesVec(std::unique_ptr> _captures_vec) { captures_vec = std::move(_captures_vec); } FuncPtr DoClone() override;