Move Frame and Scope to zeek::detail namespace

This commit is contained in:
Tim Wojtulewicz 2020-06-15 21:45:44 -07:00 committed by Tim Wojtulewicz
parent 64332ca22c
commit 937a462e70
50 changed files with 306 additions and 257 deletions

@ -1 +1 @@
Subproject commit 6c07de13247f16490c25a2066c77db1678ccd128 Subproject commit 001e1c30f9646ea1198da6f8d24dc2235dbcd390

View file

@ -10,20 +10,19 @@
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
namespace zeek {
class Type;
using TypePtr = IntrusivePtr<Type>;
namespace detail {
using ExprPtr = zeek::IntrusivePtr<Expr>;
}
}
// Note that there are two kinds of attributes: the kind (here) which // Note that there are two kinds of attributes: the kind (here) which
// modify expressions or supply metadata on types, and the kind that // modify expressions or supply metadata on types, and the kind that
// are extra metadata on every variable instance. // are extra metadata on every variable instance.
namespace zeek::detail {
namespace zeek {
class Type;
using TypePtr = IntrusivePtr<Type>;
namespace detail {
using ExprPtr = zeek::IntrusivePtr<zeek::detail::Expr>;
enum AttrTag { enum AttrTag {
ATTR_OPTIONAL, ATTR_OPTIONAL,
@ -145,7 +144,8 @@ protected:
bool global_var; bool global_var;
}; };
} } // namespace detail
} // namespace zeek
using Attr [[deprecated("Remove in v4.1. Use zeek::detail::Attr instead.")]] = zeek::detail::Attr; using Attr [[deprecated("Remove in v4.1. Use zeek::detail::Attr instead.")]] = zeek::detail::Attr;
using Attributes [[deprecated("Remove in v4.1. Use zeek::detail::Attr instead.")]] = zeek::detail::Attributes; using Attributes [[deprecated("Remove in v4.1. Use zeek::detail::Attr instead.")]] = zeek::detail::Attributes;

View file

