P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::StructTypeReplacement< T > Struct Template Reference

#include <flattenInterfaceStructs.h>

Inheritance diagram for P4::StructTypeReplacement< T >:
[legend]

Public Member Functions

 StructTypeReplacement (const P4::TypeMap *typeMap, const IR::Type_StructLike *type, AnnotationSelectionPolicy *policy)
 
virtual void dbprint (std::ostream &out) const
 
const IR::StructExpression * explode (const IR::Expression *root, cstring prefix)
 
void flatten (const P4::TypeMap *typeMap, cstring prefix, const IR::Type *type, const IR::Annotations *annotations, IR::IndexedVector< IR::StructField > *fields, AnnotationSelectionPolicy *policy)
 
- Public Member Functions inherited from P4::IHasDbPrint
void print () const
 

Public Attributes

std::map< cstring, cstringfieldNameRemap
 
const IR::Type * replacementType
 
std::map< cstring, const IR::Type_StructLike * > structFieldMap
 

Detailed Description

template<typename T>
struct P4::StructTypeReplacement< T >

Describes how a nested struct type is replaced: the new type to replace it and how each field is renamed. For example, consider the following:

struct S { bit a; bool b; }

struct T { S s; bit<6> y; }

struct M { T t; bit<3> x; }

Member Function Documentation

◆ dbprint()

template<typename T >
virtual void P4::StructTypeReplacement< T >::dbprint ( std::ostream & out) const
inlinevirtual

Implements P4::IHasDbPrint.

◆ explode()

template<typename T >
const IR::StructExpression * P4::StructTypeReplacement< T >::explode ( const IR::Expression * root,
cstring prefix )
inline

Returns a StructExpression suitable for initializing a struct for the fields that start with the given prefix. For example, for prefix .t and root R this returns { .s = { .a = R._t_s_a0, .b = R._t_s_b1 }, .y = R._t_y2 }