Resolution¶
This section contains definitions declared in the chpl::resolution namespace.
-
namespace chpl::resolution¶
Typedefs
-
using KindRequirement = llvm::Optional<chpl::types::QualifiedType::Kind>¶
An optional additional constraint on the kind of a type. Used in commonType to serve the case of functions that enforce param, type, or const returs.
-
using SubstitutionsMap = types::CompositeType::SubstitutionsMap¶
See the documentation for types::CompositeType::SubstitutionsMap.
-
using DeclMap = std::unordered_map<UniqueString, OwnedIdsWithName>¶
A DeclMap has key = string name, and value = vector of ID of a NamedDecl Using an ID here prevents needing to recompute the Scope if (say) something in the body of a Function changed.
-
using LookupConfig = unsigned int¶
Enums
-
enum DefaultsPolicy¶
Values:
-
enumerator IGNORE_DEFAULTS¶
Do not use default values when determining field type.
-
enumerator USE_DEFAULTS¶
Use default values when determining field type.
-
enumerator USE_DEFAULTS_OTHER_FIELDS¶
Do not use default values for the current field (i.e. when set up for resolving a field statement), but do use default values for all other fields. This policy is useful when determining the genericity of individual fields.
-
enumerator IGNORE_DEFAULTS¶
Functions
-
static inline CanPassResult canPass(Context *context, const types::QualifiedType &actualType, const types::QualifiedType &formalType)¶
Given an argument with QualifiedType actualType, can that argument be passed to a formal with QualifiedType formalType?
Note that a result with passes() and instantiates() indicates that the compiler should try instantiating. Once instantiation occurs, the compiler may figure out that the argument cannot be passed.
-
llvm::Optional<chpl::types::QualifiedType> commonType(Context *context, const std::vector<chpl::types::QualifiedType> &types, KindRequirement requiredKind = KindRequirement())¶
Given a (non-empty) list of types (e.g., the types of various return statements in a function), determine the type, if any, that can be used to represent all of them. Returns an llvm::Optional that contains the qualified type if one is found, or is empty otherwise.
If useRequiredKind=true is specified, the requiredKind argument is treated as a strict constraint on the kinds of the given types. For instance, specifying requiredKind=PARAM and giving non-param types will result in failure to find a common type, even if the types can otherwise by unified.
-
MostSpecificCandidates findMostSpecificCandidates(Context *context, const std::vector<const TypedFnSignature*> &lst, const CallInfo &call, const Scope *callInScope, const PoiScope *callInPoiScope)¶
Given the result of filterCandidatesInstantiating, run overload resolution aka disambiguation to determine the most specific functions.
If a most specific function cannot be found due to ambiguity, returns an empty MostSpecificCandidates that also tracks the fact there was an ambiguity (so it can be differentiated from no candidates).
-
types::QualifiedType::Kind resolveIntent(const types::QualifiedType &t, bool isThis)¶
Resolve the intent of a formal argument based on its type and (possibly generic) intent. For example ‘const’ is a generic intent and it has different behavior depending on the type.
The argument ‘isThis’ indicates if the formal argument is the ‘this’ method receiver argument.
The generic and resolved intents are all represented as QualifiedType::Kind.
If the type is not known or only partially known, this function can return a generic intent.
-
const ResolutionResultByPostorderID &resolveModuleStmt(Context *context, ID id)¶
Resolve a module-level statement or variable declaration.
-
const ResolutionResultByPostorderID &resolveModule(Context *context, ID id)¶
Resolve the contents of a Module
-
const ResolutionResultByPostorderID &scopeResolveModule(Context *context, ID id)¶
Resolve the contents of a Module but don’t resolve any paren-ful function calls or establish types.
-
const types::QualifiedType &typeForModuleLevelSymbol(Context *context, ID id)¶
Compute the type for a NamedDecl with a particular id.
-
const types::QualifiedType &typeForBuiltin(Context *context, UniqueString name)¶
Compute the type for a Builtin type using just its name
-
types::QualifiedType typeForLiteral(Context *context, const uast::Literal *literal)¶
Compute the type for a literal
-
types::QualifiedType getInstantiationType(Context *context, types::QualifiedType actualType, types::QualifiedType formalType)¶
Returns the type that results when instantiating formalType, which must be generic, with actualType.
-
const TypedFnSignature *typedSignatureInitial(Context *context, const UntypedFnSignature *untypedSig)¶
Compute a TypedFnSignature from an UntypedFnSignature. (An UntypedFnSignature can be computed with UntypedFnSignature::get()). The TypedFnSignature will represent generic and potentially unknown types if the function is generic.
-
const types::Type *initialTypeForTypeDecl(Context *context, ID declId)¶
Returns a Type that represents the initial type provided by a TypeDecl (e.g. Class, Record, etc). This type does not store the fields.
-
const ResolvedFields &resolveFieldDecl(Context *context, const types::CompositeType *ct, ID fieldId, DefaultsPolicy defaultsPolicy)¶
Resolve a single field decl (which could be e.g. a MultiDecl) within a CompositeType.
The result will not have summary information computed. fieldsForTypeDecl should be used instead unless there is a reason that one-at-a-time resolution is important.
-
const ResolvedFields &fieldsForTypeDecl(Context *context, const types::CompositeType *ct, DefaultsPolicy defaultsPolicy)¶
Compute the types of the fields for a CompositeType (such as one returned by initialTypeForTypeDecl).
If useGenericFormalDefaults is true, a generic field like record R { type t = int; } will be assumed to have the default value (int in the above case). Otherwise, these fields will remain generic.
Even if useGenericFormalDefaults is set, the default value will be ignored if the field already has a substitution in the CompositeType.
The returned fields do not include any parent class fields.
-
bool isNameOfField(Context *context, UniqueString name, const types::Type *t)¶
Return true if ‘name’ is the name of a field for type ‘t’
-
const types::QualifiedType typeWithDefaults(Context *context, types::QualifiedType t)¶
Computes the version of a type assuming that defaults for generics are needed. So, for ‘record R { type t = int; }’, this will return R(int).
-
types::Type::Genericity getTypeGenericityIgnoring(Context *context, const types::Type *t, std::set<const types::Type*> &ignore)¶
Compute whether a type is generic or not. Considers the field of a record/class. For a UnknownType, returns MAYBE_GENERIC.
Considers types in the ignore set as concrete.
-
types::Type::Genericity getTypeGenericityIgnoring(Context *context, types::QualifiedType qt, std::set<const types::Type*> &ignore)¶
Compute whether a QualifiedType is generic or not. Considers the field of a record/class. For a UnknownType, returns MAYBE_GENERIC.
Considers types in the ignore set as concrete.
-
types::Type::Genericity getTypeGenericity(Context *context, const types::Type *t)¶
Compute whether a QualifiedType is generic or not. Considers the field of a record/class. For a UnknownType, returns MAYBE_GENERIC.
-
types::Type::Genericity getTypeGenericity(Context *context, types::QualifiedType qt)¶
Compute whether a QualifiedType is generic or not. Considers the field of a record/class. For a UnknownType, returns MAYBE_GENERIC.
-
const TypedFnSignature *typeConstructorInitial(Context *context, const types::Type *t)¶
Compute an initial TypedFnSignature for a type constructor for a particular type. If some fields of
t
are still generic, it will be necessary to call instantiateSignature on it.
-
const TypedFnSignature *instantiateSignature(Context *context, const TypedFnSignature *sig, const CallInfo &call, const PoiScope *poiScope)¶
Instantiate a TypedFnSignature from the result of typedSignatureInitial, a CallInfo describing the types at the call site, and a point-of-instantiation scope representing the POI scope of the call
Returns nullptr if the instantiation failed.
-
const ResolvedFunction *resolveFunction(Context *context, const TypedFnSignature *sig, const PoiScope *poiScope)¶
Compute a ResolvedFunction given a TypedFnSignature. Checks the generic cache for potential for reuse. When reuse occurs, the ResolvedFunction might point to a different TypedFnSignature.
-
const ResolvedFunction *resolveConcreteFunction(Context *context, ID id)¶
Helper to resolve a concrete function using the above queries. Will return
nullptr
if the function is generic or has awhere false
.
-
const ResolvedFunction *scopeResolveFunction(Context *context, ID id)¶
Compute a ResolvedFunction given a TypedFnSignature, but don’t do full resolution of types or paren-ful calls in the body.
-
const ResolvedFunction *resolveOnlyCandidate(Context *context, const ResolvedExpression &r)¶
Returns the ResolvedFunction called by a particular ResolvedExpression, if there was exactly one candidate. Otherwise, it returns nullptr.
This function does not handle return intent overloading.
-
const types::QualifiedType &returnType(Context *context, const TypedFnSignature *sig, const PoiScope *poiScope)¶
Compute the return/yield type for a function.
TODO: If the function returns a param, the param’s value may not be available. This is because the function body is not resolved when the return type is explicitly declared. We probably still want to compute the value in such cases, though.
-
const std::vector<const TypedFnSignature*> &filterCandidatesInitial(Context *context, std::vector<BorrowedIdsWithName> lst, CallInfo call)¶
Compute the (potentially generic) TypedFnSignatures of possibly applicable candidate functions from a list of visible functions.
-
void filterCandidatesInstantiating(Context *context, const std::vector<const TypedFnSignature*> &lst, const CallInfo &call, const Scope *inScope, const PoiScope *inPoiScope, std::vector<const TypedFnSignature*> &result)¶
Further filter the result of filterCandidatesInitial down by doing instantiations. After this, all of the resulting TypedFnSignatures are actually candidates.
If instantiation occurs, gets/creates the new POI scope for inScope/inPoiScope.
-
CallResolutionResult resolveCall(Context *context, const uast::Call *call, const CallInfo &ci, const Scope *inScope, const PoiScope *inPoiScope)¶
Given a uast::Call, a CallInfo representing the call, a Scope representing the scope of that call, and a PoiScope representing the point-of-instantiation scope of that call, find the most specific candidates as well as the point-of-instantiation scopes that were used when resolving them.
-
CallResolutionResult resolveGeneratedCall(Context *context, const uast::AstNode *astForErr, const CallInfo &ci, const Scope *inScope, const PoiScope *inPoiScope)¶
Given a CallInfo representing a call, a Scope representing the scope of that call, and a PoiScope representing the point-of-instantiation scope of that call, find the most specific candidates as well as the point-of-instantiation scopes that were used when resolving them.
-
const Scope *scopeForModule(Context *context, ID moduleId)¶
Given an ID for a Module, returns a Scope that represents the Module scope (and what symbols are defined in it).
-
std::vector<BorrowedIdsWithName> lookupNameInScope(Context *context, const Scope *scope, const Scope *receiverScope, UniqueString name, LookupConfig config)¶
Find what a name might refer to.
‘scope’ is the context in which the name occurs (e.g. as an Identifier)
‘receiverScope’ is the scope of a type containing the name, in the case of method calls, field accesses, and resolving a name within a method. It is a Scope representing the record/class/union itself for the receiver. If provided, the receiverScope will be consulted before ‘scope’ and its parents.
The config argument is a group of or-ed together bit flags that adjusts the behavior of the lookup:
If LOOKUP_DECLS is set, looks for symbols declared in ‘scope’ and ‘receiverScope’. If LOOKUP_IMPORT_AND_USE is set, looks for symbols from use/import statements in this ‘scope’ and ‘receiverScope’. If LOOKUP_PARENTS is set, looks for symbols from parent scopes (but not parent modules of a module) including looking for declarations and handling imports, and including finding declarations in the root module. If LOOKUP_TOPLEVEL is set, checks for a toplevel module with this name. If LOOKUP_INNERMOST is true, limits search to the innermost scope with a match.
-
std::vector<BorrowedIdsWithName> lookupNameInScopeWithSet(Context *context, const Scope *scope, const Scope *receiverScope, UniqueString name, LookupConfig config, ScopeSet &visited)¶
Same as lookupNameInScope but includes a set tracking visited scopes.
-
bool isWholeScopeVisibleFromScope(Context *context, const Scope *checkScope, const Scope *fromScope)¶
Returns true if all of checkScope is visible from fromScope due to scope containment or whole-module use statements.
-
const PoiScope *pointOfInstantiationScope(Context *context, const Scope *scope, const PoiScope *parentPoiScope)¶
Returns a unique’d point-of-instantiation scope for the passed scope and parent POI scope. Collapses away POI scopes that do not affect visible functions.
-
const InnermostMatch &findInnermostDecl(Context *context, const Scope *scope, UniqueString name)¶
Given a name and a Scope, return the innermost and first ID for a definition of that name, and an indication of whether 0, 1, or more matches were found.
-
class BorrowedIdsWithName¶
- #include <scope-types.h>
Contains IDs with a particular name. This class is a lightweight reference to a collection stored in OwnedIdsWithName.
Public Functions
-
inline BorrowedIdsWithName()¶
Construct an empty BorrowedIdsWithName
-
inline BorrowedIdsWithName(ID id)¶
Construct a BorrowedIdsWithName referring to one ID
-
inline BorrowedIdsWithName(const OwnedIdsWithName &o)¶
Construct a BorrowedIdsWithName referring to the same IDs as the passed OwnedIdsWithName. This BorrowedIdsWithName assumes that the OwnedIdsWithName will continue to exist.
-
inline int numIds() const¶
Return the number of IDs stored here
-
inline bool operator==(const BorrowedIdsWithName &other) const¶
-
inline bool operator!=(const BorrowedIdsWithName &other) const¶
-
inline size_t hash() const¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
inline BorrowedIdsWithName()¶
-
class CallInfo¶
- #include <resolution-types.h>
Public Types
-
using CallInfoActualIterable = Iterable<std::vector<CallInfoActual>>¶
Public Functions
-
inline CallInfo(UniqueString name, types::QualifiedType calledType, bool isMethodCall, bool hasQuestionArg, bool isParenless, std::vector<CallInfoActual> actuals)¶
Construct a CallInfo that contains QualifiedTypes for actuals
-
CallInfo(const uast::FnCall *call)¶
Construct a CallInfo with unknown types for the actuals that can be used for FormalActualMap but not much else.
-
inline UniqueString name() const¶
return the name of the called thing
-
inline types::QualifiedType calledType() const¶
return the type of the called thing
-
inline bool isMethodCall() const¶
check if the call is a method call
-
inline bool hasQuestionArg() const¶
check if the call includes ? arg for type constructor
-
inline bool isParenless() const¶
return true if the call did not use parens
-
inline CallInfoActualIterable actuals() const¶
return the actuals
-
inline const CallInfoActual &actual(size_t i) const¶
return the i’th actual
-
inline size_t numActuals() const¶
return the number of actuals
-
inline size_t hash() const¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
using CallInfoActualIterable = Iterable<std::vector<CallInfoActual>>¶
-
class CallInfoActual¶
- #include <resolution-types.h>
Public Functions
-
inline CallInfoActual(types::QualifiedType type, UniqueString byName)¶
-
inline const types::QualifiedType &type() const¶
return the qualified type
-
inline UniqueString byName() const¶
return the name, if any, that the argument was passed with. Ex: in f(number=3), byName() would be “number”
-
inline bool operator==(const CallInfoActual &other) const¶
-
inline bool operator!=(const CallInfoActual &other) const¶
-
inline size_t hash() const¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
inline CallInfoActual(types::QualifiedType type, UniqueString byName)¶
-
class CallResolutionResult¶
- #include <resolution-types.h>
Public Functions
-
inline CallResolutionResult(types::QualifiedType exprType)¶
-
inline CallResolutionResult(MostSpecificCandidates mostSpecific, types::QualifiedType exprType, PoiInfo poiInfo)¶
-
inline const MostSpecificCandidates &mostSpecific() const¶
get the most specific candidates for return-intent overloading
-
inline const types::QualifiedType &exprType() const¶
type of the call expression
-
inline const PoiInfo &poiInfo() const¶
point-of-instantiation scopes used when resolving signature or body
-
inline bool operator==(const CallResolutionResult &other) const¶
-
inline bool operator!=(const CallResolutionResult &other) const¶
-
inline void swap(CallResolutionResult &other)¶
-
inline CallResolutionResult(types::QualifiedType exprType)¶
-
class CanPassResult¶
Public Types
-
enum ConversionKind¶
Values:
-
enumerator NONE¶
No implicit conversion is needed
-
enumerator PARAM_NARROWING¶
A narrowing param conversion is needed. These are only applicable to the particular param value e.g. 1:int converting to int(8) because 1 fits in int(8). The input of such a conversion must be param and the result is always a param.
-
enumerator NUMERIC¶
A numeric or bool conversion.
-
enumerator SUBTYPE¶
A conversion that implements subtyping
-
enumerator OTHER¶
Non-subtype conversion that doesn’t produce a param
-
enumerator NONE¶
Public Functions
-
inline CanPassResult()¶
-
~CanPassResult() = default¶
-
inline bool passes()¶
Returns true if the argument is passable
-
inline bool instantiates()¶
Returns true if passing the argument will require instantiation
-
inline bool promotes()¶
Returns true if passing the argument will require promotion
-
inline bool converts()¶
Returns true if implicit conversion is required
-
inline ConversionKind conversionKind()¶
What type of implicit conversion, if any, is needed?
-
inline bool convertsWithParamNarrowing()¶
Returns true if an implicit param narrowing conversion is required
Public Static Functions
-
static CanPassResult canPass(Context *context, const types::QualifiedType &actualType, const types::QualifiedType &formalType)¶
-
enum ConversionKind¶
-
class FormalActual¶
- #include <resolution-types.h>
FormalActual holds information on a function formal and its binding (if any)
Public Functions
-
inline const types::QualifiedType &formalType() const¶
-
inline const types::QualifiedType &actualType() const¶
-
inline int formalIdx() const¶
-
inline int actualIdx() const¶
-
inline bool hasActual() const¶
-
inline bool formalInstantiated() const¶
-
inline bool hasDefault() const¶
-
inline bool isVarArgEntry() const¶
-
inline const types::QualifiedType &formalType() const¶
-
class FormalActualMap¶
- #include <resolution-types.h>
FormalActualMap maps formals to actuals
Public Types
-
using FormalActualIterable = Iterable<std::vector<FormalActual>>¶
Public Functions
-
inline FormalActualMap(const UntypedFnSignature *sig, const CallInfo &call)¶
-
inline FormalActualMap(const TypedFnSignature *sig, const CallInfo &call)¶
-
inline bool isValid() const¶
check if mapping is valid
-
inline FormalActualIterable byFormals() const¶
get the FormalActuals in the order of the formal arguments
-
inline const FormalActual &byFormalIdx(int formalIdx) const¶
get the FormalActual for a particular formal index
-
inline const FormalActual *byActualIdx(int actualIdx) const¶
get the FormalActual for a particular actual index, and returns nullptr if none was found.
-
using FormalActualIterable = Iterable<std::vector<FormalActual>>¶
-
class InnermostMatch¶
- #include <scope-types.h>
Public Functions
-
inline InnermostMatch()¶
-
inline InnermostMatch(ID id, MatchesFound found)¶
-
inline MatchesFound found() const¶
Return the matches found
-
inline bool operator==(const InnermostMatch &other) const¶
-
inline bool operator!=(const InnermostMatch &other) const¶
-
inline void swap(InnermostMatch &other)¶
-
inline void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
Public Static Functions
-
static inline bool update(InnermostMatch &keep, InnermostMatch &addin)¶
-
inline InnermostMatch()¶
-
class MostSpecificCandidates¶
- #include <resolution-types.h>
Stores the most specific candidates when resolving a function call.
Public Types
Public Functions
-
inline MostSpecificCandidates()¶
Default-initialize MostSpecificCandidates with no candidates which is not empty due to ambiguity.
-
inline const TypedFnSignature *const *begin() const¶
-
inline const TypedFnSignature *const *end() const¶
-
inline void setBestRef(const TypedFnSignature *sig)¶
-
inline void setBestConstRef(const TypedFnSignature *sig)¶
-
inline void setBestValue(const TypedFnSignature *sig)¶
-
inline void setBestOnly(const TypedFnSignature *sig)¶
-
inline const TypedFnSignature *bestRef() const¶
-
inline const TypedFnSignature *bestConstRef() const¶
-
inline const TypedFnSignature *bestValue() const¶
-
inline const TypedFnSignature *only() const¶
If there is exactly one candidate, return that candidate. Otherwise, return nullptr.
-
inline int numBest() const¶
Returns the number of best candidates that are contained here.
-
inline bool isEmpty() const¶
Returns true if there are no most specific candidates.
-
inline bool isAmbiguous() const¶
Returns true if there are no most specific candidates due to ambiguity.
-
inline bool operator==(const MostSpecificCandidates &other) const¶
-
inline bool operator!=(const MostSpecificCandidates &other) const¶
-
inline void swap(MostSpecificCandidates &other)¶
Public Static Functions
-
static inline MostSpecificCandidates getOnly(const TypedFnSignature *fn)¶
If fn is not nullptr, creates a MostSpecificCandidates with that function. Otherwise, default-initializes a MostSpecificCandidates with no candidates that is not empty due to ambiguity.
-
static inline MostSpecificCandidates getEmpty()¶
Creates a MostSpecificCandidates with no candidates that is not empty due to ambiguity.
-
static inline MostSpecificCandidates getAmbiguous()¶
Creates a MostSpecificCandidates that represents a no candidates but that is empty due to ambiguity.
-
static inline bool update(MostSpecificCandidates &keep, MostSpecificCandidates &addin)¶
-
inline MostSpecificCandidates()¶
-
class OwnedIdsWithName¶
- #include <scope-types.h>
Collects IDs with a particular name. These can be referred to by a BorrowedIdsWithName in a way that avoids copies.
Public Functions
-
inline OwnedIdsWithName(ID id)¶
Construct an OwnedIdsWithName containing one ID.
-
inline void appendId(ID newId)¶
Append an ID to an OwnedIdsWithName.
-
inline bool operator==(const OwnedIdsWithName &other) const¶
-
inline bool operator!=(const OwnedIdsWithName &other) const¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
inline OwnedIdsWithName(ID id)¶
-
class PoiInfo¶
- #include <resolution-types.h>
Contains information about symbols available from point-of-instantiation in order to implement caching of instantiations.
Public Functions
-
inline PoiInfo()¶
-
inline void setResolved(bool resolved)¶
set resolved
-
inline size_t hash() const¶
-
inline void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
inline PoiInfo()¶
-
class PoiScope¶
- #include <scope-types.h>
PoiScope is a point-of-instantiation scope
Public Functions
-
inline void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
inline void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
class ResolutionResultByPostorderID¶
- #include <resolution-types.h>
This type is a mapping from postOrderId (which is an integer) to ResolvedExpression for storing resolution results within a symbol.
Note that an inner Function would not be covered here.
Public Functions
-
void setupForSignature(const uast::Function *func)¶
prepare to resolve the signature of the passed function
-
void setupForFunction(const uast::Function *func)¶
prepare to resolve the body of the passed function
-
void setupForParamLoop(const uast::For *loop, ResolutionResultByPostorderID &parent)¶
prepare to resolve the body of a For loop
-
inline ResolvedExpression &byIdExpanding(const ID &id)¶
-
inline ResolvedExpression &byAstExpanding(const uast::AstNode *ast)¶
-
inline ResolvedExpression &byId(const ID &id)¶
-
inline const ResolvedExpression &byId(const ID &id) const¶
-
inline ResolvedExpression &byAst(const uast::AstNode *ast)¶
-
inline const ResolvedExpression &byAst(const uast::AstNode *ast) const¶
-
inline ResolvedExpression *byIdOrNull(const ID &id)¶
-
inline const ResolvedExpression *byIdOrNull(const ID &id) const¶
-
inline ResolvedExpression *byAstOrNull(const uast::AstNode *ast)¶
-
inline const ResolvedExpression *byAstOrNull(const uast::AstNode *ast) const¶
-
inline bool operator==(const ResolutionResultByPostorderID &other) const¶
-
inline bool operator!=(const ResolutionResultByPostorderID &other) const¶
-
inline void swap(ResolutionResultByPostorderID &other)¶
Public Static Functions
-
static bool update(ResolutionResultByPostorderID &keep, ResolutionResultByPostorderID &addin)¶
-
void setupForSignature(const uast::Function *func)¶
-
class ResolvedExpression¶
- #include <resolution-types.h>
This type represents a resolved expression.
Public Types
-
using AssociatedFns = std::vector<const TypedFnSignature*>¶
Public Functions
-
inline ResolvedExpression()¶
-
inline const types::QualifiedType &type() const¶
get the qualified type
-
inline ID toId() const¶
for simple (non-function Identifier) cases, the ID of a NamedDecl it refers to
-
inline const MostSpecificCandidates &mostSpecific() const¶
For a function call, what is the most specific candidate, or when using return intent overloading, what are the most specific candidates? The choice between these needs to happen later than the main function resolution.
-
inline const AssociatedFns &associatedFns() const¶
-
inline const ResolvedParamLoop *paramLoop() const¶
-
inline void setType(const types::QualifiedType &type)¶
set the type
-
inline void setMostSpecific(const MostSpecificCandidates &mostSpecific)¶
set the most specific
-
inline void addAssociatedFn(const TypedFnSignature *fn)¶
add an associated function
-
inline void setParamLoop(const ResolvedParamLoop *paramLoop)¶
-
inline bool operator==(const ResolvedExpression &other) const¶
-
inline bool operator!=(const ResolvedExpression &other) const¶
-
inline void swap(ResolvedExpression &other)¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
Public Static Functions
-
static inline bool update(ResolvedExpression &keep, ResolvedExpression &addin)¶
-
using AssociatedFns = std::vector<const TypedFnSignature*>¶
-
class ResolvedFields¶
- #include <resolution-types.h>
ResolvedFields represents the fully resolved fields for a class/record/union/tuple type.
Public Functions
-
inline ResolvedFields()¶
-
inline void setType(const types::CompositeType *type)¶
-
inline void addField(UniqueString name, bool hasDefaultValue, ID declId, types::QualifiedType type)¶
-
inline bool isGeneric() const¶
Returns true if this is a generic type
-
inline bool isGenericWithDefaults() const¶
Returns true if this is a generic type where all generic fields have default values. For classes, this does not include consideration of the parent class.
-
inline int numFields() const¶
-
inline UniqueString fieldName(int i) const¶
-
inline bool fieldHasDefaultValue(int i) const¶
-
inline types::QualifiedType fieldType(int i) const¶
-
inline bool operator==(const ResolvedFields &other) const¶
-
inline bool operator!=(const ResolvedFields &other) const¶
-
inline void swap(ResolvedFields &other)¶
Public Static Functions
-
static inline bool update(ResolvedFields &keep, ResolvedFields &addin)¶
-
inline ResolvedFields()¶
-
class ResolvedFunction¶
- #include <resolution-types.h>
This type represents a resolved function.
Public Functions
-
inline ResolvedFunction(const TypedFnSignature *signature, uast::Function::ReturnIntent returnIntent, ResolutionResultByPostorderID resolutionById, PoiInfo poiInfo)¶
-
inline const TypedFnSignature *signature() const¶
The type signature
-
inline uast::Function::ReturnIntent returnIntent() const¶
the return intent
-
inline const ResolutionResultByPostorderID &resolutionById() const¶
this is the output of the resolution process
-
inline bool operator==(const ResolvedFunction &other) const¶
-
inline bool operator!=(const ResolvedFunction &other) const¶
-
inline void swap(ResolvedFunction &other)¶
-
inline const ResolvedExpression &byId(const ID &id) const¶
-
inline const ResolvedExpression &byAst(const uast::AstNode *ast) const¶
Public Static Functions
-
static inline bool update(owned<ResolvedFunction> &keep, owned<ResolvedFunction> &addin)¶
-
inline ResolvedFunction(const TypedFnSignature *signature, uast::Function::ReturnIntent returnIntent, ResolutionResultByPostorderID resolutionById, PoiInfo poiInfo)¶
-
class ResolvedParamLoop¶
Public Types
-
using LoopBodies = std::vector<ResolutionResultByPostorderID>¶
Public Functions
-
inline const LoopBodies &loopBodies() const¶
-
inline void setLoopBodies(const LoopBodies &loopBodies)¶
-
inline bool operator==(const ResolvedParamLoop &other) const¶
-
inline bool operator!=(const ResolvedParamLoop &other) const¶
-
inline void swap(ResolvedParamLoop &other)¶
Public Static Functions
-
static inline bool update(ResolvedParamLoop &keep, ResolvedParamLoop &addin)¶
-
using LoopBodies = std::vector<ResolutionResultByPostorderID>¶
-
class ResolvedVisibilityScope¶
- #include <scope-types.h>
Stores the result of in-order resolution of use/import statements.
Public Types
-
using VisibilitySymbolsIterable = Iterable<std::vector<VisibilitySymbols>>¶
Public Functions
-
inline VisibilitySymbolsIterable visibilityClauses() const¶
Return an iterator over the visibility clauses
-
inline void addVisibilityClause(const Scope *scope, VisibilitySymbols::Kind kind, bool isPrivate, std::vector<std::pair<UniqueString, UniqueString>> n)¶
Add a visibility clause
-
inline bool operator==(const ResolvedVisibilityScope &other) const¶
-
inline bool operator!=(const ResolvedVisibilityScope &other) const¶
Public Static Functions
-
static inline bool update(owned<ResolvedVisibilityScope> &keep, owned<ResolvedVisibilityScope> &addin)¶
-
using VisibilitySymbolsIterable = Iterable<std::vector<VisibilitySymbols>>¶
-
class Scope¶
- #include <scope-types.h>
A scope roughly corresponds to a
{ }
block. Anywhere a new symbol could be defined / is defined is a scope.The scope contains a mapping from name to ID for symbols defined within. For the root scope, it can also contain empty IDs for builtin types and symbols.
While generic instantiations generate something scope-like, the point-of-instantiation reasoning will need to be handled with a different type.
Public Functions
-
inline Scope()¶
Construct an empty scope. This scope will not yet store any defined symbols.
-
Scope(const uast::AstNode *ast, const Scope *parentScope, bool autoUsesModules)¶
Construct a Scope for a particular AST node and with a particular parent.
-
void addBuiltin(UniqueString name)¶
Add a builtin type with the provided name. This needs to be called to populate the root scope with builtins.
-
const Scope *moduleScope() const¶
Return the module scope containing this scope, or if it is a module scope, this scope.
-
inline uast::asttags::AstTag tag() const¶
Returns the AST tag of the construct that this Scope represents.
-
inline const ID &id() const¶
Return the ID of the Block or other AST node construct that this Scope represents. An empty ID indicates that this Scope is the root scope.
-
inline UniqueString name() const¶
-
inline bool containsUseImport() const¶
Returns ‘true’ if this Scope directly contains use or import statements including the automatic ‘use’ for the standard library.
-
inline bool autoUsesModules() const¶
Returns ‘true’ if the Scope includes the automatic ‘use’ for the standard library.
-
inline bool containsFunctionDecls() const¶
Returns ‘true’ if this Scope directly contains any Functions
-
inline int numDeclared() const¶
-
inline bool lookupInScope(UniqueString name, std::vector<BorrowedIdsWithName> &result) const¶
If the scope contains IDs with the provided name, append the relevant BorrowedIdsToName the the vector. Returns true if something was appended.
-
inline void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
inline Scope()¶
-
class TypedFnSignature¶
- #include <resolution-types.h>
This represents a typed function signature.
Public Types
Public Functions
-
inline bool operator==(const TypedFnSignature &other) const¶
-
inline bool operator!=(const TypedFnSignature &other) const¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
inline const ID &id() const¶
Returns the id of the relevant uast node (usually a Function but it can be a Record or Class for compiler-generated functions)
-
inline const UntypedFnSignature *untyped() const¶
Returns the UntypedFnSignature
-
inline WhereClauseResult whereClauseResult() const¶
Returns the result of evaluating the where clause
-
inline bool needsInstantiation() const¶
Returns if any of the formals are generic or unknown
-
inline const TypedFnSignature *instantiatedFrom() const¶
Is this TypedFnSignature representing an instantiation? If so, returns the generic TypedFnSignature that was instantiated. Otherwise, returns nullptr.
This function always returns the signature for the fully generic function and never a partial instantiation. That is, the result will either be nullptr or result->instantiatedFrom() will be nullptr.
-
inline bool formalIsInstantiated(int i) const¶
Returns ‘true’ if formal argument i was instantiated; that is, it was present in the SubstitutionsMap when instantiating.
-
inline const TypedFnSignature *parentFn() const¶
Is this for an inner Function? If so, what is the parent function signature?
-
inline int numFormals() const¶
Returns the number of formals
-
inline UniqueString formalName(int i) const¶
Returns the name of the i’th formal
-
inline const types::QualifiedType &formalType(int i) const¶
Returns the type of the i’th formal
Public Static Functions
-
static const TypedFnSignature *get(Context *context, const UntypedFnSignature *untypedSignature, std::vector<types::QualifiedType> formalTypes, TypedFnSignature::WhereClauseResult whereClauseResult, bool needsInstantiation, const TypedFnSignature *instantiatedFrom, const TypedFnSignature *parentFn, Bitmap formalsInstantiated)¶
Get the unique TypedFnSignature containing these components
-
static inline bool update(owned<TypedFnSignature> &keep, owned<TypedFnSignature> &addin)¶
-
inline bool operator==(const TypedFnSignature &other) const¶
-
class UntypedFnSignature¶
- #include <resolution-types.h>
An untyped function signature. This is really just the part of a function including the formals. It exists so that the process of identifying candidates does not need to depend on the bodies of the function (in terms of incremental recomputation).
For type constructors for generic types, the formal decls are actually field decls.
Public Functions
-
inline bool operator==(const UntypedFnSignature &other) const¶
-
inline bool operator!=(const UntypedFnSignature &other) const¶
-
inline const ID &id() const¶
Returns the id of the relevant uast node (usually a Function but it can be a Record or Class for compiler-generated functions)
-
inline UniqueString name() const¶
Returns the name of the function this signature represents
-
inline uast::Function::Kind kind() const¶
Returns the kind of the function this signature represents
-
inline bool isCompilerGenerated() const¶
Returns true if this compiler generated
-
inline bool isTypeConstructor() const¶
Returns true if this is a type constructor
-
inline bool isMethod() const¶
Returns true if this is a method
-
inline int numFormals() const¶
Returns the number of formals
-
inline UniqueString formalName(int i) const¶
Returns the name of the i’th formal.
-
inline bool formalHasDefault(int i) const¶
Return whether the i’th formal has a default value.
-
inline const uast::Decl *formalDecl(int i) const¶
Returns the Decl for the i’th formal / field. This will return nullptr for compiler-generated functions.
-
inline bool formalIsVarArgs(int i) const¶
-
inline void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
Public Static Functions
-
static const UntypedFnSignature *get(Context *context, ID id, UniqueString name, bool isMethod, bool isTypeConstructor, bool isCompilerGenerated, uast::asttags::AstTag idTag, uast::Function::Kind kind, std::vector<FormalDetail> formals, const uast::AstNode *whereClause)¶
Get the unique UntypedFnSignature containing these components
-
static const UntypedFnSignature *get(Context *context, const uast::Function *function)¶
Get the unique UntypedFnSignature representing a Function’s signature from a Function uAST pointer.
-
static const UntypedFnSignature *get(Context *context, ID functionId)¶
Get the unique UntypedFnSignature representing a Function’s signature from a Function ID.
-
static inline bool update(owned<UntypedFnSignature> &keep, owned<UntypedFnSignature> &addin)¶
-
struct FormalDetail¶
Public Functions
-
inline FormalDetail(UniqueString name, bool hasDefaultValue, const uast::Decl *decl, bool isVarArgs = false)¶
-
inline bool operator==(const FormalDetail &other) const¶
-
inline bool operator!=(const FormalDetail &other) const¶
-
inline size_t hash() const¶
-
inline void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
inline FormalDetail(UniqueString name, bool hasDefaultValue, const uast::Decl *decl, bool isVarArgs = false)¶
-
inline bool operator==(const UntypedFnSignature &other) const¶
-
class VisibilitySymbols¶
- #include <scope-types.h>
This class supports both
use
andimport
. It stores a normalized form of the symbols made available by a use/import clause.Public Types
-
enum Kind¶
The kind of import symbol
Values:
-
enumerator SYMBOL_ONLY¶
the scope itself only (one name in names)
-
enumerator ALL_CONTENTS¶
all the contents of the scope (and names is empty)
-
enumerator ONLY_CONTENTS¶
only the contents of the scope named in names
-
enumerator CONTENTS_EXCEPT¶
contents of the scope except the contents named in names (no renaming)
-
enumerator SYMBOL_ONLY¶
Public Functions
-
inline VisibilitySymbols()¶
-
inline VisibilitySymbols(const Scope *scope, Kind kind, bool isPrivate, std::vector<std::pair<UniqueString, UniqueString>> names)¶
-
inline bool isPrivate() const¶
Return whether or not the imported symbol is private
-
inline bool lookupName(const UniqueString &name, UniqueString &declared) const¶
Lookup the declared name for a given name Returns true if
name
is found in the list of renamed names and stores the declared name indeclared
Returns false ifname
is not found
-
inline bool operator==(const VisibilitySymbols &other) const¶
-
inline bool operator!=(const VisibilitySymbols &other) const¶
-
inline void swap(VisibilitySymbols &other)¶
Public Static Functions
-
static inline bool update(VisibilitySymbols &keep, VisibilitySymbols &addin)¶
-
enum Kind¶
-
using KindRequirement = llvm::Optional<chpl::types::QualifiedType::Kind>¶