@ -150,7 +150,7 @@ bool DbgBreakpoint::SetLocation(ParseLocationRec plr, std::string_view loc_str)
{ {
std::string loc_s(loc_str); std::string loc_s(loc_str);
kind = BP_FUNC; kind = BP_FUNC;
function_name = make_full_var_name(current_module.c_str(), function_name = make_full_var_name(zeek::detail::current_module.c_str(),
loc_s.c_str()); loc_s.c_str());
at_stmt = plr.stmt; at_stmt = plr.stmt;
const Location* loc = at_stmt->GetLocationInfo(); const Location* loc = at_stmt->GetLocationInfo();
@ -350,7 +350,7 @@ void DbgBreakpoint::PrintHitMsg()
case BP_LINE: case BP_LINE:
{ {
ODesc d; ODesc d;
Frame* f = g_frame_stack.back(); zeek::detail::Frame* f = g_frame_stack.back();
const BroFunc* func = f->GetFunction(); const BroFunc* func = f->GetFunction();
if ( func ) if ( func )

View file

@ -44,7 +44,7 @@ std::map<string, Filemap*> g_dbgfilemaps;
// current context; you don't want to do it after a step or next // current context; you don't want to do it after a step or next
// command unless you've exited a function. // command unless you've exited a function.
static bool step_or_next_pending = false; static bool step_or_next_pending = false;
static Frame* last_frame; static zeek::detail::Frame* last_frame;
DebuggerState::DebuggerState() DebuggerState::DebuggerState()
{ {
@ -55,7 +55,7 @@ DebuggerState::DebuggerState()
BreakFromSignal(false); BreakFromSignal(false);
// ### Don't choose this arbitrary size! Extend Frame. // ### Don't choose this arbitrary size! Extend Frame.
dbg_locals = new Frame(1024, /* func = */ nullptr, /* fn_args = */ nullptr); dbg_locals = new zeek::detail::Frame(1024, /* func = */ nullptr, /* fn_args = */ nullptr);
} }
DebuggerState::~DebuggerState() DebuggerState::~DebuggerState()
@ -197,11 +197,11 @@ void get_first_statement(zeek::detail::Stmt* list, zeek::detail::Stmt*& first, L
static void parse_function_name(vector<ParseLocationRec>& result, static void parse_function_name(vector<ParseLocationRec>& result,
ParseLocationRec& plr, const string& s) ParseLocationRec& plr, const string& s)
{ // function name { // function name
const auto& id = lookup_ID(s.c_str(), current_module.c_str()); const auto& id = zeek::detail::lookup_ID(s.c_str(), zeek::detail::current_module.c_str());
if ( ! id ) if ( ! id )
{ {
string fullname = make_full_var_name(current_module.c_str(), s.c_str()); string fullname = make_full_var_name(zeek::detail::current_module.c_str(), s.c_str());
debug_msg("Function %s not defined.\n", fullname.c_str()); debug_msg("Function %s not defined.\n", fullname.c_str());
plr.type = plrUnknown; plr.type = plrUnknown;
return; return;
@ -728,7 +728,7 @@ static char* get_prompt(bool reset_counter = false)
return prompt; return prompt;
} }
string get_context_description(const zeek::detail::Stmt* stmt, const Frame* frame) string get_context_description(const zeek::detail::Stmt* stmt, const zeek::detail::Frame* frame)
{ {
ODesc d; ODesc d;
const BroFunc* func = frame ? frame->GetFunction() : nullptr; const BroFunc* func = frame ? frame->GetFunction() : nullptr;
@ -769,12 +769,12 @@ int dbg_handle_debug_input()
g_debugger_state.BreakFromSignal(false); g_debugger_state.BreakFromSignal(false);
} }
Frame* curr_frame = g_frame_stack.back(); zeek::detail::Frame* curr_frame = g_frame_stack.back();
const BroFunc* func = curr_frame->GetFunction(); const BroFunc* func = curr_frame->GetFunction();
if ( func ) if ( func )
current_module = extract_module_name(func->Name()); zeek::detail::current_module = extract_module_name(func->Name());
else else
current_module = GLOBAL_MODULE_NAME; zeek::detail::current_module = GLOBAL_MODULE_NAME;
const zeek::detail::Stmt* stmt = curr_frame->GetNextStmt(); const zeek::detail::Stmt* stmt = curr_frame->GetNextStmt();
if ( ! stmt ) if ( ! stmt )
@ -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(zeek::detail::Stmt* stmt, Frame* f) bool pre_execute_stmt(zeek::detail::Stmt* stmt, zeek::detail::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(zeek::detail::Stmt* stmt, Frame* f)
return true; return true;
} }
bool post_execute_stmt(zeek::detail::Stmt* stmt, Frame* f, zeek::Val* result, stmt_flow_type* flow) bool post_execute_stmt(zeek::detail::Stmt* stmt, zeek::detail::Frame* f, zeek::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
@ -959,7 +959,7 @@ zeek::ValPtr dbg_eval_expr(const char* expr)
if ( ! (frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()) ) if ( ! (frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()) )
reporter->InternalError("Assertion failed: frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()"); reporter->InternalError("Assertion failed: frame_idx >= 0 && (unsigned) frame_idx < g_frame_stack.size()");
Frame* frame = g_frame_stack[frame_idx]; zeek::detail::Frame* frame = g_frame_stack[frame_idx];
if ( ! (frame) ) if ( ! (frame) )
reporter->InternalError("Assertion failed: frame"); reporter->InternalError("Assertion failed: frame");
@ -967,7 +967,7 @@ zeek::ValPtr dbg_eval_expr(const char* expr)
if ( func ) if ( func )
{ {
Ref(func->GetScope()); Ref(func->GetScope());
push_existing_scope(func->GetScope()); zeek::detail::push_existing_scope(func->GetScope());
} }
// ### Possibly push a debugger-local scope? // ### Possibly push a debugger-local scope?
@ -1001,7 +1001,7 @@ zeek::ValPtr dbg_eval_expr(const char* expr)
result = g_curr_debug_expr->Eval(frame); result = g_curr_debug_expr->Eval(frame);
if ( func ) if ( func )
pop_scope(); zeek::detail::pop_scope();
delete g_curr_debug_expr; delete g_curr_debug_expr;
g_curr_debug_expr = nullptr; g_curr_debug_expr = nullptr;

View file

@ -11,8 +11,10 @@
#include <map> #include <map>
#include <string> #include <string>
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek);
namespace zeek { namespace zeek {
template <class T> class IntrusivePtr; template <class T> class IntrusivePtr;
using ValPtr = zeek::IntrusivePtr<Val>; using ValPtr = zeek::IntrusivePtr<Val>;
@ -30,7 +32,6 @@ struct ParseLocationRec {
class StmtLocMapping; class StmtLocMapping;
typedef PQueue<StmtLocMapping> Filemap; // mapping for a single file typedef PQueue<StmtLocMapping> Filemap; // mapping for a single file
class Frame;
class DbgBreakpoint; class DbgBreakpoint;
class DbgWatch; class DbgWatch;
class DbgDisplay; class DbgDisplay;
@ -39,7 +40,9 @@ class StmtHashFn;
typedef std::map<int, DbgBreakpoint*> BPIDMapType; typedef std::map<int, DbgBreakpoint*> BPIDMapType;
typedef std::multimap<const zeek::detail::Stmt*, DbgBreakpoint*> BPMapType; typedef std::multimap<const zeek::detail::Stmt*, DbgBreakpoint*> BPMapType;
namespace zeek {
extern std::string current_module; extern std::string current_module;
}
class TraceState { class TraceState {
public: public:
@ -100,7 +103,7 @@ protected:
int next_bp_id, next_watch_id, next_display_id; int next_bp_id, next_watch_id, next_display_id;
private: private:
Frame* dbg_locals; // unused zeek::detail::Frame* dbg_locals; // unused
}; };
// Source line -> statement mapping. // Source line -> statement mapping.
@ -147,8 +150,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(zeek::detail::Stmt* stmt, Frame* f); bool pre_execute_stmt(zeek::detail::Stmt* stmt, zeek::detail::Frame* f);
bool post_execute_stmt(zeek::detail::Stmt* stmt, Frame* f, zeek::Val* result, stmt_flow_type* flow); bool post_execute_stmt(zeek::detail::Stmt* stmt, zeek::detail::Frame* f, zeek::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
@ -172,9 +175,9 @@ zeek::ValPtr 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 zeek::detail::Stmt* stmt, const Frame* frame); std::string get_context_description(const zeek::detail::Stmt* stmt, const zeek::detail::Frame* frame);
extern Frame* g_dbg_locals; // variables created within debugger context extern zeek::detail::Frame* g_dbg_locals; // variables created within debugger context
extern std::map<std::string, Filemap*> g_dbgfilemaps; // filename => filemap extern std::map<std::string, Filemap*> g_dbgfilemaps; // filename => filemap

View file

@ -57,7 +57,7 @@ static void lookup_global_symbols_regex(const string& orig_regex, vector<zeek::d
return; return;
} }
Scope* global = global_scope(); zeek::detail::Scope* global = zeek::detail::global_scope();
const auto& syms = global->Vars(); const auto& syms = global->Vars();
zeek::detail::ID* nextid; zeek::detail::ID* nextid;
@ -214,7 +214,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 zeek::detail::Frame* f = g_frame_stack[i];
const zeek::detail::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);

View file

@ -31,8 +31,8 @@ const zeek::FuncTypePtr& EventHandler::GetType(bool check_export)
if ( type ) if ( type )
return type; return type;
const auto& id = lookup_ID(name.data(), current_module.c_str(), false, false, const auto& id = zeek::detail::lookup_ID(name.data(), zeek::detail::current_module.c_str(),
check_export); false, false, check_export);
if ( ! id ) if ( ! id )
return zeek::FuncType::nil; return zeek::FuncType::nil;

View file

@ -17,15 +17,14 @@
#include "Val.h" #include "Val.h"
#include "ZeekArgs.h" #include "ZeekArgs.h"
class Frame; ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
class Scope; ZEEK_FORWARD_DECLARE_NAMESPACED(Scope, zeek::detail);
struct function_ingredients; struct function_ingredients;
namespace zeek { namespace zeek {
template <class T> class IntrusivePtr; template <class T> class IntrusivePtr;
}
namespace zeek::detail { namespace detail {
using IDPtr = zeek::IntrusivePtr<ID>; using IDPtr = zeek::IntrusivePtr<ID>;
@ -965,7 +964,8 @@ extern bool expr_greater(const Expr* e1, const Expr* e2);
inline bool is_vector(Expr* e) { return e->GetType()->Tag() == TYPE_VECTOR; } inline bool is_vector(Expr* e) { return e->GetType()->Tag() == TYPE_VECTOR; }
inline bool is_vector(const ExprPtr& e) { return is_vector(e.get()); } inline bool is_vector(const ExprPtr& e) { return is_vector(e.get()); }
} } // namespace detail
} // namespace zeek
using Expr [[deprecated("Remove in v4.1. Use zeek::detail::Expr instead.")]] = zeek::detail::Expr; using Expr [[deprecated("Remove in v4.1. Use zeek::detail::Expr instead.")]] = zeek::detail::Expr;
using NameExpr [[deprecated("Remove in v4.1. Use zeek::detail::NameExpr instead.")]] = zeek::detail::NameExpr; using NameExpr [[deprecated("Remove in v4.1. Use zeek::detail::NameExpr instead.")]] = zeek::detail::NameExpr;

View file

@ -11,7 +11,9 @@
#include "Val.h" #include "Val.h"
#include "ID.h" #include "ID.h"
std::vector<Frame*> g_frame_stack; std::vector<zeek::detail::Frame*> g_frame_stack;
namespace zeek::detail {
Frame::Frame(int arg_size, const BroFunc* func, const zeek::Args* fn_args) Frame::Frame(int arg_size, const BroFunc* func, const zeek::Args* fn_args)
{ {
@ -616,3 +618,5 @@ Frame::UnserializeOffsetMap(const broker::vector& data)
return std::make_pair(true, std::move(rval)); return std::make_pair(true, std::move(rval));
} }
}

View file

@ -21,17 +21,15 @@ class BroFunc;
ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Trigger, zeek::detail::trigger); ZEEK_FORWARD_DECLARE_NAMESPACED(Trigger, zeek::detail::trigger);
namespace zeek::detail { namespace zeek {
using ValPtr = zeek::IntrusivePtr<Val>;
namespace detail {
using IDPtr = zeek::IntrusivePtr<ID>; using IDPtr = zeek::IntrusivePtr<ID>;
namespace trigger { namespace trigger {
using TriggerPtr = zeek::IntrusivePtr<Trigger>; using TriggerPtr = zeek::IntrusivePtr<Trigger>;
} }
}
namespace zeek {
using ValPtr = zeek::IntrusivePtr<Val>;
}
class Frame; class Frame;
using FramePtr = zeek::IntrusivePtr<Frame>; using FramePtr = zeek::IntrusivePtr<Frame>;
@ -343,6 +341,11 @@ private:
std::unique_ptr<std::vector<BroFunc*>> functions_with_closure_frame_reference; std::unique_ptr<std::vector<BroFunc*>> functions_with_closure_frame_reference;
}; };
} // namespace detail
} // namespace zeek
using Frame [[deprecated("Remove in v4.1. Use zeek::detail::Frame instead.")]] = zeek::detail::Frame;
/** /**
* If we stopped using this and instead just made a struct of the information * If we stopped using this and instead just made a struct of the information
* that the debugger actually uses we could make the Frame a class a template. * that the debugger actually uses we could make the Frame a class a template.
@ -353,4 +356,4 @@ private:
* DebugFrame which provides the information that the debugger uses. See: * DebugFrame which provides the information that the debugger uses. See:
* https://stackoverflow.com/a/16211097 * https://stackoverflow.com/a/16211097
*/ */
extern std::vector<Frame*> g_frame_stack; extern std::vector<zeek::detail::Frame*> g_frame_stack;

View file

@ -129,7 +129,7 @@ void Func::AddBody(zeek::detail::StmtPtr /* new_body */,
Internal("Func::AddBody called"); Internal("Func::AddBody called");
} }
void Func::SetScope(ScopePtr newscope) void Func::SetScope(zeek::detail::ScopePtr newscope)
{ {
scope = std::move(newscope); scope = std::move(newscope);
} }
@ -179,7 +179,7 @@ void Func::DescribeDebug(ODesc* d, const zeek::Args* args) const
TraversalCode Func::Traverse(TraversalCallback* cb) const TraversalCode Func::Traverse(TraversalCallback* cb) const
{ {
// FIXME: Make a fake scope for builtins? // FIXME: Make a fake scope for builtins?
Scope* old_scope = cb->current_scope; zeek::detail::Scope* old_scope = cb->current_scope;
cb->current_scope = scope.get(); cb->current_scope = scope.get();
TraversalCode tc = cb->PreFunction(this); TraversalCode tc = cb->PreFunction(this);
@ -299,13 +299,13 @@ bool BroFunc::IsPure() const
[](const Body& b) { return b.stmts->IsPure(); }); [](const Body& b) { return b.stmts->IsPure(); });
} }
zeek::Val* Func::Call(val_list* args, Frame* parent) const zeek::Val* Func::Call(val_list* args, zeek::detail::Frame* parent) const
{ {
auto zargs = zeek::val_list_to_args(*args); auto zargs = zeek::val_list_to_args(*args);
return Invoke(&zargs, parent).release(); return Invoke(&zargs, parent).release();
}; };
zeek::ValPtr BroFunc::Invoke(zeek::Args* args, Frame* parent) const zeek::ValPtr BroFunc::Invoke(zeek::Args* args, zeek::detail::Frame* parent) const
{ {
#ifdef PROFILE_BRO_FUNCTIONS #ifdef PROFILE_BRO_FUNCTIONS
DEBUG_MSG("Function: %s\n", Name()); DEBUG_MSG("Function: %s\n", Name());
@ -331,7 +331,7 @@ zeek::ValPtr BroFunc::Invoke(zeek::Args* args, Frame* parent) const
return Flavor() == zeek::FUNC_FLAVOR_HOOK ? val_mgr->True() : nullptr; return Flavor() == zeek::FUNC_FLAVOR_HOOK ? val_mgr->True() : nullptr;
} }
auto f = zeek::make_intrusive<Frame>(frame_size, this, args); auto f = zeek::make_intrusive<zeek::detail::Frame>(frame_size, this, args);
if ( closure ) if ( closure )
f->CaptureClosure(closure, outer_ids); f->CaptureClosure(closure, outer_ids);
@ -479,7 +479,7 @@ void BroFunc::AddBody(zeek::detail::StmtPtr new_body,
sort(bodies.begin(), bodies.end()); sort(bodies.begin(), bodies.end());
} }
void BroFunc::AddClosure(id_list ids, Frame* f) void BroFunc::AddClosure(id_list ids, zeek::detail::Frame* f)
{ {
if ( ! f ) if ( ! f )
return; return;
@ -488,7 +488,7 @@ void BroFunc::AddClosure(id_list ids, Frame* f)
SetClosureFrame(f); SetClosureFrame(f);
} }
bool BroFunc::StrengthenClosureReference(Frame* f) bool BroFunc::StrengthenClosureReference(zeek::detail::Frame* f)
{ {
if ( closure != f ) if ( closure != f )
return false; return false;
@ -501,7 +501,7 @@ bool BroFunc::StrengthenClosureReference(Frame* f)
return true; return true;
} }
void BroFunc::SetClosureFrame(Frame* f) void BroFunc::SetClosureFrame(zeek::detail::Frame* f)
{ {
if ( closure ) if ( closure )
reporter->InternalError("Tried to override closure for BroFunc %s.", reporter->InternalError("Tried to override closure for BroFunc %s.",
@ -521,7 +521,7 @@ void BroFunc::SetClosureFrame(Frame* f)
bool BroFunc::UpdateClosure(const broker::vector& data) bool BroFunc::UpdateClosure(const broker::vector& data)
{ {
auto result = Frame::Unserialize(data); auto result = zeek::detail::Frame::Unserialize(data);
if ( ! result.first ) if ( ! result.first )
return false; return false;
@ -559,7 +559,7 @@ FuncPtr BroFunc::DoClone()
broker::expected<broker::data> BroFunc::SerializeClosure() const broker::expected<broker::data> BroFunc::SerializeClosure() const
{ {
return Frame::Serialize(closure, outer_ids); return zeek::detail::Frame::Serialize(closure, outer_ids);
} }
void BroFunc::Describe(ODesc* d) const void BroFunc::Describe(ODesc* d) const
@ -597,7 +597,7 @@ BuiltinFunc::BuiltinFunc(built_in_func arg_func, const char* arg_name,
name = make_full_var_name(GLOBAL_MODULE_NAME, arg_name); name = make_full_var_name(GLOBAL_MODULE_NAME, arg_name);
is_pure = arg_is_pure; is_pure = arg_is_pure;
const auto& id = lookup_ID(Name(), GLOBAL_MODULE_NAME, false); const auto& id = zeek::detail::lookup_ID(Name(), GLOBAL_MODULE_NAME, false);
if ( ! id ) if ( ! id )
reporter->InternalError("built-in function %s missing", Name()); reporter->InternalError("built-in function %s missing", Name());
if ( id->HasVal() ) if ( id->HasVal() )
@ -616,7 +616,7 @@ bool BuiltinFunc::IsPure() const
return is_pure; return is_pure;
} }
zeek::ValPtr BuiltinFunc::Invoke(zeek::Args* args, Frame* parent) const zeek::ValPtr BuiltinFunc::Invoke(zeek::Args* args, zeek::detail::Frame* parent) const
{ {
#ifdef PROFILE_BRO_FUNCTIONS #ifdef PROFILE_BRO_FUNCTIONS
DEBUG_MSG("Function: %s\n", Name()); DEBUG_MSG("Function: %s\n", Name());
@ -881,7 +881,7 @@ static int get_func_priority(const std::vector<zeek::detail::AttrPtr>& attrs)
return priority; return priority;
} }
function_ingredients::function_ingredients(ScopePtr scope, zeek::detail::StmtPtr body) function_ingredients::function_ingredients(zeek::detail::ScopePtr scope, zeek::detail::StmtPtr body)
{ {
frame_size = scope->Length(); frame_size = scope->Length();
inits = scope->GetInits(); inits = scope->GetInits();

View file

@ -17,20 +17,13 @@
#include "ZeekArgs.h" #include "ZeekArgs.h"
#include "BifReturnVal.h" #include "BifReturnVal.h"
class Frame; ZEEK_FORWARD_DECLARE_NAMESPACED(Scope, zeek::detail);
class Scope;
using ScopePtr = zeek::IntrusivePtr<Scope>;
ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(FuncType, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(FuncType, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
namespace zeek::detail {
using IDPtr = zeek::IntrusivePtr<ID>;
using StmtPtr = zeek::IntrusivePtr<Stmt>;
}
namespace caf { namespace caf {
template <class> class expected; template <class> class expected;
@ -42,6 +35,15 @@ using vector = std::vector<data>;
using caf::expected; using caf::expected;
} }
namespace zeek {
namespace detail {
using ScopePtr = zeek::IntrusivePtr<zeek::detail::Scope>;
using IDPtr = zeek::IntrusivePtr<ID>;
using StmtPtr = zeek::IntrusivePtr<Stmt>;
}
}
class Func; class Func;
using FuncPtr = zeek::IntrusivePtr<Func>; using FuncPtr = zeek::IntrusivePtr<Func>;
@ -69,7 +71,7 @@ public:
bool HasBodies() const { return bodies.size(); } bool HasBodies() const { return bodies.size(); }
[[deprecated("Remove in v4.1. Use Invoke() instead.")]] [[deprecated("Remove in v4.1. Use Invoke() instead.")]]
zeek::Val* Call(val_list* args, Frame* parent = nullptr) const; zeek::Val* Call(val_list* args, zeek::detail::Frame* parent = nullptr) const;
/** /**
* Calls a Zeek function. * Calls a Zeek function.
@ -78,7 +80,7 @@ public:
* @return the return value of the function call. * @return the return value of the function call.
*/ */
virtual zeek::ValPtr Invoke( virtual zeek::ValPtr Invoke(
zeek::Args* args, Frame* parent = nullptr) const = 0; zeek::Args* args, zeek::detail::Frame* parent = nullptr) const = 0;
/** /**
* A version of Invoke() taking a variable number of individual arguments. * A version of Invoke() taking a variable number of individual arguments.
@ -98,8 +100,8 @@ public:
const std::vector<zeek::detail::IDPtr>& new_inits, const std::vector<zeek::detail::IDPtr>& new_inits,
size_t new_frame_size, int priority = 0); size_t new_frame_size, int priority = 0);
virtual void SetScope(ScopePtr newscope); virtual void SetScope(zeek::detail::ScopePtr newscope);
virtual Scope* GetScope() const { return scope.get(); } virtual zeek::detail::Scope* GetScope() const { return scope.get(); }
[[deprecated("Remove in v4.1. Use GetType().")]] [[deprecated("Remove in v4.1. Use GetType().")]]
virtual zeek::FuncType* FType() const { return type.get(); } virtual zeek::FuncType* FType() const { return type.get(); }
@ -134,7 +136,7 @@ protected:
zeek::FunctionFlavor flavor) const; zeek::FunctionFlavor flavor) const;
std::vector<Body> bodies; std::vector<Body> bodies;
ScopePtr scope; zeek::detail::ScopePtr scope;
Kind kind; Kind kind;
uint32_t unique_id; uint32_t unique_id;
zeek::FuncTypePtr type; zeek::FuncTypePtr type;
@ -152,7 +154,7 @@ public:
~BroFunc() override; ~BroFunc() override;
bool IsPure() const override; bool IsPure() const override;
zeek::ValPtr Invoke(zeek::Args* args, Frame* parent) const override; zeek::ValPtr Invoke(zeek::Args* args, zeek::detail::Frame* parent) const override;
/** /**
* Adds adds a closure to the function. Closures are cloned and * Adds adds a closure to the function. Closures are cloned and
@ -161,7 +163,7 @@ public:
* @param ids IDs that are captured by the closure. * @param ids IDs that are captured by the closure.
* @param f the closure to be captured. * @param f the closure to be captured.
*/ */
void AddClosure(id_list ids, Frame* f); void AddClosure(id_list ids, zeek::detail::Frame* f);
/** /**
* Replaces the current closure with one built from *data* * Replaces the current closure with one built from *data*
@ -174,7 +176,7 @@ public:
* If the function's closure is a weak reference to the given frame, * If the function's closure is a weak reference to the given frame,
* upgrade to a strong reference of a shallow clone of that frame. * upgrade to a strong reference of a shallow clone of that frame.
*/ */
bool StrengthenClosureReference(Frame* f); bool StrengthenClosureReference(zeek::detail::Frame* f);
/** /**
* Serializes this function's closure. * Serializes this function's closure.
@ -210,7 +212,7 @@ protected:
* *
* @param f the frame to be cloned. * @param f the frame to be cloned.
*/ */
void SetClosureFrame(Frame* f); void SetClosureFrame(zeek::detail::Frame* f);
private: private:
size_t frame_size; size_t frame_size;
@ -218,11 +220,11 @@ private:
// List of the outer IDs used in the function. // List of the outer IDs used in the function.
id_list outer_ids; id_list outer_ids;
// The frame the BroFunc was initialized in. // The frame the BroFunc was initialized in.
Frame* closure = nullptr; zeek::detail::Frame* closure = nullptr;
bool weak_closure_ref = false; bool weak_closure_ref = false;
}; };
using built_in_func = BifReturnVal (*)(Frame* frame, const zeek::Args* args); using built_in_func = BifReturnVal (*)(zeek::detail::Frame* frame, const zeek::Args* args);
class BuiltinFunc final : public Func { class BuiltinFunc final : public Func {
public: public:
@ -230,7 +232,7 @@ public:
~BuiltinFunc() override; ~BuiltinFunc() override;
bool IsPure() const override; bool IsPure() const override;
zeek::ValPtr Invoke(zeek::Args* args, Frame* parent) const override; zeek::ValPtr Invoke(zeek::Args* args, zeek::detail::Frame* parent) const override;
built_in_func TheFunc() const { return func; } built_in_func TheFunc() const { return func; }
void Describe(ODesc* d) const override; void Describe(ODesc* d) const override;
@ -263,14 +265,14 @@ 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(ScopePtr scope, zeek::detail::StmtPtr body); function_ingredients(zeek::detail::ScopePtr scope, zeek::detail::StmtPtr body);
zeek::detail::IDPtr id; zeek::detail::IDPtr id;
zeek::detail::StmtPtr body; zeek::detail::StmtPtr body;
std::vector<zeek::detail::IDPtr> inits; std::vector<zeek::detail::IDPtr> inits;
int frame_size; int frame_size;
int priority; int priority;
ScopePtr scope; zeek::detail::ScopePtr scope;
}; };
extern std::vector<CallInfo> call_stack; extern std::vector<CallInfo> call_stack;

View file

@ -23,16 +23,15 @@
#include <stdlib.h> #include <stdlib.h>
// to allow bro_md5_hmac access to the hmac seed // to allow bro_md5_hmac access to the hmac seed
#include "ZeekArgs.h" #include "ZeekArgs.h"
//ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
class BroString; class BroString;
class Frame;
class BifReturnVal; class BifReturnVal;
namespace zeek::BifFunc { namespace zeek::BifFunc {
extern BifReturnVal md5_hmac_bif(::Frame* frame, const zeek::Args*); extern BifReturnVal md5_hmac_bif(zeek::detail::Frame* frame, const zeek::Args*);
} }
typedef uint64_t hash_t; typedef uint64_t hash_t;
@ -197,7 +196,7 @@ private:
inline static bool seeds_initialized = false; inline static bool seeds_initialized = false;
friend void hmac_md5(size_t size, const unsigned char* bytes, unsigned char digest[16]); friend void hmac_md5(size_t size, const unsigned char* bytes, unsigned char digest[16]);
friend BifReturnVal zeek::BifFunc::md5_hmac_bif(Frame* frame, const zeek::Args*); friend BifReturnVal zeek::BifFunc::md5_hmac_bif(zeek::detail::Frame* frame, const zeek::Args*);
}; };
typedef enum { typedef enum {

View file

@ -34,12 +34,12 @@ zeek::VectorTypePtr zeek::id::index_vec;
const zeek::detail::IDPtr& zeek::id::find(std::string_view name) const zeek::detail::IDPtr& zeek::id::find(std::string_view name)
{ {
return global_scope()->Find(name); return zeek::detail::global_scope()->Find(name);
} }
const zeek::TypePtr& zeek::id::find_type(std::string_view name) const zeek::TypePtr& zeek::id::find_type(std::string_view name)
{ {
auto id = global_scope()->Find(name); auto id = zeek::detail::global_scope()->Find(name);
if ( ! id ) if ( ! id )
reporter->InternalError("Failed to find type named: %s", reporter->InternalError("Failed to find type named: %s",
@ -50,7 +50,7 @@ const zeek::TypePtr& zeek::id::find_type(std::string_view name)
const zeek::ValPtr& zeek::id::find_val(std::string_view name) const zeek::ValPtr& zeek::id::find_val(std::string_view name)
{ {
auto id = global_scope()->Find(name); auto id = zeek::detail::global_scope()->Find(name);
if ( ! id ) if ( ! id )
reporter->InternalError("Failed to find variable named: %s", reporter->InternalError("Failed to find variable named: %s",
@ -61,7 +61,7 @@ const zeek::ValPtr& zeek::id::find_val(std::string_view name)
const zeek::ValPtr& zeek::id::find_const(std::string_view name) const zeek::ValPtr& zeek::id::find_const(std::string_view name)
{ {
auto id = global_scope()->Find(name); auto id = zeek::detail::global_scope()->Find(name);
if ( ! id ) if ( ! id )
reporter->InternalError("Failed to find variable named: %s", reporter->InternalError("Failed to find variable named: %s",
@ -366,7 +366,7 @@ TraversalCode ID::Traverse(TraversalCallback* cb) const
// FIXME: Perhaps we should be checking at other than global scope. // FIXME: Perhaps we should be checking at other than global scope.
else if ( val && IsFunc(val->GetType()->Tag()) && else if ( val && IsFunc(val->GetType()->Tag()) &&
cb->current_scope == global_scope() ) cb->current_scope == zeek::detail::global_scope() )
{ {
tc = val->AsFunc()->Traverse(cb); tc = val->AsFunc()->Traverse(cb);
HANDLE_TC_STMT_PRE(tc); HANDLE_TC_STMT_PRE(tc);

View file

@ -193,7 +193,7 @@ void net_init(const std::optional<std::string>& interface,
reporter->FatalError("problem opening dump file %s (%s)", reporter->FatalError("problem opening dump file %s (%s)",
writefile, pkt_dumper->ErrorMsg()); writefile, pkt_dumper->ErrorMsg());
if ( const auto& id = global_scope()->Find("trace_output_file") ) if ( const auto& id = zeek::detail::global_scope()->Find("trace_output_file") )
id->SetVal(zeek::make_intrusive<zeek::StringVal>(writefile)); id->SetVal(zeek::make_intrusive<zeek::StringVal>(writefile));
else else
reporter->Error("trace_output_file not defined in bro.init"); reporter->Error("trace_output_file not defined in bro.init");

View file

@ -130,7 +130,7 @@ zeek::TypePtr OpaqueVal::UnserializeType(const broker::data& data)
if ( ! name ) if ( ! name )
return nullptr; return nullptr;
const auto& id = global_scope()->Find(*name); const auto& id = zeek::detail::global_scope()->Find(*name);
if ( ! id ) if ( ! id )
return nullptr; return nullptr;

View file

@ -129,7 +129,7 @@ bool RuleConditionPayloadSize::DoMatch(Rule* rule, RuleEndpointState* state,
RuleConditionEval::RuleConditionEval(const char* func) RuleConditionEval::RuleConditionEval(const char* func)
{ {
id = global_scope()->Find(func).get(); id = zeek::detail::global_scope()->Find(func).get();
if ( ! id ) if ( ! id )
{ {
rules_error("unknown identifier", func); rules_error("unknown identifier", func);

View file

@ -1274,7 +1274,7 @@ void RuleMatcher::DumpStateStats(BroFile* f, RuleHdrTest* hdr_test)
static zeek::Val* get_bro_val(const char* label) static zeek::Val* get_bro_val(const char* label)
{ {
auto id = lookup_ID(label, GLOBAL_MODULE_NAME, false); auto id = zeek::detail::lookup_ID(label, GLOBAL_MODULE_NAME, false);
if ( ! id ) if ( ! id )
{ {
rules_error("unknown script-level identifier", label); rules_error("unknown script-level identifier", label);

View file

@ -10,7 +10,9 @@
#include "Reporter.h" #include "Reporter.h"
#include "module_util.h" #include "module_util.h"
typedef PList<Scope> scope_list; namespace zeek::detail {
using scope_list = PList<Scope>;
static scope_list scopes; static scope_list scopes;
static Scope* top_scope; static Scope* top_scope;
@ -119,8 +121,7 @@ TraversalCode Scope::Traverse(TraversalCallback* cb) const
} }
const zeek::detail::IDPtr& lookup_ID( const zeek::detail::IDPtr& lookup_ID(const char* name, const char* curr_module,
const char* name, const char* curr_module,
bool no_global, bool same_module_only, bool no_global, bool same_module_only,
bool check_export) bool check_export)
{ {
@ -154,8 +155,7 @@ const zeek::detail::IDPtr& lookup_ID(
return zeek::detail::ID::nil; return zeek::detail::ID::nil;
} }
zeek::detail::IDPtr install_ID( zeek::detail::IDPtr install_ID(const char* name, const char* module_name,
const char* name, const char* module_name,
bool is_global, bool is_export) bool is_global, bool is_export)
{ {
if ( scopes.empty() && ! is_global ) if ( scopes.empty() && ! is_global )
@ -220,3 +220,14 @@ Scope* global_scope()
{ {
return scopes.empty() ? 0 : scopes.front(); return scopes.empty() ? 0 : scopes.front();
} }
}
const zeek::detail::IDPtr& lookup_ID(
const char* name, const char* module,
bool no_global,
bool same_module_only,
bool check_export)
{
return zeek::detail::lookup_ID(name, module, no_global, same_module_only, check_export);
}

View file

@ -12,21 +12,21 @@
#include "IntrusivePtr.h" #include "IntrusivePtr.h"
#include "TraverseTypes.h" #include "TraverseTypes.h"
ZEEK_FORWARD_DECLARE_NAMESPACED(Type, zeek);
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail);
namespace zeek { namespace zeek {
template <class T> class IntrusivePtr; template <class T> class IntrusivePtr;
using TypePtr = zeek::IntrusivePtr<Type>;
class Type; namespace detail {
using TypePtr = zeek::IntrusivePtr<zeek::Type>;
}
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
namespace zeek::detail {
class Attr;
using AttrPtr = zeek::IntrusivePtr<Attr>; using AttrPtr = zeek::IntrusivePtr<Attr>;
using IDPtr = zeek::IntrusivePtr<ID>; using IDPtr = zeek::IntrusivePtr<ID>;
}
class Scope; class Scope;
using ScopePtr = zeek::IntrusivePtr<Scope>; using ScopePtr = zeek::IntrusivePtr<Scope>;
@ -88,9 +88,6 @@ protected:
std::vector<zeek::detail::IDPtr> inits; std::vector<zeek::detail::IDPtr> inits;
}; };
extern bool in_debug;
// If no_global is true, don't search in the default "global" namespace. // If no_global is true, don't search in the default "global" namespace.
extern const zeek::detail::IDPtr& lookup_ID( extern const zeek::detail::IDPtr& lookup_ID(
const char* name, const char* module, const char* name, const char* module,
@ -113,3 +110,26 @@ extern Scope* global_scope();
// Current module (identified by its name). // Current module (identified by its name).
extern std::string current_module; extern std::string current_module;
} // namespace detail
} // namespace zeek
extern bool in_debug;
using Scope [[deprecated("Remove in v4.1. Use zeek::detail::Scope instead.")]] = zeek::detail::Scope;
extern std::string& current_module [[deprecated("Remove in v4.1. Use zeek::detail::current_module.")]];
constexpr auto install_ID [[deprecated("Remove in v4.1 Use zeek::detail::install_ID instead.")]] = zeek::detail::install_ID;
constexpr auto push_scope [[deprecated("Remove in v4.1 Use zeek::detail::push_scope instead.")]] = zeek::detail::push_scope;
constexpr auto push_existing_scope[[deprecated("Remove in v4.1 Use zeek::detail::push_existing_scope instead.")]] = zeek::detail::push_existing_scope;
constexpr auto pop_scope [[deprecated("Remove in v4.1 Use zeek::detail::pop_scope instead.")]] = zeek::detail::pop_scope;
constexpr auto current_scope [[deprecated("Remove in v4.1 Use zeek::detail::current_scope instead.")]] = zeek::detail::current_scope;
constexpr auto global_scope [[deprecated("Remove in v4.1 Use zeek::detail::global_scope instead.")]] = zeek::detail::global_scope;
// Because of the use of default arguments, this function can't be aliased like the rest.
[[deprecated("Remove in v4.1 Use zeek::detail::lookup_ID instead.")]]
extern const zeek::detail::IDPtr& lookup_ID(
const char* name, const char* module,
bool no_global = false,
bool same_module_only = false,
bool check_export = true);

View file

@ -240,7 +240,7 @@ void ProfileLogger::Log()
// Script-level state. // Script-level state.
unsigned int size, mem = 0; unsigned int size, mem = 0;
const auto& globals = global_scope()->Vars(); const auto& globals = zeek::detail::global_scope()->Vars();
if ( expensive ) if ( expensive )
{ {

View file

@ -14,7 +14,8 @@
#include "TraverseTypes.h" #include "TraverseTypes.h"
class CompositeHash; class CompositeHash;
class Frame;
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
namespace zeek::detail { namespace zeek::detail {

View file

@ -7,16 +7,16 @@
TraversalCode traverse_all(TraversalCallback* cb) TraversalCode traverse_all(TraversalCallback* cb)
{ {
if ( ! global_scope() ) if ( ! zeek::detail::global_scope() )
return TC_CONTINUE; return TC_CONTINUE;
if ( ! stmts ) if ( ! stmts )
// May be null when parsing fails. // May be null when parsing fails.
return TC_CONTINUE; return TC_CONTINUE;
cb->current_scope = global_scope(); cb->current_scope = zeek::detail::global_scope();
TraversalCode tc = global_scope()->Traverse(cb); TraversalCode tc = zeek::detail::global_scope()->Traverse(cb);
HANDLE_TC_STMT_PRE(tc); HANDLE_TC_STMT_PRE(tc);
tc = stmts->Traverse(cb); tc = stmts->Traverse(cb);

View file

@ -5,8 +5,8 @@
#include "TraverseTypes.h" #include "TraverseTypes.h"
class Func; class Func;
class Scope;
ZEEK_FORWARD_DECLARE_NAMESPACED(Scope, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
@ -34,7 +34,7 @@ public:
virtual TraversalCode PreDecl(const zeek::detail::ID*) { return TC_CONTINUE; } virtual TraversalCode PreDecl(const zeek::detail::ID*) { return TC_CONTINUE; }
virtual TraversalCode PostDecl(const zeek::detail::ID*) { return TC_CONTINUE; } virtual TraversalCode PostDecl(const zeek::detail::ID*) { return TC_CONTINUE; }
Scope* current_scope; zeek::detail::Scope* current_scope;
}; };
TraversalCode traverse_all(TraversalCallback* cb); TraversalCode traverse_all(TraversalCallback* cb);

View file

@ -10,10 +10,10 @@
#include "util.h" #include "util.h"
#include "IntrusivePtr.h" #include "IntrusivePtr.h"
class Frame;
class ODesc; class ODesc;
ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);

View file

@ -1131,11 +1131,11 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name,
return; return;
} }
auto id = lookup_ID(name, module_name.c_str()); auto id = zeek::detail::lookup_ID(name, module_name.c_str());
if ( ! id ) if ( ! id )
{ {
id = install_ID(name, module_name.c_str(), true, is_export); id = zeek::detail::install_ID(name, module_name.c_str(), true, is_export);
id->SetType({zeek::NewRef{}, this}); id->SetType({zeek::NewRef{}, this});
id->SetEnumConst(); id->SetEnumConst();
@ -1733,7 +1733,7 @@ TypePtr merge_types(const TypePtr& arg_t1,
// Doing a lookup here as a roundabout way of ref-ing t1, without // Doing a lookup here as a roundabout way of ref-ing t1, without
// changing the function params which has t1 as const and also // changing the function params which has t1 as const and also
// (potentially) avoiding a pitfall mentioned earlier about clones. // (potentially) avoiding a pitfall mentioned earlier about clones.
const auto& id = global_scope()->Find(t1->GetName()); const auto& id = zeek::detail::global_scope()->Find(t1->GetName());
if ( id && id->IsType() && id->GetType()->Tag() == TYPE_ENUM ) if ( id && id->IsType() && id->GetType()->Tag() == TYPE_ENUM )
// It should make most sense to return the real type here rather // It should make most sense to return the real type here rather

View file

@ -383,7 +383,7 @@ void Val::ValDescribeReST(ODesc* d) const
#ifdef DEBUG #ifdef DEBUG
detail::ID* Val::GetID() const detail::ID* Val::GetID() const
{ {
return bound_id ? global_scope()->Find(bound_id).get() : nullptr; return bound_id ? zeek::detail::global_scope()->Find(bound_id).get() : nullptr;
} }
void Val::SetID(detail::ID* id) void Val::SetID(detail::ID* id)
@ -2331,7 +2331,7 @@ bool TableVal::CheckAndAssign(ValPtr index, ValPtr new_val)
return Assign(std::move(index), std::move(new_val)); return Assign(std::move(index), std::move(new_val));
} }
void TableVal::InitDefaultFunc(Frame* f) void TableVal::InitDefaultFunc(zeek::detail::Frame* f)
{ {
// Value aready initialized. // Value aready initialized.
if ( def_val ) if ( def_val )

View file

@ -41,7 +41,8 @@ class RE_Matcher;
class CompositeHash; class CompositeHash;
class HashKey; class HashKey;
class Frame;
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
extern double bro_start_network_time; extern double bro_start_network_time;
@ -980,7 +981,7 @@ public:
// If the &default attribute is not a function, or the functon has // If the &default attribute is not a function, or the functon has
// already been initialized, this does nothing. Otherwise, evaluates // 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(Frame* f); void InitDefaultFunc(zeek::detail::Frame* f);
unsigned int MemoryAllocation() const override; unsigned int MemoryAllocation() const override;

View file

@ -350,7 +350,7 @@ zeek::detail::StmtPtr add_local(
else else
{ {
current_scope()->AddInit(std::move(id)); zeek::detail::current_scope()->AddInit(std::move(id));
return zeek::make_intrusive<zeek::detail::NullStmt>(); return zeek::make_intrusive<zeek::detail::NullStmt>();
} }
} }
@ -568,7 +568,7 @@ void begin_func(zeek::detail::IDPtr id, const char* module_name,
else else
id->SetType(t); id->SetType(t);
push_scope(std::move(id), std::move(attrs)); zeek::detail::push_scope(std::move(id), std::move(attrs));
const auto& args = t->Params(); const auto& args = t->Params();
int num_args = args->NumFields(); int num_args = args->NumFields();
@ -576,26 +576,26 @@ void begin_func(zeek::detail::IDPtr id, const char* module_name,
for ( int i = 0; i < num_args; ++i ) for ( int i = 0; i < num_args; ++i )
{ {
zeek::TypeDecl* arg_i = args->FieldDecl(i); zeek::TypeDecl* arg_i = args->FieldDecl(i);
auto arg_id = lookup_ID(arg_i->id, module_name); auto arg_id = zeek::detail::lookup_ID(arg_i->id, module_name);
if ( arg_id && ! arg_id->IsGlobal() ) if ( arg_id && ! arg_id->IsGlobal() )
arg_id->Error("argument name used twice"); arg_id->Error("argument name used twice");
arg_id = install_ID(arg_i->id, module_name, false, false); arg_id = zeek::detail::install_ID(arg_i->id, module_name, false, false);
arg_id->SetType(arg_i->type); arg_id->SetType(arg_i->type);
if ( prototype ) if ( prototype )
arg_id->SetOffset(prototype->offsets[i]); arg_id->SetOffset(prototype->offsets[i]);
} }
if ( zeek::detail::Attr* depr_attr = find_attr(current_scope()->Attrs().get(), if ( zeek::detail::Attr* depr_attr = find_attr(zeek::detail::current_scope()->Attrs().get(),
zeek::detail::ATTR_DEPRECATED) ) zeek::detail::ATTR_DEPRECATED) )
current_scope()->GetID()->MakeDeprecated(depr_attr->GetExpr()); zeek::detail::current_scope()->GetID()->MakeDeprecated(depr_attr->GetExpr());
} }
class OuterIDBindingFinder : public TraversalCallback { class OuterIDBindingFinder : public TraversalCallback {
public: public:
OuterIDBindingFinder(Scope* s) OuterIDBindingFinder(zeek::detail::Scope* s)
{ {
scopes.emplace_back(s); scopes.emplace_back(s);
} }
@ -603,7 +603,7 @@ public:
TraversalCode PreExpr(const zeek::detail::Expr*) override; TraversalCode PreExpr(const zeek::detail::Expr*) override;
TraversalCode PostExpr(const zeek::detail::Expr*) override; TraversalCode PostExpr(const zeek::detail::Expr*) override;
std::vector<Scope*> scopes; std::vector<zeek::detail::Scope*> scopes;
std::vector<const zeek::detail::NameExpr*> outer_id_references; std::vector<const zeek::detail::NameExpr*> outer_id_references;
}; };
@ -644,7 +644,8 @@ TraversalCode OuterIDBindingFinder::PostExpr(const zeek::detail::Expr* expr)
void end_func(zeek::detail::StmtPtr body) void end_func(zeek::detail::StmtPtr body)
{ {
auto ingredients = std::make_unique<function_ingredients>(pop_scope(), std::move(body)); auto ingredients = std::make_unique<function_ingredients>(zeek::detail::pop_scope(),
std::move(body));
if ( ingredients->id->HasVal() ) if ( ingredients->id->HasVal() )
ingredients->id->GetVal()->AsFunc()->AddBody( ingredients->id->GetVal()->AsFunc()->AddBody(
@ -677,7 +678,7 @@ zeek::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, zeek::detail::Stmt* body) id_list gather_outer_ids(zeek::detail::Scope* scope, zeek::detail::Stmt* body)
{ {
OuterIDBindingFinder cb(scope); OuterIDBindingFinder cb(scope);
body->Traverse(&cb); body->Traverse(&cb);
@ -704,13 +705,13 @@ zeek::Val* internal_const_val(const char* name)
zeek::Val* opt_internal_val(const char* name) zeek::Val* opt_internal_val(const char* name)
{ {
const auto& id = lookup_ID(name, GLOBAL_MODULE_NAME); const auto& id = zeek::detail::lookup_ID(name, GLOBAL_MODULE_NAME);
return id ? id->GetVal().get() : nullptr; return id ? id->GetVal().get() : nullptr;
} }
double opt_internal_double(const char* name) double opt_internal_double(const char* name)
{ {
const auto& id = lookup_ID(name, GLOBAL_MODULE_NAME); const auto& id = zeek::detail::lookup_ID(name, GLOBAL_MODULE_NAME);
if ( ! id ) return 0.0; if ( ! id ) return 0.0;
const auto& v = id->GetVal(); const auto& v = id->GetVal();
return v ? v->InternalDouble() : 0.0; return v ? v->InternalDouble() : 0.0;
@ -718,7 +719,7 @@ double opt_internal_double(const char* name)
bro_int_t opt_internal_int(const char* name) bro_int_t opt_internal_int(const char* name)
{ {
const auto& id = lookup_ID(name, GLOBAL_MODULE_NAME); const auto& id = zeek::detail::lookup_ID(name, GLOBAL_MODULE_NAME);
if ( ! id ) return 0; if ( ! id ) return 0;
const auto& v = id->GetVal(); const auto& v = id->GetVal();
return v ? v->InternalInt() : 0; return v ? v->InternalInt() : 0;
@ -726,7 +727,7 @@ bro_int_t opt_internal_int(const char* name)
bro_uint_t opt_internal_unsigned(const char* name) bro_uint_t opt_internal_unsigned(const char* name)
{ {
const auto& id = lookup_ID(name, GLOBAL_MODULE_NAME); const auto& id = zeek::detail::lookup_ID(name, GLOBAL_MODULE_NAME);
if ( ! id ) return 0; if ( ! id ) return 0;
const auto& v = id->GetVal(); const auto& v = id->GetVal();
return v ? v->InternalUnsigned() : 0; return v ? v->InternalUnsigned() : 0;
@ -734,7 +735,7 @@ bro_uint_t opt_internal_unsigned(const char* name)
zeek::StringVal* opt_internal_string(const char* name) zeek::StringVal* opt_internal_string(const char* name)
{ {
const auto& id = lookup_ID(name, GLOBAL_MODULE_NAME); const auto& id = zeek::detail::lookup_ID(name, GLOBAL_MODULE_NAME);
if ( ! id ) return nullptr; if ( ! id ) return nullptr;
const auto& v = id->GetVal(); const auto& v = id->GetVal();
return v ? v->AsStringVal() : nullptr; return v ? v->AsStringVal() : nullptr;
@ -742,7 +743,7 @@ zeek::StringVal* opt_internal_string(const char* name)
zeek::TableVal* opt_internal_table(const char* name) zeek::TableVal* opt_internal_table(const char* name)
{ {
const auto& id = lookup_ID(name, GLOBAL_MODULE_NAME); const auto& id = zeek::detail::lookup_ID(name, GLOBAL_MODULE_NAME);
if ( ! id ) return nullptr; if ( ! id ) return nullptr;
const auto& v = id->GetVal(); const auto& v = id->GetVal();
return v ? v->AsTableVal() : nullptr; return v ? v->AsTableVal() : nullptr;
@ -750,7 +751,7 @@ zeek::TableVal* opt_internal_table(const char* name)
zeek::ListVal* internal_list_val(const char* name) zeek::ListVal* internal_list_val(const char* name)
{ {
const auto& id = lookup_ID(name, GLOBAL_MODULE_NAME); const auto& id = zeek::detail::lookup_ID(name, GLOBAL_MODULE_NAME);
if ( ! id ) if ( ! id )
return nullptr; return nullptr;

View file

@ -6,7 +6,6 @@
#include "ID.h" #include "ID.h"
#include "Type.h" #include "Type.h"
class Scope;
class EventHandlerPtr; class EventHandlerPtr;
ZEEK_FORWARD_DECLARE_NAMESPACED(StringVal, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(StringVal, zeek);
@ -15,6 +14,7 @@ ZEEK_FORWARD_DECLARE_NAMESPACED(ListVal, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(FuncType, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(FuncType, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Scope, zeek::detail);
namespace zeek::detail { namespace zeek::detail {
using StmtPtr = zeek::IntrusivePtr<zeek::detail::Stmt>; using StmtPtr = zeek::IntrusivePtr<zeek::detail::Stmt>;
@ -53,7 +53,7 @@ extern void begin_func(zeek::detail::IDPtr id, const char* module_name,
extern void end_func(zeek::detail::StmtPtr body); extern void end_func(zeek::detail::StmtPtr 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, zeek::detail::Stmt* body); extern id_list gather_outer_ids(zeek::detail::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 zeek::Val* internal_val(const char* name); extern zeek::Val* internal_val(const char* name);

View file

@ -90,7 +90,7 @@ void Manager::InitPreScript()
void Manager::InitPostScript() void Manager::InitPostScript()
{ {
const auto& id = global_scope()->Find("Tunnel::vxlan_ports"); const auto& id = zeek::detail::global_scope()->Find("Tunnel::vxlan_ports");
if ( ! (id && id->GetVal()) ) if ( ! (id && id->GetVal()) )
reporter->FatalError("Tunnel::vxlan_ports not defined"); reporter->FatalError("Tunnel::vxlan_ports not defined");

View file

@ -349,7 +349,7 @@ struct val_converter {
if ( ! name ) if ( ! name )
return nullptr; return nullptr;
const auto& id = global_scope()->Find(*name); const auto& id = zeek::detail::global_scope()->Find(*name);
if ( ! id ) if ( ! id )
return nullptr; return nullptr;
@ -693,7 +693,7 @@ struct type_checker {
if ( ! name ) if ( ! name )
return false; return false;
const auto& id = global_scope()->Find(*name); const auto& id = zeek::detail::global_scope()->Find(*name);
if ( ! id ) if ( ! id )
return false; return false;
@ -1112,12 +1112,12 @@ struct data_type_getter {
} }
}; };
zeek::EnumValPtr bro_broker::get_data_type(zeek::RecordVal* v, Frame* frame) zeek::EnumValPtr bro_broker::get_data_type(zeek::RecordVal* v, zeek::detail::Frame* frame)
{ {
return caf::visit(data_type_getter{}, opaque_field_to_data(v, frame)); return caf::visit(data_type_getter{}, opaque_field_to_data(v, frame));
} }
broker::data& bro_broker::opaque_field_to_data(zeek::RecordVal* v, Frame* f) broker::data& bro_broker::opaque_field_to_data(zeek::RecordVal* v, zeek::detail::Frame* f)
{ {
const auto& d = v->GetField(0); const auto& d = v->GetField(0);

View file

@ -46,7 +46,7 @@ zeek::RecordValPtr make_data_val(broker::data d);
* @param frame used to get location info upon error. * @param frame used to get location info upon error.
* @return a Broker::DataType value. * @return a Broker::DataType value.
*/ */
zeek::EnumValPtr get_data_type(zeek::RecordVal* v, Frame* frame); zeek::EnumValPtr get_data_type(zeek::RecordVal* v, zeek::detail::Frame* frame);
/** /**
* Convert a Bro value to a Broker data value. * Convert a Bro value to a Broker data value.
@ -188,7 +188,7 @@ struct type_name_getter {
* @return a reference to the wrapped Broker data value. A runtime interpreter * @return a reference to the wrapped Broker data value. A runtime interpreter
* exception is thrown if the the optional opaque value of \a v is not set. * exception is thrown if the the optional opaque value of \a v is not set.
*/ */
broker::data& opaque_field_to_data(zeek::RecordVal* v, Frame* f); broker::data& opaque_field_to_data(zeek::RecordVal* v, zeek::detail::Frame* f);
/** /**
* Retrieve variant data from a Broker data value. * Retrieve variant data from a Broker data value.
@ -201,7 +201,7 @@ broker::data& opaque_field_to_data(zeek::RecordVal* v, Frame* f);
* is not currently stored in the Broker data. * is not currently stored in the Broker data.
*/ */
template <typename T> template <typename T>
T& require_data_type(broker::data& d, zeek::TypeTag tag, Frame* f) T& require_data_type(broker::data& d, zeek::TypeTag tag, zeek::detail::Frame* f)
{ {
auto ptr = caf::get_if<T>(&d); auto ptr = caf::get_if<T>(&d);
if ( ! ptr ) if ( ! ptr )
@ -217,7 +217,7 @@ T& require_data_type(broker::data& d, zeek::TypeTag tag, Frame* f)
* @see require_data_type() and opaque_field_to_data(). * @see require_data_type() and opaque_field_to_data().
*/ */
template <typename T> template <typename T>
inline T& require_data_type(zeek::RecordVal* v, zeek::TypeTag tag, Frame* f) inline T& require_data_type(zeek::RecordVal* v, zeek::TypeTag tag, zeek::detail::Frame* f)
{ {
return require_data_type<T>(opaque_field_to_data(v, f), tag, f); return require_data_type<T>(opaque_field_to_data(v, f), tag, f);
} }
@ -227,7 +227,7 @@ inline T& require_data_type(zeek::RecordVal* v, zeek::TypeTag tag, Frame* f)
class SetIterator : public zeek::OpaqueVal { class SetIterator : public zeek::OpaqueVal {
public: public:
SetIterator(zeek::RecordVal* v, zeek::TypeTag tag, Frame* f) SetIterator(zeek::RecordVal* v, zeek::TypeTag tag, zeek::detail::Frame* f)
: zeek::OpaqueVal(bro_broker::opaque_of_set_iterator), : zeek::OpaqueVal(bro_broker::opaque_of_set_iterator),
dat(require_data_type<broker::set>(v, zeek::TYPE_TABLE, f)), dat(require_data_type<broker::set>(v, zeek::TYPE_TABLE, f)),
it(dat.begin()) it(dat.begin())
@ -247,7 +247,7 @@ protected:
class TableIterator : public zeek::OpaqueVal { class TableIterator : public zeek::OpaqueVal {
public: public:
TableIterator(zeek::RecordVal* v, zeek::TypeTag tag, Frame* f) TableIterator(zeek::RecordVal* v, zeek::TypeTag tag, zeek::detail::Frame* f)
: zeek::OpaqueVal(bro_broker::opaque_of_table_iterator), : zeek::OpaqueVal(bro_broker::opaque_of_table_iterator),
dat(require_data_type<broker::table>(v, zeek::TYPE_TABLE, f)), dat(require_data_type<broker::table>(v, zeek::TYPE_TABLE, f)),
it(dat.begin()) it(dat.begin())
@ -267,7 +267,7 @@ protected:
class VectorIterator : public zeek::OpaqueVal { class VectorIterator : public zeek::OpaqueVal {
public: public:
VectorIterator(zeek::RecordVal* v, zeek::TypeTag tag, Frame* f) VectorIterator(zeek::RecordVal* v, zeek::TypeTag tag, zeek::detail::Frame* f)
: zeek::OpaqueVal(bro_broker::opaque_of_vector_iterator), : zeek::OpaqueVal(bro_broker::opaque_of_vector_iterator),
dat(require_data_type<broker::vector>(v, zeek::TYPE_VECTOR, f)), dat(require_data_type<broker::vector>(v, zeek::TYPE_VECTOR, f)),
it(dat.begin()) it(dat.begin())
@ -287,7 +287,7 @@ protected:
class RecordIterator : public zeek::OpaqueVal { class RecordIterator : public zeek::OpaqueVal {
public: public:
RecordIterator(zeek::RecordVal* v, zeek::TypeTag tag, Frame* f) RecordIterator(zeek::RecordVal* v, zeek::TypeTag tag, zeek::detail::Frame* f)
: zeek::OpaqueVal(bro_broker::opaque_of_record_iterator), : zeek::OpaqueVal(bro_broker::opaque_of_record_iterator),
dat(require_data_type<broker::vector>(v, zeek::TYPE_RECORD, f)), dat(require_data_type<broker::vector>(v, zeek::TYPE_RECORD, f)),
it(dat.begin()) it(dat.begin())

View file

@ -30,7 +30,7 @@ namespace bro_broker {
static inline zeek::Val* get_option(const char* option) static inline zeek::Val* get_option(const char* option)
{ {
const auto& id = global_scope()->Find(option); const auto& id = zeek::detail::global_scope()->Find(option);
if ( ! (id && id->GetVal()) ) if ( ! (id && id->GetVal()) )
reporter->FatalError("Unknown Broker option %s", option); reporter->FatalError("Unknown Broker option %s", option);
@ -70,7 +70,7 @@ const broker::endpoint_info Manager::NoPeer{{}, {}};
int Manager::script_scope = 0; int Manager::script_scope = 0;
struct scoped_reporter_location { struct scoped_reporter_location {
scoped_reporter_location(Frame* frame) scoped_reporter_location(zeek::detail::Frame* frame)
{ {
reporter->PushLocation(frame->GetCall()->GetLocationInfo()); reporter->PushLocation(frame->GetCall()->GetLocationInfo());
} }
@ -413,7 +413,7 @@ bool Manager::PublishIdentifier(std::string topic, std::string id)
if ( peer_count == 0 ) if ( peer_count == 0 )
return true; return true;
const auto& i = global_scope()->Find(id); const auto& i = zeek::detail::global_scope()->Find(id);
if ( ! i ) if ( ! i )
return false; return false;
@ -699,7 +699,7 @@ bool Manager::AutoUnpublishEvent(const string& topic, zeek::Val* event)
return true; return true;
} }
zeek::RecordVal* Manager::MakeEvent(val_list* args, Frame* frame) zeek::RecordVal* Manager::MakeEvent(val_list* args, zeek::detail::Frame* frame)
{ {
auto rval = new zeek::RecordVal(zeek::BifType::Record::Broker::Event); auto rval = new zeek::RecordVal(zeek::BifType::Record::Broker::Event);
auto arg_vec = zeek::make_intrusive<zeek::VectorVal>(vector_of_data_type); auto arg_vec = zeek::make_intrusive<zeek::VectorVal>(vector_of_data_type);
@ -1188,7 +1188,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
++statistics.num_ids_incoming; ++statistics.num_ids_incoming;
auto id_name = std::move(iu.id_name()); auto id_name = std::move(iu.id_name());
auto id_value = std::move(iu.id_value()); auto id_value = std::move(iu.id_value());
const auto& id = global_scope()->Find(id_name); const auto& id = zeek::detail::global_scope()->Find(id_name);
if ( ! id ) if ( ! id )
{ {

View file

@ -21,9 +21,9 @@
#include "iosource/IOSource.h" #include "iosource/IOSource.h"
#include "logging/WriterBackend.h" #include "logging/WriterBackend.h"
class Frame;
class Func; class Func;
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(VectorType, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(VectorType, zeek);
namespace zeek { namespace zeek {
using VectorTypePtr = zeek::IntrusivePtr<zeek::VectorType>; using VectorTypePtr = zeek::IntrusivePtr<zeek::VectorType>;
@ -231,7 +231,7 @@ public:
* @return an `Event` record value. If an invalid event or arguments * @return an `Event` record value. If an invalid event or arguments
* were supplied the optional "name" field will not be set. * were supplied the optional "name" field will not be set.
*/ */
zeek::RecordVal* MakeEvent(val_list* args, Frame* frame); zeek::RecordVal* MakeEvent(val_list* args, zeek::detail::Frame* frame);
/** /**
* Register interest in peer event messages that use a certain topic prefix. * Register interest in peer event messages that use a certain topic prefix.

View file

@ -48,7 +48,7 @@ std::set<std::string> val_to_topic_set(zeek::Val* val)
} }
static bool publish_event_args(val_list& args, const BroString* topic, static bool publish_event_args(val_list& args, const BroString* topic,
Frame* frame) zeek::detail::Frame* frame)
{ {
bro_broker::Manager::ScriptScopeGuard ssg; bro_broker::Manager::ScriptScopeGuard ssg;
auto rval = false; auto rval = false;
@ -185,7 +185,7 @@ function Cluster::publish_rr%(pool: Pool, key: string, ...%): bool
static Func* topic_func = 0; static Func* topic_func = 0;
if ( ! topic_func ) if ( ! topic_func )
topic_func = global_scope()->Find("Cluster::rr_topic")->GetVal()->AsFunc(); topic_func = zeek::detail::global_scope()->Find("Cluster::rr_topic")->GetVal()->AsFunc();
zeek::Args vl{{zeek::NewRef{}, pool}, {zeek::NewRef{}, key}}; zeek::Args vl{{zeek::NewRef{}, pool}, {zeek::NewRef{}, key}};
auto topic = topic_func->Invoke(&vl); auto topic = topic_func->Invoke(&vl);
@ -222,7 +222,7 @@ function Cluster::publish_hrw%(pool: Pool, key: any, ...%): bool
static Func* topic_func = 0; static Func* topic_func = 0;
if ( ! topic_func ) if ( ! topic_func )
topic_func = global_scope()->Find("Cluster::hrw_topic")->GetVal()->AsFunc(); topic_func = zeek::detail::global_scope()->Find("Cluster::hrw_topic")->GetVal()->AsFunc();
zeek::Args vl{{zeek::NewRef{}, pool}, {zeek::NewRef{}, key}}; zeek::Args vl{{zeek::NewRef{}, pool}, {zeek::NewRef{}, key}};
auto topic = topic_func->Invoke(&vl); auto topic = topic_func->Invoke(&vl);

View file

@ -27,7 +27,7 @@ Config::Config(ReaderFrontend *frontend) : ReaderBackend(frontend)
fail_on_file_problem = false; fail_on_file_problem = false;
// find all option names and their types. // find all option names and their types.
const auto& globals = global_scope()->Vars(); const auto& globals = zeek::detail::global_scope()->Vars();
for ( const auto& entry : globals ) for ( const auto& entry : globals )
{ {

View file

@ -1177,7 +1177,7 @@ WriterFrontend* Manager::CreateWriter(zeek::EnumVal* id, zeek::EnumVal* writer,
if ( ! found_filter_match ) if ( ! found_filter_match )
{ {
const auto& id = global_scope()->Find("Log::default_rotation_interval"); const auto& id = zeek::detail::global_scope()->Find("Log::default_rotation_interval");
assert(id); assert(id);
winfo->interval = id->GetVal()->AsInterval(); winfo->interval = id->GetVal()->AsInterval();
} }
@ -1520,7 +1520,7 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con
Func* func = winfo->postprocessor; Func* func = winfo->postprocessor;
if ( ! func ) if ( ! func )
{ {
const auto& id = global_scope()->Find("Log::__default_rotation_postprocessor"); const auto& id = zeek::detail::global_scope()->Find("Log::__default_rotation_postprocessor");
assert(id); assert(id);
func = id->GetVal()->AsFunc(); func = id->GetVal()->AsFunc();
} }

View file

@ -58,7 +58,7 @@ static bool call_option_handlers_and_set_value(zeek::StringVal* name, const zeek
## lower-level function. ## lower-level function.
function Option::set%(ID: string, val: any, location: string &default=""%): bool function Option::set%(ID: string, val: any, location: string &default=""%): bool
%{ %{
const auto& i = global_scope()->Find(ID->CheckString()); const auto& i = zeek::detail::global_scope()->Find(ID->CheckString());
if ( ! i ) if ( ! i )
{ {
builtin_error(fmt("Could not find ID named '%s'", ID->CheckString())); builtin_error(fmt("Could not find ID named '%s'", ID->CheckString()));
@ -143,7 +143,7 @@ function Option::set%(ID: string, val: any, location: string &default=""%): bool
## .. zeek:see:: Option::set ## .. zeek:see:: Option::set
function Option::set_change_handler%(ID: string, on_change: any, priority: int &default=0%): bool function Option::set_change_handler%(ID: string, on_change: any, priority: int &default=0%): bool
%{ %{
const auto& i = global_scope()->Find(ID->CheckString()); const auto& i = zeek::detail::global_scope()->Find(ID->CheckString());
if ( ! i ) if ( ! i )
{ {
builtin_error(fmt("Could not find ID named '%s'", ID->CheckString())); builtin_error(fmt("Could not find ID named '%s'", ID->CheckString()));

View file

@ -113,7 +113,9 @@ extern int brolex();
* Part of the module facility: while parsing, keep track of which * Part of the module facility: while parsing, keep track of which
* module to put things in. * module to put things in.
*/ */
std::string current_module = GLOBAL_MODULE_NAME; std::string zeek::detail::current_module = GLOBAL_MODULE_NAME;
std::string& current_module = zeek::detail::current_module;
bool is_export = false; // true if in an export {} block bool is_export = false; // true if in an export {} block
/* /*
@ -494,9 +496,9 @@ expr:
| '$' TOK_ID func_params '=' | '$' TOK_ID func_params '='
{ {
func_hdr_location = @1; func_hdr_location = @1;
auto func_id = current_scope()->GenerateTemporary("anonymous-function"); auto func_id = zeek::detail::current_scope()->GenerateTemporary("anonymous-function");
func_id->SetInferReturnType(true); func_id->SetInferReturnType(true);
begin_func(std::move(func_id), current_module.c_str(), begin_func(std::move(func_id), zeek::detail::current_module.c_str(),
zeek::FUNC_FLAVOR_FUNCTION, false, zeek::FUNC_FLAVOR_FUNCTION, false,
{zeek::AdoptRef{}, $3}); {zeek::AdoptRef{}, $3});
} }
@ -657,14 +659,14 @@ expr:
| TOK_ID | TOK_ID
{ {
set_location(@1); set_location(@1);
auto id = lookup_ID($1, current_module.c_str()); auto id = zeek::detail::lookup_ID($1, zeek::detail::current_module.c_str());
if ( ! id ) if ( ! id )
{ {
if ( ! in_debug ) if ( ! in_debug )
{ {
/* // CHECK THAT THIS IS NOT GLOBAL. /* // CHECK THAT THIS IS NOT GLOBAL.
id = install_ID($1, current_module.c_str(), id = install_ID($1, zeek::detail::current_module.c_str(),
false, is_export); false, is_export);
*/ */
@ -803,7 +805,7 @@ enum_body_elem:
if ( $3->GetType()->Tag() != zeek::TYPE_COUNT ) if ( $3->GetType()->Tag() != zeek::TYPE_COUNT )
reporter->Error("enumerator is not a count constant"); reporter->Error("enumerator is not a count constant");
else else
cur_enum_type->AddName(current_module, $1, cur_enum_type->AddName(zeek::detail::current_module, $1,
$3->InternalUnsigned(), is_export, $4); $3->InternalUnsigned(), is_export, $4);
} }
@ -820,7 +822,7 @@ enum_body_elem:
{ {
set_location(@1); set_location(@1);
assert(cur_enum_type); assert(cur_enum_type);
cur_enum_type->AddName(current_module, $1, is_export, $2); cur_enum_type->AddName(zeek::detail::current_module, $1, is_export, $2);
} }
; ;
@ -1071,8 +1073,8 @@ formal_args_decl:
decl: decl:
TOK_MODULE TOK_ID ';' TOK_MODULE TOK_ID ';'
{ {
current_module = $2; zeek::detail::current_module = $2;
zeekygen_mgr->ModuleUsage(::filename, current_module); zeekygen_mgr->ModuleUsage(::filename, zeek::detail::current_module);
} }
| TOK_EXPORT '{' { is_export = true; } decl_list '}' | TOK_EXPORT '{' { is_export = true; } decl_list '}'
@ -1178,7 +1180,7 @@ func_hdr:
TOK_FUNCTION def_global_id func_params opt_attr TOK_FUNCTION def_global_id func_params opt_attr
{ {
zeek::IntrusivePtr id{zeek::AdoptRef{}, $2}; zeek::IntrusivePtr id{zeek::AdoptRef{}, $2};
begin_func(id, current_module.c_str(), begin_func(id, zeek::detail::current_module.c_str(),
zeek::FUNC_FLAVOR_FUNCTION, 0, {zeek::NewRef{}, $3}, zeek::FUNC_FLAVOR_FUNCTION, 0, {zeek::NewRef{}, $3},
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$4}); std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$4});
$$ = $3; $$ = $3;
@ -1193,7 +1195,7 @@ func_hdr:
reporter->Error("event %s() is no longer available, use zeek_%s() instead", name, base.c_str()); reporter->Error("event %s() is no longer available, use zeek_%s() instead", name, base.c_str());
} }
begin_func({zeek::NewRef{}, $2}, current_module.c_str(), begin_func({zeek::NewRef{}, $2}, zeek::detail::current_module.c_str(),
zeek::FUNC_FLAVOR_EVENT, 0, {zeek::NewRef{}, $3}, zeek::FUNC_FLAVOR_EVENT, 0, {zeek::NewRef{}, $3},
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$4}); std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$4});
$$ = $3; $$ = $3;
@ -1202,14 +1204,14 @@ func_hdr:
{ {
$3->ClearYieldType(zeek::FUNC_FLAVOR_HOOK); $3->ClearYieldType(zeek::FUNC_FLAVOR_HOOK);
$3->SetYieldType(zeek::base_type(zeek::TYPE_BOOL)); $3->SetYieldType(zeek::base_type(zeek::TYPE_BOOL));
begin_func({zeek::NewRef{}, $2}, current_module.c_str(), begin_func({zeek::NewRef{}, $2}, zeek::detail::current_module.c_str(),
zeek::FUNC_FLAVOR_HOOK, 0, {zeek::NewRef{}, $3}, zeek::FUNC_FLAVOR_HOOK, 0, {zeek::NewRef{}, $3},
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$4}); std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$4});
$$ = $3; $$ = $3;
} }
| TOK_REDEF TOK_EVENT event_id func_params opt_attr | TOK_REDEF TOK_EVENT event_id func_params opt_attr
{ {
begin_func({zeek::NewRef{}, $3}, current_module.c_str(), begin_func({zeek::NewRef{}, $3}, zeek::detail::current_module.c_str(),
zeek::FUNC_FLAVOR_EVENT, 1, {zeek::NewRef{}, $4}, zeek::FUNC_FLAVOR_EVENT, 1, {zeek::NewRef{}, $4},
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$5}); std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$5});
$$ = $4; $$ = $4;
@ -1258,8 +1260,8 @@ lambda_body:
// a lambda expression. // a lambda expression.
// Gather the ingredients for a BroFunc from the current scope // Gather the ingredients for a BroFunc from the current scope
auto ingredients = std::make_unique<function_ingredients>(zeek::IntrusivePtr{zeek::NewRef{}, current_scope()}, zeek::IntrusivePtr{zeek::AdoptRef{}, $3}); auto ingredients = std::make_unique<function_ingredients>(zeek::IntrusivePtr{zeek::NewRef{}, zeek::detail::current_scope()}, zeek::IntrusivePtr{zeek::AdoptRef{}, $3});
id_list outer_ids = gather_outer_ids(pop_scope().get(), ingredients->body.get()); id_list outer_ids = gather_outer_ids(zeek::detail::pop_scope().get(), ingredients->body.get());
$$ = new zeek::detail::LambdaExpr(std::move(ingredients), std::move(outer_ids)); $$ = new zeek::detail::LambdaExpr(std::move(ingredients), std::move(outer_ids));
} }
@ -1273,8 +1275,8 @@ anonymous_function:
begin_func: begin_func:
func_params func_params
{ {
auto id = current_scope()->GenerateTemporary("anonymous-function"); auto id = zeek::detail::current_scope()->GenerateTemporary("anonymous-function");
begin_func(id, current_module.c_str(), zeek::FUNC_FLAVOR_FUNCTION, 0, {zeek::AdoptRef{}, $1}); begin_func(id, zeek::detail::current_module.c_str(), zeek::FUNC_FLAVOR_FUNCTION, 0, {zeek::AdoptRef{}, $1});
$$ = id.release(); $$ = id.release();
} }
; ;
@ -1609,7 +1611,7 @@ event:
TOK_ID '(' opt_expr_list ')' TOK_ID '(' opt_expr_list ')'
{ {
set_location(@1, @4); set_location(@1, @4);
const auto& id = lookup_ID($1, current_module.c_str()); const auto& id = zeek::detail::lookup_ID($1, zeek::detail::current_module.c_str());
if ( id ) if ( id )
{ {
@ -1667,12 +1669,12 @@ case_type:
{ {
const char* name = $4; const char* name = $4;
zeek::TypePtr type{zeek::AdoptRef{}, $2}; zeek::TypePtr type{zeek::AdoptRef{}, $2};
auto case_var = lookup_ID(name, current_module.c_str()); auto case_var = zeek::detail::lookup_ID(name, zeek::detail::current_module.c_str());
if ( case_var && case_var->IsGlobal() ) if ( case_var && case_var->IsGlobal() )
case_var->Error("already a global identifier"); case_var->Error("already a global identifier");
else else
case_var = install_ID(name, current_module.c_str(), false, false); case_var = zeek::detail::install_ID(name, zeek::detail::current_module.c_str(), false, false);
add_local(case_var, std::move(type), zeek::detail::INIT_NONE, nullptr, nullptr, add_local(case_var, std::move(type), zeek::detail::INIT_NONE, nullptr, nullptr,
VAR_REGULAR); VAR_REGULAR);
@ -1688,7 +1690,7 @@ for_head:
// body so that we execute these actions - defining // body so that we execute these actions - defining
// the local variable - prior to parsing the body, // the local variable - prior to parsing the body,
// which might refer to the variable. // which might refer to the variable.
auto loop_var = lookup_ID($3, current_module.c_str()); auto loop_var = zeek::detail::lookup_ID($3, zeek::detail::current_module.c_str());
if ( loop_var ) if ( loop_var )
{ {
@ -1698,7 +1700,7 @@ for_head:
else else
{ {
loop_var = install_ID($3, current_module.c_str(), loop_var = zeek::detail::install_ID($3, zeek::detail::current_module.c_str(),
false, false); false, false);
} }
@ -1716,12 +1718,12 @@ for_head:
TOK_FOR '(' TOK_ID ',' TOK_ID TOK_IN expr ')' TOK_FOR '(' TOK_ID ',' TOK_ID TOK_IN expr ')'
{ {
set_location(@1, @8); set_location(@1, @8);
const char* module = current_module.c_str(); const char* module = zeek::detail::current_module.c_str();
// Check for previous definitions of key and // Check for previous definitions of key and
// value variables. // value variables.
auto key_var = lookup_ID($3, module); auto key_var = zeek::detail::lookup_ID($3, module);
auto val_var = lookup_ID($5, module); auto val_var = zeek::detail::lookup_ID($5, module);
// Validate previous definitions as needed. // Validate previous definitions as needed.
if ( key_var ) if ( key_var )
@ -1730,7 +1732,7 @@ for_head:
key_var->Error("global variable used in for loop"); key_var->Error("global variable used in for loop");
} }
else else
key_var = install_ID($3, module, false, false); key_var = zeek::detail::install_ID($3, module, false, false);
if ( val_var ) if ( val_var )
{ {
@ -1738,7 +1740,7 @@ for_head:
val_var->Error("global variable used in for loop"); val_var->Error("global variable used in for loop");
} }
else else
val_var = install_ID($5, module, false, false); val_var = zeek::detail::install_ID($5, module, false, false);
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());
@ -1749,10 +1751,10 @@ for_head:
TOK_FOR '(' '[' local_id_list ']' ',' TOK_ID TOK_IN expr ')' TOK_FOR '(' '[' local_id_list ']' ',' TOK_ID TOK_IN expr ')'
{ {
set_location(@1, @10); set_location(@1, @10);
const char* module = current_module.c_str(); const char* module = zeek::detail::current_module.c_str();
// Validate value variable // Validate value variable
auto val_var = lookup_ID($7, module); auto val_var = zeek::detail::lookup_ID($7, module);
if ( val_var ) if ( val_var )
{ {
@ -1760,7 +1762,7 @@ for_head:
val_var->Error("global variable used in for loop"); val_var->Error("global variable used in for loop");
} }
else else
val_var = install_ID($7, module, false, false); val_var = zeek::detail::install_ID($7, module, false, false);
$$ = new zeek::detail::ForStmt($4, {zeek::AdoptRef{}, $9}, std::move(val_var)); $$ = new zeek::detail::ForStmt($4, {zeek::AdoptRef{}, $9}, std::move(val_var));
} }
@ -1780,7 +1782,7 @@ local_id:
TOK_ID TOK_ID
{ {
set_location(@1); set_location(@1);
auto id = lookup_ID($1, current_module.c_str()); auto id = zeek::detail::lookup_ID($1, zeek::detail::current_module.c_str());
$$ = id.release(); $$ = id.release();
if ( $$ ) if ( $$ )
@ -1792,7 +1794,7 @@ local_id:
else else
{ {
$$ = install_ID($1, current_module.c_str(), $$ = zeek::detail::install_ID($1, zeek::detail::current_module.c_str(),
false, is_export).release(); false, is_export).release();
} }
} }
@ -1817,7 +1819,7 @@ global_or_event_id:
TOK_ID TOK_ID
{ {
set_location(@1); set_location(@1);
auto id = lookup_ID($1, current_module.c_str(), false, auto id = zeek::detail::lookup_ID($1, zeek::detail::current_module.c_str(), false,
defining_global_ID); defining_global_ID);
$$ = id.release(); $$ = id.release();
@ -1842,9 +1844,9 @@ global_or_event_id:
{ {
const char* module_name = const char* module_name =
resolving_global_ID ? resolving_global_ID ?
current_module.c_str() : 0; zeek::detail::current_module.c_str() : 0;
$$ = install_ID($1, module_name, $$ = zeek::detail::install_ID($1, module_name,
true, is_export).release(); true, is_export).release();
} }
} }
@ -1855,7 +1857,7 @@ resolve_id:
TOK_ID TOK_ID
{ {
set_location(@1); set_location(@1);
auto id = lookup_ID($1, current_module.c_str()); auto id = zeek::detail::lookup_ID($1, zeek::detail::current_module.c_str());
$$ = id.release(); $$ = id.release();
if ( ! $$ ) if ( ! $$ )

View file

@ -138,7 +138,7 @@ ComponentManager<T, C>::ComponentManager(const std::string& arg_module, const st
: module(arg_module), : module(arg_module),
tag_enum_type(zeek::make_intrusive<zeek::EnumType>(module + "::" + local_id)) tag_enum_type(zeek::make_intrusive<zeek::EnumType>(module + "::" + local_id))
{ {
auto id = install_ID(local_id.c_str(), module.c_str(), true, true); auto id = zeek::detail::install_ID(local_id.c_str(), module.c_str(), true, true);
add_type(id.get(), tag_enum_type, nullptr); add_type(id.get(), tag_enum_type, nullptr);
zeekygen_mgr->Identifier(std::move(id)); zeekygen_mgr->Identifier(std::move(id));
} }

View file

@ -617,7 +617,7 @@ int Manager::HookLoadFile(const Plugin::LoadType type, const string& file, const
} }
std::pair<bool, zeek::ValPtr> std::pair<bool, zeek::ValPtr>
Manager::HookCallFunction(const Func* func, Frame* parent, Manager::HookCallFunction(const Func* func, zeek::detail::Frame* parent,
zeek::Args* vecargs) const zeek::Args* vecargs) const
{ {
HookArgumentList args; HookArgumentList args;

View file

@ -256,7 +256,7 @@ public:
* the method returns null. * the method returns null.
*/ */
std::pair<bool, ValPtr> std::pair<bool, ValPtr>
HookCallFunction(const Func* func, Frame* parent, zeek::Args* args) const; HookCallFunction(const Func* func, zeek::detail::Frame* parent, zeek::Args* args) const;
/** /**
* Hook that filters the queuing of an event. * Hook that filters the queuing of an event.

View file

@ -376,7 +376,7 @@ int Plugin::HookLoadFile(const LoadType type, const std::string& file, const std
} }
std::pair<bool, zeek::ValPtr> std::pair<bool, zeek::ValPtr>
Plugin::HookFunctionCall(const Func* func, Frame* parent, Plugin::HookFunctionCall(const Func* func, zeek::detail::Frame* parent,
zeek::Args* args) zeek::Args* args)
{ {
val_list vlargs(args->size()); val_list vlargs(args->size());
@ -395,7 +395,8 @@ Plugin::HookFunctionCall(const Func* func, Frame* parent,
return {handled, {zeek::AdoptRef{}, result}}; return {handled, {zeek::AdoptRef{}, result}};
} }
std::pair<bool, zeek::Val*> Plugin::HookCallFunction(const Func* func, Frame *parent, val_list* args) std::pair<bool, zeek::Val*> Plugin::HookCallFunction(
const Func* func, zeek::detail::Frame *parent, val_list* args)
{ {
std::pair<bool, zeek::Val*> result(false, NULL); std::pair<bool, zeek::Val*> result(false, NULL);
return result; return result;

View file

@ -17,10 +17,11 @@
#define BRO_PLUGIN_BRO_VERSION BRO_VERSION_FUNCTION #define BRO_PLUGIN_BRO_VERSION BRO_VERSION_FUNCTION
class ODesc; class ODesc;
class Frame;
class Func; class Func;
class Event; class Event;
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
namespace zeek { namespace zeek {
template <class T> class IntrusivePtr; template <class T> class IntrusivePtr;
using ValPtr = zeek::IntrusivePtr<Val>; using ValPtr = zeek::IntrusivePtr<Val>;
@ -235,7 +236,7 @@ public:
/** /**
* Constructor with a Frame argument. * Constructor with a Frame argument.
*/ */
explicit HookArgument(Frame* f) { type = FRAME; arg.frame = f; } explicit HookArgument(zeek::detail::Frame* f) { type = FRAME; arg.frame = f; }
/** /**
* Constructor with a WriterInfo argument. * Constructor with a WriterInfo argument.
@ -315,7 +316,7 @@ public:
* Returns the value for a Bro frame argument. The argument's type must * Returns the value for a Bro frame argument. The argument's type must
* match accordingly. * match accordingly.
*/ */
const Frame* AsFrame() const { assert(type == FRAME); return arg.frame; } const zeek::detail::Frame* AsFrame() const { assert(type == FRAME); return arg.frame; }
/** /**
* Returns the value for a logging WriterInfo argument. The argument's type must * Returns the value for a logging WriterInfo argument. The argument's type must
@ -366,7 +367,7 @@ private:
const Event* event; const Event* event;
const Connection* conn; const Connection* conn;
const Func* func; const Func* func;
const Frame* frame; const zeek::detail::Frame* frame;
int int_; int int_;
const Val* val; const Val* val;
const val_list* vals; const val_list* vals;
@ -673,10 +674,10 @@ protected:
* pair with the first member set to 'false' and null result value. * pair with the first member set to 'false' and null result value.
*/ */
virtual std::pair<bool, ValPtr> virtual std::pair<bool, ValPtr>
HookFunctionCall(const Func* func, Frame* parent, zeek::Args* args); HookFunctionCall(const Func* func, zeek::detail::Frame* parent, zeek::Args* args);
[[deprecated("Remove in v4.1. Use HookFunctionCall()")]] [[deprecated("Remove in v4.1. Use HookFunctionCall()")]]
virtual std::pair<bool, Val*> HookCallFunction(const Func* func, Frame *parent, val_list* args); virtual std::pair<bool, Val*> HookCallFunction(const Func* func, zeek::detail::Frame *parent, val_list* args);
/** /**
* Hook into raising events. Whenever the script interpreter is about * Hook into raising events. Whenever the script interpreter is about

View file

@ -179,7 +179,7 @@ ESCSEQ (\\([^\n]|[0-7]+|x[[:xdigit:]]+))
##<.* { ##<.* {
std::string hint(cur_enum_type && last_id_tok ? std::string hint(cur_enum_type && last_id_tok ?
make_full_var_name(current_module.c_str(), last_id_tok) : ""); make_full_var_name(zeek::detail::current_module.c_str(), last_id_tok) : "");
zeekygen_mgr->PostComment(yytext + 3, hint); zeekygen_mgr->PostComment(yytext + 3, hint);
} }
@ -693,7 +693,7 @@ static int load_files(const char* orig_file)
// was done when we're finished processing it. // was done when we're finished processing it.
if ( ! did_module_restore ) if ( ! did_module_restore )
{ {
file_stack.push_back(new FileInfo(current_module)); file_stack.push_back(new FileInfo(zeek::detail::current_module));
did_module_restore = true; did_module_restore = true;
} }
else else
@ -776,7 +776,7 @@ void do_atifdef(const char* id)
{ {
++current_depth; ++current_depth;
const auto& i = lookup_ID(id, current_module.c_str()); const auto& i = zeek::detail::lookup_ID(id, zeek::detail::current_module.c_str());
if ( ! i ) if ( ! i )
{ {
@ -789,7 +789,7 @@ void do_atifndef(const char *id)
{ {
++current_depth; ++current_depth;
const auto& i = lookup_ID(id, current_module.c_str()); const auto& i = zeek::detail::lookup_ID(id, zeek::detail::current_module.c_str());
if ( i ) if ( i )
{ {
@ -1077,5 +1077,5 @@ FileInfo::~FileInfo()
yylloc.first_line = yylloc.last_line = line_number = line; yylloc.first_line = yylloc.last_line = line_number = line;
if ( restore_module != "" ) if ( restore_module != "" )
current_module = restore_module; zeek::detail::current_module = restore_module;
} }

View file

@ -542,7 +542,7 @@ zeek::Val* Value::ValueToVal(const std::string& source, const Value* val, bool&
// Enums are not a base-type, so need to look it up. // Enums are not a base-type, so need to look it up.
const auto& sv = val->val.set_val.vals[0]->val.string_val; const auto& sv = val->val.set_val.vals[0]->val.string_val;
std::string enum_name(sv.data, sv.length); std::string enum_name(sv.data, sv.length);
const auto& enum_id = global_scope()->Find(enum_name); const auto& enum_id = zeek::detail::global_scope()->Find(enum_name);
if ( ! enum_id ) if ( ! enum_id )
{ {
@ -607,7 +607,7 @@ zeek::Val* Value::ValueToVal(const std::string& source, const Value* val, bool&
std::string enum_string(val->val.string_val.data, val->val.string_val.length); std::string enum_string(val->val.string_val.data, val->val.string_val.length);
// let's try looking it up by global ID. // let's try looking it up by global ID.
const auto& id = lookup_ID(enum_string.c_str(), GLOBAL_MODULE_NAME); const auto& id = zeek::detail::lookup_ID(enum_string.c_str(), GLOBAL_MODULE_NAME);
if ( ! id || ! id->IsEnumConst() ) if ( ! id || ! id->IsEnumConst() )
{ {

View file

@ -311,7 +311,7 @@ void terminate_bro()
delete val_mgr; delete val_mgr;
// free the global scope // free the global scope
pop_scope(); zeek::detail::pop_scope();
reporter = nullptr; reporter = nullptr;
} }

View file

@ -1914,7 +1914,7 @@ function packet_source%(%): PacketSource
function global_sizes%(%): var_sizes function global_sizes%(%): var_sizes
%{ %{
auto sizes = zeek::make_intrusive<zeek::TableVal>(IntrusivePtr{zeek::NewRef{}, var_sizes}); auto sizes = zeek::make_intrusive<zeek::TableVal>(IntrusivePtr{zeek::NewRef{}, var_sizes});
const auto& globals = global_scope()->Vars(); const auto& globals = zeek::detail::global_scope()->Vars();
for ( const auto& global : globals ) for ( const auto& global : globals )
{ {
@ -1942,7 +1942,7 @@ function global_ids%(%): id_table
%{ %{
static auto id_table = zeek::id::find_type<zeek::TableType>("id_table"); static auto id_table = zeek::id::find_type<zeek::TableType>("id_table");
auto ids = zeek::make_intrusive<zeek::TableVal>(id_table); auto ids = zeek::make_intrusive<zeek::TableVal>(id_table);
const auto& globals = global_scope()->Vars(); const auto& globals = zeek::detail::global_scope()->Vars();
for ( const auto& global : globals ) for ( const auto& global : globals )
{ {
@ -1974,7 +1974,7 @@ function global_ids%(%): id_table
## the string ``"<unknown id>"`` or ``"<no ID value>"`` is returned. ## the string ``"<unknown id>"`` or ``"<no ID value>"`` is returned.
function lookup_ID%(id: string%) : any function lookup_ID%(id: string%) : any
%{ %{
const auto& i = global_scope()->Find(id->CheckString()); const auto& i = zeek::detail::global_scope()->Find(id->CheckString());
if ( ! i ) if ( ! i )
return zeek::make_intrusive<zeek::StringVal>("<unknown id>"); return zeek::make_intrusive<zeek::StringVal>("<unknown id>");
@ -1997,7 +1997,7 @@ function record_fields%(rec: any%): record_field_table
if ( rec->GetType()->Tag() == zeek::TYPE_STRING ) if ( rec->GetType()->Tag() == zeek::TYPE_STRING )
{ {
const auto& id = global_scope()->Find(rec->AsStringVal()->ToStdString()); const auto& id = zeek::detail::global_scope()->Find(rec->AsStringVal()->ToStdString());
if ( ! id || ! id->IsType() || id->GetType()->Tag() != zeek::TYPE_RECORD ) if ( ! id || ! id->IsType() || id->GetType()->Tag() != zeek::TYPE_RECORD )
{ {
@ -3905,7 +3905,7 @@ static zeek::ValPtr mmdb_getvalue(MMDB_entry_data_s* entry_data, int status,
static bool mmdb_try_open_loc () static bool mmdb_try_open_loc ()
{ {
// City database is always preferred over Country database. // City database is always preferred over Country database.
const auto& mmdb_dir_val = global_scope()->Find("mmdb_dir")->GetVal(); const auto& mmdb_dir_val = zeek::detail::global_scope()->Find("mmdb_dir")->GetVal();
std::string mmdb_dir = mmdb_dir_val->AsString()->CheckString(); std::string mmdb_dir = mmdb_dir_val->AsString()->CheckString();
if ( ! mmdb_dir.empty() ) if ( ! mmdb_dir.empty() )
@ -3933,7 +3933,7 @@ static bool mmdb_try_open_loc ()
static bool mmdb_try_open_asn () static bool mmdb_try_open_asn ()
{ {
const auto& mmdb_dir_val = global_scope()->Find("mmdb_dir")->GetVal(); const auto& mmdb_dir_val = zeek::detail::global_scope()->Find("mmdb_dir")->GetVal();
std::string mmdb_dir = mmdb_dir_val->AsString()->CheckString(); std::string mmdb_dir = mmdb_dir_val->AsString()->CheckString();
if ( ! mmdb_dir.empty() ) if ( ! mmdb_dir.empty() )

View file

@ -258,12 +258,12 @@ void ScriptInfo::DoInitPostScript()
// so just manually associating them with scripts for now. // so just manually associating them with scripts for now.
if ( name == "base/frameworks/input/main.zeek" ) if ( name == "base/frameworks/input/main.zeek" )
{ {
const auto& id = global_scope()->Find("Input::Reader"); const auto& id = zeek::detail::global_scope()->Find("Input::Reader");
types.push_back(new IdentifierInfo(id, this)); types.push_back(new IdentifierInfo(id, this));
} }
else if ( name == "base/frameworks/logging/main.zeek" ) else if ( name == "base/frameworks/logging/main.zeek" )
{ {
const auto& id = global_scope()->Find("Log::Writer"); const auto& id = zeek::detail::global_scope()->Find("Log::Writer");
types.push_back(new IdentifierInfo(id, this)); types.push_back(new IdentifierInfo(id, this));
} }
} }