Types

This section contains definitions declared in the chpl::types namespace.

namespace types

Functions

size_t hashSubstitutionsMap(const CompositeType::SubstitutionsMap &subs)
void stringifySubstitutionsMap(std::ostream &streamOut, StringifyKind stringKind, const CompositeType::SubstitutionsMap &subs)
class AnyClassType : public chpl::types::ManageableType

This class represents the generic class typeclass. It inherits from ManageableType so that it can be used with decorators and managers.

Public Functions

~AnyClassType() = default
inline virtual Type::Genericity genericity() const override

This function returns an enum Genericity value to indicate if the type is concrete, generic, generic with defaults, or maybe generic (e.g. depending on the fields).

This function needs to be defined by subclasses.

Public Static Functions

static const AnyClassType *get(Context *context)
class AnyType : public chpl::types::Type

This class represents a generic type that can instantiate to any type.

Public Functions

~AnyType() = default
virtual void stringify(std::ostream &ss, StringifyKind stringKind) const override

Public Static Functions

static const AnyType *get(Context *context)
class ArrayType : public chpl::types::CompositeType

This class represents an array type e.g. [1..10] int.

Public Functions

inline QualifiedType domainType() const
inline QualifiedType eltType() const
~ArrayType() = default
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override

Public Static Functions

static const ArrayType *getGenericArrayType(Context *context)

Return the generic array type

static const ArrayType *getArrayType(Context *context, const QualifiedType &domainType, const QualifiedType &eltType)
class BasicClassType : public chpl::types::ManageableType

This class represents an class type (e.g. class C) without considering decorators.

Public Functions

~BasicClassType() = default
inline const BasicClassType *parentClassType() const

Return the parent class type, or nullptr if this is the ‘object’ type.

inline bool isObjectType() const

Return true if this type is the ‘object’ type.

bool isSubtypeOf(const BasicClassType *parentType, bool &converts, bool &instantiates) const

Returns true if this class type is a subclass of the passed parent class type or an instantiation of a passed generic class type or a combination of the two.

The argument ‘convert’ is set to true if passing required using a parent type and ‘instantiates’ is set to true if it requires instantiation.

inline const BasicClassType *instantiatedFrom() const

If this type represents an instantiated type, returns the type it was instantiated from.

This is just instantiatedFromCompositeType() with the result cast to BasicClassType.

Public Static Functions

static const BasicClassType *get(Context *context, ID id, UniqueString name, const BasicClassType *parentType, const BasicClassType *instantiatedFrom, CompositeType::SubstitutionsMap subs)
static const BasicClassType *getRootClassType(Context *context)
static const BasicClassType *getReduceScanOpType(Context *context)
class BoolType : public chpl::types::PrimitiveType

This class represents a bool type, e.g. bool or bool(32).

Note that bool normally has width 8 but bool(8) is a separate type.

Public Functions

~BoolType() = default
inline virtual int bitwidth() const override

Returns the bit width selected for numeric types. Returns 8 for the default sized bool.

inline virtual bool isDefaultWidth() const override

Returns true if this PrimitiveType has the default width.

inline virtual const char *c_str() const override

Returns a C string for the name of this PrimitiveType.

Public Static Functions

static const BoolType *get(Context *context)
class BuiltinType : public chpl::types::Type

This class represents a builtin type that only needs a name to be used by resolution.

For example, numeric, borrowed, chpl_anyreal.

Types that are used very commonly (e.g. AnyType, UnknownType) should get their own classes.

Types that have need for different fields (e.g. PrimitiveType) should get their own classes.

Public Functions

~BuiltinType() = default
const char *c_str() const

Returns a C string for the name of this BuiltinType.

virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override

Public Static Functions

static void gatherBuiltins(Context *context, std::unordered_map<UniqueString, const Type*> &map)
class ClassType : public chpl::types::Type

This class represents an class type including a memory management decorator. E.g. if we have class C, then borrowed C? or shared C are ClassTypes.

Public Functions

~ClassType() = default
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
inline ClassTypeDecorator decorator() const

Returns the ClassTypeDecorator for this ClassType. This decorator indicates the memory management strategy.

inline const Type *manager() const

Returns the manager for this ClassType, or nullptr if the decorator does not indicate a managed type. This can return a record type or AnyOwnedType / AnySharedType.

inline const ManageableType *manageableType() const

Returns the type being managed

inline const BasicClassType *basicClassType() const

