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); 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) void ProfileFunc::Profile(const FuncType* ft, const StmtPtr& body)
{ {
num_params = ft->Params()->NumFields(); num_params = ft->Params()->NumFields();

View file

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