P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::P4Tools::P4Testgen::ExprStepper::ExternMethodImpls< StepperType > Class Template Reference

Encapsulates a set of extern method implementations. More...

#include <expr_stepper.h>

Public Types

using ImplList = std::list<std::tuple<cstring, std::vector<cstring>, MethodImpl>>
 
using MethodImpl = std::function<void(const ExternInfo &externInfo, StepperType &stepper)>
 

Public Member Functions

 ExternMethodImpls (const ImplList &implList)
 
std::optional< MethodImplfind (const IR::PathExpression &externObjectRef, const IR::ID &methodName, const IR::Vector< IR::Argument > &args) const
 

Detailed Description

template<typename StepperType>
class P4::P4Tools::P4Testgen::ExprStepper::ExternMethodImpls< StepperType >

Encapsulates a set of extern method implementations.

Member Typedef Documentation

◆ ImplList

template<typename StepperType >
using P4::P4Tools::P4Testgen::ExprStepper::ExternMethodImpls< StepperType >::ImplList = std::list<std::tuple<cstring, std::vector<cstring>, MethodImpl>>

Represents a list of extern method implementations. The components of each element in this list are as follows:

  1. The method name qualified by the extern type name (e.g., "packet_in.advance").
  2. The names of the method parameters.
  3. The method's implementation.

◆ MethodImpl

template<typename StepperType >
using P4::P4Tools::P4Testgen::ExprStepper::ExternMethodImpls< StepperType >::MethodImpl = std::function<void(const ExternInfo &externInfo, StepperType &stepper)>

The type of an extern-method implementation.

Parameters
externInfois general useful information that can be consumsed by externs (arguments, method names, etc).
stepperis the abstract stepper invoking the function. Templated on the type of stepper invoking it.

Member Function Documentation

◆ find()

template<typename StepperType >
std::optional< MethodImpl > P4::P4Tools::P4Testgen::ExprStepper::ExternMethodImpls< StepperType >::find ( const IR::PathExpression & externObjectRef,
const IR::ID & methodName,
const IR::Vector< IR::Argument > & args ) const
inline
Parameters
callthe original method call expression, can be used for stepInto calls.
receivera symbolic value representing the object on which the method is being called.
namethe name of the method being called.
argsthe list of arguments being passed to method.
statethe state in which the call is being made, with the call at the top of the current continuation body.
Returns
the matching extern-method implementation if it was found; std::nullopt otherwise.

A BUG occurs if the receiver is not an extern or if the call is ambiguous.