Returns the basic class type

const ClassType *withDecorator(Context *context, ClassTypeDecorator decorator) const

Returns the version of this ClassType with the passed decorator

Public Static Functions

static const ClassType *get(Context *context, const ManageableType *manageableType, const Type *manager, ClassTypeDecorator decorator)
class ClassTypeDecorator

This class stores a class type decorator that describes a memory management strategy.

It wraps a ClassTypeDecoratorEnum value so that it is easy to call methods on it.

Public Types

enum ClassTypeDecoratorEnum

Values:

enumerator BORROWED
enumerator BORROWED_NONNIL
enumerator BORROWED_NILABLE
enumerator UNMANAGED
enumerator UNMANAGED_NONNIL
enumerator UNMANAGED_NILABLE
enumerator MANAGED
enumerator MANAGED_NONNIL
enumerator MANAGED_NILABLE
enumerator GENERIC
enumerator GENERIC_NONNIL
enumerator GENERIC_NILABLE

Public Functions

inline explicit ClassTypeDecorator(ClassTypeDecoratorEnum val)
~ClassTypeDecorator() = default
inline ClassTypeDecoratorEnum val() const

Returns the ClassTypeDecoratorEnum value

inline ClassTypeDecorator removeNilable() const

Returns a decorator based on this one but with unknown nilability

inline ClassTypeDecorator addNonNil() const

Returns a decorator based on this one but that is non-nilable

inline ClassTypeDecorator addNilable() const

Returns a decorator based on this one but that is nilable

inline ClassTypeDecorator toBorrowed() const

Returns a decorator based on this one but with borrowed management (preserving nilability)

inline bool isUnknownNilability() const

Returns true if this decorator has unknown nilability

inline bool isNonNilable() const

Returns true if this decorator is non-nilable

inline bool isNilable() const

Returns true if this decorator is nilable

inline bool isBorrowed() const

Returns true if this decorator represents a borrowed type (e.g. borrowed C)

inline bool isUnmanaged() const

Returns true if this decorator represents a unmanaged type (e.g. unmanaged C)

inline bool isManaged() const

Returns true if this decorator represents a managed type (e.g. owned or shared)

inline bool isUnknownManagement() const

Returns true if this decorator has unknown management

inline ClassTypeDecorator combine(ClassTypeDecorator actual) const

Combines decorators assuming that this is a formal and the passed decorator is an actual

inline ClassTypeDecorator copyNilabilityFrom(ClassTypeDecorator other) const
inline bool operator==(ClassTypeDecorator other) const
inline bool operator!=(ClassTypeDecorator other) const
inline size_t hash() const
inline void swap(ClassTypeDecorator other)

Public Static Functions

static inline ClassTypeDecoratorEnum getIthDecorator(int i)

Given an integer i with 0 <= i < NUM_DECORATORS returns a decorator with that number. This can be used to iterate over the possible decorators.

static inline ClassTypeDecoratorEnum removeNilableFromDecorator(ClassTypeDecoratorEnum d)
static inline ClassTypeDecoratorEnum addNonNilToDecorator(ClassTypeDecoratorEnum d)
static inline ClassTypeDecoratorEnum addNilableToDecorator(ClassTypeDecoratorEnum d)
static inline bool isDecoratorUnknownNilability(ClassTypeDecoratorEnum d)
static inline bool isDecoratorNonNilable(ClassTypeDecoratorEnum d)
static inline bool isDecoratorNilable(ClassTypeDecoratorEnum d)
static inline bool isDecoratorBorrowed(ClassTypeDecoratorEnum d)
static inline bool isDecoratorUnmanaged(ClassTypeDecoratorEnum d)
static inline bool isDecoratorManaged(ClassTypeDecoratorEnum d)
static inline bool isDecoratorUnknownManagement(ClassTypeDecoratorEnum d)
static ClassTypeDecoratorEnum combineDecorators(ClassTypeDecoratorEnum formalDecorator, ClassTypeDecoratorEnum actualDecorator)
class ComplexType : public chpl::types::PrimitiveType

This class represents a complex type, e.g. complex or complex(64).

Public Functions

~ComplexType() = default
inline virtual int bitwidth() const override

