Stmt: move Stmt classes into zeek::detail namespace

This commit is contained in:
Tim Wojtulewicz 2020-05-07 11:07:18 -07:00
parent f952acaddc
commit 3fa4acc175
23 changed files with 177 additions and 132 deletions

View file

@ -13,8 +13,8 @@ typedef PList<ID> id_list;
class Val; class Val;
typedef PList<Val> val_list; typedef PList<Val> val_list;
class Stmt; FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
typedef PList<Stmt> stmt_list; typedef PList<zeek::detail::Stmt> stmt_list;
class BroType; class BroType;
typedef PList<BroType> type_list; typedef PList<BroType> type_list;

View file

@ -26,7 +26,7 @@ Brofiler::~Brofiler()
Unref(s); Unref(s);
} }
void Brofiler::AddStmt(Stmt* s) void Brofiler::AddStmt(zeek::detail::Stmt* s)
{ {
if ( ignoring != 0 ) if ( ignoring != 0 )
return; return;
@ -127,7 +127,7 @@ bool Brofiler::WriteStats()
return false; return false;
} }
for ( list<Stmt*>::const_iterator it = stmts.begin(); for ( list<zeek::detail::Stmt*>::const_iterator it = stmts.begin();
it != stmts.end(); ++it ) it != stmts.end(); ++it )
{ {
ODesc location_info; ODesc location_info;
@ -154,4 +154,3 @@ bool Brofiler::WriteStats()
fclose(f); fclose(f);
return true; return true;
} }

View file

