8#ifndef FRONTENDS_P4_CORELIBRARY_H_
9#define FRONTENDS_P4_CORELIBRARY_H_
11#include "frontends/common/model.h"
13#include "lib/cstring.h"
16enum class StandardExceptions {
28inline std::ostream &operator<<(std::ostream &out, P4::StandardExceptions e) {
30 case P4::StandardExceptions::NoError:
33 case P4::StandardExceptions::PacketTooShort:
34 out <<
"PacketTooShort";
36 case P4::StandardExceptions::NoMatch:
39 case P4::StandardExceptions::StackOutOfBounds:
40 out <<
"StackOutOfBounds";
42 case P4::StandardExceptions::HeaderTooShort:
43 out <<
"HeaderTooShort";
45 case P4::StandardExceptions::ParserTimeout:
46 out <<
"ParserTimeout";
49 BUG(
"Unhandled case");
63 : Extern_Model(
"packet_in"_cs),
64 extract(
"extract"_cs),
65 lookahead(
"lookahead"_cs),
66 advance(
"advance"_cs),
67 length(
"length"_cs) {}
72 int extractSecondArgSize = 32;
77 PacketOut() : Extern_Model(
"packet_out"_cs), emit(
"emit"_cs) {}
83 const StandardExceptions exc;
84 explicit P4Exception_Model(StandardExceptions exc)
86 std::stringstream str;
98 : noAction(
"NoAction"_cs),
99 exactMatch(
"exact"_cs),
100 ternaryMatch(
"ternary"_cs),
102 noError(StandardExceptions::NoError),
103 packetTooShort(StandardExceptions::PacketTooShort),
104 noMatch(StandardExceptions::NoMatch),
105 stackOutOfBounds(StandardExceptions::StackOutOfBounds),
106 headerTooShort(StandardExceptions::HeaderTooShort) {}
110 static P4CoreLibrary &instance() {
111 static P4CoreLibrary *corelib =
new P4CoreLibrary();
Definition frontends/common/model.h:55
Definition coreLibrary.h:81
Definition coreLibrary.h:60
Definition coreLibrary.h:75
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13
Definition frontends/common/model.h:19
Extern_Model : Type_Model.
Definition frontends/common/model.h:43