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

Requires two types to be equal. More...

#include <typeConstraints.h>

Inheritance diagram for P4::EqualityConstraint:
[legend]

Public Member Functions

 EqualityConstraint (const IR::Type *left, const IR::Type *right, const IR::Node *origin)
 
 EqualityConstraint (const IR::Type *left, const IR::Type *right, const TypeConstraint *derivedFrom)
 
BinaryConstraintcreate (const IR::Type *left, const IR::Type *right) const override
 
void dbprint (std::ostream &out) const override
 
 DECLARE_TYPEINFO (EqualityConstraint, BinaryConstraint)
 
bool reportError (const TypeVariableSubstitution *subst) const override
 
template<typename... Args>
bool reportError (const TypeVariableSubstitution *subst, const char *format, Args &&...args) const
 
- Public Member Functions inherited from P4::BinaryConstraint
 DECLARE_TYPEINFO (BinaryConstraint, TypeConstraint)
 
- Public Member Functions inherited from P4::TypeConstraint
 DECLARE_TYPEINFO (TypeConstraint)
 
template<typename... Args>
bool reportError (const TypeVariableSubstitution *subst, const char *format, Args &&...args) const
 
void setError (std::string_view format, std::initializer_list< const IR::Node * > nodes)
 
- Public Member Functions inherited from P4::IHasDbPrint
void print () const
 
- Public Member Functions inherited from P4::ICastable
template<typename T >
T & as ()
 Tries to convert the class to type T. A BUG occurs if the cast fails.
 
template<typename T >
const T & as () const
 Tries to convert the class to type T. A BUG occurs if the cast fails.
 
template<typename T >
T * checkedTo ()
 Performs a checked cast. A BUG occurs if the cast fails.
 
template<typename T >
const T * checkedTo () const
 Performs a checked cast. A BUG occurs if the cast fails.
 
- Public Member Functions inherited from P4::RTTI::Base
template<typename T >
bool is () const noexcept
 
virtual bool isA (TypeId typeId) const noexcept=0
 
template<typename T >
const T * to () const noexcept
 Same as to, but returns const pointer to T.
 
template<typename T >
T * to () noexcept
 
virtual TypeId typeId () const noexcept=0
 

Additional Inherited Members

- Public Attributes inherited from P4::BinaryConstraint
const IR::Type * left
 
const IR::Type * right
 
- Protected Member Functions inherited from P4::BinaryConstraint
 BinaryConstraint (const IR::Type *left, const IR::Type *right, const IR::Node *origin)
 
 BinaryConstraint (const IR::Type *left, const IR::Type *right, const TypeConstraint *derivedFrom)
 
void validate () const
 
- Protected Member Functions inherited from P4::TypeConstraint
 TypeConstraint (const IR::Node *origin)
 
 TypeConstraint (const TypeConstraint *derivedFrom)
 
std::string explain (size_t index, Explain *explainer) const
 
std::string localError (Explain *explainer) const
 
- Protected Member Functions inherited from P4::RTTI::Base
virtual const void * toImpl (TypeId typeId) const noexcept=0
 
- Protected Attributes inherited from P4::TypeConstraint
const TypeConstraintderivedFrom = nullptr
 Constraint which produced this one. May be nullptr.
 
const IR::Nodeorigin = nullptr
 Place in source code which originated the contraint. May be nullptr.
 

Detailed Description

Requires two types to be equal.

Member Function Documentation

◆ create()

BinaryConstraint * P4::EqualityConstraint::create ( const IR::Type * left,
const IR::Type * right ) const
inlineoverridevirtual

Implements P4::BinaryConstraint.

◆ dbprint()

void P4::EqualityConstraint::dbprint ( std::ostream & out) const
inlineoverridevirtual

Implements P4::IHasDbPrint.

◆ reportError() [1/2]

bool P4::EqualityConstraint::reportError ( const TypeVariableSubstitution * subst) const
inlineoverridevirtual

Implements P4::TypeConstraint.

◆ reportError() [2/2]

template<typename... Args>
bool P4::TypeConstraint::reportError ( const TypeVariableSubstitution * subst,
const char * format,
Args &&... args ) const
inline

The Constraints actually form a stack and the error message is composed in reverse order, from bottom to top. The top of the stack has no 'derivedFrom' field, and it contains the actual source position where the analysis started.