33 std::map<const IR::P4Action *, const IR::MethodCallExpression *> invocations;
34 std::set<const IR::P4Action *> all;
35 std::set<const IR::MethodCallExpression *> calls;
37 std::map<const IR::MethodCallExpression *, unsigned> defaultActions;
40 void bind(
const IR::P4Action *action,
const IR::MethodCallExpression *invocation,
43 BUG_CHECK(invocations.find(action) == invocations.end(),
"%1%: action called twice",
45 invocations.emplace(action, invocation);
46 if (allParams) all.emplace(action);
47 calls.emplace(invocation);
49 void bindDefaultAction(
const IR::P4Action *action,
50 const IR::MethodCallExpression *defaultInvocation) {
52 auto actionCallInvocation = ::P4::get(invocations, action);
53 CHECK_NULL(actionCallInvocation);
55 unsigned boundArgs = actionCallInvocation->arguments->size();
56 defaultActions.emplace(defaultInvocation, boundArgs);
58 const IR::MethodCallExpression *get(
const IR::P4Action *action)
const {
59 return ::P4::get(invocations, action);
61 bool removeAllParameters(
const IR::P4Action *action)
const {
62 return all.find(action) != all.end();
64 bool isCall(
const IR::MethodCallExpression *expression)
const {
65 return calls.find(expression) != calls.end();
67 unsigned argsToRemove(
const IR::MethodCallExpression *defaultCall)
const {
68 if (defaultActions.find(defaultCall) == defaultActions.end())
return 0;
69 return ::P4::get(defaultActions, defaultCall);
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