mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
AST profiles track the associated function/body/expression
This commit is contained in:
parent
8e1d770966
commit
f865897cac
2 changed files with 23 additions and 6 deletions
|
@ -60,12 +60,23 @@ p_hash_type script_specific_hash(const StmtPtr& body, p_hash_type generic_hash)
|
|||
|
||||
ProfileFunc::ProfileFunc(const Func* func, const StmtPtr& body, bool _abs_rec_fields)
|
||||
{
|
||||
profiled_func = func;
|
||||
profiled_body = body.get();
|
||||
abs_rec_fields = _abs_rec_fields;
|
||||
Profile(func->GetType().get(), body);
|
||||
}
|
||||
|
||||
ProfileFunc::ProfileFunc(const Stmt* s, bool _abs_rec_fields)
|
||||
{
|
||||
profiled_body = s;
|
||||
abs_rec_fields = _abs_rec_fields;
|
||||
s->Traverse(this);
|
||||
}
|
||||
|
||||
ProfileFunc::ProfileFunc(const Expr* e, bool _abs_rec_fields)
|
||||
{
|
||||
profiled_expr = e;
|
||||
|
||||
abs_rec_fields = _abs_rec_fields;
|
||||
|
||||
if ( e->Tag() == EXPR_LAMBDA )
|
||||
|
@ -84,12 +95,6 @@ ProfileFunc::ProfileFunc(const Expr* e, bool _abs_rec_fields)
|
|||
e->Traverse(this);
|
||||
}
|
||||
|
||||
ProfileFunc::ProfileFunc(const Stmt* s, bool _abs_rec_fields)
|
||||
{
|
||||
abs_rec_fields = _abs_rec_fields;
|
||||
s->Traverse(this);
|
||||
}
|
||||
|
||||
void ProfileFunc::Profile(const FuncType* ft, const StmtPtr& body)
|
||||
{
|
||||
num_params = ft->Params()->NumFields();
|
||||
|
|
|
@ -100,6 +100,12 @@ public:
|
|||
ProfileFunc(const Stmt* body, bool abs_rec_fields = false);
|
||||
ProfileFunc(const Expr* func, bool abs_rec_fields = false);
|
||||
|
||||
// Returns the function, body, or expression profiled. Each can be
|
||||
// null depending on the constructor used.
|
||||
const Func* ProfiledFunc() const { return profiled_func; }
|
||||
const Stmt* ProfiledBody() const { return profiled_body; }
|
||||
const Expr* ProfiledExpr() const { return profiled_expr; }
|
||||
|
||||
// See the comments for the associated member variables for each
|
||||
// of these accessors.
|
||||
const std::unordered_set<const ID*>& Globals() const { return globals; }
|
||||
|
@ -157,6 +163,12 @@ protected:
|
|||
// Take note of an assignment to an identifier.
|
||||
void TrackAssignment(const ID* id);
|
||||
|
||||
// The function, body, or expression profiled. Can be null
|
||||
// depending on which constructor was used.
|
||||
const Func* profiled_func = nullptr;
|
||||
const Stmt* profiled_body = nullptr;
|
||||
const Expr* profiled_expr = nullptr;
|
||||
|
||||
// Globals seen in the function.
|
||||
//
|
||||
// Does *not* include globals solely seen as the function being
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue