1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_EXECUTION_STATE_H_ 
    2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_EXECUTION_STATE_H_ 
    6#include <initializer_list> 
   15#include "backends/p4tools/common/compiler/reachability.h" 
   16#include "backends/p4tools/common/core/abstract_execution_state.h" 
   17#include "backends/p4tools/common/lib/namespace_context.h" 
   18#include "backends/p4tools/common/lib/symbolic_env.h" 
   19#include "backends/p4tools/common/lib/trace_event.h" 
   20#include "ir/declaration.h" 
   24#include "lib/cstring.h" 
   25#include "lib/exceptions.h" 
   26#include "midend/coverage.h" 
   28#include "backends/p4tools/modules/testgen/lib/continuation.h" 
   29#include "backends/p4tools/modules/testgen/lib/test_object.h" 
   31namespace P4Tools::P4Testgen {
 
   40        using ExceptionHandlers = std::map<Continuation::Exception, Continuation>;
 
   44        ExceptionHandlers exceptionHandlers;
 
 
   76    std::vector<std::reference_wrapper<const TraceEvent>> trace;
 
   93    std::stack<std::reference_wrapper<const StackFrame>> stack;
 
  101    std::map<cstring, Continuation::PropertyValue> stateProperties;
 
  109    std::map<cstring, TestObjectMap> testObjects;
 
  113    std::optional<IR::StateVariable> parserErrorLabel = std::nullopt;
 
  119    int inputPacketCursor = 0;
 
  123    std::vector<const IR::Expression *> pathConstraint;
 
  126    std::vector<uint64_t> selectedBranches;
 
  133    uint16_t numAllocatedPacketVariables = 0;
 
  139    [[nodiscard]] 
const IR::SymbolicVariable *createPacketVariable(
const IR::Type *type);
 
  149    [[nodiscard]] 
const std::vector<const IR::Expression *> &
getPathConstraint() 
const;
 
  164    [[nodiscard]] std::optional<const Continuation::Command> 
getNextCmd() 
const;
 
  167    [[nodiscard]] 
const IR::Expression *
get(
const IR::StateVariable &var) 
const override;
 
  177    void set(
const IR::StateVariable &var, 
const IR::Expression *value) 
override;
 
  180    [[nodiscard]] 
const std::vector<std::reference_wrapper<const TraceEvent>> &
getTrace() 
const;
 
  186    [[nodiscard]] 
const std::stack<std::reference_wrapper<const StackFrame>> &
getStack() 
const;
 
  198        auto iterator = stateProperties.find(propertyName);
 
  199        if (iterator != stateProperties.end()) {
 
  200            auto val = iterator->second;
 
  202                T resolvedVal = std::get<T>(val);
 
  204            } 
catch (std::bad_variant_access 
const &ex) {
 
  205                BUG(
"Expected property value type does not correspond to value type stored in the " 
  209        BUG(
"Property %s not found in configuration map.", propertyName);
 
 
  233        const auto *testObject = 
getTestObject(category, objectLabel, 
true);
 
  234        return testObject->checkedTo<T>();
 
 
  261    void replaceTopBody(
const std::vector<Continuation::Command> *cmds);
 
  265    void replaceTopBody(std::initializer_list<Continuation::Command> cmds);
 
  274        BUG_CHECK(!nodes->empty(), 
"Replaced top of execution stack with empty list");
 
  276        for (
auto it = nodes->rbegin(); it != nodes->rend(); ++it) {
 
  277            BUG_CHECK(*it, 
"Evaluation produced a null node.");
 
 
  304                                 StackFrame::ExceptionHandlers = {});
 
  312    void popContinuation(std::optional<const IR::Node *> argument_opt = std::nullopt);
 
 
  409using ExecutionStateReference = std::reference_wrapper<ExecutionState>;
 
Represents a stack of namespaces.
Definition namespace_context.h:14
 
A continuation body is a list of commands.
Definition continuation.h:129
 
void push(Command cmd)
Pushes the given command onto the command stack.
Definition continuation.cpp:43
 
void pop()
Definition continuation.cpp:45
 
Definition modules/testgen/test/small-step/util.h:41
 
std::set< const IR::Node *, SourceIdCmp > CoverageSet
Definition coverage.h:39