45class TypeVariableSubstitutionVisitor :
public Transform {
51 const IR::Node *replacement(
const IR::ITypeVar *original,
const IR::Node *node);
56 : bindings(bindings), replace(replace) {
57 setName(
"TypeVariableSubstitution");
60 const IR::Node *preorder(IR::TypeParameters *tps)
override;
61 const IR::Node *preorder(IR::Type_Any *tv)
override {
62 return replacement(getOriginal<IR::Type_Any>(), tv);
64 const IR::Node *preorder(IR::Type_Var *tv)
override {
65 return replacement(getOriginal<IR::Type_Var>(), tv);
67 const IR::Node *preorder(IR::Type_InfInt *ti)
override {
68 return replacement(getOriginal<IR::Type_InfInt>(), ti);
72class TypeSubstitutionVisitor :
public TypeVariableSubstitutionVisitor {
77 : TypeVariableSubstitutionVisitor(ts), typeMap(typeMap) {
79 setName(
"TypeSubstitutionVisitor");
81 const IR::Node *postorder(IR::PathExpression *path)
override {
83 return new IR::PathExpression(path->path->clone());
85 const IR::Node *postorder(IR::Type_Name *type)
override {
86 auto actual = typeMap->getTypeType(getOriginal<IR::Type_Name>(),
true);
87 if (
auto tv = actual->to<IR::ITypeVar>()) {
88 LOG3(
"Replacing " << tv);
89 return replacement(tv, type);
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24