add deprecation for Trigger Cache/Lookup interfaces

This commit is contained in:
Vern Paxson 2022-05-12 14:38:30 -07:00
parent 08fbc7efb3
commit 5c3cc4fba8
2 changed files with 14 additions and 2 deletions

View file

@ -4590,7 +4590,7 @@ ValPtr CallExpr::Eval(Frame* f) const
{ {
if ( trigger::Trigger* trigger = f->GetTrigger() ) if ( trigger::Trigger* trigger = f->GetTrigger() )
{ {
if ( Val* v = trigger->Lookup(this) ) if ( Val* v = trigger->Lookup((void*)this) )
{ {
DBG_LOG(DBG_NOTIFIERS, "%s: provides cached function result", trigger->Name()); DBG_LOG(DBG_NOTIFIERS, "%s: provides cached function result", trigger->Name());
return {NewRef{}, v}; return {NewRef{}, v};

View file

@ -25,6 +25,7 @@ namespace detail
class Frame; class Frame;
class Stmt; class Stmt;
class Expr; class Expr;
class CallExpr;
class ID; class ID;
class WhenInfo; class WhenInfo;
@ -86,7 +87,18 @@ public:
// void*'s so that the value can be associated with either a CallExpr // void*'s so that the value can be associated with either a CallExpr
// (for interpreted execution) or a C++ function (for compiled-to-C++). // (for interpreted execution) or a C++ function (for compiled-to-C++).
bool Cache(const void* obj, Val* val); bool Cache(const void* obj, Val* val);
Val* Lookup(const void*); Val* Lookup(const void* obj);
[[deprecated("Remove in v5.1. Use const void* interface instead.")]] bool
Cache(const CallExpr* call, Val* val)
{
return Cache((const void*)call, val);
}
[[deprecated("Remove in v5.1. Use const void* interface instead.")]] Val*
Lookup(const CallExpr* call)
{
return Lookup((const void*)call);
}
// Disable this trigger completely. Needed because Unref'ing the trigger // Disable this trigger completely. Needed because Unref'ing the trigger
// may not immediately delete it as other references may still exist. // may not immediately delete it as other references may still exist.