Add WalkAST() function for generic AST walking.

For starters, use it for the check to see if code is safe to run with the
mask all off.

This also fixes a bug where we would sometimes incorrectly say that
a whole block of code was unsafe to run with an all off mask because we came
to a NULL AST node during traversal.
This commit is contained in:
Matt Pharr
2011-12-15 16:52:47 -08:00
parent 6f6e28077f
commit f9463af75b
3 changed files with 234 additions and 3 deletions

11
ast.h
View File

@@ -91,4 +91,15 @@ private:
std::vector<Function *> functions;
};
typedef void (* ASTCallBackFunc)(ASTNode *node, void *data);
/** Walk (some portion of) an AST, starting from the given root node. At
each node, if preFunc is non-NULL, call it preFunc, passing the given
void *data pointer. Makes recursive calls to WalkAST() to process the
node's children; after doing so, postFunc, if non-NULL is called at the
node. */
extern void WalkAST(ASTNode *root, ASTCallBackFunc preFunc,
ASTCallBackFunc postFunc, void *data);
#endif // ISPC_AST_H