Change BroFunc ctor to take const-ref IntrusivePtr<ID>

This commit is contained in:
Jon Siwek 2020-05-27 17:40:02 -07:00
parent 0d19e8fb4c
commit 1f45e690a0
6 changed files with 17 additions and 17 deletions

View file

@ -4179,7 +4179,7 @@ LambdaExpr::LambdaExpr(std::unique_ptr<function_ingredients> arg_ing,
// Install a dummy version of the function globally for use only
// when broker provides a closure.
auto dummy_func = make_intrusive<BroFunc>(
ingredients->id.get(),
ingredients->id,
ingredients->body,
ingredients->inits,
ingredients->frame_size,
@ -4230,7 +4230,7 @@ Scope* LambdaExpr::GetScope() const
IntrusivePtr<Val> LambdaExpr::Eval(Frame* f) const
{
auto lamb = make_intrusive<BroFunc>(
ingredients->id.get(),
ingredients->id,
ingredients->body,
ingredients->inits,
ingredients->frame_size,

View file

@ -268,7 +268,7 @@ void Func::CheckPluginResult(bool handled, const IntrusivePtr<Val>& hook_result,
}
}
BroFunc::BroFunc(ID* arg_id, IntrusivePtr<Stmt> arg_body,
BroFunc::BroFunc(const IntrusivePtr<ID>& arg_id, IntrusivePtr<Stmt> arg_body,
const std::vector<IntrusivePtr<ID>>& aggr_inits,
size_t arg_frame_size, int priority)
: Func(BRO_FUNC)

View file

@ -129,7 +129,7 @@ protected:
class BroFunc final : public Func {
public:
BroFunc(ID* id, IntrusivePtr<Stmt> body,
BroFunc(const IntrusivePtr<ID>& id, IntrusivePtr<Stmt> body,
const std::vector<IntrusivePtr<ID>>& inits,
size_t frame_size, int priority);

View file

@ -30,7 +30,7 @@ static IntrusivePtr<Val> init_val(Expr* init, const BroType* t,
}
}
static bool add_prototype(ID* id, BroType* t,
static bool add_prototype(const IntrusivePtr<ID>& id, BroType* t,
std::vector<IntrusivePtr<Attr>>* attrs,
const IntrusivePtr<Expr>& init)
{
@ -39,7 +39,7 @@ static bool add_prototype(ID* id, BroType* t,
if ( ! IsFunc(t->Tag()) )
{
t->Error("type incompatible with previous definition", id);
t->Error("type incompatible with previous definition", id.get());
return false;
}
@ -108,7 +108,7 @@ static bool add_prototype(ID* id, BroType* t,
return true;
}
static void make_var(ID* id, IntrusivePtr<BroType> t, init_class c,
static void make_var(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t, init_class c,
IntrusivePtr<Expr> init,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
decl_type dt,
@ -308,8 +308,8 @@ static void make_var(ID* id, IntrusivePtr<BroType> t, init_class c,
}
void add_global(ID* id, IntrusivePtr<BroType> t, init_class c,
IntrusivePtr<Expr> init,
void add_global(const IntrusivePtr<ID>& id, IntrusivePtr<BroType> t,
init_class c, IntrusivePtr<Expr> init,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
decl_type dt)
{
@ -321,7 +321,7 @@ IntrusivePtr<Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<BroType> t,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>> attr,
decl_type dt)
{
make_var(id.get(), std::move(t), c, init, std::move(attr), dt, false);
make_var(id, std::move(t), c, init, std::move(attr), dt, false);
if ( init )
{
@ -352,7 +352,7 @@ extern IntrusivePtr<Expr> add_and_assign_local(IntrusivePtr<ID> id,
IntrusivePtr<Expr> init,
IntrusivePtr<Val> val)
{
make_var(id.get(), nullptr, INIT_FULL, init, nullptr, VAR_REGULAR, false);
make_var(id, nullptr, INIT_FULL, init, nullptr, VAR_REGULAR, false);
auto name_expr = make_intrusive<NameExpr>(std::move(id));
return make_intrusive<AssignExpr>(std::move(name_expr), std::move(init),
false, std::move(val));
@ -646,7 +646,7 @@ void end_func(IntrusivePtr<Stmt> body)
else
{
auto f = make_intrusive<BroFunc>(
ingredients->id.get(),
ingredients->id,
ingredients->body,
ingredients->inits,
ingredients->frame_size,

View file

@ -17,7 +17,7 @@ class ListVal;
typedef enum { VAR_REGULAR, VAR_CONST, VAR_REDEF, VAR_OPTION, } decl_type;
extern void add_global(ID* id,
extern void add_global(const IntrusivePtr<ID>& id,
IntrusivePtr<BroType> t,
init_class c,
IntrusivePtr<Expr> init,

View file

@ -1082,7 +1082,7 @@ decl:
| TOK_GLOBAL def_global_id opt_type init_class opt_init opt_attr ';'
{
IntrusivePtr id{AdoptRef{}, $2};
add_global(id.get(), {AdoptRef{}, $3}, $4, {AdoptRef{}, $5},
add_global(id, {AdoptRef{}, $3}, $4, {AdoptRef{}, $5},
std::unique_ptr<std::vector<IntrusivePtr<Attr>>>{$6},
VAR_REGULAR);
zeekygen_mgr->Identifier(std::move(id));
@ -1091,7 +1091,7 @@ decl:
| TOK_OPTION def_global_id opt_type init_class opt_init opt_attr ';'
{
IntrusivePtr id{AdoptRef{}, $2};
add_global(id.get(), {AdoptRef{}, $3}, $4, {AdoptRef{}, $5},
add_global(id, {AdoptRef{}, $3}, $4, {AdoptRef{}, $5},
std::unique_ptr<std::vector<IntrusivePtr<Attr>>>{$6},
VAR_OPTION);
zeekygen_mgr->Identifier(std::move(id));
@ -1100,7 +1100,7 @@ decl:
| TOK_CONST def_global_id opt_type init_class opt_init opt_attr ';'
{
IntrusivePtr id{AdoptRef{}, $2};
add_global(id.get(), {AdoptRef{}, $3}, $4, {AdoptRef{}, $5},
add_global(id, {AdoptRef{}, $3}, $4, {AdoptRef{}, $5},
std::unique_ptr<std::vector<IntrusivePtr<Attr>>>{$6},
VAR_CONST);
zeekygen_mgr->Identifier(std::move(id));
@ -1110,7 +1110,7 @@ decl:
{
IntrusivePtr id{AdoptRef{}, $2};
IntrusivePtr<Expr> init{AdoptRef{}, $5};
add_global(id.get(), {AdoptRef{}, $3}, $4, init,
add_global(id, {AdoptRef{}, $3}, $4, init,
std::unique_ptr<std::vector<IntrusivePtr<Attr>>>{$6},
VAR_REDEF);
zeekygen_mgr->Redef(id.get(), ::filename, $4, std::move(init));