48 std::unique_ptr<MinimalNameGenerator> nameGen;
49 AInlineWorkList::ReplacementMap *replMap;
54 const IR::Node *preorder(IR::P4Parser *cont)
override {
58 const IR::Node *preorder(IR::P4Action *action)
override;
59 const IR::Node *postorder(IR::P4Action *action)
override;
60 const IR::Node *preorder(IR::MethodCallStatement *statement)
override;
84 const IR::V1Program *global;
85 class SubstActionArgs :
public Transform {
86 const IR::ActionFunction *function;
87 const IR::Primitive *callsite;
88 const IR::Node *postorder(IR::ActionArg *arg)
override {
89 for (
unsigned i = 0; i < function->args.size(); ++i)
90 if (function->args[i] == getOriginal())
return callsite->operands[i];
91 BUG(
"Action arg not argument of action");
96 SubstActionArgs(
const IR::ActionFunction *f,
const IR::Primitive *c)
97 : function(f), callsite(c) {}
99 const IR::V1Program *preorder(IR::V1Program *gl)
override {
return global = gl; }
100 const IR::Node *preorder(IR::Primitive *p)
override {
101 if (
auto af = global->get<IR::ActionFunction>(p->name)) {
102 SubstActionArgs saa(af, p);
103 saa.setCalledBy(
this);
104 return af->action.clone()->apply(saa);
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