17#ifndef TYPECHECKING_TYPESUBSTITUTION_H_
18#define TYPECHECKING_TYPESUBSTITUTION_H_
24#include "lib/exceptions.h"
41 const IR::Type *lookup(T t)
const { return ::P4::get(binding, t); }
42 const IR::Type *get(T t)
const { return ::P4::get(binding, t); }
44 bool containsKey(T key)
const {
return binding.find(key) != binding.end(); }
48 virtual bool setBinding(T
id,
const IR::Type *type) {
51 auto it = binding.find(
id);
52 if (it != binding.end()) {
53 if (it->second != type)
return false;
56 binding.emplace(
id, type);
60 void dbprint(std::ostream &out)
const {
63 for (
auto it : binding) {
64 if (!first) out << std::endl;
65 out << dbp(it.first) <<
" " << it.first <<
" -> " << dbp(it.second) <<
" " << it.second;
70 void clear() { binding.clear(); }
77 bool setBindings(
const IR::Node *errorLocation,
const IR::TypeParameters *params,
82 cstring compose(
const IR::ITypeVar *var,
const IR::Type *substitution);
87 bool setBinding(
const IR::ITypeVar *
id,
const IR::Type *type)
override {
88 auto result = TypeSubstitution::setBinding(
id, type);
Definition stringify.h:33
Definition typeSubstitution.h:30
bool isIdentity() const
Definition typeSubstitution.h:40
Definition typeSubstitution.h:73
cstring compose(const IR::ITypeVar *var, const IR::Type *substitution)
Definition typeSubstitution.cpp:28
Definition ordered_map.h:32
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24