broader support for AST traversal, including Attr and Attributes objects

This commit is contained in:
Vern Paxson 2022-05-04 17:07:18 -07:00 committed by Tim Wojtulewicz
parent 9a2200e60a
commit a0fc8ca5e4
10 changed files with 280 additions and 23 deletions

View file

@ -166,6 +166,21 @@ void Attr::AddTag(ODesc* d) const
d->Add(attr_name(Tag()));
}
detail::TraversalCode Attr::Traverse(detail::TraversalCallback* cb) const
{
auto tc = cb->PreAttr(this);
HANDLE_TC_ATTR_PRE(tc);
if ( expr )
{
auto tc = expr->Traverse(cb);
HANDLE_TC_ATTR_PRE(tc);
}
tc = cb->PostAttr(this);
HANDLE_TC_ATTR_POST(tc);
}
Attributes::Attributes(TypePtr t, bool arg_in_record, bool is_global)
: Attributes(std::vector<AttrPtr>{}, std::move(t), arg_in_record, is_global)
{
@ -756,4 +771,19 @@ bool check_default_attr(Attr* a, const TypePtr& type, bool global_var, bool in_r
return false;
}
detail::TraversalCode Attributes::Traverse(detail::TraversalCallback* cb) const
{
auto tc = cb->PreAttrs(this);
HANDLE_TC_ATTRS_PRE(tc);
for ( const auto& a : attrs )
{
tc = a->Traverse(cb);
HANDLE_TC_ATTRS_PRE(tc);
}
tc = cb->PostAttrs(this);
HANDLE_TC_ATTRS_POST(tc);
}
}