P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::ExternInstance Struct Referencefinal

#include <externInstance.h>

Static Public Member Functions

static std::optional< ExternInstanceresolve (const IR::Expression *expr, ReferenceMap *refMap, TypeMap *typeMap, const std::optional< cstring > &defaultName=std::nullopt)
 
static std::optional< ExternInstanceresolve (const IR::PathExpression *path, ReferenceMap *refMap, TypeMap *typeMap)
 
if it has external information about what the name should be.
Returns
the extern instance that @constructorCallExpr resolves to, if any, or std::nullopt otherwise.

Anonymous instances do not have a name, but the caller may provide one via

static std::optional< ExternInstanceresolve (const IR::ConstructorCallExpression *constructorCallExpr, ReferenceMap *refMap, TypeMap *typeMap, const std::optional< cstring > &name=std::nullopt)
 

Public Attributes

const IR::IAnnotated * annotations
 
const IR::Vector< IR::Argument > * arguments
 
const IR::Expression * expression
 
const std::optional< cstringname
 
ParameterSubstitution substitution
 
const IR::Type_Extern * type
 
const IR::Vector< IR::Type > * typeArguments
 

Detailed Description

ExternInstance is a utility class that allows you to gather information about an expression that resolves to an extern instance.

The name is in analogy to MethodInstance. It provides information about the name of the extern instance, the underlying extern type, the arguments it was instantiated with, and the annotations that we applied to it. It can gather this information from either a reference to a named instance, or from an expression which constructs an anonymous instance.

Member Function Documentation

◆ resolve() [1/2]

std::optional< ExternInstance > P4::ExternInstance::resolve ( const IR::Expression * expr,
ReferenceMap * refMap,
TypeMap * typeMap,
const std::optional< cstring > & defaultName = std::nullopt )
static
Returns
the extern instance that @expr resolves to, if any, or std::nullopt otherwise.

@expr may either refer to a named extern instance (i.e., it may be a PathExpression), or it may construct an anonymous instance directly (i.e., it may be a ConstructorCallExpression). In the latter case, the instance will not have a name; @defaultName may optionally be used to specify a default name to return.

◆ resolve() [2/2]

std::optional< ExternInstance > P4::ExternInstance::resolve ( const IR::PathExpression * path,
ReferenceMap * refMap,
TypeMap * typeMap )
static
Returns
the extern instance that @path resolves to, if any, or std::nullopt otherwise.