26 TypeSubstitution() =
default;
27 TypeSubstitution(
const TypeSubstitution &other) =
default;
28 TypeSubstitution &operator=(
const TypeSubstitution &other) =
default;
32 const IR::Type *lookup(T t)
const { return ::P4::get(binding, t); }
33 const IR::Type *get(T t)
const { return ::P4::get(binding, t); }
35 bool containsKey(T key)
const {
return binding.find(key) != binding.end(); }
39 virtual bool setBinding(T
id,
const IR::Type *type) {
42 auto it = binding.find(
id);
43 if (it != binding.end()) {
44 if (it->second != type)
return false;
47 binding.emplace(
id, type);
51 void dbprint(std::ostream &out)
const override {
54 for (
auto it : binding) {
55 if (!first) out << std::endl;
56 out << dbp(it.first) <<
" -> " << dbp(it.second);
61 void clear() { binding.clear(); }
64class TypeVariableSubstitution final :
public TypeSubstitution<const IR::ITypeVar *> {
66 TypeVariableSubstitution() =
default;
67 TypeVariableSubstitution(
const TypeVariableSubstitution &other) =
default;
68 bool setBindings(
const IR::Node *errorLocation,
const IR::TypeParameters *params,
73 cstring compose(
const IR::ITypeVar *var,
const IR::Type *substitution);
76 void simpleCompose(
const TypeVariableSubstitution *other);
78 bool setBinding(
const IR::ITypeVar *
id,
const IR::Type *type)
override {
79 auto result = TypeSubstitution::setBinding(
id, type);
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13