1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_CONTINUATION_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_CONTINUATION_H_
6#include <initializer_list>
15#include "backends/p4tools/common/lib/namespace_context.h"
16#include "backends/p4tools/common/lib/trace_event.h"
19#include "lib/cstring.h"
21namespace P4::P4Tools::Test {
25namespace P4::P4Tools::P4Testgen {
54 static std::map<Exception, std::string> strings;
55 if (strings.empty()) {
56#define INSERT_ELEMENT(p) strings[p] = #p
65 return out << strings[value];
74 std::optional<const IR::Node *> expr;
79 Return() : expr(std::nullopt) {}
85 using PropertyValue = std::variant<cstring, uint64_t, int64_t, bool, const IR::Expression *>;
105 const IR::Expression *cond;
110 explicit Guard(
const IR::Expression *cond);
113 using Command = std::variant<
133 std::deque<Command> cmds;
141 const Command
next()
const;
144 void push(Command cmd);
153 bool operator==(
const Body &)
const;
156 Body(std::initializer_list<Command> cmds);
160 explicit Body(
const std::vector<Command> &cmds);
172 const IR::PathExpression *param;
175 explicit Parameter(
const IR::PathExpression *param) : param(param) {}
190 Body apply(std::optional<const IR::Node *> value_opt)
const;
204 body(
std::move(body)) {}
Represents a stack of namespaces.
Definition namespace_context.h:14
A continuation body is a list of commands.
Definition continuation.h:129
void clear()
Removes all commands in this body.
Definition continuation.cpp:50
void push(Command cmd)
Pushes the given command onto the command stack.
Definition continuation.cpp:43
const Command next() const
Definition continuation.cpp:35
bool empty() const
Determines whether this body is empty.
Definition continuation.cpp:33
void pop()
Definition continuation.cpp:45