P4C
The P4 Compiler
Loading...
Searching...
No Matches
BFN::LinearPath Struct Reference

#include <path_linearizer.h>

Public Member Functions

cstring to_cstring ()
 
cstring to_cstring (cstring, bool)
 

Public Attributes

std::vector< const IR::Expression * > components
 

Detailed Description

A linearization of a path-like expression which can be used to iterate over the components of a nested Member expression in left-to-right order.

Using an ML-like notation, the IR for the P4 expression foo.bar.baz looks something like this:

Member (Member (PathExpression "foo") "bar") "baz"

LinearPath represents the same expression as a sequence of components like this:

[ PathExpression "foo", Member "bar", Member "baz" ]

Each component in the sequence is just a pointer to the original IR node corresponding to that component, so inspecting them with a normal visitor is still possible, and you can still look them up in a ReferenceMap or TypeMap.

The first component is always a PathExpression, and the remaining components are always Member expressions.

TODO: Perhaps it'd be nice to support indexing into header stacks as well.