mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
broader support for AST traversal, including Attr and Attributes objects
This commit is contained in:
parent
9a2200e60a
commit
a0fc8ca5e4
10 changed files with 280 additions and 23 deletions
|
@ -9,6 +9,7 @@ namespace zeek
|
|||
{
|
||||
|
||||
class Func;
|
||||
class Type;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
@ -16,6 +17,8 @@ namespace detail
|
|||
class Stmt;
|
||||
class Expr;
|
||||
class ID;
|
||||
class Attributes;
|
||||
class Attr;
|
||||
|
||||
class TraversalCallback
|
||||
{
|
||||
|
@ -41,6 +44,20 @@ public:
|
|||
virtual TraversalCode PreDecl(const ID*) { return TC_CONTINUE; }
|
||||
virtual TraversalCode PostDecl(const ID*) { return TC_CONTINUE; }
|
||||
|
||||
// A caution regarding using the next two: when traversing types,
|
||||
// there's a possibility of encountering a (directly or indirectly)
|
||||
// recursive record. So you'll need some way of avoiding that,
|
||||
// such as remembering which types have already been traversed
|
||||
// and skipping via TC_ABORTSTMT when seen again.
|
||||
virtual TraversalCode PreType(const Type*) { return TC_CONTINUE; }
|
||||
virtual TraversalCode PostType(const Type*) { return TC_CONTINUE; }
|
||||
|
||||
virtual TraversalCode PreAttrs(const Attributes*) { return TC_CONTINUE; }
|
||||
virtual TraversalCode PostAttrs(const Attributes*) { return TC_CONTINUE; }
|
||||
|
||||
virtual TraversalCode PreAttr(const Attr*) { return TC_CONTINUE; }
|
||||
virtual TraversalCode PostAttr(const Attr*) { return TC_CONTINUE; }
|
||||
|
||||
ScopePtr current_scope;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue