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;
85 const IR::V1Program *global;
86 class SubstActionArgs :
public Transform {
87 const IR::ActionFunction *function;
88 const IR::Primitive *callsite;
89 const IR::Node *postorder(IR::ActionArg *arg)
override {
90 for (
unsigned i = 0; i < function->args.size(); ++i)
91 if (function->args[i] == getOriginal())
return callsite->operands[i];
92 BUG(
"Action arg not argument of action");
97 SubstActionArgs(
const IR::ActionFunction *f,
const IR::Primitive *c)
98 : function(f), callsite(c) {}
100 const IR::V1Program *preorder(IR::V1Program *gl)
override {
return global = gl; }
101 const IR::Node *preorder(IR::Primitive *p)
override {
102 if (
auto af = global->get<IR::ActionFunction>(p->name)) {
103 SubstActionArgs saa(af, p);
104 saa.setCalledBy(
this);
105 return af->action.clone()->apply(saa);
Visitor mixin for looking up names in enclosing scopes from the Visitor::Context.
Definition resolveReferences.h:33
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24