diff --git a/src/Frame.h b/src/Frame.h index 7c081939c1..a0fc5146d5 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -53,6 +53,13 @@ public: */ Frame(int size, const ScriptFunc* func, const zeek::Args* fn_args); + /** + * Returns the size of the frame. + * + * @return the number of elements in the frame. + */ + int FrameSize() const { return size; } + /** * @param n the index to get. * @return the value at index *n* of the underlying array. diff --git a/src/Func.h b/src/Func.h index 06f2d26306..14aad967aa 100644 --- a/src/Func.h +++ b/src/Func.h @@ -344,14 +344,19 @@ public: const IDPtr& GetID() const { return id; } const StmtPtr& Body() const { return body; } - void SetBody(StmtPtr _body) { body = std::move(_body); } const auto& Inits() const { return inits; } + void ClearInits() { inits.clear(); } + size_t FrameSize() const { return frame_size; } int Priority() const { return priority; } const ScopePtr& Scope() const { return scope; } const auto& Groups() const { return groups; } + // Used by script optimization to update lambda ingredients + // after compilation. + void SetFrameSize(size_t _frame_size) { frame_size = std::move(_frame_size); } + private: IDPtr id; StmtPtr body; diff --git a/src/Val.cc b/src/Val.cc index 0288cc1738..6c9e214bc2 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -2787,6 +2787,11 @@ void TableVal::InitDefaultFunc(detail::Frame* f) def_val = def_attr->GetExpr()->Eval(f); } +void TableVal::InitDefaultVal(ValPtr _def_val) + { + def_val = std::move(_def_val); + } + void TableVal::InitTimer(double delay) { timer = new TableValTimer(this, run_state::network_time + delay); diff --git a/src/Val.h b/src/Val.h index 75dd006df3..6909f4807c 100644 --- a/src/Val.h +++ b/src/Val.h @@ -968,9 +968,13 @@ public: // If the &default attribute is not a function, or the function has // already been initialized, this does nothing. Otherwise, evaluates - // the function in the frame allowing it to capture its closure. + // the function in the frame, allowing it to capture its closure. void InitDefaultFunc(detail::Frame* f); + // An alternative that assigns the default value directly. Used + // by ZAM compilation. + void InitDefaultVal(ValPtr def_val); + void ClearTimer(detail::Timer* t) { if ( timer == t )