P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::TypeConstraint Class Referenceabstract
Inheritance diagram for P4::TypeConstraint:
[legend]

Public Member Functions

 DECLARE_TYPEINFO (TypeConstraint)
 
virtual bool reportError (const TypeVariableSubstitution *subst) const =0
 
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
virtual void dbprint (std::ostream &out) const =0
 
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
 

Protected Member Functions

 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

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.
 

Member Function Documentation

◆ reportError()

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.