mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 01:28:20 +00:00
Merge remote-tracking branch 'origin/topic/timw/266-namespaces-part2'
* origin/topic/timw/266-namespaces-part2: Rename BroString files to ZeekString Update NEWS entry with note about class renames Rename BroObj to Obj Rename BroString to zeek::String Move Func up to zeek namespace, rename BroFunc to ScriptFunc Mark global val_mgr as deprecated and fix uses of it to use namespaced version Minor cleanup items from PR review Update binpac and bifcl submodules with review changes Move Location to zeek::detail and BroObj to zeek Move BroString to zeek namespace Move Dictionary/PDict, List/PList, and Queue/PQueue to zeek namespace Remove typedef that should have been removed in 3.1 Move Func and associated classes into zeek::detail namespace Move Frame and Scope to zeek::detail namespace Move all Val classes to the zeek namespaces Use type aliases for IntrusivePtr definitions Move deprecation macro to zeek-config.h.in to avoid having to over-include util.h Move IntrusivePtr and utility methods to the zeek namespace
This commit is contained in:
commit
76e67ff239
340 changed files with 8293 additions and 7822 deletions
137
src/Stmt.h
137
src/Stmt.h
|
@ -14,7 +14,8 @@
|
|||
#include "TraverseTypes.h"
|
||||
|
||||
class CompositeHash;
|
||||
class Frame;
|
||||
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
|
||||
|
||||
namespace zeek::detail {
|
||||
|
||||
|
@ -23,15 +24,21 @@ class ForStmt;
|
|||
class EventExpr;
|
||||
class ListExpr;
|
||||
|
||||
class Stmt : public BroObj {
|
||||
using EventExprPtr = zeek::IntrusivePtr<EventExpr>;
|
||||
using ListExprPtr = zeek::IntrusivePtr<ListExpr>;
|
||||
|
||||
class Stmt;
|
||||
using StmtPtr = zeek::IntrusivePtr<Stmt>;
|
||||
|
||||
class Stmt : public Obj {
|
||||
public:
|
||||
BroStmtTag Tag() const { return tag; }
|
||||
|
||||
~Stmt() override;
|
||||
|
||||
virtual IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const = 0;
|
||||
virtual ValPtr Exec(Frame* f, stmt_flow_type& flow) const = 0;
|
||||
|
||||
Stmt* Ref() { ::Ref(this); return this; }
|
||||
Stmt* Ref() { zeek::Ref(this); return this; }
|
||||
|
||||
bool SetLocationInfo(const Location* loc) override
|
||||
{ return Stmt::SetLocationInfo(loc, loc); }
|
||||
|
@ -80,17 +87,17 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
protected:
|
||||
ExprListStmt(BroStmtTag t, IntrusivePtr<ListExpr> arg_l);
|
||||
ExprListStmt(BroStmtTag t, ListExprPtr arg_l);
|
||||
|
||||
~ExprListStmt() override;
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
virtual IntrusivePtr<Val> DoExec(std::vector<IntrusivePtr<Val>> vals,
|
||||
stmt_flow_type& flow) const = 0;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
virtual ValPtr DoExec(std::vector<ValPtr> vals,
|
||||
stmt_flow_type& flow) const = 0;
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
||||
IntrusivePtr<ListExpr> l;
|
||||
ListExprPtr l;
|
||||
};
|
||||
|
||||
class PrintStmt final : public ExprListStmt {
|
||||
|
@ -99,16 +106,16 @@ public:
|
|||
explicit PrintStmt(L&& l) : ExprListStmt(STMT_PRINT, std::forward<L>(l)) { }
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> DoExec(std::vector<IntrusivePtr<Val>> vals,
|
||||
stmt_flow_type& flow) const override;
|
||||
ValPtr DoExec(std::vector<ValPtr> vals,
|
||||
stmt_flow_type& flow) const override;
|
||||
};
|
||||
|
||||
class ExprStmt : public Stmt {
|
||||
public:
|
||||
explicit ExprStmt(IntrusivePtr<Expr> e);
|
||||
explicit ExprStmt(ExprPtr e);
|
||||
~ExprStmt() override;
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
|
||||
const Expr* StmtExpr() const { return e.get(); }
|
||||
|
||||
|
@ -117,18 +124,18 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
protected:
|
||||
ExprStmt(BroStmtTag t, IntrusivePtr<Expr> e);
|
||||
ExprStmt(BroStmtTag t, ExprPtr e);
|
||||
|
||||
virtual IntrusivePtr<Val> DoExec(Frame* f, Val* v, stmt_flow_type& flow) const;
|
||||
virtual ValPtr DoExec(Frame* f, Val* v, stmt_flow_type& flow) const;
|
||||
|
||||
bool IsPure() const override;
|
||||
|
||||
IntrusivePtr<Expr> e;
|
||||
ExprPtr e;
|
||||
};
|
||||
|
||||
class IfStmt final : public ExprStmt {
|
||||
public:
|
||||
IfStmt(IntrusivePtr<Expr> test, IntrusivePtr<Stmt> s1, IntrusivePtr<Stmt> s2);
|
||||
IfStmt(ExprPtr test, StmtPtr s1, StmtPtr s2);
|
||||
~IfStmt() override;
|
||||
|
||||
const Stmt* TrueBranch() const { return s1.get(); }
|
||||
|
@ -139,16 +146,16 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> DoExec(Frame* f, Val* v, stmt_flow_type& flow) const override;
|
||||
ValPtr DoExec(Frame* f, Val* v, stmt_flow_type& flow) const override;
|
||||
bool IsPure() const override;
|
||||
|
||||
IntrusivePtr<Stmt> s1;
|
||||
IntrusivePtr<Stmt> s2;
|
||||
StmtPtr s1;
|
||||
StmtPtr s2;
|
||||
};
|
||||
|
||||
class Case final : public BroObj {
|
||||
class Case final : public Obj {
|
||||
public:
|
||||
Case(IntrusivePtr<ListExpr> c, id_list* types, IntrusivePtr<Stmt> arg_s);
|
||||
Case(ListExprPtr c, id_list* types, StmtPtr arg_s);
|
||||
~Case() override;
|
||||
|
||||
const ListExpr* ExprCases() const { return expr_cases.get(); }
|
||||
|
@ -165,16 +172,16 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<ListExpr> expr_cases;
|
||||
ListExprPtr expr_cases;
|
||||
id_list* type_cases;
|
||||
IntrusivePtr<Stmt> s;
|
||||
StmtPtr s;
|
||||
};
|
||||
|
||||
using case_list = PList<Case>;
|
||||
using case_list = zeek::PList<Case>;
|
||||
|
||||
class SwitchStmt final : public ExprStmt {
|
||||
public:
|
||||
SwitchStmt(IntrusivePtr<Expr> index, case_list* cases);
|
||||
SwitchStmt(ExprPtr index, case_list* cases);
|
||||
~SwitchStmt() override;
|
||||
|
||||
const case_list* Cases() const { return cases; }
|
||||
|
@ -184,7 +191,7 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> DoExec(Frame* f, Val* v, stmt_flow_type& flow) const override;
|
||||
ValPtr DoExec(Frame* f, Val* v, stmt_flow_type& flow) const override;
|
||||
bool IsPure() const override;
|
||||
|
||||
// Initialize composite hash and case label map.
|
||||
|
@ -209,46 +216,46 @@ protected:
|
|||
case_list* cases;
|
||||
int default_case_idx;
|
||||
CompositeHash* comp_hash;
|
||||
PDict<int> case_label_value_map;
|
||||
zeek::PDict<int> case_label_value_map;
|
||||
std::vector<std::pair<ID*, int>> case_label_type_list;
|
||||
};
|
||||
|
||||
class AddStmt final : public ExprStmt {
|
||||
public:
|
||||
explicit AddStmt(IntrusivePtr<Expr> e);
|
||||
explicit AddStmt(ExprPtr e);
|
||||
|
||||
bool IsPure() const override;
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
|
||||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
};
|
||||
|
||||
class DelStmt final : public ExprStmt {
|
||||
public:
|
||||
explicit DelStmt(IntrusivePtr<Expr> e);
|
||||
explicit DelStmt(ExprPtr e);
|
||||
|
||||
bool IsPure() const override;
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
|
||||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
};
|
||||
|
||||
class EventStmt final : public ExprStmt {
|
||||
public:
|
||||
explicit EventStmt(IntrusivePtr<EventExpr> e);
|
||||
explicit EventStmt(EventExprPtr e);
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
|
||||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<EventExpr> event_expr;
|
||||
EventExprPtr event_expr;
|
||||
};
|
||||
|
||||
class WhileStmt final : public Stmt {
|
||||
public:
|
||||
|
||||
WhileStmt(IntrusivePtr<Expr> loop_condition, IntrusivePtr<Stmt> body);
|
||||
WhileStmt(ExprPtr loop_condition, StmtPtr body);
|
||||
~WhileStmt() override;
|
||||
|
||||
bool IsPure() const override;
|
||||
|
@ -258,20 +265,20 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
|
||||
IntrusivePtr<Expr> loop_condition;
|
||||
IntrusivePtr<Stmt> body;
|
||||
ExprPtr loop_condition;
|
||||
StmtPtr body;
|
||||
};
|
||||
|
||||
class ForStmt final : public ExprStmt {
|
||||
public:
|
||||
ForStmt(id_list* loop_vars, IntrusivePtr<Expr> loop_expr);
|
||||
ForStmt(id_list* loop_vars, ExprPtr loop_expr);
|
||||
// Special constructor for key value for loop.
|
||||
ForStmt(id_list* loop_vars, IntrusivePtr<Expr> loop_expr, IntrusivePtr<ID> val_var);
|
||||
ForStmt(id_list* loop_vars, ExprPtr loop_expr, IDPtr val_var);
|
||||
~ForStmt() override;
|
||||
|
||||
void AddBody(IntrusivePtr<Stmt> arg_body) { body = std::move(arg_body); }
|
||||
void AddBody(StmtPtr arg_body) { body = std::move(arg_body); }
|
||||
|
||||
const id_list* LoopVar() const { return loop_vars; }
|
||||
const Expr* LoopExpr() const { return e.get(); }
|
||||
|
@ -284,20 +291,20 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Val> DoExec(Frame* f, Val* v, stmt_flow_type& flow) const override;
|
||||
ValPtr DoExec(Frame* f, Val* v, stmt_flow_type& flow) const override;
|
||||
|
||||
id_list* loop_vars;
|
||||
IntrusivePtr<Stmt> body;
|
||||
StmtPtr body;
|
||||
// Stores the value variable being used for a key value for loop.
|
||||
// Always set to nullptr unless special constructor is called.
|
||||
IntrusivePtr<ID> value_var;
|
||||
IDPtr value_var;
|
||||
};
|
||||
|
||||
class NextStmt final : public Stmt {
|
||||
public:
|
||||
NextStmt() : Stmt(STMT_NEXT) { }
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
bool IsPure() const override;
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
@ -311,7 +318,7 @@ class BreakStmt final : public Stmt {
|
|||
public:
|
||||
BreakStmt() : Stmt(STMT_BREAK) { }
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
bool IsPure() const override;
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
@ -325,7 +332,7 @@ class FallthroughStmt final : public Stmt {
|
|||
public:
|
||||
FallthroughStmt() : Stmt(STMT_FALLTHROUGH) { }
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
bool IsPure() const override;
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
@ -337,9 +344,9 @@ protected:
|
|||
|
||||
class ReturnStmt final : public ExprStmt {
|
||||
public:
|
||||
explicit ReturnStmt(IntrusivePtr<Expr> e);
|
||||
explicit ReturnStmt(ExprPtr e);
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
};
|
||||
|
@ -349,7 +356,7 @@ public:
|
|||
StmtList();
|
||||
~StmtList() override;
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
|
||||
const stmt_list& Stmts() const { return stmts; }
|
||||
stmt_list& Stmts() { return stmts; }
|
||||
|
@ -369,7 +376,7 @@ public:
|
|||
EventBodyList() : StmtList()
|
||||
{ topmost = false; tag = STMT_EVENT_BODY_LIST; }
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
||||
|
@ -383,11 +390,11 @@ protected:
|
|||
|
||||
class InitStmt final : public Stmt {
|
||||
public:
|
||||
explicit InitStmt(std::vector<IntrusivePtr<ID>> arg_inits);
|
||||
explicit InitStmt(std::vector<IDPtr> arg_inits);
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
|
||||
const std::vector<IntrusivePtr<ID>>& Inits() const
|
||||
const std::vector<IDPtr>& Inits() const
|
||||
{ return inits; }
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
@ -395,14 +402,14 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
protected:
|
||||
std::vector<IntrusivePtr<ID>> inits;
|
||||
std::vector<IDPtr> inits;
|
||||
};
|
||||
|
||||
class NullStmt final : public Stmt {
|
||||
public:
|
||||
NullStmt() : Stmt(STMT_NULL) { }
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
bool IsPure() const override;
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
@ -413,12 +420,12 @@ public:
|
|||
class WhenStmt final : public Stmt {
|
||||
public:
|
||||
// s2 is null if no timeout block given.
|
||||
WhenStmt(IntrusivePtr<Expr> cond,
|
||||
IntrusivePtr<Stmt> s1, IntrusivePtr<Stmt> s2,
|
||||
IntrusivePtr<Expr> timeout, bool is_return);
|
||||
WhenStmt(ExprPtr cond,
|
||||
StmtPtr s1, StmtPtr s2,
|
||||
ExprPtr timeout, bool is_return);
|
||||
~WhenStmt() override;
|
||||
|
||||
IntrusivePtr<Val> Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
ValPtr Exec(Frame* f, stmt_flow_type& flow) const override;
|
||||
bool IsPure() const override;
|
||||
|
||||
const Expr* Cond() const { return cond.get(); }
|
||||
|
@ -431,10 +438,10 @@ public:
|
|||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
protected:
|
||||
IntrusivePtr<Expr> cond;
|
||||
IntrusivePtr<Stmt> s1;
|
||||
IntrusivePtr<Stmt> s2;
|
||||
IntrusivePtr<Expr> timeout;
|
||||
ExprPtr cond;
|
||||
StmtPtr s1;
|
||||
StmtPtr s2;
|
||||
ExprPtr timeout;
|
||||
bool is_return;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue