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)
-
~AnyClassType() = default
-
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
-
~AnyType() = default
-
class ArrayType : public chpl::types::CompositeType
This class represents an array type e.g.
[1..10] int
.Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
inline QualifiedType domainType() const
-
inline QualifiedType eltType() const
-
const RuntimeType *runtimeType(Context *context) const
-
~ArrayType() = default
-
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
Public Static Functions
-
static const ArrayType *getArrayType(Context *context, const QualifiedType &instance, const QualifiedType &domainType, const QualifiedType &eltType)
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
class BasicClassType : public chpl::types::ManageableType
This class represents an class type (e.g.
class C
) without considering decorators.Public Functions
-
~BasicClassType() = default
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
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(Context *context, 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)
-
~BasicClassType() = default
-
class BoolType : public chpl::types::PrimitiveType
This class represents the
bool
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.
-
~BoolType() = default
-
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)
-
~BuiltinType() = default
-
class ClassType : public chpl::types::Type
This class represents an class type including a memory management decorator. E.g. if we have
class C
, thenborrowed C?
orshared C
are ClassTypes.Public Functions
-
~ClassType() = default
-
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
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
-
const RecordType *managerRecordType(Context *context) const
Returns the recordType for the manager. This will be instantiated, e.g. as ‘_owned(C)’ for some class C.
Public Static Functions
-
static const ClassType *get(Context *context, const ManageableType *manageableType, const Type *manager, ClassTypeDecorator decorator)
-
~ClassType() = default
-
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
-
enumerator BORROWED
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)
-
enum ClassTypeDecoratorEnum
-
class ComplexType : public chpl::types::PrimitiveType
This class represents a complex type, e.g.
complex
orcomplex(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)
-
~ComplexType() = default
-
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 fromt
toint
.Similarly, if we have
proc f(a, param b) { }
Then
f(1.0, 2)
creates an instantiation off
with the SubstitutionsMap containing a mapping froma
toreal
and a mapping fromb
toint
.
-
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 uast::Decl::Linkage linkage() const
Returns the linkage of the underlying uAST for this composite.
-
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 void stringifySubstitutions(std::ostream &ss, chpl::StringifyKind stringKind, const SubstitutionsMap &subs)
-
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 const RecordType *getDistributionType(Context *context)
Get the _distribution type
-
static const RecordType *getOwnedRecordType(Context *context, const BasicClassType *bct, const ClassTypeDecorator ©NilabilityFrom)
Get the record _owned implementing owned
Get the record _shared implementing shared
-
static const RecordType *getSyncType(Context *context)
Get the sync type (_syncvar record)
-
using SubstitutionsMap = std::unordered_map<ID, types::QualifiedType>
-
class CPtrType : public chpl::types::PtrType
Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
inline bool isConst() const
-
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
Public Static Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
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)
-
~CStringType() = default
-
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
Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
inline bool isSubdomain() const
-
inline bool isSparse() const
-
inline const DomainType *parentDomain() const
-
int rankInt() const
-
inline const QualifiedType &rank() const
-
inline const QualifiedType &idxType() const
-
inline const QualifiedType &strides() const
-
inline const QualifiedType &parSafe() const
-
const RuntimeType *runtimeType(Context *context) 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 &instance, const QualifiedType &rank, const QualifiedType &idxType, const QualifiedType &strides)
Return a rectangular domain type
-
static const DomainType *getAssociativeType(Context *context, const QualifiedType &instance, const QualifiedType &idxType, const QualifiedType &parSafe)
Return an associative domain type
-
static const DomainType *getSubdomainType(Context *context, const QualifiedType &instance, const QualifiedType &parentDomain)
Return a subdomain type
-
static const DomainType *getSparseType(Context *context, const QualifiedType &instance, const QualifiedType &parentDomain)
Return a sparse domain type
-
static const QualifiedType &getDefaultDistType(Context *context)
Get the default distribution type
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
class EnumType : public chpl::types::Type
Public Functions
-
~EnumType() = default
-
virtual void stringify(std::ostream &ss, StringifyKind stringKind) const override
-
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 *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.
-
~EnumType() = default
-
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)
-
~ErroneousType() = default
-
class ExternType : public chpl::types::Type
Public Functions
-
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
-
inline UniqueString linkageName() const
Public Static Functions
-
static const ExternType *get(Context *context, UniqueString linkageName, ID id)
-
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
-
class FnIteratorType : public chpl::types::IteratorType
Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
inline const resolution::TypedFnSignature *iteratorFn() const
-
inline const QualifiedType &yieldType() const
Public Static Functions
-
static const FnIteratorType *get(Context *context, const resolution::PoiScope *poiScope, const resolution::TypedFnSignature *iteratorFn, QualifiedType yieldType)
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
class HeapBufferType : public chpl::types::PtrType
Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
Public Static Functions
-
static const HeapBufferType *get(Context *context)
-
static const HeapBufferType *get(Context *context, const Type *eltType)
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
class ImagType : public chpl::types::PrimitiveType
This class represents a imag type, e.g.
imag
orimag(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.
-
~ImagType() = default
-
class InterfaceType : public chpl::types::Type
Public Types
-
using SubstitutionsMap = CompositeType::SubstitutionsMap
Public Functions
-
const ID &idForAssociatedType(Context *context, UniqueString name) const
-
bool isInstantiationOf(Context *context, const InterfaceType *genericType) const
Returns true if ‘this’ is an instantiation of genericType
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
inline UniqueString name() const
-
inline const SubstitutionsMap &substitutions() const
-
virtual void stringify(std::ostream &ss, StringifyKind stringKind) const override
Public Static Functions
-
static const InterfaceType *get(Context *context, ID id, UniqueString name, SubstitutionsMap subs)
-
static const InterfaceType *getContextManagerType(Context *context)
-
static const InterfaceType *withTypes(Context *context, const InterfaceType *ift, std::vector<QualifiedType> types)
-
using SubstitutionsMap = CompositeType::SubstitutionsMap
-
class IntType : public chpl::types::PrimitiveType
This class represents an int type, e.g.
int
orint(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.
-
~IntType() = default
-
class IteratorType : public chpl::types::Type
Subclassed by chpl::types::FnIteratorType, chpl::types::LoopExprIteratorType, chpl::types::PromotionIteratorType
Public Functions
-
inline const resolution::PoiScope *poiScope() const
-
inline const resolution::PoiScope *poiScope() const
-
class LoopExprIteratorType : public chpl::types::IteratorType
Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
inline const QualifiedType &yieldType() const
-
inline bool isZippered() const
-
inline bool supportsParallel() const
-
inline const QualifiedType &iterand() const
Public Static Functions
-
static const LoopExprIteratorType *get(Context *context, QualifiedType yieldType, const resolution::PoiScope *poiScope, bool isZippered, bool supportsParallel, QualifiedType iterand, ID sourceLocation)
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
class ManageableType : public chpl::types::CompositeType
General subclass for “things that have management”. Mostly this will be basic class types (e.g., the
C
inmanaged C?
), but we also want to share the code for adding management and nilability to the genericclass
typeclass. So bothC
(and other Chapel subclasses ofRootClass
) andclass
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
-
~NilType() = default
-
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)
-
~NothingType() = default
-
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
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const
-
virtual void serialize(Serializer &ser) const
-
virtual bool isNonZero() const = 0
-
virtual bool isZero() const = 0
Public Static Functions
-
static bool castAllowed(Context *context, const QualifiedType &a, const QualifiedType &b)
-
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)
-
struct ComplexDouble
Public Functions
-
inline ComplexDouble(double re, double im)
-
inline explicit operator bool() const
-
inline bool operator==(const ComplexDouble &other) const
-
inline bool operator!=(const ComplexDouble &other) const
-
inline size_t hash() const
-
inline ComplexDouble(double re, double im)
-
struct EnumValue
-
struct NoneValue
-
virtual ~Param() = 0
-
class PlaceholderType : public chpl::types::Type
Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override
Public Static Functions
-
static const PlaceholderType *get(Context *context, ID id)
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
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.
-
~PrimitiveType() = default
-
class PromotionIteratorType : public chpl::types::IteratorType
Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
inline const resolution::TypedFnSignature *scalarFn() const
-
inline const QualifiedType &yieldType() const
-
inline const resolution::PromotedFormalMap &promotedFormals() const
Public Static Functions
-
static const PromotionIteratorType *get(Context *context, const resolution::PoiScope *poiScope, const resolution::TypedFnSignature *scalarFn, QualifiedType retType, resolution::PromotedFormalMap promotedFormals)
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
class PtrType : public chpl::types::Type
Subclassed by chpl::types::CPtrType, chpl::types::HeapBufferType
-
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 Functions
-
inline QualifiedType()
-
inline const QualifiedType substitute(Context *context, const PlaceholderMap &subs) const
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map. See also Type::substitute.
-
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’ or a numeric param storing nonzero; ‘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 isTypeQuery() const
Returns true if kind is TYPE_QUERY
-
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 stringify(std::ostream &ss, chpl::StringifyKind stringKind) const
Public Static Functions
-
static QualifiedType makeParamBool(Context *context, bool b)
-
static QualifiedType makeParamInt(Context *context, int64_t i)
-
static QualifiedType makeParamString(Context *context, UniqueString s)
-
static QualifiedType makeParamString(Context *context, std::string s)
-
static QualifiedType createParamBool(Context *context, bool x)
-
static bool update(QualifiedType &keep, QualifiedType &addin)
Public Static Attributes
-
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 TYPE_QUERY = uast::Qualifier::TYPE_QUERY
-
static const Kind PARENLESS_FUNCTION = uast::Qualifier::PARENLESS_FUNCTION
-
static const Kind INIT_RECEIVER = uast::Qualifier::INIT_RECEIVER
-
inline QualifiedType()
-
class RealType : public chpl::types::PrimitiveType
This class represents a real type, e.g.
real
orreal(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.
-
~RealType() = default
-
class RecordType : public chpl::types::CompositeType
This class represents a record type, e.g., if we have
record R
, thenR
refers to a RecordType.Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
~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
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
class RuntimeType : public chpl::types::Type
This class encodes Chapel’s notion of runtime types. In production, calls to functions tagged with “runtime type init fn” are adjusted to store their arguments into a new record. This record exists at runtime, and is used as part of Chapel’s runtime type support.
Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
inline const resolution::TypedFnSignature *initializer() const
Public Static Functions
-
static const RuntimeType *get(Context *context, const resolution::TypedFnSignature *initializer)
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
class TupleType : public chpl::types::CompositeType
This class represents a tuple type e.g.
(int, real)
.Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
~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.
-
const 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
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, bool isVarArgTuple = false)
-
static const TupleType *getVarArgTuple(Context *context, QualifiedType paramSize, QualifiedType starEltType)
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
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::CStringType, chpl::types::ClassType, chpl::types::CompositeType, chpl::types::EnumType, chpl::types::ErroneousType, chpl::types::ExternType, chpl::types::InterfaceType, chpl::types::IteratorType, chpl::types::NilType, chpl::types::NothingType, chpl::types::PlaceholderType, chpl::types::PrimitiveType, chpl::types::PtrType, chpl::types::RuntimeType, 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.
-
enumerator CONCRETE
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 virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
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 isCArrayType(Context *context, const Type *&outEltType, const IntParam *&outSize) const
returns true if this represents the c_array type. If it does, sets outEltType and outSize to the element type and size of the c_array.
-
bool isOwnedRecordType() const
returns true if this represents the _owned builtin record
returns true if this represents the _shared builtin record
-
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 isPointerLikeType() 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 isRecordLike() const
-
bool hasPragma(Context *context, uast::pragmatags::PragmaTag p) const
Returns true if 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()
-
template<typename ReturnType, typename Visitor>
inline ReturnType dispatch(Visitor &v) const The dispatch function supports calling a method according to the tag (aka runtime type) of a type node.
It is a template and the Visitor argument should provide functions like
MyReturnType MyVisitor::visit(const types::Type* t); MyReturnType MyVisitor::visit(const types::BoolType* t);
and these will be invoked according to C++ overload resolution (where in particular an exact match will be preferred).
It is generally necessary to specify the ReturnType when calling it, e.g.
t->dispatch<MyReturnType>(myVisitor);
The return type currently needs to be default constructable.
Public Static Functions
-
static void gatherBuiltins(Context *context, std::unordered_map<UniqueString, const Type*> &map)
-
template<typename TargetType>
static inline const TargetType *substitute(Context *context, const TargetType *type, const PlaceholderMap &subs) For a given subclass of ‘Type’, replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map, handling the case in which the type is null.
Since replacing placeholders ought not to change which subclass the type is, asserts and casts the result back to the same subclass.
-
static bool isPod(chpl::resolution::ResolutionContext *rc, 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.
-
static bool isDefaultInitializable(chpl::resolution::ResolutionContext *rc, const Type *t)
-
enum Genericity
-
class UintType : public chpl::types::PrimitiveType
This class represents a uint type, e.g.
uint
oruint(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.
-
~UintType() = default
-
class UnionType : public chpl::types::CompositeType
This class represents a union type, e.g., if we have
union U
, thenU
refers to a UnionType.Public Functions
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
replaces placeholders (as in PlaceholderType in the type) according to their values in the ‘subs’ map.
-
~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)
-
inline virtual const Type *substitute(Context *context, const PlaceholderMap &subs) const override
-
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)
-
~UnknownType() = default
-
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
-
~VoidType() = default
-
namespace detail
Functions
-
namespace paramtags
-
size_t hashSubstitutionsMap(const CompositeType::SubstitutionsMap &subs)