mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
Reformat the world
This commit is contained in:
parent
194cb24547
commit
b2f171ec69
714 changed files with 35149 additions and 35203 deletions
101
src/Frame.h
101
src/Frame.h
|
@ -2,43 +2,46 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include <broker/data.hh>
|
||||
#include <broker/expected.hh>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "zeek/ZeekList.h" // for typedef val_list
|
||||
#include "zeek/IntrusivePtr.h"
|
||||
#include "zeek/Obj.h"
|
||||
#include "zeek/Type.h"
|
||||
#include "zeek/IntrusivePtr.h"
|
||||
#include "zeek/ZeekArgs.h"
|
||||
#include "zeek/ZeekList.h" // for typedef val_list
|
||||
|
||||
namespace zeek {
|
||||
namespace zeek
|
||||
{
|
||||
|
||||
using ValPtr = IntrusivePtr<Val>;
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class CallExpr;
|
||||
class ScriptFunc;
|
||||
using IDPtr = IntrusivePtr<ID>;
|
||||
|
||||
namespace trigger {
|
||||
namespace trigger
|
||||
{
|
||||
|
||||
class Trigger;
|
||||
using TriggerPtr = IntrusivePtr<Trigger>;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class Frame;
|
||||
using FramePtr = IntrusivePtr<Frame>;
|
||||
|
||||
class Frame : public Obj {
|
||||
class Frame : public Obj
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructs a new frame belonging to *func* with *fn_args*
|
||||
|
@ -83,8 +86,7 @@ public:
|
|||
* @param v the value to associate it with
|
||||
*/
|
||||
void SetElement(const ID* id, ValPtr v);
|
||||
void SetElement(const IDPtr& id, ValPtr v)
|
||||
{ SetElement(id.get(), std::move(v)); }
|
||||
void SetElement(const IDPtr& id, ValPtr v) { SetElement(id.get(), std::move(v)); }
|
||||
|
||||
/**
|
||||
* Gets the value associated with *id* and returns it. Returns
|
||||
|
@ -93,8 +95,7 @@ public:
|
|||
* @param id the id who's value to retreive
|
||||
* @return the value associated with *id*
|
||||
*/
|
||||
const ValPtr& GetElementByID(const IDPtr& id) const
|
||||
{ return GetElementByID(id.get()); }
|
||||
const ValPtr& GetElementByID(const IDPtr& id) const { return GetElementByID(id.get()); }
|
||||
|
||||
/**
|
||||
* Adjusts the current offset being used for frame accesses.
|
||||
|
@ -103,7 +104,7 @@ public:
|
|||
* @param incr Amount by which to increase the frame offset.
|
||||
* Use a negative value to shrink the offset.
|
||||
*/
|
||||
void AdjustOffset(int incr) { current_offset += incr; }
|
||||
void AdjustOffset(int incr) { current_offset += incr; }
|
||||
|
||||
/**
|
||||
* Resets all of the indexes from [*startIdx, frame_size) in
|
||||
|
@ -120,43 +121,40 @@ public:
|
|||
/**
|
||||
* @return the function that the frame is associated with.
|
||||
*/
|
||||
const ScriptFunc* GetFunction() const { return function; }
|
||||
const ScriptFunc* GetFunction() const { return function; }
|
||||
|
||||
/**
|
||||
* @return the arguments passed to the function that this frame
|
||||
* is associated with.
|
||||
*/
|
||||
const Args* GetFuncArgs() const { return func_args; }
|
||||
const Args* GetFuncArgs() const { return func_args; }
|
||||
|
||||
/**
|
||||
* Change the function that the frame is associated with.
|
||||
*
|
||||
* @param func the function for the frame to be associated with.
|
||||
*/
|
||||
void SetFunction(ScriptFunc* func) { function = func; }
|
||||
void SetFunction(ScriptFunc* func) { function = func; }
|
||||
|
||||
/**
|
||||
* Sets the next statement to be executed in the context of the frame.
|
||||
*
|
||||
* @param stmt the statement to set it to.
|
||||
*/
|
||||
void SetNextStmt(Stmt* stmt) { next_stmt = stmt; }
|
||||
void SetNextStmt(Stmt* stmt) { next_stmt = stmt; }
|
||||
|
||||
/**
|
||||
* @return the next statement to be executed in the context of the frame.
|
||||
*/
|
||||
Stmt* GetNextStmt() const { return next_stmt; }
|
||||
Stmt* GetNextStmt() const { return next_stmt; }
|
||||
|
||||
/** Used to implement "next" command in debugger. */
|
||||
void BreakBeforeNextStmt(bool should_break)
|
||||
{ break_before_next_stmt = should_break; }
|
||||
bool BreakBeforeNextStmt() const
|
||||
{ return break_before_next_stmt; }
|
||||
void BreakBeforeNextStmt(bool should_break) { break_before_next_stmt = should_break; }
|
||||
bool BreakBeforeNextStmt() const { return break_before_next_stmt; }
|
||||
|
||||
/** Used to implement "finish" command in debugger. */
|
||||
void BreakOnReturn(bool should_break)
|
||||
{ break_on_return = should_break; }
|
||||
bool BreakOnReturn() const { return break_on_return; }
|
||||
void BreakOnReturn(bool should_break) { break_on_return = should_break; }
|
||||
bool BreakOnReturn() const { return break_on_return; }
|
||||
|
||||
/**
|
||||
* Performs a deep copy of all the values in the current frame. If
|
||||
|
@ -233,8 +231,8 @@ public:
|
|||
* reflects captures with copy-semantics rather than deprecated
|
||||
* reference semantics.
|
||||
*/
|
||||
static std::pair<bool, FramePtr> Unserialize(const broker::vector& data,
|
||||
const std::optional<FuncType::CaptureList>& captures);
|
||||
static std::pair<bool, FramePtr>
|
||||
Unserialize(const broker::vector& data, const std::optional<FuncType::CaptureList>& captures);
|
||||
|
||||
/**
|
||||
* Sets the IDs that the frame knows offsets for. These offsets will
|
||||
|
@ -257,17 +255,17 @@ public:
|
|||
// the trigger needs to be registered.
|
||||
void SetTrigger(trigger::TriggerPtr arg_trigger);
|
||||
void ClearTrigger();
|
||||
trigger::Trigger* GetTrigger() const { return trigger.get(); }
|
||||
trigger::Trigger* GetTrigger() const { return trigger.get(); }
|
||||
|
||||
void SetCall(const CallExpr* arg_call) { call = arg_call; }
|
||||
void ClearCall() { call = nullptr; }
|
||||
const CallExpr* GetCall() const { return call; }
|
||||
void SetCall(const CallExpr* arg_call) { call = arg_call; }
|
||||
void ClearCall() { call = nullptr; }
|
||||
const CallExpr* GetCall() const { return call; }
|
||||
|
||||
void SetCallLoc(const Location* loc) { call_loc = loc; }
|
||||
void SetCallLoc(const Location* loc) { call_loc = loc; }
|
||||
const detail::Location* GetCallLocation() const;
|
||||
|
||||
void SetDelayed() { delayed = true; }
|
||||
bool HasDelayed() const { return delayed; }
|
||||
void SetDelayed() { delayed = true; }
|
||||
bool HasDelayed() const { return delayed; }
|
||||
|
||||
/**
|
||||
* Track a new function that refers to this frame for use as a closure.
|
||||
|
@ -279,15 +277,15 @@ public:
|
|||
void AddFunctionWithClosureRef(ScriptFunc* func);
|
||||
|
||||
private:
|
||||
|
||||
using OffsetMap = std::unordered_map<std::string, int>;
|
||||
|
||||
struct Element {
|
||||
struct Element
|
||||
{
|
||||
ValPtr val;
|
||||
// Weak reference is used to prevent circular reference memory leaks
|
||||
// in lambdas/closures.
|
||||
bool weak_ref;
|
||||
};
|
||||
};
|
||||
|
||||
const ValPtr& GetElementByID(const ID* id) const;
|
||||
|
||||
|
@ -321,20 +319,17 @@ private:
|
|||
bool IsCaptureID(const ID* in) const;
|
||||
|
||||
/** Serializes an offset_map */
|
||||
static broker::expected<broker::data>
|
||||
SerializeOffsetMap(const OffsetMap& in);
|
||||
static broker::expected<broker::data> SerializeOffsetMap(const OffsetMap& in);
|
||||
|
||||
/** Serializes an IDPList */
|
||||
static broker::expected<broker::data>
|
||||
SerializeIDList(const IDPList& in);
|
||||
static broker::expected<broker::data> SerializeIDList(const IDPList& in);
|
||||
|
||||
/** Unserializes an offset map. */
|
||||
static std::pair<bool, std::unordered_map<std::string, int>>
|
||||
UnserializeOffsetMap(const broker::vector& data);
|
||||
|
||||
/** Unserializes an IDPList. */
|
||||
static std::pair<bool, IDPList>
|
||||
UnserializeIDList(const broker::vector& data);
|
||||
static std::pair<bool, IDPList> UnserializeIDList(const broker::vector& data);
|
||||
|
||||
/** The number of vals that can be stored in this frame. */
|
||||
int size;
|
||||
|
@ -392,13 +387,13 @@ private:
|
|||
|
||||
trigger::TriggerPtr trigger;
|
||||
const CallExpr* call = nullptr;
|
||||
const Location* call_loc = nullptr; // only needed if call is nil
|
||||
const Location* call_loc = nullptr; // only needed if call is nil
|
||||
|
||||
std::unique_ptr<std::vector<ScriptFunc*>> functions_with_closure_frame_reference;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace zeek
|
||||
} // namespace detail
|
||||
} // namespace zeek
|
||||
|
||||
/**
|
||||
* If we stopped using this and instead just made a struct of the information
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue