35 TypeSubstitution() =
default;
36 TypeSubstitution(
const TypeSubstitution &other) =
default;
37 TypeSubstitution &operator=(
const TypeSubstitution &other) =
default;
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(); }
73class TypeVariableSubstitution final :
public TypeSubstitution<const IR::ITypeVar *> {
75 TypeVariableSubstitution() =
default;
76 TypeVariableSubstitution(
const TypeVariableSubstitution &other) =
default;
77 bool setBindings(
const IR::Node *errorLocation,
const IR::TypeParameters *params,
82 cstring compose(
const IR::ITypeVar *var,
const IR::Type *substitution);
85 void simpleCompose(
const TypeVariableSubstitution *other);
87 bool setBinding(
const IR::ITypeVar *
id,
const IR::Type *type)
override {
88 auto result = TypeSubstitution::setBinding(
id, type);
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24