36 : subst(subst), typeMap(typeMap), tc(tc) {
40 LOG3(
"ConstantTypeSubstitution " << subst);
43 const IR::Node *postorder(IR::Constant *cst)
override {
44 auto cstType = typeMap->getType(getOriginal(),
true);
45 if (!cstType->is<IR::ITypeVar>())
return cst;
47 while (repl->is<IR::ITypeVar>()) {
48 auto next = subst->get(repl->to<IR::ITypeVar>());
49 BUG_CHECK(next != repl,
"Cycle in substitutions: %1%", next);
53 if (repl != cstType) {
55 LOG2(
"Inferred type " << repl <<
" for " << cst);
56 cst =
new IR::Constant(cst->srcInfo, repl, cst->value, cst->base);
58 LOG2(
"No type inferred for " << cst <<
" repl is " << repl);
63 const IR::Expression *convert(
const IR::Expression *expr,
const Visitor::Context *ctxt) {
64 auto result = expr->apply(*
this, ctxt)->to<IR::Expression>();
65 if (result != expr && (
::P4::errorCount() == 0)) tc->learn(result,
this, ctxt);
71 if (result != vec) tc->learn(result,
this, ctxt);
77 if (result != vec) tc->learn(result,
this, ctxt);
Visitor mixin for looking up names in enclosing scopes from the Visitor::Context.
Definition resolveReferences.h:35
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24