Spicy
Classes | Public Member Functions | List of all members
hilti::expression::TypeWrapped Class Reference

#include <type-wrapped.h>

Inheritance diagram for hilti::expression::TypeWrapped:
hilti::NodeBase hilti::trait::isExpression hilti::trait::isNode hilti::trait::isNode

Classes

struct  ValidateTypeMatch
 

Public Member Functions

 TypeWrapped (Expression e, Meta m=Meta())
 
 TypeWrapped (Expression e, Type t, Meta m=Meta())
 
 TypeWrapped (Expression e, Type t, ValidateTypeMatch _, Meta m=Meta())
 
 TypeWrapped (Expression e, NodeRef t, Meta m=Meta())
 
 TypeWrapped (Expression e, NodeRef t, ValidateTypeMatch _, Meta m=Meta())
 
const auto & expression () const
 
bool validateTypeMatch () const
 
bool operator== (const TypeWrapped &other) const
 
bool isLhs () const
 
bool isTemporary () const
 
Type type () const
 
auto isConstant () const
 
auto isEqual (const Expression &other) const
 
auto properties () const
 
- Public Member Functions inherited from hilti::NodeBase
 NodeBase (Meta meta)
 
 NodeBase (std::vector< Node > childs, Meta meta)
 
template<typename T >
const T & child (int i) const
 
template<typename T >
void assertChildIsA (int i)
 
template<typename T >
std::vector< T > childs (int begin, int end) const
 
template<typename T >
std::vector< T > childsOfType () const
 
template<typename T >
auto nodesOfType () const
 
template<typename T >
auto nodesOfType ()
 
void addChild (Node n)
 
auto & childs () const
 
auto & childs ()
 
auto & meta () const
 
void setMeta (Meta m)
 
const NodeReforiginalNode () const
 
void setOriginalNode (const NodeRef &n)
 
void clearCache ()
 

Detailed Description

AST node for an expression wrapped into another which does not have a known type yet, for example because IDs are stil unresolved. With a "normal" expression, calling type() would yield an unusable type. This expression instead returns a place-holder type that's derived on one of two ways:

1. If the fully resolved type of the expression is actually known
   a-priori, it can be jsut passed into the constructor and will then
   always be returned, independent of the inner expression's type
   itself.

2. If no explicit type is given, `type()` returns a proxy type that
   evaluates the expression's type on demand once requested (but not,
   crucially, immediately). So once the expression is fully resolved,
   this will yield its correct type. In the meantime, the proxy can be
   passed around like any other type.

In case 1, one can in addition require that the expression's eventual fully-resolved type matches the type that was specified. If it doesn't the validator will then reject the code.

Member Function Documentation

◆ isConstant()

auto hilti::expression::TypeWrapped::isConstant ( ) const
inline

Implements Expression interface.

◆ isEqual()

auto hilti::expression::TypeWrapped::isEqual ( const Expression &  other) const
inline

Implements Expression interface.

◆ isLhs()

bool hilti::expression::TypeWrapped::isLhs ( ) const
inline

Implements Expression interface.

◆ isTemporary()

bool hilti::expression::TypeWrapped::isTemporary ( ) const
inline

Implements Expression interface.

◆ properties()

auto hilti::expression::TypeWrapped::properties ( ) const
inline

Implements Node interface.

◆ type()

Type hilti::expression::TypeWrapped::type ( ) const
inline

Implements Expression interface.


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