@ -5,7 +5,8 @@
#include <list> #include <list>
#include <string> #include <string>
class Stmt; #include "util.h"
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
/** /**
* A simple class for managing stats of Bro script coverage across Bro runs. * A simple class for managing stats of Bro script coverage across Bro runs.
@ -39,13 +40,13 @@ public:
void IncIgnoreDepth() { ignoring++; } void IncIgnoreDepth() { ignoring++; }
void DecIgnoreDepth() { ignoring--; } void DecIgnoreDepth() { ignoring--; }
void AddStmt(Stmt* s); void AddStmt(zeek::detail::Stmt* s);
private: private:
/** /**
* The current, global Brofiler instance creates this list at parse-time. * The current, global Brofiler instance creates this list at parse-time.
*/ */
std::list<Stmt*> stmts; std::list<zeek::detail::Stmt*> stmts;
/** /**
* Indicates whether new statments will not be considered as part of * Indicates whether new statments will not be considered as part of

View file

@ -166,7 +166,7 @@ bool DbgBreakpoint::SetLocation(ParseLocationRec plr, std::string_view loc_str)
return true; return true;
} }
bool DbgBreakpoint::SetLocation(Stmt* stmt) bool DbgBreakpoint::SetLocation(zeek::detail::Stmt* stmt)
{ {
if ( ! stmt ) if ( ! stmt )
return false; return false;
@ -290,7 +290,7 @@ BreakCode DbgBreakpoint::HasHit()
return bcHit; return bcHit;
} }
BreakCode DbgBreakpoint::ShouldBreak(Stmt* s) BreakCode DbgBreakpoint::ShouldBreak(zeek::detail::Stmt* s)
{ {
if ( ! IsEnabled() ) if ( ! IsEnabled() )
return bcNoHit; return bcNoHit;

View file

@ -3,9 +3,11 @@
#pragma once #pragma once
#include <string> #include <string>
#include "util.h"
struct ParseLocationRec; struct ParseLocationRec;
class Stmt;
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
enum BreakCode { bcNoHit, bcHit, bcHitAndDelete }; enum BreakCode { bcNoHit, bcHit, bcHitAndDelete };
class DbgBreakpoint { class DbgBreakpoint {
@ -20,7 +22,7 @@ public:
// True if breakpoint could be set; false otherwise // True if breakpoint could be set; false otherwise
bool SetLocation(ParseLocationRec plr, std::string_view loc_str); bool SetLocation(ParseLocationRec plr, std::string_view loc_str);
bool SetLocation(Stmt* stmt); bool SetLocation(zeek::detail::Stmt* stmt);
bool SetLocation(double time); bool SetLocation(double time);
bool Reset(); // cancel and re-apply bpt when restarting execution bool Reset(); // cancel and re-apply bpt when restarting execution
@ -35,7 +37,7 @@ public:
// //
// NOTE: If it returns a hit, the DbgBreakpoint object will take // NOTE: If it returns a hit, the DbgBreakpoint object will take
// appropriate action (e.g., resetting counters). // appropriate action (e.g., resetting counters).
BreakCode ShouldBreak(Stmt* s); BreakCode ShouldBreak(zeek::detail::Stmt* s);
BreakCode ShouldBreak(double t); BreakCode ShouldBreak(double t);
const std::string& GetCondition() const { return condition; } const std::string& GetCondition() const { return condition; }
@ -70,7 +72,7 @@ protected:
bool enabled; // ### comment this and next bool enabled; // ### comment this and next
bool temporary; bool temporary;
Stmt* at_stmt; zeek::detail::Stmt* at_stmt;
double at_time; // break when the virtual time is this double at_time; // break when the virtual time is this
// Support for conditional and N'th time breakpoints. // Support for conditional and N'th time breakpoints.

View file

@ -135,7 +135,7 @@ int TraceState::LogTrace(const char* fmt, ...)
// Prefix includes timestamp and file/line info. // Prefix includes timestamp and file/line info.
fprintf(trace_file, "%.6f ", network_time); fprintf(trace_file, "%.6f ", network_time);
const Stmt* stmt; const zeek::detail::Stmt* stmt;
Location loc; Location loc;
loc.filename = nullptr; loc.filename = nullptr;
@ -174,7 +174,7 @@ int TraceState::LogTrace(const char* fmt, ...)
// Helper functions. // Helper functions.
void get_first_statement(Stmt* list, Stmt*& first, Location& loc) void get_first_statement(zeek::detail::Stmt* list, zeek::detail::Stmt*& first, Location& loc)
{ {
if ( ! list ) if ( ! list )
{ {
@ -231,7 +231,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
return; return;
} }
Stmt* body = nullptr; // the particular body we care about; 0 = all zeek::detail::Stmt* body = nullptr; // the particular body we care about; 0 = all
if ( bodies.size() == 1 ) if ( bodies.size() == 1 )
body = bodies[0].stmts.get(); body = bodies[0].stmts.get();
@ -243,7 +243,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
"Please choose one of the following options:\n"); "Please choose one of the following options:\n");
for ( unsigned int i = 0; i < bodies.size(); ++i ) for ( unsigned int i = 0; i < bodies.size(); ++i )
{ {
Stmt* first; zeek::detail::Stmt* first;
Location stmt_loc; Location stmt_loc;
get_first_statement(bodies[i].stmts.get(), first, stmt_loc); get_first_statement(bodies[i].stmts.get(), first, stmt_loc);
debug_msg("[%d] %s:%d\n", i+1, stmt_loc.filename, stmt_loc.first_line); debug_msg("[%d] %s:%d\n", i+1, stmt_loc.filename, stmt_loc.first_line);
@ -286,7 +286,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
plr.type = plrFunction; plr.type = plrFunction;
// Find first atomic (non-STMT_LIST) statement // Find first atomic (non-STMT_LIST) statement
Stmt* first; zeek::detail::Stmt* first;
Location stmt_loc; Location stmt_loc;
if ( body ) if ( body )
@ -728,7 +728,7 @@ static char* get_prompt(bool reset_counter = false)
return prompt; return prompt;
} }
string get_context_description(const Stmt* stmt, const Frame* frame) string get_context_description(const zeek::detail::Stmt* stmt, const Frame* frame)
{ {
ODesc d; ODesc d;
const BroFunc* func = frame ? frame->GetFunction() : nullptr; const BroFunc* func = frame ? frame->GetFunction() : nullptr;
@ -776,7 +776,7 @@ int dbg_handle_debug_input()
else else
current_module = GLOBAL_MODULE_NAME; current_module = GLOBAL_MODULE_NAME;
const Stmt* stmt = curr_frame->GetNextStmt(); const zeek::detail::Stmt* stmt = curr_frame->GetNextStmt();
if ( ! stmt ) if ( ! stmt )
reporter->InternalError("Assertion failed: stmt != 0"); reporter->InternalError("Assertion failed: stmt != 0");
@ -840,7 +840,7 @@ int dbg_handle_debug_input()
// Return true to continue execution, false to abort. // Return true to continue execution, false to abort.
bool pre_execute_stmt(Stmt* stmt, Frame* f) bool pre_execute_stmt(zeek::detail::Stmt* stmt, Frame* f)
{ {
if ( ! g_policy_debug || if ( ! g_policy_debug ||
stmt->Tag() == STMT_LIST || stmt->Tag() == STMT_NULL ) stmt->Tag() == STMT_LIST || stmt->Tag() == STMT_NULL )
@ -905,7 +905,7 @@ bool pre_execute_stmt(Stmt* stmt, Frame* f)
return true; return true;
} }
bool post_execute_stmt(Stmt* stmt, Frame* f, Val* result, stmt_flow_type* flow) bool post_execute_stmt(zeek::detail::Stmt* stmt, Frame* f, Val* result, stmt_flow_type* flow)
{ {
// Handle the case where someone issues a "next" debugger command, // Handle the case where someone issues a "next" debugger command,
// but we're at a return statement, so the next statement is in // but we're at a return statement, so the next statement is in

View file

@ -5,6 +5,7 @@
#include "Obj.h" #include "Obj.h"
#include "Queue.h" #include "Queue.h"
#include "StmtEnums.h" #include "StmtEnums.h"
#include "util.h"
#include <vector> #include <vector>
#include <map> #include <map>
@ -12,14 +13,15 @@
template <class T> class IntrusivePtr; template <class T> class IntrusivePtr;
class Val; class Val;
class Stmt;
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
// This needs to be defined before we do the includes that come after it. // This needs to be defined before we do the includes that come after it.
enum ParseLocationRecType { plrUnknown, plrFileAndLine, plrFunction }; enum ParseLocationRecType { plrUnknown, plrFileAndLine, plrFunction };
struct ParseLocationRec { struct ParseLocationRec {
ParseLocationRecType type; ParseLocationRecType type;
int32_t line; int32_t line;
Stmt* stmt; zeek::detail::Stmt* stmt;
const char* filename; const char* filename;
}; };
@ -33,7 +35,7 @@ class DbgDisplay;
class StmtHashFn; class StmtHashFn;
typedef std::map<int, DbgBreakpoint*> BPIDMapType; typedef std::map<int, DbgBreakpoint*> BPIDMapType;
typedef std::multimap<const Stmt*, DbgBreakpoint*> BPMapType; typedef std::multimap<const zeek::detail::Stmt*, DbgBreakpoint*> BPMapType;
extern std::string current_module; extern std::string current_module;
@ -104,15 +106,15 @@ private:
class StmtLocMapping { class StmtLocMapping {
public: public:
StmtLocMapping() { } StmtLocMapping() { }
StmtLocMapping(const Location* l, Stmt* s) { loc = *l; stmt = s; } StmtLocMapping(const Location* l, zeek::detail::Stmt* s) { loc = *l; stmt = s; }
bool StartsAfter(const StmtLocMapping* m2); bool StartsAfter(const StmtLocMapping* m2);
const Location& Loc() const { return loc; } const Location& Loc() const { return loc; }
Stmt* Statement() const { return stmt; } zeek::detail::Stmt* Statement() const { return stmt; }
protected: protected:
Location loc; Location loc;
Stmt* stmt; zeek::detail::Stmt* stmt;
}; };
@ -143,8 +145,8 @@ std::vector<ParseLocationRec> parse_location_string(const std::string& s);
// Debugging hooks. // Debugging hooks.
// Return true to continue execution, false to abort. // Return true to continue execution, false to abort.
bool pre_execute_stmt(Stmt* stmt, Frame* f); bool pre_execute_stmt(zeek::detail::Stmt* stmt, Frame* f);
bool post_execute_stmt(Stmt* stmt, Frame* f, Val* result, stmt_flow_type* flow); bool post_execute_stmt(zeek::detail::Stmt* stmt, Frame* f, Val* result, stmt_flow_type* flow);
// Returns 1 if successful, 0 otherwise. // Returns 1 if successful, 0 otherwise.
// If cmdfile is non-nil, it contains the location of a file of commands // If cmdfile is non-nil, it contains the location of a file of commands
@ -168,7 +170,7 @@ IntrusivePtr<Val> dbg_eval_expr(const char* expr);
int dbg_read_internal_state(); int dbg_read_internal_state();
// Get line that looks like "In FnFoo(arg = val) at File:Line". // Get line that looks like "In FnFoo(arg = val) at File:Line".
std::string get_context_description(const Stmt* stmt, const Frame* frame); std::string get_context_description(const zeek::detail::Stmt* stmt, const Frame* frame);
extern Frame* g_dbg_locals; // variables created within debugger context extern Frame* g_dbg_locals; // variables created within debugger context

View file

@ -216,7 +216,7 @@ static int dbg_backtrace_internal(int start, int end)
for ( int i = start; i >= end; --i ) for ( int i = start; i >= end; --i )
{ {
const Frame* f = g_frame_stack[i]; const Frame* f = g_frame_stack[i];
const Stmt* stmt = f ? f->GetNextStmt() : nullptr; const zeek::detail::Stmt* stmt = f ? f->GetNextStmt() : nullptr;
string context = get_context_description(stmt, f); string context = get_context_description(stmt, f);
debug_msg("#%d %s\n", debug_msg("#%d %s\n",
@ -333,7 +333,7 @@ int dbg_cmd_frame(DebugCmd cmd, const vector<string>& args)
// Set the current location to the new frame being looked at // Set the current location to the new frame being looked at
// for 'list', 'break', etc. // for 'list', 'break', etc.
const Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt(); const zeek::detail::Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt();
if ( ! stmt ) if ( ! stmt )
reporter->InternalError("Assertion failed: %s", "stmt != 0"); reporter->InternalError("Assertion failed: %s", "stmt != 0");
@ -373,7 +373,7 @@ int dbg_cmd_break(DebugCmd cmd, const vector<string>& args)
g_frame_stack.size() - 1 - g_frame_stack.size() - 1 -
g_debugger_state.curr_frame_idx; g_debugger_state.curr_frame_idx;
Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt(); zeek::detail::Stmt* stmt = g_frame_stack[user_frame_number]->GetNextStmt();
if ( ! stmt ) if ( ! stmt )
reporter->InternalError("Assertion failed: %s", "stmt != 0"); reporter->InternalError("Assertion failed: %s", "stmt != 0");

View file

@ -59,7 +59,6 @@ enum BroExprTag : int {
extern const char* expr_name(BroExprTag t); extern const char* expr_name(BroExprTag t);
template <class T> class IntrusivePtr; template <class T> class IntrusivePtr;
class Stmt;
class Frame; class Frame;
class Scope; class Scope;
class ListExpr; class ListExpr;
@ -71,6 +70,7 @@ class EventExpr;
struct function_ingredients; struct function_ingredients;
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
class Expr : public BroObj { class Expr : public BroObj {
public: public:

View file

@ -2,9 +2,6 @@
#pragma once #pragma once
#include "Obj.h"
#include "IntrusivePtr.h"
#include <list> #include <list>
#include <string> #include <string>
#include <utility> #include <utility>
@ -15,10 +12,16 @@
#include <krb5.h> #include <krb5.h>
#endif // NEED_KRB5_H #endif // NEED_KRB5_H
#include "Obj.h"
#include "IntrusivePtr.h"
#include "util.h"
class Attributes; class Attributes;
class BroType; class BroType;
class RecordVal; class RecordVal;
FORWARD_DECLARE_NAMESPACED(PrintStmt, zeek::detail);
class BroFile final : public BroObj { class BroFile final : public BroObj {
public: public:
explicit BroFile(FILE* arg_f); explicit BroFile(FILE* arg_f);
@ -77,7 +80,7 @@ public:
protected: protected:
friend class PrintStmt; friend class zeek::detail::PrintStmt;
BroFile() { Init(); } BroFile() { Init(); }
void Init(); void Init();

View file

@ -118,12 +118,12 @@ public:
* *
* @param stmt the statement to set it to. * @param stmt the statement to set it to.
*/ */
void SetNextStmt(Stmt* stmt) { next_stmt = stmt; } void SetNextStmt(zeek::detail::Stmt* stmt) { next_stmt = stmt; }
/** /**
* @return the next statement to be executed in the context of the frame. * @return the next statement to be executed in the context of the frame.
*/ */
Stmt* GetNextStmt() const { return next_stmt; } zeek::detail::Stmt* GetNextStmt() const { return next_stmt; }
/** Used to implement "next" command in debugger. */ /** Used to implement "next" command in debugger. */
void BreakBeforeNextStmt(bool should_break) void BreakBeforeNextStmt(bool should_break)
@ -319,7 +319,7 @@ private:
const zeek::Args* func_args; const zeek::Args* func_args;
/** The next statement to be evaluted in the context of this frame. */ /** The next statement to be evaluted in the context of this frame. */
Stmt* next_stmt; zeek::detail::Stmt* next_stmt;
IntrusivePtr<trigger::Trigger> trigger; IntrusivePtr<trigger::Trigger> trigger;
const CallExpr* call; const CallExpr* call;

