P4C
The P4 Compiler
Loading...
Searching...
No Matches
bindVariables.h
1/*
2 * SPDX-FileCopyrightText: 2016 VMware, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef FRONTENDS_P4_TYPECHECKING_BINDVARIABLES_H_
8#define FRONTENDS_P4_TYPECHECKING_BINDVARIABLES_H_
9
10#include "frontends/p4/typeChecking/typeChecker.h"
11#include "frontends/p4/typeMap.h"
12#include "ir/ir.h"
13
14namespace P4 {
15
16// Insert explicit type specializations where they are missing
17class DoBindTypeVariables : public Transform {
18 TypeMap *typeMap;
19 const IR::Type *getVarValue(const IR::Type_Var *var, const IR::Node *errorPosition) const;
20 const IR::Node *insertTypes(const IR::Node *node);
21
22 public:
23 explicit DoBindTypeVariables(TypeMap *typeMap) : typeMap(typeMap) {
24 CHECK_NULL(typeMap);
25 setName("DoBindTypeVariables");
26 }
27
30 const IR::Node *preorder(IR::Annotation *annotation) override;
31
32 const IR::Node *postorder(IR::Expression *expression) override;
33 const IR::Node *postorder(IR::Declaration_Instance *decl) override;
34 const IR::Node *postorder(IR::MethodCallExpression *expression) override;
35 const IR::Node *postorder(IR::ConstructorCallExpression *expression) override;
36};
37
38class BindTypeVariables : public PassManager {
39 public:
40 explicit BindTypeVariables(TypeMap *typeMap) {
41 CHECK_NULL(typeMap);
42 passes.push_back(new ClearTypeMap(typeMap));
43 passes.push_back(new TypeInference(typeMap, false)); // may insert casts
44 passes.push_back(new DoBindTypeVariables(typeMap));
45 passes.push_back(new ClearTypeMap(typeMap, true));
46 setName("BindTypeVariables");
47 }
48};
49
50} // namespace P4
51
52#endif /* FRONTENDS_P4_TYPECHECKING_BINDVARIABLES_H_ */
Definition typeChecker.h:32
Definition bindVariables.h:17
const IR::Node * preorder(IR::Annotation *annotation) override
Definition bindVariables.cpp:143
Definition node.h:53
Definition visitor.h:442
Definition typeChecker.h:491
Definition typeMap.h:32
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13