mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Move ID to the zeek::detail namespace
This commit is contained in:
parent
9992ec5c11
commit
0d623d003c
30 changed files with 221 additions and 182 deletions
|
@ -7,8 +7,8 @@
|
||||||
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
typedef PList<zeek::detail::Expr> expr_list;
|
typedef PList<zeek::detail::Expr> expr_list;
|
||||||
|
|
||||||
class ID;
|
FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
typedef PList<ID> id_list;
|
typedef PList<zeek::detail::ID> id_list;
|
||||||
|
|
||||||
class Val;
|
class Val;
|
||||||
typedef PList<Val> val_list;
|
typedef PList<Val> val_list;
|
||||||
|
|
|
@ -30,12 +30,12 @@ using namespace std;
|
||||||
//
|
//
|
||||||
// Helper routines
|
// Helper routines
|
||||||
//
|
//
|
||||||
bool string_is_regex(const string& s)
|
static bool string_is_regex(const string& s)
|
||||||
{
|
{
|
||||||
return strpbrk(s.data(), "?*\\+");
|
return strpbrk(s.data(), "?*\\+");
|
||||||
}
|
}
|
||||||
|
|
||||||
void lookup_global_symbols_regex(const string& orig_regex, vector<ID*>& matches,
|
static void lookup_global_symbols_regex(const string& orig_regex, vector<zeek::detail::ID*>& matches,
|
||||||
bool func_only = false)
|
bool func_only = false)
|
||||||
{
|
{
|
||||||
if ( streq(orig_regex.c_str(), "") )
|
if ( streq(orig_regex.c_str(), "") )
|
||||||
|
@ -61,17 +61,17 @@ void lookup_global_symbols_regex(const string& orig_regex, vector<ID*>& matches,
|
||||||
Scope* global = global_scope();
|
Scope* global = global_scope();
|
||||||
const auto& syms = global->Vars();
|
const auto& syms = global->Vars();
|
||||||
|
|
||||||
ID* nextid;
|
zeek::detail::ID* nextid;
|
||||||
for ( const auto& sym : syms )
|
for ( const auto& sym : syms )
|
||||||
{
|
{
|
||||||
ID* nextid = sym.second.get();
|
zeek::detail::ID* nextid = sym.second.get();
|
||||||
if ( ! func_only || nextid->GetType()->Tag() == TYPE_FUNC )
|
if ( ! func_only || nextid->GetType()->Tag() == TYPE_FUNC )
|
||||||
if ( ! regexec (&re, nextid->Name(), 0, 0, 0) )
|
if ( ! regexec (&re, nextid->Name(), 0, 0, 0) )
|
||||||
matches.push_back(nextid);
|
matches.push_back(nextid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void choose_global_symbols_regex(const string& regex, vector<ID*>& choices,
|
static void choose_global_symbols_regex(const string& regex, vector<zeek::detail::ID*>& choices,
|
||||||
bool func_only = false)
|
bool func_only = false)
|
||||||
{
|
{
|
||||||
lookup_global_symbols_regex(regex, choices, func_only);
|
lookup_global_symbols_regex(regex, choices, func_only);
|
||||||
|
@ -111,7 +111,7 @@ void choose_global_symbols_regex(const string& regex, vector<ID*>& choices,
|
||||||
int option = atoi(input.c_str());
|
int option = atoi(input.c_str());
|
||||||
if ( option > 0 && option <= (int) choices.size() )
|
if ( option > 0 && option <= (int) choices.size() )
|
||||||
{
|
{
|
||||||
ID* choice = choices[option - 1];
|
zeek::detail::ID* choice = choices[option - 1];
|
||||||
choices.clear();
|
choices.clear();
|
||||||
choices.push_back(choice);
|
choices.push_back(choice);
|
||||||
return;
|
return;
|
||||||
|
@ -398,7 +398,7 @@ int dbg_cmd_break(DebugCmd cmd, const vector<string>& args)
|
||||||
vector<string> locstrings;
|
vector<string> locstrings;
|
||||||
if ( string_is_regex(args[0]) )
|
if ( string_is_regex(args[0]) )
|
||||||
{
|
{
|
||||||
vector<ID*> choices;
|
vector<zeek::detail::ID*> choices;
|
||||||
choose_global_symbols_regex(args[0], choices, true);
|
choose_global_symbols_regex(args[0], choices, true);
|
||||||
for ( unsigned int i = 0; i < choices.size(); ++i )
|
for ( unsigned int i = 0; i < choices.size(); ++i )
|
||||||
locstrings.push_back(choices[i]->Name());
|
locstrings.push_back(choices[i]->Name());
|
||||||
|
|
12
src/Frame.cc
12
src/Frame.cc
|
@ -77,7 +77,7 @@ void Frame::SetElementWeak(int n, Val* v)
|
||||||
frame[n] = {{AdoptRef{}, v}, true};
|
frame[n] = {{AdoptRef{}, v}, true};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::SetElement(const ID* id, IntrusivePtr<Val> v)
|
void Frame::SetElement(const zeek::detail::ID* id, IntrusivePtr<Val> v)
|
||||||
{
|
{
|
||||||
if ( closure )
|
if ( closure )
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ void Frame::SetElement(const ID* id, IntrusivePtr<Val> v)
|
||||||
SetElement(id->Offset(), std::move(v));
|
SetElement(id->Offset(), std::move(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
const IntrusivePtr<Val>& Frame::GetElementByID(const ID* id) const
|
const IntrusivePtr<Val>& Frame::GetElementByID(const zeek::detail::ID* id) const
|
||||||
{
|
{
|
||||||
if ( closure )
|
if ( closure )
|
||||||
{
|
{
|
||||||
|
@ -478,7 +478,7 @@ void Frame::AddKnownOffsets(const id_list& ids)
|
||||||
offset_map = std::make_unique<OffsetMap>();
|
offset_map = std::make_unique<OffsetMap>();
|
||||||
|
|
||||||
std::transform(ids.begin(), ids.end(), std::inserter(*offset_map, offset_map->end()),
|
std::transform(ids.begin(), ids.end(), std::inserter(*offset_map, offset_map->end()),
|
||||||
[] (const ID* id) -> std::pair<std::string, int>
|
[] (const zeek::detail::ID* id) -> std::pair<std::string, int>
|
||||||
{
|
{
|
||||||
return std::make_pair(std::string(id->Name()), id->Offset());
|
return std::make_pair(std::string(id->Name()), id->Offset());
|
||||||
});
|
});
|
||||||
|
@ -523,10 +523,10 @@ void Frame::ClearElement(int n)
|
||||||
frame[n] = {nullptr, false};
|
frame[n] = {nullptr, false};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Frame::IsOuterID(const ID* in) const
|
bool Frame::IsOuterID(const zeek::detail::ID* in) const
|
||||||
{
|
{
|
||||||
return std::any_of(outer_ids.begin(), outer_ids.end(),
|
return std::any_of(outer_ids.begin(), outer_ids.end(),
|
||||||
[&in](ID* id)-> bool { return strcmp(id->Name(), in->Name()) == 0; });
|
[&in](zeek::detail::ID* id)-> bool { return strcmp(id->Name(), in->Name()) == 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
broker::expected<broker::data> Frame::SerializeIDList(const id_list& in)
|
broker::expected<broker::data> Frame::SerializeIDList(const id_list& in)
|
||||||
|
@ -588,7 +588,7 @@ Frame::UnserializeIDList(const broker::vector& data)
|
||||||
return std::make_pair(false, std::move(rval));
|
return std::make_pair(false, std::move(rval));
|
||||||
}
|
}
|
||||||
|
|
||||||
ID* id = new ID(has_name->c_str(), SCOPE_FUNCTION, false);
|
auto* id = new zeek::detail::ID(has_name->c_str(), zeek::detail::SCOPE_FUNCTION, false);
|
||||||
id->SetOffset(*has_offset);
|
id->SetOffset(*has_offset);
|
||||||
rval.push_back(id);
|
rval.push_back(id);
|
||||||
std::advance(where, 1);
|
std::advance(where, 1);
|
||||||
|
|
12
src/Frame.h
12
src/Frame.h
|
@ -66,8 +66,8 @@ public:
|
||||||
* @param id the ID to associate
|
* @param id the ID to associate
|
||||||
* @param v the value to associate it with
|
* @param v the value to associate it with
|
||||||
*/
|
*/
|
||||||
void SetElement(const ID* id, IntrusivePtr<Val> v);
|
void SetElement(const zeek::detail::ID* id, IntrusivePtr<Val> v);
|
||||||
void SetElement(const IntrusivePtr<ID>& id, IntrusivePtr<Val> v)
|
void SetElement(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<Val> v)
|
||||||
{ SetElement(id.get(), std::move(v)); }
|
{ SetElement(id.get(), std::move(v)); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,11 +77,11 @@ public:
|
||||||
* @param id the id who's value to retreive
|
* @param id the id who's value to retreive
|
||||||
* @return the value associated with *id*
|
* @return the value associated with *id*
|
||||||
*/
|
*/
|
||||||
const IntrusivePtr<Val>& GetElementByID(const IntrusivePtr<ID>& id) const
|
const IntrusivePtr<Val>& GetElementByID(const IntrusivePtr<zeek::detail::ID>& id) const
|
||||||
{ return GetElementByID(id.get()); }
|
{ return GetElementByID(id.get()); }
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetElementByID().")]]
|
[[deprecated("Remove in v4.1. Use GetElementByID().")]]
|
||||||
Val* GetElement(const ID* id) const
|
Val* GetElement(const zeek::detail::ID* id) const
|
||||||
{ return GetElementByID(id).get(); }
|
{ return GetElementByID(id).get(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,7 +247,7 @@ private:
|
||||||
bool weak_ref;
|
bool weak_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
const IntrusivePtr<Val>& GetElementByID(const ID* id) const;
|
const IntrusivePtr<Val>& GetElementByID(const zeek::detail::ID* id) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the element at index *n* of the underlying array to *v*, but does
|
* Sets the element at index *n* of the underlying array to *v*, but does
|
||||||
|
@ -273,7 +273,7 @@ private:
|
||||||
void ClearElement(int n);
|
void ClearElement(int n);
|
||||||
|
|
||||||
/** Have we captured this id? */
|
/** Have we captured this id? */
|
||||||
bool IsOuterID(const ID* in) const;
|
bool IsOuterID(const zeek::detail::ID* in) const;
|
||||||
|
|
||||||
/** Serializes an offset_map */
|
/** Serializes an offset_map */
|
||||||
static broker::expected<broker::data>
|
static broker::expected<broker::data>
|
||||||
|
|
10
src/Func.cc
10
src/Func.cc
|
@ -122,7 +122,7 @@ Func::Func(Kind arg_kind) : kind(arg_kind)
|
||||||
Func::~Func() = default;
|
Func::~Func() = default;
|
||||||
|
|
||||||
void Func::AddBody(IntrusivePtr<zeek::detail::Stmt> /* new_body */,
|
void Func::AddBody(IntrusivePtr<zeek::detail::Stmt> /* new_body */,
|
||||||
const std::vector<IntrusivePtr<ID>>& /* new_inits */,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& /* new_inits */,
|
||||||
size_t /* new_frame_size */, int /* priority */)
|
size_t /* new_frame_size */, int /* priority */)
|
||||||
{
|
{
|
||||||
Internal("Func::AddBody called");
|
Internal("Func::AddBody called");
|
||||||
|
@ -268,8 +268,8 @@ void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BroFunc::BroFunc(const IntrusivePtr<ID>& arg_id, IntrusivePtr<zeek::detail::Stmt> arg_body,
|
BroFunc::BroFunc(const IntrusivePtr<zeek::detail::ID>& arg_id, IntrusivePtr<zeek::detail::Stmt> arg_body,
|
||||||
const std::vector<IntrusivePtr<ID>>& aggr_inits,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& aggr_inits,
|
||||||
size_t arg_frame_size, int priority)
|
size_t arg_frame_size, int priority)
|
||||||
: Func(BRO_FUNC)
|
: Func(BRO_FUNC)
|
||||||
{
|
{
|
||||||
|
@ -450,7 +450,7 @@ IntrusivePtr<Val> BroFunc::Invoke(zeek::Args* args, Frame* parent) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void BroFunc::AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
|
void BroFunc::AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
|
||||||
const std::vector<IntrusivePtr<ID>>& new_inits,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& new_inits,
|
||||||
size_t new_frame_size, int priority)
|
size_t new_frame_size, int priority)
|
||||||
{
|
{
|
||||||
if ( new_frame_size > frame_size )
|
if ( new_frame_size > frame_size )
|
||||||
|
@ -575,7 +575,7 @@ void BroFunc::Describe(ODesc* d) const
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<zeek::detail::Stmt> BroFunc::AddInits(IntrusivePtr<zeek::detail::Stmt> body,
|
IntrusivePtr<zeek::detail::Stmt> BroFunc::AddInits(IntrusivePtr<zeek::detail::Stmt> body,
|
||||||
const std::vector<IntrusivePtr<ID>>& inits)
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& inits)
|
||||||
{
|
{
|
||||||
if ( inits.empty() )
|
if ( inits.empty() )
|
||||||
return body;
|
return body;
|
||||||
|
|
19
src/Func.h
19
src/Func.h
|
@ -22,11 +22,11 @@
|
||||||
class Val;
|
class Val;
|
||||||
class FuncType;
|
class FuncType;
|
||||||
class Frame;
|
class Frame;
|
||||||
class ID;
|
|
||||||
class Scope;
|
class Scope;
|
||||||
|
|
||||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
||||||
|
FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
|
|
||||||
class Func : public BroObj {
|
class Func : public BroObj {
|
||||||
public:
|
public:
|
||||||
|
@ -79,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<zeek::detail::Stmt> new_body,
|
virtual void AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
|
||||||
const std::vector<IntrusivePtr<ID>>& new_inits,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& new_inits,
|
||||||
size_t new_frame_size, int priority = 0);
|
size_t new_frame_size, int priority = 0);
|
||||||
|
|
||||||
virtual void SetScope(IntrusivePtr<Scope> newscope);
|
virtual void SetScope(IntrusivePtr<Scope> newscope);
|
||||||
|
@ -129,8 +129,8 @@ protected:
|
||||||
|
|
||||||
class BroFunc final : public Func {
|
class BroFunc final : public Func {
|
||||||
public:
|
public:
|
||||||
BroFunc(const IntrusivePtr<ID>& id, IntrusivePtr<zeek::detail::Stmt> body,
|
BroFunc(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<zeek::detail::Stmt> body,
|
||||||
const std::vector<IntrusivePtr<ID>>& inits,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& inits,
|
||||||
size_t frame_size, int priority);
|
size_t frame_size, int priority);
|
||||||
|
|
||||||
~BroFunc() override;
|
~BroFunc() override;
|
||||||
|
@ -168,7 +168,7 @@ public:
|
||||||
broker::expected<broker::data> SerializeClosure() const;
|
broker::expected<broker::data> SerializeClosure() const;
|
||||||
|
|
||||||
void AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
|
void AddBody(IntrusivePtr<zeek::detail::Stmt> new_body,
|
||||||
const std::vector<IntrusivePtr<ID>>& new_inits,
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& new_inits,
|
||||||
size_t new_frame_size, int priority) override;
|
size_t new_frame_size, int priority) override;
|
||||||
|
|
||||||
/** Sets this function's outer_id list. */
|
/** Sets this function's outer_id list. */
|
||||||
|
@ -179,8 +179,9 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BroFunc() : Func(BRO_FUNC) {}
|
BroFunc() : Func(BRO_FUNC) {}
|
||||||
IntrusivePtr<zeek::detail::Stmt> AddInits(IntrusivePtr<zeek::detail::Stmt> body,
|
IntrusivePtr<zeek::detail::Stmt> AddInits(
|
||||||
const std::vector<IntrusivePtr<ID>>& inits);
|
IntrusivePtr<zeek::detail::Stmt> body,
|
||||||
|
const std::vector<IntrusivePtr<zeek::detail::ID>>& inits);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones this function along with its closures.
|
* Clones this function along with its closures.
|
||||||
|
@ -269,9 +270,9 @@ struct function_ingredients {
|
||||||
// to build a function.
|
// to build a function.
|
||||||
function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<zeek::detail::Stmt> body);
|
function_ingredients(IntrusivePtr<Scope> scope, IntrusivePtr<zeek::detail::Stmt> body);
|
||||||
|
|
||||||
IntrusivePtr<ID> id;
|
IntrusivePtr<zeek::detail::ID> id;
|
||||||
IntrusivePtr<zeek::detail::Stmt> body;
|
IntrusivePtr<zeek::detail::Stmt> body;
|
||||||
std::vector<IntrusivePtr<ID>> inits;
|
std::vector<IntrusivePtr<zeek::detail::ID>> inits;
|
||||||
int frame_size;
|
int frame_size;
|
||||||
int priority;
|
int priority;
|
||||||
IntrusivePtr<Scope> scope;
|
IntrusivePtr<Scope> scope;
|
||||||
|
|
27
src/ID.cc
27
src/ID.cc
|
@ -31,7 +31,7 @@ IntrusivePtr<TableType> zeek::id::count_set;
|
||||||
IntrusivePtr<VectorType> zeek::id::string_vec;
|
IntrusivePtr<VectorType> zeek::id::string_vec;
|
||||||
IntrusivePtr<VectorType> zeek::id::index_vec;
|
IntrusivePtr<VectorType> zeek::id::index_vec;
|
||||||
|
|
||||||
const IntrusivePtr<ID>& zeek::id::find(std::string_view name)
|
const IntrusivePtr<zeek::detail::ID>& zeek::id::find(std::string_view name)
|
||||||
{
|
{
|
||||||
return global_scope()->Find(name);
|
return global_scope()->Find(name);
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,8 @@ void zeek::id::detail::init()
|
||||||
index_vec = zeek::id::find_type<VectorType>("index_vec");
|
index_vec = zeek::id::find_type<VectorType>("index_vec");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
ID::ID(const char* arg_name, IDScope arg_scope, bool arg_is_export)
|
ID::ID(const char* arg_name, IDScope arg_scope, bool arg_is_export)
|
||||||
{
|
{
|
||||||
name = copy_string(arg_name);
|
name = copy_string(arg_name);
|
||||||
|
@ -118,6 +120,9 @@ ID::ID(const char* arg_name, IDScope arg_scope, bool arg_is_export)
|
||||||
SetLocationInfo(&start_location, &end_location);
|
SetLocationInfo(&start_location, &end_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ID::ID(const char* arg_name, ::IDScope arg_scope, bool arg_is_export) :
|
||||||
|
ID(arg_name, static_cast<IDScope>(arg_scope), arg_is_export) {}
|
||||||
|
|
||||||
ID::~ID()
|
ID::~ID()
|
||||||
{
|
{
|
||||||
delete [] name;
|
delete [] name;
|
||||||
|
@ -205,7 +210,7 @@ void ID::SetVal(IntrusivePtr<Val> v, init_class c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ID::SetVal(IntrusivePtr<zeek::detail::Expr> ev, init_class c)
|
void ID::SetVal(IntrusivePtr<Expr> ev, init_class c)
|
||||||
{
|
{
|
||||||
const auto& a = attrs->Find(c == INIT_EXTRA ? ATTR_ADD_FUNC : ATTR_DEL_FUNC);
|
const auto& a = attrs->Find(c == INIT_EXTRA ? ATTR_ADD_FUNC : ATTR_DEL_FUNC);
|
||||||
|
|
||||||
|
@ -215,6 +220,16 @@ void ID::SetVal(IntrusivePtr<zeek::detail::Expr> ev, init_class c)
|
||||||
EvalFunc(a->GetExpr(), std::move(ev));
|
EvalFunc(a->GetExpr(), std::move(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ID::SetVal(IntrusivePtr<Val> v, ::init_class c)
|
||||||
|
{
|
||||||
|
SetVal(v, static_cast<init_class>(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ID::SetVal(IntrusivePtr<Expr> ev, ::init_class c)
|
||||||
|
{
|
||||||
|
SetVal(ev, static_cast<init_class>(c));
|
||||||
|
}
|
||||||
|
|
||||||
bool ID::IsRedefinable() const
|
bool ID::IsRedefinable() const
|
||||||
{
|
{
|
||||||
return GetAttr(ATTR_REDEF) != nullptr;
|
return GetAttr(ATTR_REDEF) != nullptr;
|
||||||
|
@ -276,7 +291,7 @@ bool ID::IsDeprecated() const
|
||||||
return GetAttr(ATTR_DEPRECATED) != nullptr;
|
return GetAttr(ATTR_DEPRECATED) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ID::MakeDeprecated(IntrusivePtr<zeek::detail::Expr> deprecation)
|
void ID::MakeDeprecated(IntrusivePtr<Expr> deprecation)
|
||||||
{
|
{
|
||||||
if ( IsDeprecated() )
|
if ( IsDeprecated() )
|
||||||
return;
|
return;
|
||||||
|
@ -337,13 +352,13 @@ void ID::SetOption()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ID::EvalFunc(IntrusivePtr<zeek::detail::Expr> ef, IntrusivePtr<zeek::detail::Expr> ev)
|
void ID::EvalFunc(IntrusivePtr<Expr> ef, IntrusivePtr<Expr> ev)
|
||||||
{
|
{
|
||||||
auto arg1 = make_intrusive<zeek::detail::ConstExpr>(val);
|
auto arg1 = make_intrusive<zeek::detail::ConstExpr>(val);
|
||||||
auto args = make_intrusive<zeek::detail::ListExpr>();
|
auto args = make_intrusive<zeek::detail::ListExpr>();
|
||||||
args->Append(std::move(arg1));
|
args->Append(std::move(arg1));
|
||||||
args->Append(std::move(ev));
|
args->Append(std::move(ev));
|
||||||
auto ce = make_intrusive<zeek::detail::CallExpr>(std::move(ef), std::move(args));
|
auto ce = make_intrusive<CallExpr>(std::move(ef), std::move(args));
|
||||||
SetVal(ce->Eval(nullptr));
|
SetVal(ce->Eval(nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,3 +670,5 @@ std::vector<Func*> ID::GetOptionHandlers() const
|
||||||
v.push_back(element.second.get());
|
v.push_back(element.second.get());
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
32
src/ID.h
32
src/ID.h
|
@ -22,16 +22,25 @@ class VectorType;
|
||||||
class EnumType;
|
class EnumType;
|
||||||
class Attributes;
|
class Attributes;
|
||||||
|
|
||||||
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
enum [[deprecated("Remove in v4.1. Use zeek::detail::init_class instead.")]] init_class { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, };
|
||||||
|
enum [[deprecated("Remove in v4.1. Use zeek::detail::IDScope instead.")]] IDScope { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL };
|
||||||
|
|
||||||
typedef enum { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, } init_class;
|
namespace zeek::detail {
|
||||||
typedef enum { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL } IDScope;
|
|
||||||
|
class Expr;
|
||||||
|
|
||||||
|
enum init_class { INIT_NONE, INIT_FULL, INIT_EXTRA, INIT_REMOVE, };
|
||||||
|
enum IDScope { SCOPE_FUNCTION, SCOPE_MODULE, SCOPE_GLOBAL };
|
||||||
|
|
||||||
class ID final : public BroObj, public notifier::Modifiable {
|
class ID final : public BroObj, public notifier::Modifiable {
|
||||||
public:
|
public:
|
||||||
static inline const IntrusivePtr<ID> nil;
|
static inline const IntrusivePtr<ID> nil;
|
||||||
|
|
||||||
ID(const char* name, IDScope arg_scope, bool arg_is_export);
|
ID(const char* name, IDScope arg_scope, bool arg_is_export);
|
||||||
|
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::IDScope")]]
|
||||||
|
ID(const char* name, ::IDScope arg_scope, bool arg_is_export);
|
||||||
|
|
||||||
~ID() override;
|
~ID() override;
|
||||||
|
|
||||||
const char* Name() const { return name; }
|
const char* Name() const { return name; }
|
||||||
|
@ -71,7 +80,12 @@ public:
|
||||||
void SetVal(IntrusivePtr<Val> v);
|
void SetVal(IntrusivePtr<Val> v);
|
||||||
|
|
||||||
void SetVal(IntrusivePtr<Val> v, init_class c);
|
void SetVal(IntrusivePtr<Val> v, init_class c);
|
||||||
void SetVal(IntrusivePtr<zeek::detail::Expr> ev, init_class c);
|
void SetVal(IntrusivePtr<Expr> ev, init_class c);
|
||||||
|
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::init_class")]]
|
||||||
|
void SetVal(IntrusivePtr<Val> v, ::init_class c);
|
||||||
|
[[deprecated("Remove in v4.1. Use version that takes zeek::detail::init_class")]]
|
||||||
|
void SetVal(IntrusivePtr<Expr> ev, ::init_class c);
|
||||||
|
|
||||||
bool HasVal() const { return val != nullptr; }
|
bool HasVal() const { return val != nullptr; }
|
||||||
|
|
||||||
|
@ -118,7 +132,7 @@ public:
|
||||||
|
|
||||||
bool IsDeprecated() const;
|
bool IsDeprecated() const;
|
||||||
|
|
||||||
void MakeDeprecated(IntrusivePtr<zeek::detail::Expr> deprecation);
|
void MakeDeprecated(IntrusivePtr<Expr> deprecation);
|
||||||
|
|
||||||
std::string GetDeprecationWarning() const;
|
std::string GetDeprecationWarning() const;
|
||||||
|
|
||||||
|
@ -145,7 +159,7 @@ public:
|
||||||
std::vector<Func*> GetOptionHandlers() const;
|
std::vector<Func*> GetOptionHandlers() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void EvalFunc(IntrusivePtr<zeek::detail::Expr> ef, IntrusivePtr<zeek::detail::Expr> ev);
|
void EvalFunc(IntrusivePtr<Expr> ef, IntrusivePtr<Expr> ev);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void UpdateValID();
|
void UpdateValID();
|
||||||
|
@ -165,6 +179,10 @@ protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
using ID [[deprecated("Remove in v4.1. Use zeek::detail::ID instead.")]] = zeek::detail::ID;
|
||||||
|
|
||||||
namespace zeek::id {
|
namespace zeek::id {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,7 +191,7 @@ namespace zeek::id {
|
||||||
* @return The identifier, which may reference a nil object if no such
|
* @return The identifier, which may reference a nil object if no such
|
||||||
* name exists.
|
* name exists.
|
||||||
*/
|
*/
|
||||||
const IntrusivePtr<ID>& find(std::string_view name);
|
const IntrusivePtr<zeek::detail::ID>& find(std::string_view name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup an ID by its name and return its type. A fatal occurs if the ID
|
* Lookup an ID by its name and return its type. A fatal occurs if the ID
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
|
|
||||||
#include <stdint.h> // for u_char
|
#include <stdint.h> // for u_char
|
||||||
#include <sys/types.h> // for u_char
|
#include <sys/types.h> // for u_char
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
class ID;
|
|
||||||
class Rule;
|
class Rule;
|
||||||
class RuleEndpointState;
|
class RuleEndpointState;
|
||||||
|
|
||||||
|
FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
|
|
||||||
// Base class for all rule conditions except patterns and "header".
|
// Base class for all rule conditions except patterns and "header".
|
||||||
class RuleCondition {
|
class RuleCondition {
|
||||||
public:
|
public:
|
||||||
|
@ -111,7 +113,5 @@ public:
|
||||||
|
|
||||||
void PrintDebug() override;
|
void PrintDebug() override;
|
||||||
private:
|
private:
|
||||||
ID* id;
|
zeek::detail::ID* id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
38
src/Scope.cc
38
src/Scope.cc
|
@ -15,7 +15,7 @@ typedef PList<Scope> scope_list;
|
||||||
static scope_list scopes;
|
static scope_list scopes;
|
||||||
static Scope* top_scope;
|
static Scope* top_scope;
|
||||||
|
|
||||||
Scope::Scope(IntrusivePtr<ID> id,
|
Scope::Scope(IntrusivePtr<zeek::detail::ID> id,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> al)
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> al)
|
||||||
: scope_id(std::move(id)), attrs(std::move(al))
|
: scope_id(std::move(id)), attrs(std::move(al))
|
||||||
{
|
{
|
||||||
|
@ -35,17 +35,17 @@ Scope::Scope(IntrusivePtr<ID> id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const IntrusivePtr<ID>& Scope::Find(std::string_view name) const
|
const IntrusivePtr<zeek::detail::ID>& Scope::Find(std::string_view name) const
|
||||||
{
|
{
|
||||||
auto entry = local.find(name);
|
auto entry = local.find(name);
|
||||||
|
|
||||||
if ( entry != local.end() )
|
if ( entry != local.end() )
|
||||||
return entry->second;
|
return entry->second;
|
||||||
|
|
||||||
return ID::nil;
|
return zeek::detail::ID::nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<ID> Scope::Remove(std::string_view name)
|
IntrusivePtr<zeek::detail::ID> Scope::Remove(std::string_view name)
|
||||||
{
|
{
|
||||||
auto entry = local.find(name);
|
auto entry = local.find(name);
|
||||||
|
|
||||||
|
@ -59,12 +59,12 @@ IntrusivePtr<ID> Scope::Remove(std::string_view name)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<ID> Scope::GenerateTemporary(const char* name)
|
IntrusivePtr<zeek::detail::ID> Scope::GenerateTemporary(const char* name)
|
||||||
{
|
{
|
||||||
return make_intrusive<ID>(name, SCOPE_FUNCTION, false);
|
return make_intrusive<zeek::detail::ID>(name, zeek::detail::SCOPE_FUNCTION, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<IntrusivePtr<ID>> Scope::GetInits()
|
std::vector<IntrusivePtr<zeek::detail::ID>> Scope::GetInits()
|
||||||
{
|
{
|
||||||
auto rval = std::move(inits);
|
auto rval = std::move(inits);
|
||||||
inits = {};
|
inits = {};
|
||||||
|
@ -100,7 +100,7 @@ void Scope::Describe(ODesc* d) const
|
||||||
|
|
||||||
for ( const auto& entry : local )
|
for ( const auto& entry : local )
|
||||||
{
|
{
|
||||||
ID* id = entry.second.get();
|
zeek::detail::ID* id = entry.second.get();
|
||||||
id->Describe(d);
|
id->Describe(d);
|
||||||
d->NL();
|
d->NL();
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ TraversalCode Scope::Traverse(TraversalCallback* cb) const
|
||||||
{
|
{
|
||||||
for ( const auto& entry : local )
|
for ( const auto& entry : local )
|
||||||
{
|
{
|
||||||
ID* id = entry.second.get();
|
zeek::detail::ID* id = entry.second.get();
|
||||||
TraversalCode tc = id->Traverse(cb);
|
TraversalCode tc = id->Traverse(cb);
|
||||||
HANDLE_TC_STMT_PRE(tc);
|
HANDLE_TC_STMT_PRE(tc);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ TraversalCode Scope::Traverse(TraversalCallback* cb) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const IntrusivePtr<ID>& lookup_ID(const char* name, const char* curr_module,
|
const IntrusivePtr<zeek::detail::ID>& lookup_ID(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)
|
||||||
{
|
{
|
||||||
|
@ -150,30 +150,30 @@ const IntrusivePtr<ID>& lookup_ID(const char* name, const char* curr_module,
|
||||||
return global_scope()->Find(globalname);
|
return global_scope()->Find(globalname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ID::nil;
|
return zeek::detail::ID::nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<ID> install_ID(const char* name, const char* module_name,
|
IntrusivePtr<zeek::detail::ID> install_ID(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 )
|
||||||
reporter->InternalError("local identifier in global scope");
|
reporter->InternalError("local identifier in global scope");
|
||||||
|
|
||||||
IDScope scope;
|
zeek::detail::IDScope scope;
|
||||||
if ( is_export || ! module_name ||
|
if ( is_export || ! module_name ||
|
||||||
(is_global &&
|
(is_global &&
|
||||||
normalized_module_name(module_name) == GLOBAL_MODULE_NAME) )
|
normalized_module_name(module_name) == GLOBAL_MODULE_NAME) )
|
||||||
scope = SCOPE_GLOBAL;
|
scope = zeek::detail::SCOPE_GLOBAL;
|
||||||
else if ( is_global )
|
else if ( is_global )
|
||||||
scope = SCOPE_MODULE;
|
scope = zeek::detail::SCOPE_MODULE;
|
||||||
else
|
else
|
||||||
scope = SCOPE_FUNCTION;
|
scope = zeek::detail::SCOPE_FUNCTION;
|
||||||
|
|
||||||
std::string full_name = make_full_var_name(module_name, name);
|
std::string full_name = make_full_var_name(module_name, name);
|
||||||
|
|
||||||
auto id = make_intrusive<ID>(full_name.data(), scope, is_export);
|
auto id = make_intrusive<zeek::detail::ID>(full_name.data(), scope, is_export);
|
||||||
|
|
||||||
if ( SCOPE_FUNCTION != scope )
|
if ( zeek::detail::SCOPE_FUNCTION != scope )
|
||||||
global_scope()->Insert(std::move(full_name), id);
|
global_scope()->Insert(std::move(full_name), id);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -189,7 +189,7 @@ void push_existing_scope(Scope* scope)
|
||||||
scopes.push_back(scope);
|
scopes.push_back(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_scope(IntrusivePtr<ID> id,
|
void push_scope(IntrusivePtr<zeek::detail::ID> id,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)
|
||||||
{
|
{
|
||||||
top_scope = new Scope(std::move(id), std::move(attrs));
|
top_scope = new Scope(std::move(id), std::move(attrs));
|
||||||
|
|
33
src/Scope.h
33
src/Scope.h
|
@ -13,31 +13,32 @@
|
||||||
#include "TraverseTypes.h"
|
#include "TraverseTypes.h"
|
||||||
|
|
||||||
template <class T> class IntrusivePtr;
|
template <class T> class IntrusivePtr;
|
||||||
class ID;
|
|
||||||
class BroType;
|
class BroType;
|
||||||
class ListVal;
|
class ListVal;
|
||||||
|
|
||||||
|
FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
|
|
||||||
class Scope : public BroObj {
|
class Scope : public BroObj {
|
||||||
public:
|
public:
|
||||||
explicit Scope(IntrusivePtr<ID> id,
|
explicit Scope(IntrusivePtr<zeek::detail::ID> id,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> al);
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> al);
|
||||||
|
|
||||||
const IntrusivePtr<ID>& Find(std::string_view name) const;
|
const IntrusivePtr<zeek::detail::ID>& Find(std::string_view name) const;
|
||||||
|
|
||||||
template<typename N>
|
template<typename N>
|
||||||
[[deprecated("Remove in v4.1. Use Find().")]]
|
[[deprecated("Remove in v4.1. Use Find().")]]
|
||||||
ID* Lookup(N&& name) const
|
zeek::detail::ID* Lookup(N&& name) const
|
||||||
{ return Find(name).get(); }
|
{ return Find(name).get(); }
|
||||||
|
|
||||||
template<typename N, typename I>
|
template<typename N, typename I>
|
||||||
void Insert(N&& name, I&& id) { local[std::forward<N>(name)] = std::forward<I>(id); }
|
void Insert(N&& name, I&& id) { local[std::forward<N>(name)] = std::forward<I>(id); }
|
||||||
|
|
||||||
IntrusivePtr<ID> Remove(std::string_view name);
|
IntrusivePtr<zeek::detail::ID> Remove(std::string_view name);
|
||||||
|
|
||||||
[[deprecated("Remove in v4.1. Use GetID().")]]
|
[[deprecated("Remove in v4.1. Use GetID().")]]
|
||||||
ID* ScopeID() const { return scope_id.get(); }
|
zeek::detail::ID* ScopeID() const { return scope_id.get(); }
|
||||||
|
|
||||||
const IntrusivePtr<ID>& GetID() const
|
const IntrusivePtr<zeek::detail::ID>& GetID() const
|
||||||
{ return scope_id; }
|
{ return scope_id; }
|
||||||
|
|
||||||
const std::unique_ptr<std::vector<IntrusivePtr<Attr>>>& Attrs() const
|
const std::unique_ptr<std::vector<IntrusivePtr<Attr>>>& Attrs() const
|
||||||
|
@ -52,14 +53,14 @@ public:
|
||||||
size_t Length() const { return local.size(); }
|
size_t Length() const { return local.size(); }
|
||||||
const auto& Vars() { return local; }
|
const auto& Vars() { return local; }
|
||||||
|
|
||||||
IntrusivePtr<ID> GenerateTemporary(const char* name);
|
IntrusivePtr<zeek::detail::ID> GenerateTemporary(const char* name);
|
||||||
|
|
||||||
// Returns the list of variables needing initialization, and
|
// Returns the list of variables needing initialization, and
|
||||||
// removes it from this Scope.
|
// removes it from this Scope.
|
||||||
std::vector<IntrusivePtr<ID>> GetInits();
|
std::vector<IntrusivePtr<zeek::detail::ID>> GetInits();
|
||||||
|
|
||||||
// Adds a variable to the list.
|
// Adds a variable to the list.
|
||||||
void AddInit(IntrusivePtr<ID> id)
|
void AddInit(IntrusivePtr<zeek::detail::ID> id)
|
||||||
{ inits.emplace_back(std::move(id)); }
|
{ inits.emplace_back(std::move(id)); }
|
||||||
|
|
||||||
void Describe(ODesc* d) const override;
|
void Describe(ODesc* d) const override;
|
||||||
|
@ -67,26 +68,26 @@ public:
|
||||||
TraversalCode Traverse(TraversalCallback* cb) const;
|
TraversalCode Traverse(TraversalCallback* cb) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IntrusivePtr<ID> scope_id;
|
IntrusivePtr<zeek::detail::ID> scope_id;
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs;
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs;
|
||||||
IntrusivePtr<BroType> return_type;
|
IntrusivePtr<BroType> return_type;
|
||||||
std::map<std::string, IntrusivePtr<ID>, std::less<>> local;
|
std::map<std::string, IntrusivePtr<zeek::detail::ID>, std::less<>> local;
|
||||||
std::vector<IntrusivePtr<ID>> inits;
|
std::vector<IntrusivePtr<zeek::detail::ID>> inits;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern bool in_debug;
|
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 IntrusivePtr<ID>& lookup_ID(const char* name, const char* module,
|
extern const IntrusivePtr<zeek::detail::ID>& lookup_ID(const char* name, const char* module,
|
||||||
bool no_global = false,
|
bool no_global = false,
|
||||||
bool same_module_only = false,
|
bool same_module_only = false,
|
||||||
bool check_export = true);
|
bool check_export = true);
|
||||||
|
|
||||||
extern IntrusivePtr<ID> install_ID(const char* name, const char* module_name,
|
extern IntrusivePtr<zeek::detail::ID> install_ID(const char* name, const char* module_name,
|
||||||
bool is_global, bool is_export);
|
bool is_global, bool is_export);
|
||||||
|
|
||||||
extern void push_scope(IntrusivePtr<ID> id,
|
extern void push_scope(IntrusivePtr<zeek::detail::ID> id,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs);
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs);
|
||||||
extern void push_existing_scope(Scope* scope);
|
extern void push_existing_scope(Scope* scope);
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,7 @@ void ProfileLogger::Log()
|
||||||
|
|
||||||
for ( const auto& global : globals )
|
for ( const auto& global : globals )
|
||||||
{
|
{
|
||||||
ID* id = global.second.get();
|
auto id = global.second;
|
||||||
|
|
||||||
// We don't show/count internal globals as they are always
|
// We don't show/count internal globals as they are always
|
||||||
// contained in some other global user-visible container.
|
// contained in some other global user-visible container.
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
class Func;
|
class Func;
|
||||||
class Scope;
|
class Scope;
|
||||||
class ID;
|
|
||||||
|
|
||||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
|
FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
|
||||||
|
|
||||||
class TraversalCallback {
|
class TraversalCallback {
|
||||||
public:
|
public:
|
||||||
|
@ -25,14 +25,14 @@ public:
|
||||||
virtual TraversalCode PreExpr(const zeek::detail::Expr*) { return TC_CONTINUE; }
|
virtual TraversalCode PreExpr(const zeek::detail::Expr*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostExpr(const zeek::detail::Expr*) { return TC_CONTINUE; }
|
virtual TraversalCode PostExpr(const zeek::detail::Expr*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
virtual TraversalCode PreID(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PreID(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostID(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PostID(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
virtual TraversalCode PreTypedef(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PreTypedef(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostTypedef(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PostTypedef(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
virtual TraversalCode PreDecl(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PreDecl(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
virtual TraversalCode PostDecl(const ID*) { return TC_CONTINUE; }
|
virtual TraversalCode PostDecl(const zeek::detail::ID*) { return TC_CONTINUE; }
|
||||||
|
|
||||||
Scope* current_scope;
|
Scope* current_scope;
|
||||||
};
|
};
|
||||||
|
|
|
@ -391,7 +391,7 @@ void Trigger::Timeout()
|
||||||
Unref(this);
|
Unref(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::Register(ID* id)
|
void Trigger::Register(zeek::detail::ID* id)
|
||||||
{
|
{
|
||||||
assert(! disabled);
|
assert(! disabled);
|
||||||
notifier::registry.Register(id, this);
|
notifier::registry.Register(id, this);
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
class Frame;
|
class Frame;
|
||||||
class Val;
|
class Val;
|
||||||
class ID;
|
|
||||||
class ODesc;
|
class ODesc;
|
||||||
|
|
||||||
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
|
||||||
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
|
||||||
FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
FORWARD_DECLARE_NAMESPACED(CallExpr, zeek::detail);
|
||||||
|
FORWARD_DECLARE_NAMESPACED(ID, 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
|
||||||
|
@ -89,7 +89,7 @@ private:
|
||||||
friend class TriggerTimer;
|
friend class TriggerTimer;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Register(ID* id);
|
void Register(zeek::detail::ID* id);
|
||||||
void Register(Val* val);
|
void Register(Val* val);
|
||||||
void UnregisterAll();
|
void UnregisterAll();
|
||||||
|
|
||||||
|
|
|
@ -379,12 +379,12 @@ void Val::ValDescribeReST(ODesc* d) const
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
ID* Val::GetID() const
|
zeek::detail::ID* Val::GetID() const
|
||||||
{
|
{
|
||||||
return bound_id ? global_scope()->Find(bound_id).get() : nullptr;
|
return bound_id ? global_scope()->Find(bound_id).get() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Val::SetID(ID* id)
|
void Val::SetID(zeek::detail::ID* id)
|
||||||
{
|
{
|
||||||
delete [] bound_id;
|
delete [] bound_id;
|
||||||
bound_id = id ? copy_string(id->Name()) : nullptr;
|
bound_id = id ? copy_string(id->Name()) : nullptr;
|
||||||
|
|
|
@ -324,9 +324,9 @@ public:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// For debugging, we keep a reference to the global ID to which a
|
// For debugging, we keep a reference to the global ID to which a
|
||||||
// value has been bound *last*.
|
// value has been bound *last*.
|
||||||
ID* GetID() const;
|
zeek::detail::ID* GetID() const;
|
||||||
|
|
||||||
void SetID(ID* id);
|
void SetID(zeek::detail::ID* id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool WouldOverflow(const BroType* from_type, const BroType* to_type, const Val* val);
|
static bool WouldOverflow(const BroType* from_type, const BroType* to_type, const Val* val);
|
||||||
|
|
33
src/Var.cc
33
src/Var.cc
|
@ -30,7 +30,7 @@ static IntrusivePtr<Val> init_val(zeek::detail::Expr* init, const BroType* t,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool add_prototype(const IntrusivePtr<ID>& id, BroType* t,
|
static bool add_prototype(const IntrusivePtr<zeek::detail::ID>& id, BroType* t,
|
||||||
std::vector<IntrusivePtr<Attr>>* attrs,
|
std::vector<IntrusivePtr<Attr>>* attrs,
|
||||||
const IntrusivePtr<zeek::detail::Expr>& init)
|
const IntrusivePtr<zeek::detail::Expr>& init)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,8 @@ static bool add_prototype(const IntrusivePtr<ID>& id, BroType* t,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_class c,
|
static void make_var(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroType> t,
|
||||||
|
zeek::detail::init_class c,
|
||||||
IntrusivePtr<zeek::detail::Expr> init,
|
IntrusivePtr<zeek::detail::Expr> init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||||
decl_type dt,
|
decl_type dt,
|
||||||
|
@ -227,14 +228,14 @@ static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_c
|
||||||
|
|
||||||
if ( do_init )
|
if ( do_init )
|
||||||
{
|
{
|
||||||
if ( c == INIT_NONE && dt == VAR_REDEF && t->IsTable() &&
|
if ( c == zeek::detail::INIT_NONE && dt == VAR_REDEF && t->IsTable() &&
|
||||||
init && init->Tag() == zeek::detail::EXPR_ASSIGN )
|
init && init->Tag() == zeek::detail::EXPR_ASSIGN )
|
||||||
// e.g. 'redef foo["x"] = 1' is missing an init class, but the
|
// e.g. 'redef foo["x"] = 1' is missing an init class, but the
|
||||||
// intention clearly isn't to overwrite entire existing table val.
|
// intention clearly isn't to overwrite entire existing table val.
|
||||||
c = INIT_EXTRA;
|
c = zeek::detail::INIT_EXTRA;
|
||||||
|
|
||||||
if ( init && ((c == INIT_EXTRA && id->GetAttr(ATTR_ADD_FUNC)) ||
|
if ( init && ((c == zeek::detail::INIT_EXTRA && id->GetAttr(ATTR_ADD_FUNC)) ||
|
||||||
(c == INIT_REMOVE && id->GetAttr(ATTR_DEL_FUNC)) ))
|
(c == zeek::detail::INIT_REMOVE && id->GetAttr(ATTR_DEL_FUNC)) ))
|
||||||
// Just apply the function.
|
// Just apply the function.
|
||||||
id->SetVal(init, c);
|
id->SetVal(init, c);
|
||||||
|
|
||||||
|
@ -301,22 +302,22 @@ static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_c
|
||||||
// For events, add a function value (without any body) here so that
|
// For events, add a function value (without any body) here so that
|
||||||
// we can later access the ID even if no implementations have been
|
// we can later access the ID even if no implementations have been
|
||||||
// defined.
|
// defined.
|
||||||
std::vector<IntrusivePtr<ID>> inits;
|
std::vector<IntrusivePtr<zeek::detail::ID>> inits;
|
||||||
auto f = make_intrusive<BroFunc>(id, nullptr, inits, 0, 0);
|
auto f = make_intrusive<BroFunc>(id, nullptr, inits, 0, 0);
|
||||||
id->SetVal(make_intrusive<Val>(std::move(f)));
|
id->SetVal(make_intrusive<Val>(std::move(f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_global(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t,
|
void add_global(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroType> t,
|
||||||
init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
zeek::detail::init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||||
decl_type dt)
|
decl_type dt)
|
||||||
{
|
{
|
||||||
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<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<BroType> t,
|
IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id, IntrusivePtr<BroType> t,
|
||||||
init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
zeek::detail::init_class c, IntrusivePtr<zeek::detail::Expr> init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||||
decl_type dt)
|
decl_type dt)
|
||||||
{
|
{
|
||||||
|
@ -324,7 +325,7 @@ IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<Bro
|
||||||
|
|
||||||
if ( init )
|
if ( init )
|
||||||
{
|
{
|
||||||
if ( c != INIT_FULL )
|
if ( c != zeek::detail::INIT_FULL )
|
||||||
id->Error("can't use += / -= for initializations of local variables");
|
id->Error("can't use += / -= for initializations of local variables");
|
||||||
|
|
||||||
// copy Location to the stack, because AssignExpr may free "init"
|
// copy Location to the stack, because AssignExpr may free "init"
|
||||||
|
@ -347,17 +348,17 @@ IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<Bro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<ID> id,
|
extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<zeek::detail::ID> id,
|
||||||
IntrusivePtr<zeek::detail::Expr> init,
|
IntrusivePtr<zeek::detail::Expr> init,
|
||||||
IntrusivePtr<Val> val)
|
IntrusivePtr<Val> val)
|
||||||
{
|
{
|
||||||
make_var(id, nullptr, INIT_FULL, init, nullptr, VAR_REGULAR, false);
|
make_var(id, nullptr, zeek::detail::INIT_FULL, init, nullptr, VAR_REGULAR, false);
|
||||||
auto name_expr = make_intrusive<zeek::detail::NameExpr>(std::move(id));
|
auto name_expr = make_intrusive<zeek::detail::NameExpr>(std::move(id));
|
||||||
return make_intrusive<zeek::detail::AssignExpr>(std::move(name_expr), std::move(init),
|
return make_intrusive<zeek::detail::AssignExpr>(std::move(name_expr), std::move(init),
|
||||||
false, std::move(val));
|
false, std::move(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_type(ID* id, IntrusivePtr<BroType> t,
|
void add_type(zeek::detail::ID* id, IntrusivePtr<BroType> t,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr)
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr)
|
||||||
{
|
{
|
||||||
std::string new_type_name = id->Name();
|
std::string new_type_name = id->Name();
|
||||||
|
@ -458,7 +459,7 @@ static bool canonical_arg_types_match(const FuncType* decl, const FuncType* impl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void begin_func(IntrusivePtr<ID> id, const char* module_name,
|
void begin_func(IntrusivePtr<zeek::detail::ID> id, const char* module_name,
|
||||||
function_flavor flavor, bool is_redef,
|
function_flavor flavor, bool is_redef,
|
||||||
IntrusivePtr<FuncType> t,
|
IntrusivePtr<FuncType> t,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)
|
||||||
|
|
14
src/Var.h
14
src/Var.h
|
@ -18,28 +18,28 @@ FORWARD_DECLARE_NAMESPACED(Expr, 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<zeek::detail::ID>& id,
|
||||||
IntrusivePtr<BroType> t,
|
IntrusivePtr<BroType> t,
|
||||||
init_class c,
|
zeek::detail::init_class c,
|
||||||
IntrusivePtr<zeek::detail::Expr> init,
|
IntrusivePtr<zeek::detail::Expr> init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||||
decl_type dt);
|
decl_type dt);
|
||||||
|
|
||||||
extern IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id,
|
extern IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id,
|
||||||
IntrusivePtr<BroType> t,
|
IntrusivePtr<BroType> t,
|
||||||
init_class c,
|
zeek::detail::init_class c,
|
||||||
IntrusivePtr<zeek::detail::Expr> init,
|
IntrusivePtr<zeek::detail::Expr> init,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
|
||||||
decl_type dt);
|
decl_type dt);
|
||||||
|
|
||||||
extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<ID> id,
|
extern IntrusivePtr<zeek::detail::Expr> add_and_assign_local(IntrusivePtr<zeek::detail::ID> id,
|
||||||
IntrusivePtr<zeek::detail::Expr> init,
|
IntrusivePtr<zeek::detail::Expr> init,
|
||||||
IntrusivePtr<Val> val = nullptr);
|
IntrusivePtr<Val> val = nullptr);
|
||||||
|
|
||||||
extern void add_type(ID* id, IntrusivePtr<BroType> t,
|
extern void add_type(zeek::detail::ID* id, IntrusivePtr<BroType> t,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr);
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr);
|
||||||
|
|
||||||
extern void begin_func(IntrusivePtr<ID> id, const char* module_name,
|
extern void begin_func(IntrusivePtr<zeek::detail::ID> id, const char* module_name,
|
||||||
function_flavor flavor, bool is_redef,
|
function_flavor flavor, bool is_redef,
|
||||||
IntrusivePtr<FuncType> t,
|
IntrusivePtr<FuncType> t,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs = nullptr);
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs = nullptr);
|
||||||
|
|
|
@ -31,7 +31,7 @@ Config::Config(ReaderFrontend *frontend) : ReaderBackend(frontend)
|
||||||
|
|
||||||
for ( const auto& entry : globals )
|
for ( const auto& entry : globals )
|
||||||
{
|
{
|
||||||
ID* id = entry.second.get();
|
auto id = entry.second;
|
||||||
if ( ! id->IsOption() )
|
if ( ! id->IsOption() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Option;
|
||||||
#include "NetVar.h"
|
#include "NetVar.h"
|
||||||
#include "broker/Data.h"
|
#include "broker/Data.h"
|
||||||
|
|
||||||
static bool call_option_handlers_and_set_value(StringVal* name, const IntrusivePtr<ID>& i,
|
static bool call_option_handlers_and_set_value(StringVal* name, const IntrusivePtr<zeek::detail::ID>& i,
|
||||||
IntrusivePtr<Val> val,
|
IntrusivePtr<Val> val,
|
||||||
StringVal* location)
|
StringVal* location)
|
||||||
{
|
{
|
||||||
|
|
22
src/parse.y
22
src/parse.y
|
@ -136,7 +136,7 @@ std::vector<int> saved_in_init;
|
||||||
|
|
||||||
static Location func_hdr_location;
|
static Location func_hdr_location;
|
||||||
EnumType *cur_enum_type = 0;
|
EnumType *cur_enum_type = 0;
|
||||||
static ID* cur_decl_type_id = 0;
|
static zeek::detail::ID* cur_decl_type_id = 0;
|
||||||
|
|
||||||
static void parser_new_enum (void)
|
static void parser_new_enum (void)
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ static void parser_new_enum (void)
|
||||||
reporter->FatalError("incorrect syntax for enum type declaration");
|
reporter->FatalError("incorrect syntax for enum type declaration");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parser_redef_enum (ID *id)
|
static void parser_redef_enum (zeek::detail::ID *id)
|
||||||
{
|
{
|
||||||
/* Redef an enum. id points to the enum to be redefined.
|
/* Redef an enum. id points to the enum to be redefined.
|
||||||
Let cur_enum_type point to it. */
|
Let cur_enum_type point to it. */
|
||||||
|
@ -166,7 +166,7 @@ static void parser_redef_enum (ID *id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void extend_record(ID* id, std::unique_ptr<type_decl_list> fields,
|
static void extend_record(zeek::detail::ID* id, std::unique_ptr<type_decl_list> fields,
|
||||||
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)
|
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)
|
||||||
{
|
{
|
||||||
std::set<BroType*> types = BroType::GetAliases(id->Name());
|
std::set<BroType*> types = BroType::GetAliases(id->Name());
|
||||||
|
@ -232,9 +232,9 @@ static bool expr_is_table_type_name(const zeek::detail::Expr* expr)
|
||||||
%union {
|
%union {
|
||||||
bool b;
|
bool b;
|
||||||
char* str;
|
char* str;
|
||||||
ID* id;
|
zeek::detail::ID* id;
|
||||||
id_list* id_l;
|
id_list* id_l;
|
||||||
init_class ic;
|
zeek::detail::init_class ic;
|
||||||
Val* val;
|
Val* val;
|
||||||
RE_Matcher* re;
|
RE_Matcher* re;
|
||||||
zeek::detail::Expr* expr;
|
zeek::detail::Expr* expr;
|
||||||
|
@ -1295,10 +1295,10 @@ opt_type:
|
||||||
;
|
;
|
||||||
|
|
||||||
init_class:
|
init_class:
|
||||||
{ $$ = INIT_NONE; }
|
{ $$ = zeek::detail::INIT_NONE; }
|
||||||
| '=' { $$ = INIT_FULL; }
|
| '=' { $$ = zeek::detail::INIT_FULL; }
|
||||||
| TOK_ADD_TO { $$ = INIT_EXTRA; }
|
| TOK_ADD_TO { $$ = zeek::detail::INIT_EXTRA; }
|
||||||
| TOK_REMOVE_FROM { $$ = INIT_REMOVE; }
|
| TOK_REMOVE_FROM { $$ = zeek::detail::INIT_REMOVE; }
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_init:
|
opt_init:
|
||||||
|
@ -1658,7 +1658,7 @@ case_type_list:
|
||||||
case_type:
|
case_type:
|
||||||
TOK_TYPE type
|
TOK_TYPE type
|
||||||
{
|
{
|
||||||
$$ = new ID(0, SCOPE_FUNCTION, 0);
|
$$ = new zeek::detail::ID(0, zeek::detail::SCOPE_FUNCTION, 0);
|
||||||
$$->SetType({AdoptRef{}, $2});
|
$$->SetType({AdoptRef{}, $2});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1673,7 +1673,7 @@ case_type:
|
||||||
else
|
else
|
||||||
case_var = install_ID(name, current_module.c_str(), false, false);
|
case_var = install_ID(name, current_module.c_str(), false, false);
|
||||||
|
|
||||||
add_local(case_var, std::move(type), INIT_NONE, nullptr, nullptr,
|
add_local(case_var, std::move(type), zeek::detail::INIT_NONE, nullptr, nullptr,
|
||||||
VAR_REGULAR);
|
VAR_REGULAR);
|
||||||
$$ = case_var.release();
|
$$ = case_var.release();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1918,7 +1918,7 @@ function global_sizes%(%): var_sizes
|
||||||
|
|
||||||
for ( const auto& global : globals )
|
for ( const auto& global : globals )
|
||||||
{
|
{
|
||||||
ID* id = global.second.get();
|
auto id = global.second;
|
||||||
if ( id->HasVal() )
|
if ( id->HasVal() )
|
||||||
{
|
{
|
||||||
auto id_name = make_intrusive<StringVal>(id->Name());
|
auto id_name = make_intrusive<StringVal>(id->Name());
|
||||||
|
@ -1946,7 +1946,7 @@ function global_ids%(%): id_table
|
||||||
|
|
||||||
for ( const auto& global : globals )
|
for ( const auto& global : globals )
|
||||||
{
|
{
|
||||||
ID* id = global.second.get();
|
zeek::detail::ID* id = global.second.get();
|
||||||
static auto script_id = zeek::id::find_type<RecordType>("script_id");
|
static auto script_id = zeek::id::find_type<RecordType>("script_id");
|
||||||
auto rec = make_intrusive<RecordVal>(script_id);
|
auto rec = make_intrusive<RecordVal>(script_id);
|
||||||
rec->Assign(0, make_intrusive<StringVal>(type_name(id->GetType()->Tag())));
|
rec->Assign(0, make_intrusive<StringVal>(type_name(id->GetType()->Tag())));
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace zeekygen;
|
using namespace zeekygen;
|
||||||
|
|
||||||
IdentifierInfo::IdentifierInfo(IntrusivePtr<ID> arg_id, ScriptInfo* script)
|
IdentifierInfo::IdentifierInfo(IntrusivePtr<zeek::detail::ID> arg_id, ScriptInfo* script)
|
||||||
: Info(),
|
: Info(),
|
||||||
comments(), id(std::move(arg_id)), initial_val(), redefs(), fields(),
|
comments(), id(std::move(arg_id)), initial_val(), redefs(), fields(),
|
||||||
last_field_seen(), declaring_script(script)
|
last_field_seen(), declaring_script(script)
|
||||||
|
@ -31,7 +31,7 @@ IdentifierInfo::~IdentifierInfo()
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentifierInfo::AddRedef(const string& script, init_class ic,
|
void IdentifierInfo::AddRedef(const string& script, zeek::detail::init_class ic,
|
||||||
IntrusivePtr<zeek::detail::Expr> init_expr, const vector<string>& comments)
|
IntrusivePtr<zeek::detail::Expr> init_expr, const vector<string>& comments)
|
||||||
{
|
{
|
||||||
Redefinition* redef = new Redefinition(script, ic, std::move(init_expr), comments);
|
Redefinition* redef = new Redefinition(script, ic, std::move(init_expr), comments);
|
||||||
|
@ -141,7 +141,7 @@ time_t IdentifierInfo::DoGetModificationTime() const
|
||||||
|
|
||||||
IdentifierInfo::Redefinition::Redefinition(
|
IdentifierInfo::Redefinition::Redefinition(
|
||||||
std::string arg_script,
|
std::string arg_script,
|
||||||
init_class arg_ic,
|
zeek::detail::init_class arg_ic,
|
||||||
IntrusivePtr<zeek::detail::Expr> arg_expr,
|
IntrusivePtr<zeek::detail::Expr> arg_expr,
|
||||||
std::vector<std::string> arg_comments)
|
std::vector<std::string> arg_comments)
|
||||||
: from_script(std::move(arg_script)),
|
: from_script(std::move(arg_script)),
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
* @param script The info object associated with the script in which \a id
|
* @param script The info object associated with the script in which \a id
|
||||||
* is declared.
|
* is declared.
|
||||||
*/
|
*/
|
||||||
IdentifierInfo(IntrusivePtr<ID> id, ScriptInfo* script);
|
IdentifierInfo(IntrusivePtr<zeek::detail::ID> id, ScriptInfo* script);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dtor. Releases any references to script-level objects.
|
* Dtor. Releases any references to script-level objects.
|
||||||
|
@ -70,7 +70,7 @@ public:
|
||||||
* @param init_expr The initialization expression used.
|
* @param init_expr The initialization expression used.
|
||||||
* @param comments Comments associated with the redef statement.
|
* @param comments Comments associated with the redef statement.
|
||||||
*/
|
*/
|
||||||
void AddRedef(const std::string& from_script, init_class ic,
|
void AddRedef(const std::string& from_script, zeek::detail::init_class ic,
|
||||||
IntrusivePtr<zeek::detail::Expr> init_expr,
|
IntrusivePtr<zeek::detail::Expr> init_expr,
|
||||||
const std::vector<std::string>& comments);
|
const std::vector<std::string>& comments);
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @return the script-level ID tracked by this info object.
|
* @return the script-level ID tracked by this info object.
|
||||||
*/
|
*/
|
||||||
ID* GetID() const
|
zeek::detail::ID* GetID() const
|
||||||
{ return id.get(); }
|
{ return id.get(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,11 +127,11 @@ public:
|
||||||
*/
|
*/
|
||||||
struct Redefinition {
|
struct Redefinition {
|
||||||
std::string from_script; /**< Name of script doing the redef. */
|
std::string from_script; /**< Name of script doing the redef. */
|
||||||
init_class ic;
|
zeek::detail::init_class ic;
|
||||||
IntrusivePtr<zeek::detail::Expr> init_expr;
|
IntrusivePtr<zeek::detail::Expr> init_expr;
|
||||||
std::vector<std::string> comments; /**< Zeekygen comments on redef. */
|
std::vector<std::string> comments; /**< Zeekygen comments on redef. */
|
||||||
|
|
||||||
Redefinition(std::string arg_script, init_class arg_ic,
|
Redefinition(std::string arg_script, zeek::detail::init_class arg_ic,
|
||||||
IntrusivePtr<zeek::detail::Expr> arg_expr,
|
IntrusivePtr<zeek::detail::Expr> arg_expr,
|
||||||
std::vector<std::string> arg_comments);
|
std::vector<std::string> arg_comments);
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ private:
|
||||||
typedef std::map<std::string, RecordField*> record_field_map;
|
typedef std::map<std::string, RecordField*> record_field_map;
|
||||||
|
|
||||||
std::vector<std::string> comments;
|
std::vector<std::string> comments;
|
||||||
IntrusivePtr<ID> id;
|
IntrusivePtr<zeek::detail::ID> id;
|
||||||
IntrusivePtr<Val> initial_val;
|
IntrusivePtr<Val> initial_val;
|
||||||
redef_list redefs;
|
redef_list redefs;
|
||||||
record_field_map fields;
|
record_field_map fields;
|
||||||
|
|
|
@ -27,7 +27,7 @@ static void DbgAndWarn(const char* msg)
|
||||||
DBG_LOG(DBG_ZEEKYGEN, "%s", msg);
|
DBG_LOG(DBG_ZEEKYGEN, "%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WarnMissingScript(const char* type, const ID* id,
|
static void WarnMissingScript(const char* type, const zeek::detail::ID* id,
|
||||||
const string& script)
|
const string& script)
|
||||||
{
|
{
|
||||||
if ( script == "<command line>" )
|
if ( script == "<command line>" )
|
||||||
|
@ -216,7 +216,7 @@ void Manager::ModuleUsage(const string& path, const string& module)
|
||||||
module.c_str(), name.c_str());
|
module.c_str(), name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentifierInfo* Manager::CreateIdentifierInfo(IntrusivePtr<ID> id, ScriptInfo* script)
|
IdentifierInfo* Manager::CreateIdentifierInfo(IntrusivePtr<zeek::detail::ID> id, ScriptInfo* script)
|
||||||
{
|
{
|
||||||
const auto& id_name = id->Name();
|
const auto& id_name = id->Name();
|
||||||
auto prev = identifiers.GetInfo(id_name);
|
auto prev = identifiers.GetInfo(id_name);
|
||||||
|
@ -247,7 +247,7 @@ IdentifierInfo* Manager::CreateIdentifierInfo(IntrusivePtr<ID> id, ScriptInfo* s
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::StartType(IntrusivePtr<ID> id)
|
void Manager::StartType(IntrusivePtr<zeek::detail::ID> id)
|
||||||
{
|
{
|
||||||
if ( disabled )
|
if ( disabled )
|
||||||
return;
|
return;
|
||||||
|
@ -273,12 +273,12 @@ void Manager::StartType(IntrusivePtr<ID> id)
|
||||||
incomplete_type = CreateIdentifierInfo(std::move(id), script_info);
|
incomplete_type = CreateIdentifierInfo(std::move(id), script_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsEnumType(ID* id)
|
static bool IsEnumType(zeek::detail::ID* id)
|
||||||
{
|
{
|
||||||
return id->IsType() ? id->GetType()->Tag() == TYPE_ENUM : false;
|
return id->IsType() ? id->GetType()->Tag() == TYPE_ENUM : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::Identifier(IntrusivePtr<ID> id)
|
void Manager::Identifier(IntrusivePtr<zeek::detail::ID> id)
|
||||||
{
|
{
|
||||||
if ( disabled )
|
if ( disabled )
|
||||||
return;
|
return;
|
||||||
|
@ -337,7 +337,7 @@ void Manager::Identifier(IntrusivePtr<ID> id)
|
||||||
CreateIdentifierInfo(std::move(id), script_info);
|
CreateIdentifierInfo(std::move(id), script_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::RecordField(const ID* id, const TypeDecl* field,
|
void Manager::RecordField(const zeek::detail::ID* id, const TypeDecl* field,
|
||||||
const string& path)
|
const string& path)
|
||||||
{
|
{
|
||||||
if ( disabled )
|
if ( disabled )
|
||||||
|
@ -360,8 +360,8 @@ void Manager::RecordField(const ID* id, const TypeDecl* field,
|
||||||
field->id, id->Name(), script.c_str());
|
field->id, id->Name(), script.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::Redef(const ID* id, const string& path,
|
void Manager::Redef(const zeek::detail::ID* id, const string& path,
|
||||||
init_class ic, IntrusivePtr<zeek::detail::Expr> init_expr)
|
zeek::detail::init_class ic, IntrusivePtr<zeek::detail::Expr> init_expr)
|
||||||
{
|
{
|
||||||
if ( disabled )
|
if ( disabled )
|
||||||
return;
|
return;
|
||||||
|
@ -397,8 +397,8 @@ void Manager::Redef(const ID* id, const string& path,
|
||||||
id->Name(), from_script.c_str());
|
id->Name(), from_script.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::Redef(const ID* id, const std::string& path,
|
void Manager::Redef(const zeek::detail::ID* id, const std::string& path,
|
||||||
init_class ic)
|
zeek::detail::init_class ic)
|
||||||
{
|
{
|
||||||
Redef(id, path, ic, nullptr);
|
Redef(id, path, ic, nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,14 +110,14 @@ public:
|
||||||
* Signal that a record or enum type is now being parsed.
|
* Signal that a record or enum type is now being parsed.
|
||||||
* @param id The record or enum type identifier.
|
* @param id The record or enum type identifier.
|
||||||
*/
|
*/
|
||||||
void StartType(IntrusivePtr<ID> id);
|
void StartType(IntrusivePtr<zeek::detail::ID> id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a script-level identifier for which information/documentation
|
* Register a script-level identifier for which information/documentation
|
||||||
* will be gathered.
|
* will be gathered.
|
||||||
* @param id The script-level identifier.
|
* @param id The script-level identifier.
|
||||||
*/
|
*/
|
||||||
void Identifier(IntrusivePtr<ID> id);
|
void Identifier(IntrusivePtr<zeek::detail::ID> id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a record-field for which information/documentation will be
|
* Register a record-field for which information/documentation will be
|
||||||
|
@ -128,7 +128,7 @@ public:
|
||||||
* declared. This can be different from the place where the record type
|
* declared. This can be different from the place where the record type
|
||||||
* is declared due to redefs.
|
* is declared due to redefs.
|
||||||
*/
|
*/
|
||||||
void RecordField(const ID* id, const TypeDecl* field,
|
void RecordField(const zeek::detail::ID* id, const TypeDecl* field,
|
||||||
const std::string& path);
|
const std::string& path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,10 +138,10 @@ public:
|
||||||
* @param ic The initialization class that was used (e.g. =, +=, -=).
|
* @param ic The initialization class that was used (e.g. =, +=, -=).
|
||||||
* @param init_expr The intiialization expression that was used.
|
* @param init_expr The intiialization expression that was used.
|
||||||
*/
|
*/
|
||||||
void Redef(const ID* id, const std::string& path,
|
void Redef(const zeek::detail::ID* id, const std::string& path,
|
||||||
init_class ic, IntrusivePtr<zeek::detail::Expr> init_expr);
|
zeek::detail::init_class ic, IntrusivePtr<zeek::detail::Expr> init_expr);
|
||||||
void Redef(const ID* id, const std::string& path,
|
void Redef(const zeek::detail::ID* id, const std::string& path,
|
||||||
init_class ic = INIT_NONE);
|
zeek::detail::init_class ic = zeek::detail::INIT_NONE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register Zeekygen script summary content.
|
* Register Zeekygen script summary content.
|
||||||
|
@ -217,7 +217,7 @@ private:
|
||||||
typedef std::vector<std::string> comment_buffer_t;
|
typedef std::vector<std::string> comment_buffer_t;
|
||||||
typedef std::map<std::string, comment_buffer_t> comment_buffer_map_t;
|
typedef std::map<std::string, comment_buffer_t> comment_buffer_map_t;
|
||||||
|
|
||||||
IdentifierInfo* CreateIdentifierInfo(IntrusivePtr<ID> id, ScriptInfo* script);
|
IdentifierInfo* CreateIdentifierInfo(IntrusivePtr<zeek::detail::ID> id, ScriptInfo* script);
|
||||||
|
|
||||||
bool disabled;
|
bool disabled;
|
||||||
comment_buffer_t comment_buffer; // For whatever next identifier comes in.
|
comment_buffer_t comment_buffer; // For whatever next identifier comes in.
|
||||||
|
|
|
@ -82,7 +82,7 @@ static string make_summary(const string& heading, char underline, char border,
|
||||||
for ( id_info_list::const_iterator it = id_list.begin();
|
for ( id_info_list::const_iterator it = id_list.begin();
|
||||||
it != id_list.end(); ++it )
|
it != id_list.end(); ++it )
|
||||||
{
|
{
|
||||||
ID* id = (*it)->GetID();
|
auto* id = (*it)->GetID();
|
||||||
ODesc d;
|
ODesc d;
|
||||||
d.SetQuotes(true);
|
d.SetQuotes(true);
|
||||||
id->DescribeReSTShort(&d);
|
id->DescribeReSTShort(&d);
|
||||||
|
@ -105,7 +105,7 @@ static string make_redef_summary(const string& heading, char underline,
|
||||||
for ( id_info_set::const_iterator it = id_set.begin(); it != id_set.end();
|
for ( id_info_set::const_iterator it = id_set.begin(); it != id_set.end();
|
||||||
++it )
|
++it )
|
||||||
{
|
{
|
||||||
ID* id = (*it)->GetID();
|
auto* id = (*it)->GetID();
|
||||||
ODesc d;
|
ODesc d;
|
||||||
d.SetQuotes(true);
|
d.SetQuotes(true);
|
||||||
id->DescribeReSTShort(&d);
|
id->DescribeReSTShort(&d);
|
||||||
|
@ -179,7 +179,7 @@ void ScriptInfo::DoInitPostScript()
|
||||||
it != id_info.end(); ++it )
|
it != id_info.end(); ++it )
|
||||||
{
|
{
|
||||||
IdentifierInfo* info = it->second;
|
IdentifierInfo* info = it->second;
|
||||||
ID* id = info->GetID();
|
auto* id = info->GetID();
|
||||||
|
|
||||||
if ( ! zeekygen::is_public_api(id) )
|
if ( ! zeekygen::is_public_api(id) )
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -78,10 +78,10 @@ bool zeekygen::prettify_params(string& s)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zeekygen::is_public_api(const ID* id)
|
bool zeekygen::is_public_api(const zeek::detail::ID* id)
|
||||||
{
|
{
|
||||||
return (id->Scope() == SCOPE_GLOBAL) ||
|
return (id->Scope() == zeek::detail::SCOPE_GLOBAL) ||
|
||||||
(id->Scope() == SCOPE_MODULE && id->IsExport());
|
(id->Scope() == zeek::detail::SCOPE_MODULE && id->IsExport());
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t zeekygen::get_mtime(const string& filename)
|
time_t zeekygen::get_mtime(const string& filename)
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
|
|
||||||
#include <time.h> // for time_t
|
#include <time.h> // for time_t
|
||||||
|
|
||||||
class ID;
|
namespace zeek::detail { class ID; }
|
||||||
|
using ID [[deprecated("Remove in v4.1. Use zeek::detail::ID instead")]] = zeek::detail::ID;
|
||||||
|
|
||||||
namespace zeekygen {
|
namespace zeekygen {
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ bool prettify_params(std::string& s);
|
||||||
* @return true if the ID is in the global scope or if it's exported in to
|
* @return true if the ID is in the global scope or if it's exported in to
|
||||||
* any modules namespace.
|
* any modules namespace.
|
||||||
*/
|
*/
|
||||||
bool is_public_api(const ID* id);
|
bool is_public_api(const zeek::detail::ID* id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the modification time of a file or abort if there's an error.
|
* Get the modification time of a file or abort if there's an error.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue