7#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_CONTINUATION_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_CONTINUATION_H_
12#include <initializer_list>
21#include "backends/p4tools/common/lib/namespace_context.h"
22#include "backends/p4tools/common/lib/trace_event.h"
25#include "lib/cstring.h"
27namespace P4::P4Tools::Test {
31namespace P4::P4Tools::P4Testgen {
60 static std::map<Exception, std::string> strings;
61 if (strings.empty()) {
62#define INSERT_ELEMENT(p) strings[p] = #p
71 return out << strings[value];
80 std::optional<const IR::Node *> expr;
85 Return() : expr(std::nullopt) {}
86 explicit Return(
const IR::Node *expr);
91 using PropertyValue = std::variant<cstring, uint64_t, int64_t, bool, const IR::Expression *>;
93 struct PropertyUpdate {
100 bool operator==(
const PropertyUpdate &other)
const;
111 const IR::Expression *cond;
116 explicit Guard(
const IR::Expression *cond);
119 using Command = std::variant<
136 friend class Continuation;
139 std::deque<Command> cmds;
147 const Command
next()
const;
150 void push(Command cmd);
159 bool operator==(
const Body &)
const;
162 Body(std::initializer_list<Command> cmds);
166 explicit Body(
const std::vector<Command> &cmds);
178 const IR::PathExpression *param;
181 explicit Parameter(
const IR::PathExpression *param) : param(param) {}
196 Body apply(std::optional<const IR::Node *> value_opt)
const;
210 body(
std::move(body)) {}
Represents a stack of namespaces.
Definition namespace_context.h:20
A continuation body is a list of commands.
Definition continuation.h:135
void clear()
Removes all commands in this body.
Definition continuation.cpp:54
void push(Command cmd)
Pushes the given command onto the command stack.
Definition continuation.cpp:47
Body(std::initializer_list< Command > cmds)
Allows the command stack to be initialized with a list initializer.
Definition continuation.cpp:60
const Command next() const
Definition continuation.cpp:39
bool empty() const
Determines whether this body is empty.
Definition continuation.cpp:37
void pop()
Definition continuation.cpp:49