support for profiling function bodies w/o needing accompanying ScriptFunc object

This commit is contained in:
Vern Paxson 2021-05-30 17:44:24 -07:00
parent 6a0bee1108
commit 9900a3468c
2 changed files with 12 additions and 5 deletions

View file

@ -85,6 +85,12 @@ 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();

View file

@ -86,11 +86,12 @@ public:
// function and one of its bodies.
ProfileFunc(const Func* func, const StmtPtr& body, bool abs_rec_fields);
// Constructor for profiling an AST expression. This exists
// to support (1) profiling lambda expressions, and (2) traversing
// attribute expressions (such as &default=expr) to discover what
// components they include.
ProfileFunc(const Expr* func, bool abs_rec_fields);
// Constructors for profiling an AST statement expression. These exist
// to support (1) profiling lambda expressions and loop bodies, and
// (2) traversing attribute expressions (such as &default=expr)
// to discover what components they include.
ProfileFunc(const Stmt* body, bool abs_rec_fields = false);
ProfileFunc(const Expr* func, bool abs_rec_fields = false);
// See the comments for the associated member variables for each
// of these accessors.