P4C
The P4 Compiler
Loading...
Searching...
No Matches
bindVariables.h
1#ifndef FRONTENDS_P4_TYPECHECKING_BINDVARIABLES_H_
2#define FRONTENDS_P4_TYPECHECKING_BINDVARIABLES_H_
3
4#include "frontends/p4/typeChecking/typeChecker.h"
5#include "frontends/p4/typeMap.h"
6#include "ir/ir.h"
7
8namespace P4 {
9
10// Insert explicit type specializations where they are missing
13 TypeMap *typeMap;
14 const IR::Type *getVarValue(const IR::Type_Var *var, const IR::Node *errorPosition) const;
15 const IR::Node *insertTypes(const IR::Node *node);
16
17 public:
18 explicit DoBindTypeVariables(TypeMap *typeMap) : typeMap(typeMap) {
19 CHECK_NULL(typeMap);
20 setName("DoBindTypeVariables");
21 newTypes = new IR::IndexedVector<IR::Node>();
22 }
23
26 const IR::Node *preorder(IR::Annotation *annotation) override;
27
28 const IR::Node *postorder(IR::Expression *expression) override;
29 const IR::Node *postorder(IR::Declaration_Instance *decl) override;
30 const IR::Node *postorder(IR::MethodCallExpression *expression) override;
31 const IR::Node *postorder(IR::ConstructorCallExpression *expression) override;
32 const IR::Node *postorder(IR::P4Parser *parser) override { return insertTypes(parser); }
33 const IR::Node *postorder(IR::P4Control *control) override { return insertTypes(control); }
34};
35
37 public:
38 explicit BindTypeVariables(TypeMap *typeMap) {
39 CHECK_NULL(typeMap);
40 passes.push_back(new ClearTypeMap(typeMap));
41 passes.push_back(new TypeInference(typeMap, false)); // may insert casts
42 passes.push_back(new DoBindTypeVariables(typeMap));
43 passes.push_back(new ClearTypeMap(typeMap, true));
44 setName("BindTypeVariables");
45 }
46};
47
48} // namespace P4
49
50#endif /* FRONTENDS_P4_TYPECHECKING_BINDVARIABLES_H_ */
Definition bindVariables.h:36
Definition typeChecker.h:32
Definition bindVariables.h:11
const IR::Node * preorder(IR::Annotation *annotation) override
Definition bindVariables.cpp:138
Definition node.h:52
Definition node.h:95
Definition pass_manager.h:40
Definition visitor.h:424
Definition typeChecker.h:481
Definition typeMap.h:41
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24