Returns the bit width of this complex (64 or 128 bits, including both components

inline int componentBitwidth() const

Returns the bit width of a single component of this complex (which is half of bitwidth() )

inline virtual bool isDefaultWidth() const override

Returns true if this PrimitiveType has the default width.

inline virtual const char *c_str() const override

Returns a C string for the name of this PrimitiveType.

Public Static Functions

static const ComplexType *get(Context *context, int bitwidth)
class CompositeType : public chpl::types::Type

This class represents an aggregate type which is a type that contains other elements as fields. Subclasses include BasicClass, Record, Union, and Tuple types.

This class itself does not represent the field types. Instead, it uses the uAST ID of the class/record/union. For a generic type, it also uses a SubstitutionsMap.

(Storing field types in this class would present significant challenges for computing this type in an immutable way within the query framework).

For a generic-with-default type, the main type (with no substitutions) is generic, and the defaulted version is an instantiation of that.

E.g., for record R { type t = int; },

the CompositeType for R with no substitutions is a generic type when the version with the default is needed, it will be computed as a CompositeType for R with the substitution t->int which is instantiated from the above type.

Subclassed by chpl::types::ArrayType, chpl::types::DomainType, chpl::types::ManageableType, chpl::types::RecordType, chpl::types::TupleType, chpl::types::UnionType

Public Types

using SubstitutionsMap = std::unordered_map<ID, types::QualifiedType>

A SubstitutionsMap stores a mapping from uAST ID of a field or formal argument to the QualifiedType for it.

When a generic type or function is instantiated, the SubstitutionsMap describes the types that are used to instantiate it. For example, if we have

record R {
  type t;
}

Then R(int) is the RecordType with SubstitutionsMap containing a mapping from t to int.

Similarly, if we have

proc f(a, param b) { }

Then f(1.0, 2) creates an instantiation of f with the SubstitutionsMap containing a mapping from a to real and a mapping from b to int.

using SubstitutionPair = std::pair<ID, QualifiedType>
using SortedSubstitutions = std::vector<SubstitutionPair>

Public Functions

virtual ~CompositeType() = 0
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
inline const ID &id() const

Return the uAST ID associated with this CompositeType

inline UniqueString name() const

Returns the name of the uAST associated with this CompositeType

inline const CompositeType *instantiatedFromCompositeType() const

If this type represents an instantiated type, returns the type it was instantiated from.

This function always returns the fully generic type and never a partial instantiation. That is, the result will either be nullptr or result->instantiatedFrom() will be nullptr.

inline bool isInstantiationOf(Context *context, const CompositeType *genericType) const

Returns true if ‘this’ is an instantiation of genericType

inline const SubstitutionsMap &substitutions() const

Returns the substitutions map

SortedSubstitutions sortedSubstitutions() const

Returns the substitutions sorted by key ID

inline types::QualifiedType substitution(ID declId) const

Returns the substitution for a particular declId, or an empty QualifiedType if no substitution was found.

Public Static Functions

static const RecordType *getStringType(Context *context)

Get the string type

static const RecordType *getRangeType(Context *context)

Get the range type

static const RecordType *getBytesType(Context *context)

Get the bytes type

static const RecordType *getLocaleType(Context *context)

Get the locale type

static const RecordType *getLocaleIDType(Context *context)

Get the chpl_localeID_t type

static bool isMissingBundledType(Context *context, ID id)

When compiling without a standard library (for testing purposes), the compiler code needs to work around the fact that there is no definition available for the bundled types needed by the language but provided in the library (such as ‘string’ or ‘Error’). This function allows code to easily detect that case.

static bool isMissingBundledClassType(Context *context, ID id)

When compiling without a standard library (for testing purposes), the compiler code needs to work around the fact that there is no definition available for the class types needed by the language but provided in the library (such as ‘ReduceScanOp’). This function allows code to easily detect that case.

static bool isMissingBundledRecordType(Context *context, ID id)

When compiling without a standard library (for testing purposes), the compiler code needs to work around the fact that there is no definition available for the record types needed by the language but provided in the library (such as ‘string’). This function allows code to easily detect that case.

static const ClassType *getErrorType(Context *context)
class CPtrType : public chpl::types::Type

Public Functions

inline const ID &id(Context *context) const
inline const Type *eltType() const
const CPtrType *withoutConst(Context *context) const
inline bool isConst() const
inline bool isVoidPtr() const
bool isInstantiationOf(Context *context, const CPtrType *genericType) const
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override

Public Static Functions

static const CPtrType *get(Context *context)
static const CPtrType *get(Context *context, const Type *eltType)
static const CPtrType *getCVoidPtrType(Context *context)
static const CPtrType *getConst(Context *context)
static const CPtrType *getConst(Context *context, const Type *eltType)
static const ID &getId(Context *context)
static const ID &getConstId(Context *context)
class CStringType : public chpl::types::Type

This class represents the string type.

Public Functions

~CStringType() = default
virtual void stringify(std::ostream &ss, StringifyKind stringKind) const override

Public Static Functions

static const CStringType *get(Context *context)
class DomainType : public chpl::types::CompositeType

This class represents a domain type e.g. domain(1).

NB: This type’s representation is a work-in-progress and subject to change.

In practice this type is represented by the _domain record in ChapelDomain, but does not follow all of the normal record rules. The record implementation primarily exists as a composite type with some fields and on which we can call methods.

Furthermore, this type currently represents its type and param properties entirely in the compiler, i.e., not as fields in _domain. These properties are stored in the SubstitutionsMap for this type.

TODO: Should _domain store type and param fields directly for ‘idxType’, etc.?

Public Types

enum Kind

Values:

enumerator Rectangular
enumerator Associative
enumerator Unknown

Public Functions

inline Kind kind() const
int rankInt() const
inline const QualifiedType &rank() const
inline const QualifiedType &idxType() const
inline const QualifiedType &stridable() const
inline const QualifiedType &parSafe() const
~DomainType() = default
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override

Public Static Functions

static const DomainType *getGenericDomainType(Context *context)

Return the generic domain type

static const DomainType *getRectangularType(Context *context, const QualifiedType &rank, const QualifiedType &idxType, const QualifiedType &stridable)

Return a rectangular domain type

static const DomainType *getAssociativeType(Context *context, const QualifiedType &idxType, const QualifiedType &parSafe)

Return an associative domain type

class EnumType : public chpl::types::Type

Public Functions

~EnumType() = default
virtual void stringify(std::ostream &ss, StringifyKind stringKind) const override
inline const ID &id() const

Return the uAST ID associated with this EnumType

inline UniqueString name() const

Return the name of the uAST associated with this EnumType

inline bool isAbstract() const

An enum type is abstract if none of its constants have an initializer part defined.

inline bool isConcrete() const

An enum type is concrete if its first constant has an initializer part defined.

inline bool isSemiConcrete() const

An enum type is semi-concrete if some of its constants, but not the first constant, have an initializer part defined.

Public Static Functions

static const EnumType *get(Context *context, ID id, UniqueString name)

Get an enum type for an ID.

static const EnumType *getBoundKindType(Context *context)

Get the type for a range’s boundKind

static const EnumType *getIterKindType(Context *context)

Get the type representing an iterator’s “iteration kind”.

static const std::map<UniqueString, QualifiedType> *getParamConstantsMapOrNull(Context *context, const EnumType *et)

Given an enum type ‘et’, get a map from the name of each constant in ‘et’ to each constant represented as a param value. If there are multiple enum constants with the same name (which means the AST is semantically incorrect), then only the first constant is added to the map. Returns ‘nullptr’ if ‘et’ is ‘nullptr’ or has an empty ID, or if it does not have any AST representing it.

class ErroneousType : public chpl::types::Type

This class represents an erroneous type - that is, a type used as an error sentinel type. Errors with this type should be ignored.

Public Functions

~ErroneousType() = default

Public Static Functions

static const ErroneousType *get(Context *context)
class ExternType : public chpl::types::Type

Public Functions

virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
inline UniqueString linkageName() const
inline const ID &id() const

Public Static Functions

static const ExternType *get(Context *context, UniqueString linkageName, ID id)
class ImagType : public chpl::types::PrimitiveType

This class represents a imag type, e.g. imag or imag(32).

Public Functions

~ImagType() = default
inline virtual int bitwidth() const override

Returns the bit width selected for numeric types. Returns 8 for the default sized bool.

inline virtual bool isDefaultWidth() const override

Returns true if this PrimitiveType has the default width.

inline virtual const char *c_str() const override

Returns a C string for the name of this PrimitiveType.

Public Static Functions

static const ImagType *get(Context *context, int bitwidth)
class IntType : public chpl::types::PrimitiveType

This class represents an int type, e.g. int or int(32).

Public Functions

~IntType() = default
inline virtual int bitwidth() const override

Returns the bit width selected for numeric types. Returns 8 for the default sized bool.

inline virtual bool isDefaultWidth() const override

Returns true if this PrimitiveType has the default width.

inline virtual const char *c_str() const override

Returns a C string for the name of this PrimitiveType.

Public Static Functions

static const IntType *get(Context *context, int bitwidth)

Get an integer type. Bitwidth 0 creates a default width int.

static inline int defaultBitwidth()

what is stored in bitwidth_ for the default ‘int’?

class ManageableType : public chpl::types::CompositeType

General subclass for “things that have management”. Mostly this will be basic class types (e.g., the C in managed C?), but we also want to share the code for adding management and nilability to the generic class typeclass. So both C (and other Chapel subclasses of RootClass) and class will inherit from ManageableType.

Subclassed by chpl::types::AnyClassType, chpl::types::BasicClassType

class NilType : public chpl::types::Type

This class represents the type of nil.

Public Functions

~NilType() = default
virtual void stringify(std::ostream &ss, StringifyKind stringKind) const override

Public Static Functions

static const NilType *get(Context *context)
class NothingType : public chpl::types::Type

This class represents the nothing type.

Public Functions

~NothingType() = default
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override

Public Static Functions

static const NothingType *get(Context *context)
class Param

This is the base class for classes that represent a param value.

Functions like someParam->isUint32Param() / someParam->toUint32Param() are available and generated for all Param subclasses.

Public Functions

virtual ~Param() = 0
inline ParamTag tag() const

Returns the tag indicating which Param subclass this is.

inline bool operator==(const Param &other) const
inline bool operator!=(const Param &other) const
inline void mark(Context *context) const
bool completeMatch(const Param *other) const
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const
virtual void serialize(Serializer &ser) const

Public Static Functions

static optional<ParamTag> tryGuessParamTagFromType(const Type *type)
template<typename T>
static inline bool update(owned<T> &keep, owned<T> &addin)
static bool isParamOpFoldable(chpl::uast::PrimitiveTag op)
static QualifiedType fold(Context *context, const chpl::uast::AstNode *astForErr, chpl::uast::PrimitiveTag op, QualifiedType a, QualifiedType b)
static const Param *deserialize(Deserializer &des)
static uint64_t binStr2uint64(const char *str, size_t len, std::string &err)
static uint64_t octStr2uint64(const char *str, size_t len, std::string &err)
static uint64_t decStr2uint64(const char *str, size_t len, std::string &err)
static int64_t decStr2int64(const char *str, size_t len, std::string &err)
static uint64_t hexStr2uint64(const char *str, size_t len, std::string &err)
static double str2double(const char *str, size_t len, std::string &err)
static const EnumParam *getEnumParam(Context *context, ID id)
struct ComplexDouble

Public Functions

inline ComplexDouble(double re, double im)
inline bool operator==(const ComplexDouble &other) const
inline bool operator!=(const ComplexDouble &other) const
inline size_t hash() const

Public Members

double re
double im
struct EnumValue

Public Functions

inline EnumValue(ID id, std::string str)
inline bool operator==(const EnumValue &other) const
inline bool operator!=(const EnumValue &other) const
inline size_t hash() const

Public Members

ID id
std::string str
struct NoneValue

Public Functions

inline bool operator==(const NoneValue &other) const
inline bool operator!=(const NoneValue &other) const
inline size_t hash() const
class PrimitiveType : public chpl::types::Type

This class represents a primitive numeric type (e.g. bool, real(32)) that can have a width.

Subclassed by chpl::types::BoolType, chpl::types::ComplexType, chpl::types::ImagType, chpl::types::IntType, chpl::types::RealType, chpl::types::UintType

Public Functions

~PrimitiveType() = default
virtual int bitwidth() const = 0

Returns the bit width selected for numeric types. Returns 8 for the default sized bool.

virtual bool isDefaultWidth() const = 0

Returns true if this PrimitiveType has the default width.

virtual const char *c_str() const = 0

Returns a C string for the name of this PrimitiveType.

virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override

Compute a string representing this type.

Public Static Functions

static const PrimitiveType *getWithNameAndWidth(Context *context, UniqueString name, int bitwidth)

Get the PrimitiveType according to name and bitwidth, or nullptr if the name or bitwidth are invalid.

class QualifiedType

This class represents a combination of 3 things: a Type subclass pointer representing a Chapel type a Kind representing variable kind or intent (e.g. ref, value, const) a param value for when the Kind is PARAM.

This combination is the type information that the resolver needs.

Public Types

using Kind = uast::Qualifier

Public Functions

inline QualifiedType()
inline QualifiedType(Kind kind, const Type *type)
inline QualifiedType(Kind kind, const Type *type, const Param *param)
inline Kind kind() const

Returns the kind of the expression this QualifiedType represents

inline const Type *type() const

Returns the Type subclass that represents the type part of this QualifiedType

inline const Param *param() const

Returns the param value for this QualifiedType. Note that an uninstantiated param formal will have kind() == PARAM but won’t yet have a param value.

inline bool hasTypePtr() const
inline bool hasParamPtr() const
inline Type::Genericity typeGenericity() const

Returns the fast-to-compute genericity of the contained Type pointer. Does not include consideration of fields. If the type can have fields and they have not been considered, returns Type::MAYBE_GENERIC.

To consider fields, use the getTypeGenericity.

inline Type::Genericity genericity() const

Returns the fast-to-compute genericity of this QualifiedType. Does not include consideration of fields. If the type can have fields and they have not been considered, returns Type::MAYBE_GENERIC.

To consider fields, use the getTypeGenericity.

inline bool isUnknown() const
inline bool isUnknownKindOrType() const
inline bool isErroneousType() const
inline bool isGenericOrUnknown() const
inline bool isUnknownOrErroneous() const
inline bool isType() const

Returns true if kind is TYPE

inline bool isParam() const

Returns true if kind is PARAM

bool isParamTrue() const

Returns ‘true’ if storing a BoolParam ‘true’; ‘false’ otherwise

bool isParamFalse() const

Returns ‘true’ if storing a BoolParam ‘false’; ‘false’ otherwise

bool isParamKnownTuple() const

Returns ‘true’ if storing a tuple type whose constituent types are all known params.

inline bool isConst() const

Returns true if the value cannot be modified directly (but might be modified by some other aliasing variable). In particular, returns true for all kinds other than REF and VALUE.

inline bool isImmutable() const

Returns true if the type refers to something immutable (that cannot be modified by any task / other reference to it).

inline bool isRef() const

Returns true if the value is a reference, whether constant or mutable.

inline bool isIn() const

Returns true if the value is an in-intent formal, whether constant or mutable.

inline bool isNonConcreteIntent() const

Returns true if the kind is one of the non-concrete intents (unknown, default intent, or const intent) and false otherwise.

bool needsSplitInitTypeInfo(Context *context) const

Returns true if the type might need to get more info from split-init.

inline bool operator==(const QualifiedType &other) const
inline bool operator!=(const QualifiedType &other) const
inline void swap(QualifiedType &other)
inline size_t hash() const
void mark(Context *context) const
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const

Public Static Functions

static const char *kindToString(Kind k)
static bool update(QualifiedType &keep, QualifiedType &addin)

Public Static Attributes

static const Kind UNKNOWN = uast::Qualifier::UNKNOWN
static const Kind DEFAULT_INTENT = uast::Qualifier::DEFAULT_INTENT
static const Kind CONST_INTENT = uast::Qualifier::CONST_INTENT
static const Kind REF_MAYBE_CONST = uast::Qualifier::REF_MAYBE_CONST
static const Kind VAR = uast::Qualifier::VAR
static const Kind CONST_VAR = uast::Qualifier::CONST_VAR
static const Kind CONST_REF = uast::Qualifier::CONST_REF
static const Kind REF = uast::Qualifier::REF
static const Kind IN = uast::Qualifier::IN
static const Kind CONST_IN = uast::Qualifier::CONST_IN
static const Kind OUT = uast::Qualifier::OUT
static const Kind INOUT = uast::Qualifier::INOUT
static const Kind PARAM = uast::Qualifier::PARAM
static const Kind TYPE = uast::Qualifier::TYPE
static const Kind TYPE_QUERY = uast::Qualifier::TYPE_QUERY
static const Kind INDEX = uast::Qualifier::INDEX
static const Kind FUNCTION = uast::Qualifier::FUNCTION
static const Kind PARENLESS_FUNCTION = uast::Qualifier::PARENLESS_FUNCTION
static const Kind MODULE = uast::Qualifier::MODULE
static const Kind INIT_RECEIVER = uast::Qualifier::INIT_RECEIVER
class RealType : public chpl::types::PrimitiveType

This class represents a real type, e.g. real or real(32).

Public Functions

~RealType() = default
inline virtual int bitwidth() const override

Returns the bit width selected for numeric types. Returns 8 for the default sized bool.

inline virtual bool isDefaultWidth() const override

Returns true if this PrimitiveType has the default width.

inline virtual const char *c_str() const override

Returns a C string for the name of this PrimitiveType.

Public Static Functions

static const RealType *get(Context *context, int bitwidth)
class RecordType : public chpl::types::CompositeType

This class represents a record type, e.g., if we have record R, then R refers to a RecordType.

Public Functions

~RecordType() = default
inline const RecordType *instantiatedFrom() const

If this type represents an instantiated type, returns the type it was instantiated from.

This is just instantiatedFromCompositeType() with the result cast to RecordType.

Public Static Functions

static const RecordType *get(Context *context, ID id, UniqueString name, const RecordType *instantiatedFrom, CompositeType::SubstitutionsMap subs)

Get a record type for an ID, possibly instantiated with substitutions

class TupleType : public chpl::types::CompositeType

This class represents a tuple type e.g. (int, real).

Public Functions

~TupleType() = default
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
inline int numElements() const

Returns the number of tuple elements. Returns ‘-1’ if the size is not known.

QualifiedType elementType(int i) const

Return the type of the i’th element

inline bool isStarTuple() const

Return true if this is a star tuple - that is, all of the element types are the same.

inline bool isParamKnown() const

Return true if this tuple’s elements are all non-generic params, e.g., (param b: bool = true, param i: int = 0).

inline bool isVarArgTuple() const
inline bool isKnownSize() const
QualifiedType starType() const
const TupleType *toValueTuple(Context *context, bool makeConst = false) const

Return the value tuple variant of this tuple type. Element types are made const if makeConst is set to true.

const TupleType *toReferentialTuple(Context *context, bool makeConst = false) const

Return the referential tuple variant of this tuple type. Element types are made const if makeConst is set to true.

Public Static Functions

static const TupleType *getValueTuple(Context *context, std::vector<const Type*> eltTypes, bool makeConst = false)

Return a value tuple type based on the vector of actual types. The types are made const if makeConst is set to true.

static const TupleType *getReferentialTuple(Context *context, std::vector<const Type*> eltTypes, bool makeConst = false)

Return a referential tuple type based on the vector of actual types. The types are made const if makeConst is set to true.

static const TupleType *getQualifiedTuple(Context *context, std::vector<QualifiedType> eltTypes)
static const TupleType *getStarTuple(Context *context, QualifiedType paramSize, QualifiedType starEltType)
static const TupleType *getGenericTupleType(Context *context)

Return the generic tuple type _tuple

class Type

This is the base class for classes that represent a type.

Functions like someType->isRecord() / someType->toRecord() are available and generated for all Type subclasses.

Subclassed by chpl::types::AnyType, chpl::types::BuiltinType, chpl::types::CPtrType, chpl::types::CStringType, chpl::types::ClassType, chpl::types::CompositeType, chpl::types::EnumType, chpl::types::ErroneousType, chpl::types::ExternType, chpl::types::NilType, chpl::types::NothingType, chpl::types::PrimitiveType, chpl::types::UnknownType, chpl::types::VoidType

Public Types

enum Genericity

Values:

enumerator CONCRETE

A concrete type e.g. ‘int’

enumerator GENERIC

A generic type, e.g. ‘integral’

enumerator GENERIC_WITH_DEFAULTS

A type that is generic but has a default for each generic field. E.g. ‘record R { type t = int; }’.

enumerator MAYBE_GENERIC

When we need more information to decide if the type is generic. It might depend on fields, e.g.

Public Functions

virtual Genericity genericity() const = 0

This function returns an enum Genericity value to indicate if the type is concrete, generic, generic with defaults, or maybe generic (e.g. depending on the fields).

This function needs to be defined by subclasses.

virtual ~Type() = 0
inline TypeTag tag() const

Returns the tag indicating which Type subclass this is.

inline bool operator==(const Type &other) const
inline bool operator!=(const Type &other) const
inline void mark(Context *context) const
bool completeMatch(const Type *other) const
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const
template<typename TargetType>
inline bool is() const

Check if this type is particular subclass. The call someType->is<IntType>() returns whether or not someType is an IntType.

bool isStringType() const

returns true if this represents the string type

bool isBytesType() const

returns true if this represents the bytes type

bool isLocaleType() const

returns true if this represents the locale type

inline bool isStringLikeType() const

returns true if it’s string, bytes, or c_string type

inline bool isIntegralType() const

returns true if it’s an int or uint type of any width

inline bool isNumericType() const

returns true if it’s a numeric type of any width; that includes int, uint, real, imag, complex

inline bool isNumericOrBoolType() const

returns true if it’s a numeric type or bool type of any width

inline bool isPtrType() const

returns true for a type that is a kind of pointer

bool isNilablePtrType() const

returns true for a pointer type that can store nil

bool isUserRecordType() const

Returns true for a type that is a user-defined record. The compiler treats some internal types as records but the language design does not insist that they are.

bool hasPragma(Context *context, uast::pragmatags::PragmaTag p) const

Returns true if the this type has the pragma ‘p’ attached to it.

const CompositeType *getCompositeType() const

If ‘this’ is a CompositeType, return it. If ‘this’ is a ClassType, return the basicClassType. Otherwise, returns nullptr.

template<typename TargetType>
inline const TargetType *to() const

Try cast to a type known at compile-time. The call someType->to<IntType>() returns nullptr if someType is not an IntType, and cast to IntType if it is.

template<typename TargetType>
inline TargetType *to()

Public Static Functions

template<typename T>
static inline bool update(owned<T> &keep, owned<T> &addin)
static void gatherBuiltins(Context *context, std::unordered_map<UniqueString, const Type*> &map)
static bool isPod(Context *context, const Type *t)

Given a type ‘t’, determine if ‘t’ is “plain-old-data” (POD).

If ‘t’ is marked with the pragma “plain old data” then it is always considered to be POD, and no further evaluation takes place.

If ‘t’ is the sync type, the single type, an atomic type, the array type, or the domain type, then ‘t’ is not POD.

If ‘t’ is a class with ‘owned’ or ‘shared’ management, then ‘t’ is not POD.

If ‘t’ is a record, class, or union type, and any member of ‘t’ is not POD, then ‘t’ is not POD.

If ‘t’ is a record or union type with a user-defined ‘deinit’, ‘init=’, or assignment operator, then ‘t’ is not POD.

If ‘t’ is generic then it is considered to be not POD for the purposes of this evaluation.

All other cases are considered to be POD.

class UintType : public chpl::types::PrimitiveType

This class represents a uint type, e.g. uint or uint(32).

Public Functions

~UintType() = default
inline virtual int bitwidth() const override

Returns the bit width selected for numeric types. Returns 8 for the default sized bool.

inline virtual bool isDefaultWidth() const override

Returns true if this PrimitiveType has the default width.

inline virtual const char *c_str() const override

Returns a C string for the name of this PrimitiveType.

Public Static Functions

static const UintType *get(Context *context, int bitwidth)
static inline int defaultBitwidth()

what is stored in bitwidth_ for the default ‘uint’?

class UnionType : public chpl::types::CompositeType

This class represents a union type, e.g., if we have union U, then U refers to a UnionType.

Public Functions

~UnionType() = default
inline const UnionType *instantiatedFrom() const

If this type represents an instantiated type, returns the type it was instantiated from.

This is just instantiatedFromCompositeType() with the result cast to UnionType.

Public Static Functions

static const UnionType *get(Context *context, ID id, UniqueString name, const UnionType *instantiatedFrom, CompositeType::SubstitutionsMap subs)
class UnknownType : public chpl::types::Type

This class represents an unknown type when the type is not known because it is not yet established.

Public Functions

~UnknownType() = default

Public Static Functions

static const UnknownType *get(Context *context)
class VoidType : public chpl::types::Type

This class represents the void type.

Public Functions

~VoidType() = default
virtual void stringify(std::ostream &ss, StringifyKind stringKind) const override

Public Static Functions

static const VoidType *get(Context *context)
namespace detail

Functions

template<typename T>
const T *typeToConst(const Type *type) = delete
template<typename T>
T *typeTo(Type *type) = delete
template<typename T>
bool typeIs(const Type *type) = delete
namespace paramtags

Enums

enum ParamTag

This enum is used to identify which union elements a Param stores

Values:

namespace typetags

Enums

enum TypeTag

This enum is used to identify which ASTType subclass a node is.

Values:

enumerator NUM_TYPE_TAGS

Functions

const char *tagToString(TypeTag tag)