mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
ID: Add AddAttr() helper
This is just a follow-up as code cleanup, but not required to be backported to 5.1.
This commit is contained in:
parent
ef920ef3f5
commit
da5fdb2072
5 changed files with 13 additions and 17 deletions
|
@ -883,9 +883,7 @@ function_ingredients::function_ingredients(ScopePtr scope, StmtPtr body,
|
|||
if ( a->Tag() == ATTR_IS_USED )
|
||||
{
|
||||
// Associate this with the identifier, too.
|
||||
std::vector<AttrPtr> used_attr;
|
||||
used_attr.emplace_back(make_intrusive<Attr>(ATTR_IS_USED));
|
||||
id->AddAttrs(make_intrusive<Attributes>(used_attr, nullptr, false, true));
|
||||
id->AddAttr(make_intrusive<Attr>(ATTR_IS_USED));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
15
src/ID.cc
15
src/ID.cc
|
@ -311,8 +311,7 @@ void ID::MakeDeprecated(ExprPtr deprecation)
|
|||
if ( IsDeprecated() )
|
||||
return;
|
||||
|
||||
std::vector<AttrPtr> attrv{make_intrusive<Attr>(ATTR_DEPRECATED, std::move(deprecation))};
|
||||
AddAttrs(make_intrusive<Attributes>(std::move(attrv), GetType(), false, IsGlobal()));
|
||||
AddAttr(make_intrusive<Attr>(ATTR_DEPRECATED, std::move(deprecation)));
|
||||
}
|
||||
|
||||
std::string ID::GetDeprecationWarning() const
|
||||
|
@ -329,6 +328,13 @@ std::string ID::GetDeprecationWarning() const
|
|||
return util::fmt("deprecated (%s): %s", Name(), result.c_str());
|
||||
}
|
||||
|
||||
void ID::AddAttr(AttrPtr a, bool is_redef)
|
||||
{
|
||||
std::vector<AttrPtr> attrv{std::move(a)};
|
||||
auto attrs = make_intrusive<Attributes>(std::move(attrv), GetType(), false, IsGlobal());
|
||||
AddAttrs(std::move(attrs), is_redef);
|
||||
}
|
||||
|
||||
void ID::AddAttrs(AttributesPtr a, bool is_redef)
|
||||
{
|
||||
if ( attrs )
|
||||
|
@ -354,10 +360,7 @@ void ID::SetOption()
|
|||
|
||||
// option implied redefinable
|
||||
if ( ! IsRedefinable() )
|
||||
{
|
||||
std::vector<AttrPtr> attrv{make_intrusive<Attr>(ATTR_REDEF)};
|
||||
AddAttrs(make_intrusive<Attributes>(std::move(attrv), GetType(), false, IsGlobal()));
|
||||
}
|
||||
AddAttr(make_intrusive<Attr>(ATTR_REDEF));
|
||||
}
|
||||
|
||||
void ID::EvalFunc(ExprPtr ef, ExprPtr ev)
|
||||
|
|
1
src/ID.h
1
src/ID.h
|
@ -116,6 +116,7 @@ public:
|
|||
bool IsRedefinable() const;
|
||||
|
||||
void SetAttrs(AttributesPtr attr);
|
||||
void AddAttr(AttrPtr a, bool is_redef = false);
|
||||
void AddAttrs(AttributesPtr attr, bool is_redef = false);
|
||||
void RemoveAttr(AttrTag a);
|
||||
void UpdateValAttrs();
|
||||
|
|
|
@ -181,9 +181,7 @@ RuleConditionEval::RuleConditionEval(const char* func)
|
|||
"and a 'string' type",
|
||||
func);
|
||||
|
||||
std::vector<AttrPtr> attrv{make_intrusive<Attr>(ATTR_IS_USED, nullptr)};
|
||||
id->AddAttrs(
|
||||
make_intrusive<Attributes>(std::move(attrv), id->GetType(), false, id->IsGlobal()));
|
||||
id->AddAttr(make_intrusive<Attr>(ATTR_IS_USED));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,11 +109,7 @@ void activate_bodies__CPP(const char* fn, const char* module, bool exported, Typ
|
|||
}
|
||||
|
||||
if ( ! fg->GetAttr(ATTR_IS_USED) )
|
||||
{
|
||||
vector<AttrPtr> used_attr;
|
||||
used_attr.emplace_back(make_intrusive<Attr>(ATTR_IS_USED));
|
||||
fg->AddAttrs(make_intrusive<Attributes>(used_attr, nullptr, false, true));
|
||||
}
|
||||
fg->AddAttr(make_intrusive<Attr>(ATTR_IS_USED));
|
||||
|
||||
auto v = fg->GetVal();
|
||||
if ( ! v )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue