21 #ifndef BM_BM_SIM_CONDITIONALS_H_
22 #define BM_BM_SIM_CONDITIONALS_H_
29 #include "control_flow.h"
30 #include "expressions.h"
35 :
public ControlFlowNode,
public Expression {
37 Conditional(
const std::string &name, p4object_id_t
id)
38 : ControlFlowNode(name, id) {}
39 Conditional(
const std::string &name, p4object_id_t
id,
40 std::unique_ptr<SourceInfo> source_info)
41 : ControlFlowNode(name, id, std::move(source_info)) {}
43 bool eval(
const PHV &phv)
const {
44 return eval_bool(phv);
47 void set_next_node_if_true(ControlFlowNode *next_node) {
48 true_next = next_node;
51 void set_next_node_if_false(ControlFlowNode *next_node) {
52 false_next = next_node;
56 const ControlFlowNode *operator()(Packet *pkt)
const override;
58 Conditional(
const Conditional &other) =
delete;
59 Conditional &
operator=(
const Conditional &other) =
delete;
61 Conditional(Conditional &&other) =
default;
62 Conditional &
operator=(Conditional &&other) =
default;
65 ControlFlowNode *true_next{
nullptr};
66 ControlFlowNode *false_next{
nullptr};
71 #endif // BM_BM_SIM_CONDITIONALS_H_