Move ID to the zeek::detail namespace

This commit is contained in:
Tim Wojtulewicz 2020-05-18 18:16:25 -07:00
parent 9992ec5c11
commit 0d623d003c
30 changed files with 221 additions and 182 deletions

View file

@ -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,
const IntrusivePtr<zeek::detail::Expr>& init)
{
@ -108,7 +108,8 @@ static bool add_prototype(const IntrusivePtr<ID>& id, BroType* t,
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,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
decl_type dt,
@ -227,14 +228,14 @@ static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_c
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 )
// e.g. 'redef foo["x"] = 1' is missing an init class, but the
// 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)) ||
(c == INIT_REMOVE && id->GetAttr(ATTR_DEL_FUNC)) ))
if ( init && ((c == zeek::detail::INIT_EXTRA && id->GetAttr(ATTR_ADD_FUNC)) ||
(c == zeek::detail::INIT_REMOVE && id->GetAttr(ATTR_DEL_FUNC)) ))
// Just apply the function.
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
// we can later access the ID even if no implementations have been
// defined.
std::vector<IntrusivePtr<ID>> inits;
std::vector<IntrusivePtr<zeek::detail::ID>> inits;
auto f = make_intrusive<BroFunc>(id, nullptr, inits, 0, 0);
id->SetVal(make_intrusive<Val>(std::move(f)));
}
}
void add_global(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t,
init_class c, IntrusivePtr<zeek::detail::Expr> init,
void add_global(const IntrusivePtr<zeek::detail::ID>& id, IntrusivePtr<BroType> t,
zeek::detail::init_class c, IntrusivePtr<zeek::detail::Expr> init,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
decl_type dt)
{
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,
init_class c, IntrusivePtr<zeek::detail::Expr> init,
IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<zeek::detail::ID> id, IntrusivePtr<BroType> t,
zeek::detail::init_class c, IntrusivePtr<zeek::detail::Expr> init,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
decl_type dt)
{
@ -324,7 +325,7 @@ IntrusivePtr<zeek::detail::Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<Bro
if ( init )
{
if ( c != INIT_FULL )
if ( c != zeek::detail::INIT_FULL )
id->Error("can't use += / -= for initializations of local variables");
// 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<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));
return make_intrusive<zeek::detail::AssignExpr>(std::move(name_expr), std::move(init),
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::string new_type_name = id->Name();
@ -458,7 +459,7 @@ static bool canonical_arg_types_match(const FuncType* decl, const FuncType* impl
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,
IntrusivePtr<FuncType> t,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attrs)