View file

@ -121,7 +121,7 @@ Func::Func(Kind arg_kind) : kind(arg_kind)
Func::~Func() = default; Func::~Func() = default;
void Func::AddBody(IntrusivePtr<Stmt> /* new_body */, void Func::AddBody(IntrusivePtr<zeek::detail::Stmt> /* new_body */,
const std::vector<IntrusivePtr<ID>>& /* new_inits */, const std::vector<IntrusivePtr<ID>>& /* new_inits */,
size_t /* new_frame_size */, int /* priority */) size_t /* new_frame_size */, int /* priority */)
{ {
@ -268,7 +268,7 @@ void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
} }
} }
BroFunc::BroFunc(const IntrusivePtr<ID>& arg_id, IntrusivePtr<Stmt> arg_body, BroFunc::BroFunc(const IntrusivePtr<ID>& arg_id, IntrusivePtr<zeek::detail::Stmt> arg_body,
const std::vector<IntrusivePtr<ID>>& aggr_inits, const std::vector<IntrusivePtr<ID>>& aggr_inits,
size_t arg_frame_size, int priority) size_t arg_frame_size, int priority)
: Func(BRO_FUNC) : Func(BRO_FUNC)
@ -449,7 +449,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
return result; return result;
} }
void BroFunc::AddBody(IntrusivePtr<Stmt> new_body, void BroFunc::AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
const std::vector<IntrusivePtr<ID>>& new_inits, const std::vector<IntrusivePtr<ID>>& new_inits,
size_t new_frame_size, int priority) size_t new_frame_size, int priority)
{ {
@ -574,14 +574,14 @@ void BroFunc::Describe(ODesc* d) const
} }
} }
IntrusivePtr<Stmt> BroFunc::AddInits(IntrusivePtr<Stmt> body, IntrusivePtr<zeek::detail::Stmt> BroFunc::AddInits(IntrusivePtr<zeek::detail::Stmt> body,
const std::vector<IntrusivePtr<ID>>& inits) const std::vector<IntrusivePtr<ID>>& inits)
{ {
if ( inits.empty() ) if ( inits.empty() )
return body; return body;
auto stmt_series = make_intrusive<StmtList>(); auto stmt_series = make_intrusive<zeek::detail::StmtList>();
stmt_series->Stmts().push_back(new InitStmt(inits)); stmt_series->Stmts().push_back(new zeek::detail::InitStmt(inits));
stmt_series->Stmts().push_back(body.release()); stmt_series->Stmts().push_back(body.release());
return stmt_series; return stmt_series;
@ -879,7 +879,7 @@ static int get_func_priority(const std::vector<IntrusivePtr<Attr>>& attrs)
return priority; return priority;
} }
function_ingredients::function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<Stmt> body) function_ingredients::function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<zeek::detail::Stmt> body)
{ {
frame_size = scope->Length(); frame_size = scope->Length();
inits = scope->GetInits(); inits = scope->GetInits();

View file

@ -22,12 +22,13 @@
class Val; class Val;
class ListExpr; class ListExpr;
class FuncType; class FuncType;
class Stmt;
class Frame; class Frame;
class ID; class ID;
class CallExpr; class CallExpr;
class Scope; class Scope;
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
class Func : public BroObj { class Func : public BroObj {
public: public:
static inline const IntrusivePtr<Func> nil; static inline const IntrusivePtr<Func> nil;
@ -42,7 +43,7 @@ public:
function_flavor Flavor() const { return GetType()->Flavor(); } function_flavor Flavor() const { return GetType()->Flavor(); }
struct Body { struct Body {
IntrusivePtr<Stmt> stmts; IntrusivePtr<zeek::detail::Stmt> stmts;
int priority; int priority;
bool operator<(const Body& other) const bool operator<(const Body& other) const
{ return priority > other.priority; } // reverse sort { return priority > other.priority; } // reverse sort
@ -78,7 +79,7 @@ public:
} }
// Add a new event handler to an existing function (event). // Add a new event handler to an existing function (event).
virtual void AddBody(IntrusivePtr<Stmt> new_body, virtual void AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
const std::vector<IntrusivePtr<ID>>& new_inits, const std::vector<IntrusivePtr<ID>>& new_inits,
size_t new_frame_size, int priority = 0); size_t new_frame_size, int priority = 0);
@ -129,7 +130,7 @@ protected:
class BroFunc final : public Func { class BroFunc final : public Func {
public: public:
BroFunc(const IntrusivePtr<ID>& id, IntrusivePtr<Stmt> body, BroFunc(const IntrusivePtr<ID>& id, IntrusivePtr<zeek::detail::Stmt> body,
const std::vector<IntrusivePtr<ID>>& inits, const std::vector<IntrusivePtr<ID>>& inits,
size_t frame_size, int priority); size_t frame_size, int priority);
@ -167,7 +168,7 @@ public:
*/ */
broker::expected<broker::data> SerializeClosure() const; broker::expected<broker::data> SerializeClosure() const;
void AddBody(IntrusivePtr<Stmt> new_body, void AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
const std::vector<IntrusivePtr<ID>>& new_inits, const std::vector<IntrusivePtr<ID>>& new_inits,
size_t new_frame_size, int priority) override; size_t new_frame_size, int priority) override;
@ -179,7 +180,7 @@ public:
protected: protected:
BroFunc() : Func(BRO_FUNC) {} BroFunc() : Func(BRO_FUNC) {}
IntrusivePtr<Stmt> AddInits(IntrusivePtr<Stmt> body, IntrusivePtr<zeek::detail::Stmt> AddInits(IntrusivePtr<zeek::detail::Stmt> body,
const std::vector<IntrusivePtr<ID>>& inits); const std::vector<IntrusivePtr<ID>>& inits);
/** /**
@ -267,10 +268,10 @@ struct function_ingredients {
// Gathers all of the information from a scope and a function body needed // Gathers all of the information from a scope and a function body needed
// to build a function. // to build a function.
function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<Stmt> body); function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<zeek::detail::Stmt> body);
IntrusivePtr<ID> id; IntrusivePtr<ID> id;
IntrusivePtr<Stmt> body; IntrusivePtr<zeek::detail::Stmt> body;
std::vector<IntrusivePtr<ID>> inits; std::vector<IntrusivePtr<ID>> inits;
int frame_size; int frame_size;
int priority; int priority;

View file

@ -2,6 +2,8 @@
#include "zeek-config.h" #include "zeek-config.h"
#include "Stmt.h"
#include "CompHash.h" #include "CompHash.h"
#include "Expr.h" #include "Expr.h"
#include "Event.h" #include "Event.h"
@ -9,7 +11,6 @@
#include "File.h" #include "File.h"
#include "Reporter.h" #include "Reporter.h"
#include "NetVar.h" #include "NetVar.h"
#include "Stmt.h"
#include "Scope.h" #include "Scope.h"
#include "Var.h" #include "Var.h"
#include "Desc.h" #include "Desc.h"
@ -34,6 +35,8 @@ const char* stmt_name(BroStmtTag t)
return stmt_names[int(t)]; return stmt_names[int(t)];
} }
namespace zeek::detail {
Stmt::Stmt(BroStmtTag arg_tag) Stmt::Stmt(BroStmtTag arg_tag)
{ {
tag = arg_tag; tag = arg_tag;
@ -1833,3 +1836,5 @@ TraversalCode WhenStmt::Traverse(TraversalCallback* cb) const
tc = cb->PostStmt(this); tc = cb->PostStmt(this);
HANDLE_TC_STMT_POST(tc); HANDLE_TC_STMT_POST(tc);
} }
}

View file

@ -13,13 +13,16 @@
#include "TraverseTypes.h" #include "TraverseTypes.h"
class StmtList;
class CompositeHash; class CompositeHash;
class EventExpr; class EventExpr;
class ListExpr; class ListExpr;
class ForStmt;
class Frame; class Frame;
namespace zeek::detail {
class StmtList;
class ForStmt;
class Stmt : public BroObj { class Stmt : public BroObj {
public: public:
BroStmtTag Tag() const { return tag; } BroStmtTag Tag() const { return tag; }
@ -447,3 +450,27 @@ protected:
IntrusivePtr<Expr> timeout; IntrusivePtr<Expr> timeout;
bool is_return; bool is_return;
}; };
}
using Stmt [[deprecated("Remove in v4.1. Use zeek::detail::Stmt instead.")]] = zeek::detail::Stmt;
using ExprListStmt [[deprecated("Remove in v4.1. Use zeek::detail::ExprListStmt instead.")]] = zeek::detail::ExprListStmt;
using PrintStmt [[deprecated("Remove in v4.1. Use zeek::detail::PrintStmt instead.")]] = zeek::detail::PrintStmt;
using ExprStmt [[deprecated("Remove in v4.1. Use zeek::detail::ExprStmt instead.")]] = zeek::detail::ExprStmt;
using IfStmt [[deprecated("Remove in v4.1. Use zeek::detail::IfStmt instead.")]] = zeek::detail::IfStmt;
using Case [[deprecated("Remove in v4.1. Use zeek::detail::Case instead.")]] = zeek::detail::Case;
using SwitchStmt [[deprecated("Remove in v4.1. Use zeek::detail::SwitchStmt instead.")]] = zeek::detail::SwitchStmt;
using AddStmt [[deprecated("Remove in v4.1. Use zeek::detail::AddStmt instead.")]] = zeek::detail::AddStmt;
using DelStmt [[deprecated("Remove in v4.1. Use zeek::detail::DelStmt instead.")]] = zeek::detail::DelStmt;
using EventStmt [[deprecated("Remove in v4.1. Use zeek::detail::EventStmt instead.")]] = zeek::detail::EventStmt;
using WhileStmt [[deprecated("Remove in v4.1. Use zeek::detail::WhileStmt instead.")]] = zeek::detail::WhileStmt;
using ForStmt [[deprecated("Remove in v4.1. Use zeek::detail::ForStmt instead.")]] = zeek::detail::ForStmt;
using NextStmt [[deprecated("Remove in v4.1. Use zeek::detail::NextStmt instead.")]] = zeek::detail::NextStmt;
using BreakStmt [[deprecated("Remove in v4.1. Use zeek::detail::BreakStmt instead.")]] = zeek::detail::BreakStmt;
using FallthroughStmt [[deprecated("Remove in v4.1. Use zeek::detail::FallthroughStmt instead.")]] = zeek::detail::FallthroughStmt;
using ReturnStmt [[deprecated("Remove in v4.1. Use zeek::detail::ReturnStmt instead.")]] = zeek::detail::ReturnStmt;
using StmtList [[deprecated("Remove in v4.1. Use zeek::detail::StmtList instead.")]] = zeek::detail::StmtList;
using EventBodyList [[deprecated("Remove in v4.1. Use zeek::detail::EventBodyList instead.")]] = zeek::detail::EventBodyList;
using InitStmt [[deprecated("Remove in v4.1. Use zeek::detail::InitStmt instead.")]] = zeek::detail::InitStmt;
using NullStmt [[deprecated("Remove in v4.1. Use zeek::detail::NullStmt instead.")]] = zeek::detail::NullStmt;
using WhenStmt [[deprecated("Remove in v4.1. Use zeek::detail::WhenStmt instead.")]] = zeek::detail::WhenStmt;

View file

@ -6,10 +6,11 @@
class Func; class Func;
class Scope; class Scope;
class Stmt;
class Expr; class Expr;
class ID; class ID;
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
class TraversalCallback { class TraversalCallback {
public: public:
TraversalCallback() { current_scope = nullptr; } TraversalCallback() { current_scope = nullptr; }
@ -18,8 +19,8 @@ public:
virtual TraversalCode PreFunction(const Func*) { return TC_CONTINUE; } virtual TraversalCode PreFunction(const Func*) { return TC_CONTINUE; }
virtual TraversalCode PostFunction(const Func*) { return TC_CONTINUE; } virtual TraversalCode PostFunction(const Func*) { return TC_CONTINUE; }
virtual TraversalCode PreStmt(const Stmt*) { return TC_CONTINUE; } virtual TraversalCode PreStmt(const zeek::detail::Stmt*) { return TC_CONTINUE; }
virtual TraversalCode PostStmt(const Stmt*) { return TC_CONTINUE; } virtual TraversalCode PostStmt(const zeek::detail::Stmt*) { return TC_CONTINUE; }
virtual TraversalCode PreExpr(const Expr*) { return TC_CONTINUE; } virtual TraversalCode PreExpr(const Expr*) { return TC_CONTINUE; }
virtual TraversalCode PostExpr(const Expr*) { return TC_CONTINUE; } virtual TraversalCode PostExpr(const Expr*) { return TC_CONTINUE; }

View file

@ -122,7 +122,8 @@ protected:
} }
Trigger::Trigger(Expr* arg_cond, Stmt* arg_body, Stmt* arg_timeout_stmts, Trigger::Trigger(Expr* arg_cond, zeek::detail::Stmt* arg_body,
zeek::detail::Stmt* arg_timeout_stmts,
Expr* arg_timeout, Frame* arg_frame, Expr* arg_timeout, Frame* arg_frame,
bool arg_is_return, const Location* arg_location) bool arg_is_return, const Location* arg_location)
{ {

View file

@ -1,21 +1,23 @@
#pragma once #pragma once
#include "Obj.h"
#include "Notifier.h"
#include "iosource/IOSource.h"
#include <list> #include <list>
#include <vector> #include <vector>
#include <map> #include <map>
#include "Obj.h"
#include "Notifier.h"
#include "iosource/IOSource.h"
#include "util.h"
class CallExpr; class CallExpr;
class Expr; class Expr;
class Stmt;
class Frame; class Frame;
class Val; class Val;
class ID; class ID;
class ODesc; class ODesc;
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
namespace trigger { namespace trigger {
// Triggers are the heart of "when" statements: expressions that when // Triggers are the heart of "when" statements: expressions that when
// they become true execute a body of statements. // they become true execute a body of statements.
@ -29,7 +31,7 @@ public:
// instantiation. Note that if the condition is already true, the // instantiation. Note that if the condition is already true, the
// statements are executed immediately and the object is deleted // statements are executed immediately and the object is deleted
// right away. // right away.
Trigger(Expr* cond, Stmt* body, Stmt* timeout_stmts, Expr* timeout, Trigger(Expr* cond, zeek::detail::Stmt* body, zeek::detail::Stmt* timeout_stmts, Expr* timeout,
Frame* f, bool is_return, const Location* loc); Frame* f, bool is_return, const Location* loc);
~Trigger() override; ~Trigger() override;
@ -92,8 +94,8 @@ private:
void UnregisterAll(); void UnregisterAll();
Expr* cond; Expr* cond;
Stmt* body; zeek::detail::Stmt* body;
Stmt* timeout_stmts; zeek::detail::Stmt* timeout_stmts;
Expr* timeout; Expr* timeout;
double timeout_value; double timeout_value;
Frame* frame; Frame* frame;

View file

@ -316,7 +316,7 @@ void add_global(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t,
make_var(id, std::move(t), c, std::move(init), std::move(attr), dt, true); make_var(id, std::move(t), c, std::move(init), std::move(attr), dt, true);
} }
IntrusivePtr<Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<BroType> t, IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<BroType> t,
init_class c, IntrusivePtr<Expr> init, init_class c, IntrusivePtr<Expr> init,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr, std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
decl_type dt) decl_type dt)
@ -336,7 +336,7 @@ IntrusivePtr<Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<BroType> t,
auto assign_expr = make_intrusive<AssignExpr>(std::move(name_expr), auto assign_expr = make_intrusive<AssignExpr>(std::move(name_expr),
std::move(init), 0, std::move(init), 0,
nullptr, id->GetAttrs()); nullptr, id->GetAttrs());
auto stmt = make_intrusive<ExprStmt>(std::move(assign_expr)); auto stmt = make_intrusive<zeek::detail::ExprStmt>(std::move(assign_expr));
stmt->SetLocationInfo(&location); stmt->SetLocationInfo(&location);
return stmt; return stmt;
} }
@ -344,7 +344,7 @@ IntrusivePtr<Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<BroType> t,
else else
{ {
current_scope()->AddInit(std::move(id)); current_scope()->AddInit(std::move(id));
return make_intrusive<NullStmt>(); return make_intrusive<zeek::detail::NullStmt>();
} }
} }
@ -633,7 +633,7 @@ TraversalCode OuterIDBindingFinder::PostExpr(const Expr* expr)
return TC_CONTINUE; return TC_CONTINUE;
} }
void end_func(IntrusivePtr<Stmt> body) void end_func(IntrusivePtr<zeek::detail::Stmt> body)
{ {
auto ingredients = std::make_unique<function_ingredients>(pop_scope(), std::move(body)); auto ingredients = std::make_unique<function_ingredients>(pop_scope(), std::move(body));
@ -668,7 +668,7 @@ Val* internal_val(const char* name)
return zeek::id::find_val(name).get(); return zeek::id::find_val(name).get();
} }
id_list gather_outer_ids(Scope* scope, Stmt* body) id_list gather_outer_ids(Scope* scope, zeek::detail::Stmt* body)
{ {
OuterIDBindingFinder cb(scope); OuterIDBindingFinder cb(scope);
body->Traverse(&cb); body->Traverse(&cb);

View file

@ -8,13 +8,14 @@
class Expr; class Expr;
class FuncType; class FuncType;
class Stmt;
class Scope; class Scope;
class EventHandlerPtr; class EventHandlerPtr;
class StringVal; class StringVal;
class TableVal; class TableVal;
class ListVal; class ListVal;
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
typedef enum { VAR_REGULAR, VAR_CONST, VAR_REDEF, VAR_OPTION, } decl_type; typedef enum { VAR_REGULAR, VAR_CONST, VAR_REDEF, VAR_OPTION, } decl_type;
extern void add_global(const IntrusivePtr<ID>& id, extern void add_global(const IntrusivePtr<ID>& id,
@ -24,7 +25,7 @@ extern void add_global(const IntrusivePtr<ID>& id,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr, std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
decl_type dt); decl_type dt);
extern IntrusivePtr<Stmt> add_local(IntrusivePtr<ID> id, extern IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id,
IntrusivePtr<BroType> t, IntrusivePtr<BroType> t,
init_class c, init_class c,
IntrusivePtr<Expr> init, IntrusivePtr<Expr> init,
@ -43,10 +44,10 @@ extern void begin_func(IntrusivePtr<ID> id, const char* module_name,
IntrusivePtr<FuncType> t, IntrusivePtr<FuncType> t,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs = nullptr); std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs = nullptr);
extern void end_func(IntrusivePtr<Stmt> body); extern void end_func(IntrusivePtr<zeek::detail::Stmt> body);
// Gather all IDs referenced inside a body that aren't part of a given scope. // Gather all IDs referenced inside a body that aren't part of a given scope.
extern id_list gather_outer_ids(Scope* scope, Stmt* body); extern id_list gather_outer_ids(Scope* scope, zeek::detail::Stmt* body);
[[deprecated("Remove in v4.1. Use zeek::id::find_val().")]] [[deprecated("Remove in v4.1. Use zeek::id::find_val().")]]
extern Val* internal_val(const char* name); extern Val* internal_val(const char* name);

View file

@ -41,5 +41,5 @@ extern std::vector<std::string> zeek_script_prefixes; // -p flag
extern const char* command_line_policy; // -e flag extern const char* command_line_policy; // -e flag
extern std::vector<std::string> params; extern std::vector<std::string> params;
class Stmt; FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
extern Stmt* stmts; // global statements extern zeek::detail::Stmt* stmts; // global statements

View file

@ -239,7 +239,7 @@ static bool expr_is_table_type_name(const Expr* expr)
RE_Matcher* re; RE_Matcher* re;
Expr* expr; Expr* expr;
EventExpr* event_expr; EventExpr* event_expr;
Stmt* stmt; zeek::detail::Stmt* stmt;
ListExpr* list; ListExpr* list;
BroType* type; BroType* type;
RecordType* record; RecordType* record;
@ -247,8 +247,8 @@ static bool expr_is_table_type_name(const Expr* expr)
TypeList* type_l; TypeList* type_l;
TypeDecl* type_decl; TypeDecl* type_decl;
type_decl_list* type_decl_l; type_decl_list* type_decl_l;
Case* c_case; zeek::detail::Case* c_case;
case_list* case_l; zeek::detail::case_list* case_l;
Attr* attr; Attr* attr;
std::vector<IntrusivePtr<Attr>>* attr_l; std::vector<IntrusivePtr<Attr>>* attr_l;
attr_tag attrtag; attr_tag attrtag;
@ -994,7 +994,7 @@ type:
{ {
if ( ! $1 || ! ($$ = $1->IsType() ? $1->GetType().get() : nullptr) ) if ( ! $1 || ! ($$ = $1->IsType() ? $1->GetType().get() : nullptr) )
{ {
NullStmt here; zeek::detail::NullStmt here;
if ( $1 ) if ( $1 )
$1->Error("not a Zeek type", &here); $1->Error("not a Zeek type", &here);
$$ = error_type()->Ref(); $$ = error_type()->Ref();
@ -1413,7 +1413,7 @@ stmt:
| TOK_PRINT expr_list ';' opt_no_test | TOK_PRINT expr_list ';' opt_no_test
{ {
set_location(@1, @3); set_location(@1, @3);
$$ = new PrintStmt(IntrusivePtr{AdoptRef{}, $2}); $$ = new zeek::detail::PrintStmt(IntrusivePtr{AdoptRef{}, $2});
if ( ! $4 ) if ( ! $4 )
brofiler.AddStmt($$); brofiler.AddStmt($$);
} }
@ -1421,7 +1421,7 @@ stmt:
| TOK_EVENT event ';' opt_no_test | TOK_EVENT event ';' opt_no_test
{ {
set_location(@1, @3); set_location(@1, @3);
$$ = new EventStmt({AdoptRef{}, $2}); $$ = new zeek::detail::EventStmt({AdoptRef{}, $2});
if ( ! $4 ) if ( ! $4 )
brofiler.AddStmt($$); brofiler.AddStmt($$);
} }
@ -1429,19 +1429,19 @@ stmt:
| TOK_IF '(' expr ')' stmt | TOK_IF '(' expr ')' stmt
{ {
set_location(@1, @4); set_location(@1, @4);
$$ = new IfStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, make_intrusive<NullStmt>()); $$ = new zeek::detail::IfStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, make_intrusive<zeek::detail::NullStmt>());
} }
| TOK_IF '(' expr ')' stmt TOK_ELSE stmt | TOK_IF '(' expr ')' stmt TOK_ELSE stmt
{ {
set_location(@1, @4); set_location(@1, @4);
$$ = new IfStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, {AdoptRef{}, $7}); $$ = new zeek::detail::IfStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, {AdoptRef{}, $7});
} }
| TOK_SWITCH expr '{' case_list '}' | TOK_SWITCH expr '{' case_list '}'
{ {
set_location(@1, @2); set_location(@1, @2);
$$ = new SwitchStmt({AdoptRef{}, $2}, $4); $$ = new zeek::detail::SwitchStmt({AdoptRef{}, $2}, $4);
} }
| for_head stmt | for_head stmt
@ -1451,13 +1451,13 @@ stmt:
| TOK_WHILE '(' expr ')' stmt | TOK_WHILE '(' expr ')' stmt
{ {
$$ = new WhileStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}); $$ = new zeek::detail::WhileStmt({AdoptRef{}, $3}, {AdoptRef{}, $5});
} }
| TOK_NEXT ';' opt_no_test | TOK_NEXT ';' opt_no_test
{ {
set_location(@1, @2); set_location(@1, @2);
$$ = new NextStmt; $$ = new zeek::detail::NextStmt;
if ( ! $3 ) if ( ! $3 )
brofiler.AddStmt($$); brofiler.AddStmt($$);
} }
@ -1465,7 +1465,7 @@ stmt:
| TOK_BREAK ';' opt_no_test | TOK_BREAK ';' opt_no_test
{ {
set_location(@1, @2); set_location(@1, @2);
$$ = new BreakStmt; $$ = new zeek::detail::BreakStmt;
if ( ! $3 ) if ( ! $3 )
brofiler.AddStmt($$); brofiler.AddStmt($$);
} }
@ -1473,7 +1473,7 @@ stmt:
| TOK_FALLTHROUGH ';' opt_no_test | TOK_FALLTHROUGH ';' opt_no_test
{ {
set_location(@1, @2); set_location(@1, @2);
$$ = new FallthroughStmt; $$ = new zeek::detail::FallthroughStmt;
if ( ! $3 ) if ( ! $3 )
brofiler.AddStmt($$); brofiler.AddStmt($$);
} }
@ -1481,7 +1481,7 @@ stmt:
| TOK_RETURN ';' opt_no_test | TOK_RETURN ';' opt_no_test
{ {
set_location(@1, @2); set_location(@1, @2);
$$ = new ReturnStmt(0); $$ = new zeek::detail::ReturnStmt(0);
if ( ! $3 ) if ( ! $3 )
brofiler.AddStmt($$); brofiler.AddStmt($$);
} }
@ -1489,7 +1489,7 @@ stmt:
| TOK_RETURN expr ';' opt_no_test | TOK_RETURN expr ';' opt_no_test
{ {
set_location(@1, @2); set_location(@1, @2);
$$ = new ReturnStmt({AdoptRef{}, $2}); $$ = new zeek::detail::ReturnStmt({AdoptRef{}, $2});
if ( ! $4 ) if ( ! $4 )
brofiler.AddStmt($$); brofiler.AddStmt($$);
} }
@ -1497,7 +1497,7 @@ stmt:
| TOK_ADD expr ';' opt_no_test | TOK_ADD expr ';' opt_no_test
{ {
set_location(@1, @3); set_location(@1, @3);
$$ = new AddStmt({AdoptRef{}, $2}); $$ = new zeek::detail::AddStmt({AdoptRef{}, $2});
if ( ! $4 ) if ( ! $4 )
brofiler.AddStmt($$); brofiler.AddStmt($$);
} }
@ -1505,7 +1505,7 @@ stmt:
| TOK_DELETE expr ';' opt_no_test | TOK_DELETE expr ';' opt_no_test
{ {
set_location(@1, @3); set_location(@1, @3);
$$ = new DelStmt({AdoptRef{}, $2}); $$ = new zeek::detail::DelStmt({AdoptRef{}, $2});
if ( ! $4 ) if ( ! $4 )
brofiler.AddStmt($$); brofiler.AddStmt($$);
} }
@ -1535,14 +1535,14 @@ stmt:
| TOK_WHEN '(' expr ')' stmt | TOK_WHEN '(' expr ')' stmt
{ {
set_location(@3, @5); set_location(@3, @5);
$$ = new WhenStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, $$ = new zeek::detail::WhenStmt({AdoptRef{}, $3}, {AdoptRef{}, $5},
nullptr, nullptr, false); nullptr, nullptr, false);
} }
| TOK_WHEN '(' expr ')' stmt TOK_TIMEOUT expr '{' opt_no_test_block stmt_list '}' | TOK_WHEN '(' expr ')' stmt TOK_TIMEOUT expr '{' opt_no_test_block stmt_list '}'
{ {
set_location(@3, @9); set_location(@3, @9);
$$ = new WhenStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, $$ = new zeek::detail::WhenStmt({AdoptRef{}, $3}, {AdoptRef{}, $5},
{AdoptRef{}, $10}, {AdoptRef{}, $7}, false); {AdoptRef{}, $10}, {AdoptRef{}, $7}, false);
if ( $9 ) if ( $9 )
brofiler.DecIgnoreDepth(); brofiler.DecIgnoreDepth();
@ -1552,14 +1552,14 @@ stmt:
| TOK_RETURN TOK_WHEN '(' expr ')' stmt | TOK_RETURN TOK_WHEN '(' expr ')' stmt
{ {
set_location(@4, @6); set_location(@4, @6);
$$ = new WhenStmt({AdoptRef{}, $4}, {AdoptRef{}, $6}, nullptr, $$ = new zeek::detail::WhenStmt({AdoptRef{}, $4}, {AdoptRef{}, $6}, nullptr,
nullptr, true); nullptr, true);
} }
| TOK_RETURN TOK_WHEN '(' expr ')' stmt TOK_TIMEOUT expr '{' opt_no_test_block stmt_list '}' | TOK_RETURN TOK_WHEN '(' expr ')' stmt TOK_TIMEOUT expr '{' opt_no_test_block stmt_list '}'
{ {
set_location(@4, @10); set_location(@4, @10);
$$ = new WhenStmt({AdoptRef{}, $4}, {AdoptRef{}, $6}, $$ = new zeek::detail::WhenStmt({AdoptRef{}, $4}, {AdoptRef{}, $6},
{AdoptRef{}, $11}, {AdoptRef{}, $8}, true); {AdoptRef{}, $11}, {AdoptRef{}, $8}, true);
if ( $10 ) if ( $10 )
brofiler.DecIgnoreDepth(); brofiler.DecIgnoreDepth();
@ -1568,7 +1568,7 @@ stmt:
| index_slice '=' expr ';' opt_no_test | index_slice '=' expr ';' opt_no_test
{ {
set_location(@1, @4); set_location(@1, @4);
$$ = new ExprStmt(get_assign_expr({AdoptRef{}, $1}, $$ = new zeek::detail::ExprStmt(get_assign_expr({AdoptRef{}, $1},
{AdoptRef{}, $3}, in_init)); {AdoptRef{}, $3}, in_init));
if ( ! $5 ) if ( ! $5 )
@ -1578,7 +1578,7 @@ stmt:
| expr ';' opt_no_test | expr ';' opt_no_test
{ {
set_location(@1, @2); set_location(@1, @2);
$$ = new ExprStmt({AdoptRef{}, $1}); $$ = new zeek::detail::ExprStmt({AdoptRef{}, $1});
if ( ! $3 ) if ( ! $3 )
brofiler.AddStmt($$); brofiler.AddStmt($$);
} }
@ -1586,11 +1586,11 @@ stmt:
| ';' | ';'
{ {
set_location(@1, @1); set_location(@1, @1);
$$ = new NullStmt; $$ = new zeek::detail::NullStmt;
} }
| conditional | conditional
{ $$ = new NullStmt; } { $$ = new zeek::detail::NullStmt; }
; ;
stmt_list: stmt_list:
@ -1601,7 +1601,7 @@ stmt_list:
$1->UpdateLocationEndInfo(@2); $1->UpdateLocationEndInfo(@2);
} }
| |
{ $$ = new StmtList(); } { $$ = new zeek::detail::StmtList(); }
; ;
event: event:
@ -1630,18 +1630,18 @@ case_list:
case_list case case_list case
{ $1->push_back($2); } { $1->push_back($2); }
| |
{ $$ = new case_list; } { $$ = new zeek::detail::case_list; }
; ;
case: case:
TOK_CASE expr_list ':' stmt_list TOK_CASE expr_list ':' stmt_list
{ $$ = new Case({AdoptRef{}, $2}, 0, {AdoptRef{}, $4}); } { $$ = new zeek::detail::Case({AdoptRef{}, $2}, 0, {AdoptRef{}, $4}); }
| |
TOK_CASE case_type_list ':' stmt_list TOK_CASE case_type_list ':' stmt_list
{ $$ = new Case(nullptr, $2, {AdoptRef{}, $4}); } { $$ = new zeek::detail::Case(nullptr, $2, {AdoptRef{}, $4}); }
| |
TOK_DEFAULT ':' stmt_list TOK_DEFAULT ':' stmt_list
{ $$ = new Case(nullptr, 0, {AdoptRef{}, $3}); } { $$ = new zeek::detail::Case(nullptr, 0, {AdoptRef{}, $3}); }
; ;
case_type_list: case_type_list:
@ -1704,12 +1704,12 @@ for_head:
id_list* loop_vars = new id_list; id_list* loop_vars = new id_list;
loop_vars->push_back(loop_var.release()); loop_vars->push_back(loop_var.release());
$$ = new ForStmt(loop_vars, {AdoptRef{}, $5}); $$ = new zeek::detail::ForStmt(loop_vars, {AdoptRef{}, $5});
} }
| |
TOK_FOR '(' '[' local_id_list ']' TOK_IN expr ')' TOK_FOR '(' '[' local_id_list ']' TOK_IN expr ')'
{ {
$$ = new ForStmt($4, {AdoptRef{}, $7}); $$ = new zeek::detail::ForStmt($4, {AdoptRef{}, $7});
} }
| |
TOK_FOR '(' TOK_ID ',' TOK_ID TOK_IN expr ')' TOK_FOR '(' TOK_ID ',' TOK_ID TOK_IN expr ')'
@ -1742,7 +1742,7 @@ for_head:
id_list* loop_vars = new id_list; id_list* loop_vars = new id_list;
loop_vars->push_back(key_var.release()); loop_vars->push_back(key_var.release());
$$ = new ForStmt(loop_vars, {AdoptRef{}, $7}, std::move(val_var)); $$ = new zeek::detail::ForStmt(loop_vars, {AdoptRef{}, $7}, std::move(val_var));
} }
| |
TOK_FOR '(' '[' local_id_list ']' ',' TOK_ID TOK_IN expr ')' TOK_FOR '(' '[' local_id_list ']' ',' TOK_ID TOK_IN expr ')'
@ -1761,7 +1761,7 @@ for_head:
else else
val_var = install_ID($7, module, false, false); val_var = install_ID($7, module, false, false);
$$ = new ForStmt($4, {AdoptRef{}, $9}, std::move(val_var)); $$ = new zeek::detail::ForStmt($4, {AdoptRef{}, $9}, std::move(val_var));
} }
; ;

View file

@ -101,7 +101,7 @@ zeek::Supervisor* zeek::supervisor_mgr = nullptr;
trigger::Manager* trigger_mgr = nullptr; trigger::Manager* trigger_mgr = nullptr;
std::vector<std::string> zeek_script_prefixes; std::vector<std::string> zeek_script_prefixes;
Stmt* stmts; zeek::detail::Stmt* stmts;
RuleMatcher* rule_matcher = nullptr; RuleMatcher* rule_matcher = nullptr;
EventRegistry* event_registry = nullptr; EventRegistry* event_registry = nullptr;
ProfileLogger* profiling_logger = nullptr; ProfileLogger* profiling_logger = nullptr;