Spicy
Public Member Functions | Public Attributes | List of all members
hilti::CoercedExpression Struct Reference

#include <coercion.h>

Public Member Functions

 operator bool () const
 
 CoercedExpression (const Expression &src)
 
 CoercedExpression (const Type &src, Expression coerced)
 
 CoercedExpression ()=default
 
 CoercedExpression (const result::Error &error)
 

Public Attributes

Result< Expression > coerced = {}
 
std::optional< Expression > nexpr = {}
 
bool consider_type_changed = false
 

Detailed Description

Return type for the functions doing expression coercion.

Constructor & Destructor Documentation

◆ CoercedExpression() [1/4]

hilti::CoercedExpression::CoercedExpression ( const Expression &  src)
inline

Represents a successful coercion that led the source expression not changing, which will be assigned to the coerced field.

Note
The expression not changing doesn't necessarily mean that the expression's type is exactly matching the coercion's destination type. However, even if not, the caller should proceed by using the coerced field value for anywhere where the coerced expression is expected.
Parameters
srcthe original source expression

◆ CoercedExpression() [2/4]

hilti::CoercedExpression::CoercedExpression ( const Type src,
Expression  coerced 
)
inline

Represents a successful coercion that led to a new expression different from the source expression.

Parameters
srcthe original source expression's type
coercedthe resulting expression that src was coerced to

◆ CoercedExpression() [3/4]

hilti::CoercedExpression::CoercedExpression ( )
default

Represents an unsuccessful coercion.

◆ CoercedExpression() [4/4]

hilti::CoercedExpression::CoercedExpression ( const result::Error error)
inline

Represents an unsuccessful coercion, carrying an error message along explaining why it failed.

Member Function Documentation

◆ operator bool()

hilti::CoercedExpression::operator bool ( ) const
inline

Returns true if coercion was successful.

Member Data Documentation

◆ coerced

Result<Expression> hilti::CoercedExpression::coerced = {}

Coerced expression if successful, an error if not. This will be set even if the coerced expression ends up being identical to the source expression.

◆ consider_type_changed

bool hilti::CoercedExpression::consider_type_changed = false

If coerced is set, true if type of new expression's type is to be considered changed compared to source expression's type for overload resolution

◆ nexpr

std::optional<Expression> hilti::CoercedExpression::nexpr = {}

Coerced expression if successful and the coerced expression is not identical to original one; unset otherwise.


The documentation for this struct was generated from the following file: