![]() |
P4C
The P4 Compiler
|
Represents state of execution after having reached a program point. More...
#include <abstract_execution_state.h>
Public Member Functions | |
| AbstractExecutionState (AbstractExecutionState &&)=default | |
| AbstractExecutionState (const IR::P4Program *program) | |
| Creates an initial execution state for the given program. | |
| void | assignStructLike (const IR::StateVariable &left, const IR::Expression *right) |
| virtual AbstractExecutionState & | clone () const =0 |
| void | copyIn (const Target &target, const IR::Parameter *internalParam, cstring externalParamName) |
| void | copyOut (const IR::Parameter *internalParam, cstring externalParamName) |
| void | declareVariable (const Target &target, const IR::Declaration_Variable &declVar) |
| bool | exists (const IR::StateVariable &var) const |
| Checks whether the given variable exists in the symbolic environment of this state. | |
| const IR::IDeclaration * | findDecl (const IR::Path *path) const |
| Looks up a declaration from a path. A BUG occurs if no declaration is found. | |
| const IR::IDeclaration * | findDecl (const IR::PathExpression *pathExpr) const |
| Looks up a declaration from a path expression. A BUG occurs if no declaration is found. | |
| const IR::P4Table * | findTable (const IR::Member *member) const |
| virtual const IR::Expression * | get (const IR::StateVariable &var) const =0 |
| std::vector< IR::StateVariable > | getFlatFields (const IR::StateVariable &parent, std::vector< IR::StateVariable > *validVector=nullptr) const |
| const NamespaceContext * | getNamespaceContext () const |
| const IR::P4Action * | getP4Action (const IR::MethodCallExpression *actionExpr) const |
| const SymbolicEnv & | getSymbolicEnv () const |
| void | initializeBlockParams (const Target &target, const IR::Type_Declaration *typeDecl, const std::vector< cstring > *blockParams) |
| void | initializeStructLike (const Target &target, const IR::StateVariable &targetVar, bool forceTaint) |
| AbstractExecutionState & | operator= (AbstractExecutionState &&)=delete |
| void | popNamespace () |
| Exists a namespace of declarations. | |
| void | printSymbolicEnv (std::ostream &out=std::cout) const |
| Produce a formatted output of the current symbolic environment. | |
| void | pushNamespace (const IR::INamespace *ns) |
| Enters a namespace of declarations. | |
| const IR::Type * | resolveType (const IR::Type *type) const |
| Resolves a Type in the current environment. | |
| virtual void | set (const IR::StateVariable &var, const IR::Expression *value)=0 |
| void | setNamespaceContext (const NamespaceContext *namespaces) |
| Replaces the namespace context in the current state with the given context. | |
| void | setStructLike (const IR::StateVariable &targetVar, const IR::StateVariable &sourceVar) |
| Set the members of struct-like @target with the values of struct-like @source. | |
Protected Member Functions | |
| AbstractExecutionState () | |
| Used for debugging and testing. | |
| AbstractExecutionState (const AbstractExecutionState &)=default | |
| Execution state needs to be explicitly copied using the clone call.. | |
| const IR::Expression * | convertToComplexExpression (const IR::StateVariable &parent) const |
| AbstractExecutionState & | operator= (const AbstractExecutionState &)=default |
| Do not accidentally copy-assign the execution state. | |
Static Protected Member Functions | |
| static std::vector< const IR::Expression * > | flattenComplexExpression (const IR::Expression *inputExpression, std::vector< const IR::Expression * > &flatValids) |
Protected Attributes | |
| SymbolicEnv | env |
| The symbolic environment. Maps program variables to their symbolic values. | |
| const NamespaceContext * | namespaces |
Represents state of execution after having reached a program point.
| void P4Tools::AbstractExecutionState::assignStructLike | ( | const IR::StateVariable & | left, |
| const IR::Expression * | right ) |
Assign a struct-like expression to
| left. | Unrolls |
| right | into a series of individual assignments. |
|
nodiscardpure virtual |
Allocate a new execution state object with the same state as this object. Returns a reference, not a pointer.
Implemented in P4Tools::P4Testgen::ExecutionState.
|
protected |
Convert the input reference into a complex expression such as a HeaderExpression, StructExpression, or HeaderStackExpression.
| void P4Tools::AbstractExecutionState::copyIn | ( | const Target & | target, |
| const IR::Parameter * | internalParam, | ||
| cstring | externalParamName ) |
Copy the values referenced by
externalParamName into the values references by
internalParam. Any parameter with the direction "out" is de-initialized.
| void P4Tools::AbstractExecutionState::copyOut | ( | const IR::Parameter * | internalParam, |
| cstring | externalParamName ) |
Copy the values referenced by
internalParam into the values references by
externalParamName. Only parameters with the direction out or inout are copied.
| void P4Tools::AbstractExecutionState::declareVariable | ( | const Target & | target, |
| const IR::Declaration_Variable & | declVar ) |
Initialize a Declaration_Variable to its default value. Does not expect an initializer.
| const IR::P4Table * P4Tools::AbstractExecutionState::findTable | ( | const IR::Member * | member | ) | const |
Looks up the
| member | in the environment of |
| state. | Returns nullptr if the member is not a table type. |
|
staticprotected |
Takes in a complex expression as a StructExpression, ListExpression, or HeaderStackExpression, flattens it into a vector and
|
nodiscardpure virtual |
Implemented in P4Tools::P4Testgen::ExecutionState.
|
nodiscard |
Takes an input struct type @ts and a prefix @parent and returns a vector of references to members of the struct. The vector contains all the Type_Base (bit and bool) members in canonical representation (e.g., {"prefix.h.ethernet.dst_address", "prefix.h.ethernet.src_address", ...}). If
|
nodiscard |
|
nodiscard |
This is done by looking up the reference in the execution state. Throws a BUG, if the action does not exist.
|
nodiscard |
| void P4Tools::AbstractExecutionState::initializeBlockParams | ( | const Target & | target, |
| const IR::Type_Declaration * | typeDecl, | ||
| const std::vector< cstring > * | blockParams ) |
Initialize a set of parameters contained in
blockParams to their default values. The default values are specified by the target.
| void P4Tools::AbstractExecutionState::initializeStructLike | ( | const Target & | target, |
| const IR::StateVariable & | targetVar, | ||
| bool | forceTaint ) |
Initialize all the members of a struct-like object by calling the initialization function of the active target. Headers validity is set to "false".
|
pure virtual |
Sets the symbolic value of the given state variable to the given value. Constant folding is done on the given value before updating the symbolic state.
Implemented in P4Tools::P4Testgen::ExecutionState.
|
protected |
The namespace context in the IR for the current state. The innermost element is the P4 program, representing the top-level namespace.