P4C
The P4 Compiler
Loading...
Searching...
No Matches
formulae.h
1#ifndef BACKENDS_P4TOOLS_COMMON_LIB_FORMULAE_H_
2#define BACKENDS_P4TOOLS_COMMON_LIB_FORMULAE_H_
3
4#include <functional>
5#include <string>
6
7#include "ir/ir.h"
8#include "ir/node.h"
9#include "lib/exceptions.h"
10
11namespace P4::P4Tools {
12
16template <class Self, class Node = IR::Expression>
18 protected:
19 std::reference_wrapper<const Node> node;
20
21 // Implicit conversions to allow implementations to be treated like a Node*.
22 operator const Node *() const { return &node.get(); }
23 const Node &operator*() const { return node.get(); }
24 const Node *operator->() const { return &node.get(); }
25
28 explicit AbstractRepCheckedNode(const Node *node, std::string classDesc) : node(*node) {
29 BUG_CHECK(Self::repOk(node), "%1%: Not a valid %2%.", node, classDesc);
30 }
31
32 DECLARE_TYPEINFO(AbstractRepCheckedNode);
33};
34
35} // namespace P4::P4Tools
36
37#endif /* BACKENDS_P4TOOLS_COMMON_LIB_FORMULAE_H_ */
Definition castable.h:36
Definition formulae.h:17
AbstractRepCheckedNode(const Node *node, std::string classDesc)
Definition formulae.h:28
Definition common/compiler/compiler_result.cpp:3