![]() |
P4C
The P4 Compiler
|
#include <continuation.h>
Classes | |
| class | Body |
| A continuation body is a list of commands. More... | |
| struct | Guard |
| class | Parameter |
| struct | PropertyUpdate |
| struct | Return |
Public Types | |
| using | Command |
| enum class | Exception { Exit , NoMatch , Reject , Drop , PacketTooShort , Abort } |
| Enumerates the exceptions that can be thrown during symbolic execution. More... | |
| using | PropertyValue = std::variant<cstring, uint64_t, int64_t, bool, const IR::Expression *> |
Public Member Functions | |
| Continuation (Body body) | |
| Creates a parameterless continuation. | |
| Continuation (std::optional< const Parameter * > parameterOpt, Body body) | |
| Body | apply (std::optional< const IR::Node * > value_opt) const |
Static Public Member Functions | |
| static const Parameter * | genParameter (const IR::Type *type, cstring name, const NamespaceContext *ctx) |
Public Attributes | |
| Body | body |
| std::optional< const IR::PathExpression * > | parameterOpt |
| Represents the continuation's parameter. | |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const Exception value) |
A continuation is a function that optionally takes an argument and executes a sequence of commands.
| using P4Tools::P4Testgen::Continuation::Command |
| using P4Tools::P4Testgen::Continuation::PropertyValue = std::variant<cstring, uint64_t, int64_t, bool, const IR::Expression *> |
Alias for various property types that can be set. We restrict these to keep the feature simple.
|
strong |
Enumerates the exceptions that can be thrown during symbolic execution.
| Enumerator | |
|---|---|
| Exit | Thrown when an exit statement is encountered. |
| NoMatch | Thrown when a select expression fails to match. This models P4's error.NoMatch. |
| Reject | Thrown when the parser reaches the reject state. |
| Drop | This is an internal interpreter exception to express drop semantics. |
| PacketTooShort | Thrown on premature packet end. Models P4's error.PacketTooShort. |
| Abort | Thrown when the target terminates. |
|
inline |
Creates a continuation. The continuation will have the given parameter, if one is provided; otherwise, the continuation will have no parameters.
| Continuation::Body P4Tools::P4Testgen::Continuation::apply | ( | std::optional< const IR::Node * > | value_opt | ) | const |
Expressions in the metalanguage include P4 non-expressions. Because of this, the value (if provided) does not necessarily need to be an instance of IR::Expression.
Creates a visitor for Commands that substitutes the given value for the given parameter.
|
static |
|
friend |
A helper function to print the string values of the exception enum. Unfortunately, this is a little clunky to use an maintain because we have to add new enum fields manually. TODO: Find a better implementation to print enums. Also use constexpr instead.