Clean up initialization in Func.h

This commit is contained in:
Tim Wojtulewicz 2025-10-07 15:05:22 -07:00
parent 66a58c757b
commit 75422b5d21
3 changed files with 14 additions and 26 deletions

View file

@ -21,13 +21,6 @@ Frame::Frame(int arg_size, const ScriptFunc* func, const zeek::Args* fn_args) {
function = func; function = func;
func_args = fn_args; func_args = fn_args;
next_stmt = nullptr;
break_before_next_stmt = false;
break_on_return = false;
call = nullptr;
delayed = false;
// We could Ref()/Unref() the captures frame, but there's really // We could Ref()/Unref() the captures frame, but there's really
// no need because by definition this current frame exists to // no need because by definition this current frame exists to
// enable execution of the function, and its captures frame won't // enable execution of the function, and its captures frame won't
@ -35,7 +28,6 @@ Frame::Frame(int arg_size, const ScriptFunc* func, const zeek::Args* fn_args) {
// after this frame does. // after this frame does.
captures = function ? function->GetCapturesFrame() : nullptr; captures = function ? function->GetCapturesFrame() : nullptr;
captures_offset_map = function ? function->GetCapturesOffsetMap() : nullptr; captures_offset_map = function ? function->GetCapturesOffsetMap() : nullptr;
current_offset = 0;
} }
void Frame::SetElement(int n, ValPtr v) { void Frame::SetElement(int n, ValPtr v) {

View file

@ -216,9 +216,9 @@ private:
/** The number of vals that can be stored in this frame. */ /** The number of vals that can be stored in this frame. */
int size; int size;
bool break_before_next_stmt; bool break_before_next_stmt = false;
bool break_on_return; bool break_on_return = false;
bool delayed; bool delayed = false;
/** Associates ID's offsets with values. */ /** Associates ID's offsets with values. */
std::unique_ptr<Element[]> frame; std::unique_ptr<Element[]> frame;
@ -228,25 +228,25 @@ private:
* This is how we support inlined functions without having to * This is how we support inlined functions without having to
* alter the offsets associated with their local variables. * alter the offsets associated with their local variables.
*/ */
int current_offset; int current_offset = 0;
/** Frame used for lambda/when captures. */ /** Frame used for lambda/when captures. */
Frame* captures; Frame* captures = nullptr;
/** Maps IDs to offsets into the "captures" frame. If the ID /** Maps IDs to offsets into the "captures" frame. If the ID
* isn't present, then it's not a capture. * isn't present, then it's not a capture.
*/ */
const OffsetMap* captures_offset_map; const OffsetMap* captures_offset_map = nullptr;
/** The function this frame is associated with. */ /** The function this frame is associated with. */
const ScriptFunc* function; const ScriptFunc* function = nullptr;
// The following is only needed for the debugger. // The following is only needed for the debugger.
/** The arguments to the function that this Frame is associated with. */ /** The arguments to the function that this Frame is associated with. */
const zeek::Args* func_args; const zeek::Args* func_args = nullptr;
/** The next statement to be evaluated in the context of this frame. */ /** The next statement to be evaluated in the context of this frame. */
Stmt* next_stmt; Stmt* next_stmt = nullptr;
trigger::TriggerPtr trigger; trigger::TriggerPtr trigger;
const CallExpr* call = nullptr; const CallExpr* call = nullptr;

View file

@ -339,20 +339,16 @@ public:
void Describe(ODesc* d) const override; void Describe(ODesc* d) const override;
protected: protected:
BuiltinFunc() { BuiltinFunc() = default;
func = nullptr; built_in_func func = nullptr;
is_pure = false; bool is_pure = false;
}
built_in_func func;
bool is_pure;
}; };
extern bool check_built_in_call(BuiltinFunc* f, CallExpr* call); extern bool check_built_in_call(BuiltinFunc* f, CallExpr* call);
struct CallInfo { struct CallInfo {
const CallExpr* call; const CallExpr* call = nullptr;
const Func* func; const Func* func = nullptr;
const zeek::Args& args; const zeek::Args& args;
}; };