P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4Tools::P4Testgen::ExternMethodImpls Class Reference

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

Public Types

using ImplList = std::list<std::tuple<cstring, std::vector<cstring>, MethodImpl>>
 
using MethodImpl
 

Public Member Functions

 ExternMethodImpls (const ImplList &implList)
 
bool exec (const IR::MethodCallExpression *call, const IR::Expression *receiver, IR::ID &name, const IR::Vector< IR::Argument > *args, const ExecutionState &state, SmallStepEvaluator::Result &result) const
 

Detailed Description

Encapsulates a set of extern method implementations.

Member Typedef Documentation

◆ ImplList

using P4Tools::P4Testgen::ExternMethodImpls::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

Initial value:
std::function<void(const IR::MethodCallExpression *, const IR::Expression *,
IR::ID &, const IR::Vector<IR::Argument> *,
const ExecutionState &, SmallStepEvaluator::Result &)>
Definition externInstance.h:33

The type of an extern-method implementation. See exec for an explanation of the arguments.

Member Function Documentation

◆ exec()

bool P4Tools::P4Testgen::ExternMethodImpls::exec ( const IR::MethodCallExpression * call,
const IR::Expression * receiver,
IR::ID & name,
const IR::Vector< IR::Argument > * args,
const ExecutionState & state,
SmallStepEvaluator::Result & result ) const

Evaluates a call to an extern method. Upon return, the given result will be augmented with the successor states resulting from evaluating the call.

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
true if a matching extern-method implementation was found; false otherwise.

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