Types¶
This section contains definitions declared in the chpl::types namespace.
-
namespace chpl::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¶
- #include <AnyClassType.h>
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¶
- #include <AnyType.h>
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¶
- #include <ArrayType.h>
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 *getArrayType(Context *context, const QualifiedType &domainType, const QualifiedType &eltType)¶
-
inline QualifiedType domainType() const¶
-
class BasicClassType : public chpl::types::ManageableType¶
- #include <BasicClassType.h>
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)¶
-
~BasicClassType() = default¶
-
class BoolType : public chpl::types::PrimitiveType¶
- #include <BoolType.h>
This class represents a bool type, e.g.
bool
orbool(32)
.Note that
bool
normally has width8
butbool(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.
-
~BoolType() = default¶
-
class BuiltinType : public chpl::types::Type¶
- #include <BuiltinType.h>
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¶
- #include <ClassType.h>
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 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)¶
-
~ClassType() = default¶
-
class ClassTypeDecorator¶
- #include <ClassTypeDecorator.h>
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¶
- #include <ComplexType.h>
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 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 ComplexType *get(Context *context, int bitwidth)¶
-
~ComplexType() = default¶
-
class CompositeType : public chpl::types::Type¶
- #include <CompositeType.h>
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 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 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.
-
using SubstitutionsMap = std::unordered_map<ID, types::QualifiedType>¶
-
class CPtrType : public chpl::types::Type¶
Public Functions
-
inline bool isVoidPtr() const¶
-
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override¶
-
inline bool isVoidPtr() const¶
-
class CStringType : public chpl::types::Type¶
- #include <CStringType.h>
This class represents the string type.
Public Functions
-
~CStringType() = default¶
Public Static Functions
-
static const CStringType *get(Context *context)¶
-
~CStringType() = default¶
-
class DomainType : public chpl::types::CompositeType¶
- #include <DomainType.h>
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 Functions
-
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
-
int rankInt() const¶
-
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
-
~EnumType() = default¶
-
class ErroneousType : public chpl::types::Type¶
- #include <ErroneousType.h>
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)¶
-
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const override¶
-
class ImagType : public chpl::types::PrimitiveType¶
- #include <ImagType.h>
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 IntType : public chpl::types::PrimitiveType¶
- #include <IntType.h>
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 ManageableType : public chpl::types::CompositeType¶
- #include <ManageableType.h>
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¶
- #include <NilType.h>
This class represents the type of
nil
.Public Functions
-
~NilType() = default¶
-
~NilType() = default¶
-
class NothingType : public chpl::types::Type¶
- #include <NothingType.h>
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¶
- #include <Param.h>
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¶
Public Static Functions
-
static QualifiedType fold(Context *context, 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 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 NoneValue¶
-
virtual ~Param() = 0¶
-
class PrimitiveType : public chpl::types::Type¶
- #include <PrimitiveType.h>
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 QualifiedType¶
- #include <QualifiedType.h>
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 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 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 isNonConcreteIntent() const¶
Returns true if the kind is one of the non-concrete intents (unknown, default intent, or const intent) and false otherwise.
-
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 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¶
-
inline QualifiedType()¶
-
class RealType : public chpl::types::PrimitiveType¶
- #include <RealType.h>
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¶
- #include <RecordType.h>
This class represents a record type, e.g., if we have
record R
, thenR
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
-
~RecordType() = default¶
-
class TupleType : public chpl::types::CompositeType¶
- #include <TupleType.h>
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¶
Public Static Functions
-
static const TupleType *getValueTuple(Context *context, std::vector<const Type*> eltTypes)¶
Return a value tuple type based on the vector of actual types.
-
static const TupleType *getReferentialTuple(Context *context, std::vector<const Type*> eltTypes)¶
Return a referential tuple type based on the vector of actual types.
-
static const TupleType *getQualifiedTuple(Context *context, std::vector<QualifiedType> eltTypes)¶
-
static const TupleType *getStarTuple(Context *context, QualifiedType paramSize, QualifiedType starEltType)¶
-
~TupleType() = default¶
-
class Type¶
- #include <Type.h>
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.
-
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¶
-
virtual void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
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.
-
const CompositeType *getCompositeType() const¶
If ‘this’ is a CompositeType, return it. If ‘this’ is a ClassType, return the basicClassType. Otherwise, returns nullptr.
-
enum Genericity¶
-
class UintType : public chpl::types::PrimitiveType¶
- #include <UintType.h>
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¶
- #include <UnionType.h>
This class represents a union type, e.g., if we have
union U
, thenU
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)¶
-
~UnionType() = default¶
-
class UnknownType : public chpl::types::Type¶
- #include <UnknownType.h>
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¶
- #include <VoidType.h>
This class represents the void type.
Public Functions
-
~VoidType() = default¶
-
~VoidType() = default¶
-
namespace paramtags¶
-
size_t hashSubstitutionsMap(const CompositeType::SubstitutionsMap &subs)¶