P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4::SideEffects Class Reference

Determines whether an expression may have method or constructor invocations. More...

Inheritance diagram for P4::SideEffects:

Public Member Functions

 SideEffects (ReferenceMap *refMap, TypeMap *typeMap)
 
void postorder (const IR::ConstructorCallExpression *cce) override
 
void postorder (const IR::MethodCallExpression *mce) override
 

Static Public Member Functions

static bool check (const IR::Expression *expression, const Visitor *calledBy, ReferenceMap *refMap, TypeMap *typeMap)
 
static bool hasSideEffect (const IR::MethodCallExpression *mce, ReferenceMap *refMap, TypeMap *typeMap)
 

Public Attributes

const IR::Node * nodeWithSideEffect = nullptr
 Last visited side-effecting node. Null if no node has side effects.
 
unsigned sideEffectCount = 0
 Number of side effects in this expression.
 

Detailed Description

Determines whether an expression may have method or constructor invocations.

The TypeMap and ReferenceMap arguments may be null, in which case every method call expression is counted. With type information, invocations of isValid() are ignored.

Constructor & Destructor Documentation

◆ SideEffects()

P4::SideEffects::SideEffects ( ReferenceMap * refMap,
TypeMap * typeMap )
inline

The @refMap and @typeMap arguments can be null, in which case the check will be more conservative.

Member Function Documentation

◆ check()

static bool P4::SideEffects::check ( const IR::Expression * expression,
const Visitor * calledBy,
ReferenceMap * refMap,
TypeMap * typeMap )
inlinestatic
Returns
true if the expression may have side-effects.

◆ hasSideEffect()

static bool P4::SideEffects::hasSideEffect ( const IR::MethodCallExpression * mce,
ReferenceMap * refMap,
TypeMap * typeMap )
inlinestatic
Returns
true if the method call expression may have side-effects.