Resolution¶
This section contains definitions declared in the chpl::resolution namespace.
-
namespace resolution¶
Typedefs
-
using CalledFnsSet = std::unordered_map<const ResolvedFunction*, CalledFnOrder>¶
-
using KindRequirement = 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 returns.
-
using SubstitutionsMap = types::CompositeType::SubstitutionsMap¶
-
using PoiRecursiveCalls = std::set<std::pair<const TypedFnSignature*, const PoiScope*>>¶
-
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¶
LookupConfig is a bit-set of the LOOKUP_ flags defined above
-
using CheckedScopes = std::unordered_map<CheckedScope, IdAndFlags::FlagSet>¶
Enums
-
enum SkipCallResolutionReason¶
In some situations, we may decide not to resolve a call. This could happen if we believe it to already be ill-formed (e.g., why would we resolve f(x) if x is ill-typed?
This enum contains reasons why we might want that to do that.
Values:
-
enumerator NONE¶
-
enumerator UNKNOWN_PARAM¶
-
enumerator GENERIC_TYPE¶
-
enumerator GENERIC_VALUE¶
-
enumerator UNKNOWN_ACT¶
-
enumerator ERRONEOUS_ACT¶
-
enumerator OTHER_REASON¶
-
enumerator NONE¶
-
enum class 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¶
-
enum CandidateFailureReason¶
An enum that represents the reason why a function candidate was filtered out during call resolution.
Values:
-
enumerator FAIL_CANNOT_PASS¶
-
enumerator FAIL_FORMAL_ACTUAL_MISMATCH¶
-
enumerator FAIL_FORMAL_ACTUAL_MISMATCH_ITERATOR_API¶
-
enumerator FAIL_VARARG_MISMATCH¶
-
enumerator FAIL_WHERE_CLAUSE¶
-
enumerator FAIL_PARENLESS_MISMATCH¶
-
enumerator FAIL_CANDIDATE_OTHER¶
-
enumerator FAIL_CANNOT_PASS¶
-
enum PassingFailureReason¶
An enum that represents the reason why an actual couldn’t be passed to a formal.
Values:
-
enumerator FAIL_INCOMPATIBLE_NILABILITY¶
-
enumerator FAIL_INCOMPATIBLE_MGMT¶
-
enumerator FAIL_INCOMPATIBLE_MGR¶
-
enumerator FAIL_EXPECTED_SUBTYPE¶
-
enumerator FAIL_INCOMPATIBLE_TUPLE_SIZE¶
-
enumerator FAIL_INCOMPATIBLE_TUPLE_STAR¶
-
enumerator FAIL_CANNOT_CONVERT¶
-
enumerator FAIL_CANNOT_INSTANTIATE¶
-
enumerator FAIL_DID_NOT_INSTANTIATE¶
-
enumerator FAIL_TYPE_VS_NONTYPE¶
-
enumerator FAIL_NOT_PARAM¶
-
enumerator FAIL_MISMATCHED_PARAM¶
-
enumerator FAIL_UNKNOWN_ACTUAL_TYPE¶
-
enumerator FAIL_UNKNOWN_FORMAL_TYPE¶
-
enumerator FAIL_GENERIC_TO_NONTYPE¶
-
enumerator FAIL_NOT_EXACT_MATCH¶
-
enumerator FAIL_FORMAL_OTHER¶
-
enumerator FAIL_INCOMPATIBLE_NILABILITY¶
Functions
-
template<typename ResolvedVisitorImpl>
static bool resolvedVisitorEnterFor(ResolvedVisitorImpl &v, const uast::For *loop)¶
-
template<typename ResolvedVisitorImpl>
static bool resolvedVisitorEnterAst(ResolvedVisitorImpl &v, const uast::AstNode *ast)¶
-
int gatherFnsCalledByFn(Context *context, const ResolvedFunction *fn, CalledFnOrder order, CalledFnsSet &called)¶
-
int gatherTransitiveFnsCalledByFn(Context *context, const ResolvedFunction *fn, CalledFnOrder order, CalledFnsSet &called)¶
-
int gatherTransitiveFnsForFnId(Context *context, ID fnId, CalledFnsSet &called)¶
-
int gatherFnsCalledByModInit(Context *context, ID moduleId, CalledFnsSet &called)¶
-
int gatherTransitiveFnsCalledByModInit(Context *context, ID moduleId, CalledFnsSet &called)¶
-
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.
-
static inline CanPassResult canPassScalar(Context *context, const types::QualifiedType &actualType, const types::QualifiedType &formalType)¶
-
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 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.
-
std::set<ID> computeElidedCopies(Context *context, const uast::AstNode *symbol, const ResolutionResultByPostorderID &byPostorder, const PoiScope *poiScope, const std::set<ID> &allSplitInitedVars, types::QualifiedType fnYieldedType)¶
-
MostSpecificCandidates findMostSpecificCandidates(Context *context, const CandidatesAndForwardingInfo &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).
‘lst’ contains all of the TypedFnSignatures that are candidates for the call ‘call’.
If forwarding is in use, for any candidate, ‘forwardingInfo’ contains an element for each of the candidates in ‘lst’ and stores the actual type passed to the method receiver. This indicates which ‘forwarding’ statement is in use.
-
types::QualifiedType::Kind resolveIntent(const types::QualifiedType &t, bool isThis, bool isInit)¶
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 argument ‘isInit’ indicates if the function being resolved is an ‘init’ or ‘init=’ function.
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, bool currentModule = false)¶
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
-
const types::QualifiedType &typeForSysCType(Context *context, UniqueString name)¶
Get the QualifiedType for the well-known types in ChapelSysCTypes
-
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 std::map<ID, types::QualifiedType> &computeNumericValuesOfEnumElements(Context *context, ID node)¶
Returns a map from enum element IDs to their numeric values. The caller is responsible for validating that node is an enum ID. If an invalid ID is given, an empty map is returned.
Abstract elements are not stored in the returned map, to distinguish from non-abstract elements whose values could not be computed.
-
const chpl::optional<types::QualifiedType> &computeUnderlyingTypeOfEnum(Context *context, ID element)¶
-
const chpl::optional<types::QualifiedType> &computeNumericValueOfEnumElement(Context *context, ID element)¶
Returns the numeric value of an enum element. The caller is responsible for validating that element is an enum element ID. If an invalid ID is given, an empty optional is returned.
-
ID lookupEnumElementByNumericValue(Context *context, const ID &node, const types::QualifiedType &value)¶
-
const TypedFnSignature *const &typedSignatureInitial(ResolutionContext *rc, const UntypedFnSignature *untyped)¶
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 TypedFnSignature *typedSignatureInitialForId(ResolutionContext *rc, ID id)¶
Compute a initial TypedFnSignature for an ID. 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, bool syntaxOnly = false)¶
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.
If syntaxOnly is set, computes basic information (field order, IDs) but does not compute types.
-
const ResolvedFields &fieldsForTypeDecl(Context *context, const types::CompositeType *ct, DefaultsPolicy defaultsPolicy, bool syntaxOnly = false)¶
Compute the fields and their types 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.
If syntaxOnly is set, computes basic information (field order, IDs) but does not compute types.
-
const types::CompositeType *isNameOfField(Context *context, UniqueString name, const types::Type *t)¶
If ‘name’ is the name of a field for type ‘t’, returns a non-null pointer; Otherwise, returns ‘nullptr’.
The returned pointer will point to the type containing the field. For records and unions, that will just be ‘t’. For classes, it won’t necessarily be ‘t’, since a field might come from a superclass. If the field comes from a superclass, this function will return the BasicClass type for the superclass that contains the field directly.
-
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.
-
bool isFieldSyntacticallyGeneric(Context *context, const ID &field, types::QualifiedType *formalType = nullptr)¶
-
bool shouldIncludeFieldInTypeConstructor(Context *context, const ID &fieldId, const types::QualifiedType &fieldType, types::QualifiedType *formalType = nullptr)¶
Returns true if the field should be included in the type constructor. In that event, also sets formalType to the type the formal should use.
This is also used to decide if a field needs to be include in a type’s substitutions.
-
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.
-
ApplicabilityResult instantiateSignature(ResolutionContext *rc, 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
-
const ResolvedFunction *resolveFunction(ResolutionContext *rc, 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 ResolutionResultByPostorderID &scopeResolveAggregate(Context *context, ID id)¶
-
const ResolutionResultByPostorderID &scopeResolveEnum(Context *context, ID id)¶
-
types::QualifiedType returnType(ResolutionContext *rc, const TypedFnSignature *sig, const PoiScope *poiScope)¶
Compute the return type for a function. If the function is an iterator, the return type will be an
IteratorType
. To compute the yield type, seeyieldType
.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.
-
types::QualifiedType yieldType(ResolutionContext *rc, const TypedFnSignature *sig, const PoiScope *poiScope)¶
An iterator-specific variant of ‘returnType’ which does not wrap the function’s return in an
IterableType
, returning instead the type of values yielded by the function.
-
const TypedFnSignature *inferOutFormals(ResolutionContext *rc, const TypedFnSignature *sig, const PoiScope *poiScope)¶
Compute the types for any generic ‘out’ formal types after instantiation of any other generic arguments.
‘out’ formals with concrete type will already have their types represented in the ‘sig’ passed here (through typedSignatureInitial and potentially instantiateSignature).
For the generic ‘out’ formals, their types are inferred from the body of the function.
The returned TypedFnSignature* will have the inferred out formal types.
-
const TypedFnSignature *inferRefMaybeConstFormals(ResolutionContext *rc, const TypedFnSignature *sig, const PoiScope *poiScope)¶
Try to compute the TypedFnSignature with REF_MAYBE_CONST formals computed as ‘ref’ or ‘const ref’. If the TypedFnSignature is currently being resolved, instead of returning a new TypedFnSignature, this function returns ‘nullptr’. In that case, the caller is responsible for attempting this again later once the current set of recursive functions is resolved.
-
const CandidatesAndForwardingInfo &filterCandidatesInitial(ResolutionContext *rc, MatchingIdsWithName lst, CallInfo call)¶
Compute the (potentially generic) TypedFnSignatures of possibly applicable candidate functions from a list of visible functions.
-
void filterCandidatesInstantiating(ResolutionContext *rc, const CandidatesAndForwardingInfo &lst, const CallInfo &call, const Scope *inScope, const PoiScope *inPoiScope, CandidatesAndForwardingInfo &result, std::vector<ApplicabilityResult> *rejected = nullptr)¶
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(ResolutionContext *rc, const uast::Call *call, const CallInfo &ci, const CallScopeInfo &inScopes, std::vector<ApplicabilityResult> *rejected = nullptr)¶
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.
‘resolveCallInMethod’ should be used instead when resolving a non-method call within a method.
-
CallResolutionResult resolveCallInMethod(ResolutionContext *rc, const uast::Call *call, const CallInfo &ci, const CallScopeInfo &inScopes, types::QualifiedType implicitReceiver, std::vector<ApplicabilityResult> *rejected = nullptr)¶
Similar to resolveCall, but handles the implicit scope provided by a method.
When a resolving a call within a method, the implicitReceiver should be set to the ‘this’ type of the method.
If implicitReceiver.type() == nullptr, it will be ignored.
-
CallResolutionResult resolveGeneratedCall(Context *context, const uast::AstNode *astForErrAndPoi, const CallInfo &ci, const CallScopeInfo &inScopes, std::vector<ApplicabilityResult> *rejected = nullptr)¶
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.
-
CallResolutionResult resolveGeneratedCallInMethod(Context *context, const uast::AstNode *astForErrAndPoi, const CallInfo &ci, const CallScopeInfo &inScopes, types::QualifiedType implicitReceiver)¶
Similar to resolveGeneratedCall but handles the implicit scope provided by a method.
When a resolving a call within a method, the implicitReceiver should be set to the ‘this’ type of the method.
If implicitReceiver.type() == nullptr, it will be ignored.
-
const TypedFnSignature *tryResolveInitEq(Context *context, const uast::AstNode *astForScopeOrErr, const types::Type *lhsType, const types::Type *rhsType, const PoiScope *poiScope = nullptr)¶
-
const TypedFnSignature *tryResolveAssign(Context *context, const uast::AstNode *astForScopeOrErr, const types::Type *lhsType, const types::Type *rhsType, const PoiScope *poiScope = nullptr)¶
-
const TypedFnSignature *tryResolveDeinit(Context *context, const uast::AstNode *astForScopeOrErr, const types::Type *t, const PoiScope *poiScope = nullptr)¶
-
bool isTypeDefaultInitializable(Context *context, const types::Type *t)¶
Given a type ‘t’, compute whether or not ‘t’ is default initializable. If ‘t’ is a generic type, it is considered non-default-initializable. Considers the fields and substitutions of composite types.
-
CopyableAssignableInfo getCopyOrAssignableInfo(Context *context, const types::Type *t, bool checkCopyable)¶
Determine whether type ‘t’ is copyable/assignable from const or/and from ref. When checkCopyable is true, this checks copyability, and for false checks assignability.
-
const std::unordered_map<UniqueString, types::QualifiedType> &getCompilerGeneratedGlobals(Context *context)¶
Determine the types of various compiler-generated globals, which depend on the settings the compiler / Dyno was started with.
-
void reportInvalidMultipleInheritance(Context *context, const uast::Class *node, const uast::AstNode *firstParent, const uast::AstNode *secondParent)¶
-
const std::vector<const uast::Function*> &getTestsGatheredViaPrimitive(Context *context)¶
One of the compiler primitives has the side effect of collecting all test functions. This helper retrieves the list of test functions that has been collected.
-
const types::QualifiedType &getIterKindConstantOrUnknown(Context *context, uast::Function::IteratorKind kind)¶
Retrieve the ‘param’ tag for an iterator constant. If the ‘iterKind’ enum is not available, this will return an unknown type.
-
const uast::Decl *findFieldByName(Context *context, const uast::AggregateDecl *ad, const types::CompositeType *ct, UniqueString name)¶
Returns the field in ‘ad’ (or its parent) that matches ‘name’.
-
const MostSpecificCandidate &findTaggedIteratorForType(ResolutionContext *rc, const types::FnIteratorType *fnIter, uast::Function::IteratorKind iterKind, const Scope *overrideLookupScope = nullptr)¶
Given a an iterator type produced by an
iter
proc, find the given iterator overload (e.g., leader, follower).
-
const types::QualifiedType &taggedYieldTypeForType(ResolutionContext *rc, const types::FnIteratorType *fnIter, uast::Function::IteratorKind iterKind, const Scope *overrideLookupScope = nullptr)¶
Given a an iterator type produced by an
iter
proc, find the given iterator and determine its yield type.If ‘overrideLookupScope’ is provided, instead of using the fnIterator’s scope, the provided scope will be used to look up the tagged iterator. This can be used to see if under the old rules, we could’ve found competing overloads.
-
const types::QualifiedType &yieldTypeForIterator(ResolutionContext *rc, const types::IteratorType *iter)¶
-
TheseResolutionResult resolveTheseCall(ResolutionContext *rc, const uast::AstNode *iterand, const types::QualifiedType &receiverType, uast::Function::IteratorKind iterKind, const types::QualifiedType &followThis, const CallScopeInfo &inScopes)¶
Resolve a call to the special ‘these’ iterator method. For certain types, this circumvents the normal call resolution process, since iterating over these types is handled by the compiler.
the ‘iterand’ is an AST node to use as an anchor for errors etc. the ‘receiverType’ is the type of the receiver on which
these
is being invoked the ‘iterKind’ is the kind of iterator being requested (leader, follower, etc.) the ‘followThis’ is the type of ‘followThis’ for the follower iterator, if any the ‘inScopes’ is the scope information for the call
-
const uast::BuilderResult *builderResultForDefaultFunction(Context *context, UniqueString typePath, UniqueString name)¶
Given a type’s symbol path and the name of a default function, return a BuilderResult storing the generated default function uAST.
-
const types::QualifiedType &getPromotionType(Context *context, types::QualifiedType qt)¶
Get the ‘promotion type’ for the given type. E.g., the promotion type for a range is the type of the range’s elements.
-
const Scope *scopeForModule(Context *context, ID moduleId)¶
Given an ID for a Module, returns a Scope that represents the Module’s scope (and notes the symbols that are defined in it).
-
const bool &isNameBuiltinGenericType(Context *context, UniqueString name)¶
-
MatchingIdsWithName lookupNameInScope(Context *context, const Scope *scope, const MethodLookupHelper *methodLookupHelper, const ReceiverScopeHelper *receiverScopeHelper, 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)
‘methodLookupHelper’ should be nullptr unless working on resolving a method call/field access or forwarding expressions within a class/record. It should be used for something like ‘foo.bar()’ and in such a case, when looking up ‘bar’, it should reflect the scopes for ‘foo’. Methods at this scope will be considered in addition to the usual.
‘receiverScopeHelper’ should be provided any time it’s possible for the scope lookup process to encounter an enclosing method when resolving something that might use the implicit ‘this’. In particular, in a method, something like ‘baz’ might refer to a field or a method. So, the ‘receiverScopeHelper’ assists in such cases by calculating a MethodLookupHelper for the receiver.
The config argument is a group of or-ed together bit flags that adjusts the behavior of the lookup. Please see ‘LookupConfig’ and the related constants such as ‘LOOKUP_DECLS’ for further details.
-
MatchingIdsWithName lookupNameInScopeWithWarnings(Context *context, const Scope *scope, const MethodLookupHelper *methodLookupHelper, const ReceiverScopeHelper *receiverScopeHelper, UniqueString name, LookupConfig config, ID idForWarnings)¶
Same as lookupNameInScope but can produce warnings based on the ID passed in.
-
MatchingIdsWithName lookupNameInScopeTracing(Context *context, const Scope *scope, const MethodLookupHelper *methodLookupHelper, const ReceiverScopeHelper *receiverScopeHelper, UniqueString name, LookupConfig config, std::vector<ResultVisibilityTrace> &traceResult)¶
Same as lookupNameInScope but traces how each symbol was found, for error messages.
-
MatchingIdsWithName lookupNameInScopeWithSet(Context *context, const Scope *scope, const MethodLookupHelper *methodLookupHelper, const ReceiverScopeHelper *receiverScopeHelper, UniqueString name, LookupConfig config, CheckedScopes &visited)¶
Same as lookupNameInScope but includes a set tracking visited scopes.
-
std::map<UniqueString, MatchingIdsWithName> getSymbolsAvailableInScope(Context *context, const Scope *scope)¶
Collect all symbols that are available in this scope, including ones brought in through visibility statements. This function follows the same rules as lookupNameInScope, except it collects all symbols instead of one with a specific name.
Currently, this is only intended for tool support; the resolver itself should rely on lookupNameInScope.
-
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.
-
const std::vector<ID> findUsedImportedIds(Context *context, const Scope *scope)¶
Given a scope, returns a vector of IDs for all the modules and enums that were either used or imported in that scope. May return an empty vector if no modules were used or imported in the scope.
-
const std::vector<ID> &findMentionedModules(Context *context, ID modId)¶
Given a ID for a module, returns a vector of IDs for all the modules that are used, imported, or mentioned in that module.
-
const ResolvedVisibilityScope *resolveVisibilityStmts(Context *context, const Scope *scope, bool skipPrivate = false)¶
Resolve the uses and imports in a given scope.
If ‘skipPrivate’ is set, avoids resolving visibility statements that only expose scope-private symbols. This helps avoid unnecessary work.
-
const Scope *scopeForAutoModule(Context *context)¶
Return the scope for the automatically included ‘ChapelStandard’ module, or nullptr if it could not be found.
-
const std::vector<ID> &moduleInitializationOrder(Context *context, ID mainModule, std::vector<ID> commandLineModules)¶
Given the ID for the main module, compute the order in which modules should be initialized. ‘commandLineModules’ can be provided with the list of modules that are named on the command line.
The result is vector of IDs indicating the order in which modules with those IDs should be initialized.
-
void emitMultipleDefinedSymbolErrors(Context *context, const Scope *scope)¶
Check for symbol names with multiple definitions within a scope. This query only exists to emit errors.
-
const ModulePublicSymbols *publicSymbolsForModule(Context *context, const Scope *modScope)¶
Given a Scope* for a Module, return a DeclMap containing all symbols publicly available from that module, including those brought in transitively by use/import.
-
bool lookupInDeclMap(const DeclMap &declared, UniqueString name, MatchingIdsWithName &result, IdAndFlags::Flags filterFlags, const IdAndFlags::FlagSet &excludeFlags)¶
Gather matches to ‘name’ that match ‘filterFlags’ and aren’t excluded by ‘excludeFlags’. Store any gathered into ‘result’
Variables
-
const LookupConfig IDENTIFIER_LOOKUP_CONFIG = LOOKUP_DECLS | LOOKUP_IMPORT_AND_USE | LOOKUP_PARENTS | LOOKUP_EXTERN_BLOCKS¶
The configuration used to look up a plain identifier in a scope when resolving expressions.
-
class ApplicabilityResult¶
Represents either a function that was accepted during call resolution, or the reason why that function was rejected.
Public Functions
-
inline ApplicabilityResult()¶
-
inline bool operator==(const ApplicabilityResult &other) const¶
-
inline bool operator!=(const ApplicabilityResult &other) const¶
-
inline size_t hash() const¶
-
inline const TypedFnSignature *initialForErr() const¶
-
inline const TypedFnSignature *candidate() const¶
-
inline bool success() const¶
-
inline CandidateFailureReason reason() const¶
-
inline PassingFailureReason formalReason() const¶
-
inline int formalIdx() const¶
Public Static Functions
-
static inline ApplicabilityResult success(const TypedFnSignature *candidate)¶
-
static inline ApplicabilityResult failure(const TypedFnSignature *initialForErr, PassingFailureReason reason, int formalIdx)¶
-
static inline ApplicabilityResult failure(ID idForErr, CandidateFailureReason reason)¶
-
static inline bool update(ApplicabilityResult &keep, ApplicabilityResult &addin)¶
-
inline ApplicabilityResult()¶
-
class AssociatedAction¶
This type represents an associated action (for use within a ResolvedExpression).
Public Types
Public Functions
-
inline AssociatedAction(Action action, const TypedFnSignature *fn, ID id)¶
-
inline bool operator==(const AssociatedAction &other) const¶
-
inline bool operator!=(const AssociatedAction &other) const¶
-
inline const TypedFnSignature *fn() const¶
Return which function is called to help with the action
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
inline AssociatedAction(Action action, const TypedFnSignature *fn, ID id)¶
-
struct CalledFnOrder¶
-
class CallInfo¶
-
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
-
inline const 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 isOpCall() const¶
check if the call is an operator 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¶
Public Static Functions
-
static CallInfo createSimple(UniqueString calledFnName)¶
Construct a CallInfo with no arguments, for calling a regular function by name. Does not handle methods.
-
static CallInfo createSimple(UniqueString calledFnName, types::QualifiedType arg1type)¶
Construct a CallInfo with one argument, for calling a regular function by name. Does not handle methods.
-
static CallInfo createSimple(UniqueString calledFnName, types::QualifiedType arg1type, types::QualifiedType arg2type)¶
Construct a CallInfo with two arguments, for calling a regular function by name. Does not handle methods.
-
static CallInfo createUnknown(const uast::FnCall *call)¶
Construct a CallInfo with unknown types for the actuals that can be used for FormalActualMap but not much else. Assumes that the calledExpression is an identifier and that it is a function name (vs a method invocation).
-
static CallInfo create(Context *context, const uast::Call *call, const ResolutionResultByPostorderID &byPostorder, bool raiseErrors = true, std::vector<const uast::AstNode*> *actualAsts = nullptr, ID *moduleScopeId = nullptr, UniqueString rename = UniqueString())¶
Construct a CallInfo from a Call and optionally raise errors that occur when doing so. Assumes that the actual arguments have already been resolved and their types are available in ‘byPostorder’.
If ‘raiseErrors’ is ‘true’ (the default), then errors encountered will be raised on the current query.
If actualAsts is provided and not ‘nullptr’, it will be updated to contain the uAST pointers for each actual.
If moduleScopeId is provided and not ‘nullptr’, it will be updated with the ID of the scope that should be searched for candidates. That is, if the call expression is ‘M.f(…)’ for a module ‘M’, then ‘moduleScopeId’ will be set to the ID of the module ‘M’.
-
static CallInfo createWithReceiver(const CallInfo &ci, types::QualifiedType receiverType, UniqueString rename = UniqueString())¶
Construct a CallInfo by adding a method receiver argument to the passed CallInfo.
-
static CallInfo copyAndRename(const CallInfo &ci, UniqueString rename)¶
Copy and rename a CallInfo.
-
static void prepareActuals(Context *context, const uast::Call *call, const ResolutionResultByPostorderID &byPostorder, bool raiseErrors, std::vector<CallInfoActual> &actuals, const uast::AstNode *&questionArg, std::vector<const uast::AstNode*> *actualAsts)¶
Prepare actuals for a call for later use in creating a CallInfo. This is a helper function for CallInfo::create that is sometimes useful to call separately.
Sets ‘actuals’ and ‘hasQuestionArg’.
If actualIds is not ‘nullptr’, then the toID value of each actual is pushed to that array.
-
using CallInfoActualIterable = Iterable<std::vector<CallInfoActual>>¶
-
class CallInfoActual¶
Public Functions
-
inline explicit CallInfoActual(types::QualifiedType type)¶
-
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 explicit CallInfoActual(types::QualifiedType type)¶
-
class CallResolutionResult¶
-
Public Functions
-
inline CallResolutionResult()¶
-
inline CallResolutionResult(types::QualifiedType exprType, types::QualifiedType yieldedType = types::QualifiedType())¶
-
inline CallResolutionResult(MostSpecificCandidates mostSpecific, bool rejectedPossibleIteratorCandidates, types::QualifiedType exprType, types::QualifiedType yieldedType, PoiInfo poiInfo, bool speciallyHandled = false)¶
-
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 types::QualifiedType &yieldedType() const¶
type of the yielded expression, if the call expression is an iterator
-
inline const PoiInfo &poiInfo() const¶
point-of-instantiation scopes used when resolving signature or body
-
inline bool speciallyHandled() const¶
whether the resolution result was handled using some compiler-level logic
-
inline bool rejectedPossibleIteratorCandidates() const¶
whether we rejected candidates because they expected a tag or followThis. This might indicate that we need to re-resolve with tag to find parallel iterators.
-
inline bool operator==(const CallResolutionResult &other) const¶
-
inline bool operator!=(const CallResolutionResult &other) const¶
-
inline size_t hash() const¶
-
inline void swap(CallResolutionResult &other)¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
Public Static Functions
-
static inline CallResolutionResult getEmpty()¶
-
inline CallResolutionResult()¶
-
class CallScopeInfo¶
When resolving calls like f(), we need three scopes to search. The ‘call scope’, which becomes relevant if we’re resolving a generic function. When we resolve a generic function, and come across other calls, this ‘call scope’ becomes the ‘poi scope’ for resolving those dependent calls. The ‘lookup scope’, which is used to restrict where we search for candidates. For instance, when resolving
M.f()
, we don’t want to look forf
in the current scope, only in the scope ofM
. The call scope is not always the same as the ‘lookup scope’ because while resolvingM.f
, we still want to use the ‘call scope’ for POI. The ‘POI scope’, which is used when resolving calls in generic functions as described in the first bullet.This data structure bundles all three scopes for convenient threading through the call resolution process.
Public Functions
Public Static Functions
-
static CallScopeInfo forNormalCall(const Scope *scope, const PoiScope *poiScope)¶
-
static CallScopeInfo forQualifiedCall(Context *context, const ID &moduleId, const Scope *scope, const PoiScope *poiScope)¶
-
static CallScopeInfo forIteratorOverloadSearch(const Scope *callScope, const Scope *lookupScope, const PoiScope *poiScope)¶
-
static CallScopeInfo forNormalCall(const Scope *scope, const PoiScope *poiScope)¶
-
struct CandidatesAndForwardingInfo¶
Public Types
-
using const_iterator = std::vector<const TypedFnSignature*>::const_iterator¶
Public Functions
-
inline void addCandidate(const TypedFnSignature *candidate)¶
-
inline void takeFromOther(CandidatesAndForwardingInfo &other)¶
-
inline const TypedFnSignature *get(size_t i) const¶
-
inline const types::QualifiedType &getForwardingInfo(size_t i) const¶
-
inline bool empty() const¶
-
inline size_t size() const¶
-
inline bool hasForwardingInfo() const¶
-
inline const_iterator begin() const¶
-
inline const_iterator end() const¶
-
inline size_t hash() const¶
-
inline bool operator==(const CandidatesAndForwardingInfo &other) const¶
-
inline void swap(CandidatesAndForwardingInfo &other)¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
Public Static Functions
-
static inline bool update(CandidatesAndForwardingInfo &keep, CandidatesAndForwardingInfo &addin)¶
-
using const_iterator = std::vector<const TypedFnSignature*>::const_iterator¶
-
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 BORROWS¶
A conversion that borrows a managed type (without subtyping)
-
enumerator BORROWS_SUBTYPE¶
A conversion that implements subtyping AND borrows a managed type
-
enumerator OTHER¶
Non-subtype conversion that doesn’t produce a param
-
enumerator NONE¶
Public Functions
-
inline CanPassResult()¶
-
~CanPassResult() = default¶
-
inline bool passes() const¶
Returns true if the argument is passable
-
inline PassingFailureReason reason() const¶
-
inline bool instantiates() const¶
Returns true if passing the argument will require instantiation
-
inline bool promotes() const¶
Returns true if passing the argument will require promotion
-
inline bool converts() const¶
Returns true if implicit conversion is required
-
inline ConversionKind conversionKind() const¶
What type of implicit conversion, if any, is needed?
-
inline bool convertsWithParamNarrowing() const¶
Returns true if an implicit param narrowing conversion is required
-
inline bool convertsWithBorrowing() const¶
Returns true if an implicit borrowing conversion is required. Does not include borrowing with implicit subtyping.
Public Static Functions
-
static CanPassResult canPassScalar(Context *context, const types::QualifiedType &actualType, const types::QualifiedType &formalType)¶
-
static CanPassResult canPass(Context *context, const types::QualifiedType &actualType, const types::QualifiedType &formalType)¶
-
enum ConversionKind¶
-
struct CheckedScope¶
The type to help maintain a checked scope
Public Functions
-
inline CheckedScope(UniqueString forName, const Scope *scope)¶
-
inline bool operator==(const CheckedScope &other) const¶
-
inline bool operator!=(const CheckedScope &other) const¶
-
inline size_t hash() const¶
-
inline CheckedScope(UniqueString forName, const Scope *scope)¶
-
struct CopyableAssignableInfo¶
Public Functions
-
inline CopyableAssignableInfo()¶
-
inline bool isFromConst() const¶
-
inline bool isFromRef() const¶
-
inline void intersectWith(const CopyableAssignableInfo &other)¶
-
inline bool operator==(const CopyableAssignableInfo &other) const¶
-
inline bool operator!=(const CopyableAssignableInfo &other) const¶
-
inline void swap(CopyableAssignableInfo &other)¶
Public Static Functions
-
static inline CopyableAssignableInfo fromConst()¶
-
static inline CopyableAssignableInfo fromRef()¶
-
static inline CopyableAssignableInfo fromNone()¶
-
static inline bool update(CopyableAssignableInfo &keep, CopyableAssignableInfo &addin)¶
-
inline CopyableAssignableInfo()¶
-
class FormalActual¶
FormalActual holds information on a function formal and its binding (if any)
Public Functions
-
inline bool operator==(const FormalActual &other) const¶
-
inline bool operator!=(const FormalActual &other) const¶
-
inline size_t hash() const¶
-
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 bool operator==(const FormalActual &other) const¶
-
class FormalActualMap¶
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 operator==(const FormalActualMap &other) const¶
-
inline bool operator!=(const FormalActualMap &other) const¶
-
inline size_t hash() const¶
-
inline bool isValid() const¶
check if mapping is valid
-
inline CandidateFailureReason reason() const¶
Check why the mapping was invalid.
-
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 IdAndFlags¶
Helper type to store an ID and key information that is relevant to scope resolution.
Public Types
-
using Flags = uint16_t¶
A bit-set of the flags defined in the above enum. Represents a conjunction / AND of all the set bit. E.g.: just IdAndFlags::PUBLIC — only public symbols just IdAndFlags::METHOD_FIELD — only methods/fields IdAndFlags::PUBLIC | IdAndFlags::METHOD_FIELD — only public symbols that are methods/fields Empty Flags — match everything
Public Functions
-
inline IdAndFlags()¶
-
IdAndFlags(ID id, bool isPublic, bool isMethodOrField, bool isParenfulFunction, bool isMethod, bool isModule, bool isType)¶
-
inline bool operator==(const IdAndFlags &other) const¶
-
inline bool operator!=(const IdAndFlags &other) const¶
-
inline size_t hash() const¶
-
inline bool isPublic() const¶
-
inline bool isMethodOrField() const¶
-
inline bool isMethod() const¶
-
inline bool isParenfulFunction() const¶
-
inline bool isModule() const¶
-
inline bool isType() const¶
-
inline bool matchesFilter(Flags filterFlags, const FlagSet &excludeFlagSet) const¶
Returns true if this IdAndFlags matches filterFlags, and does not match the exclude flag set. See the comments on Flags and FlagSet for how the matching works.
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
Public Static Functions
-
static inline IdAndFlags createForModule(ID id, bool isPublic)¶
-
static inline IdAndFlags createForBuiltinType()¶
-
static inline IdAndFlags createForBuiltinVar()¶
-
class FlagSet¶
A set of bit-sets / flag combinations. Logically, while Flags represents a conjunction of all of its bitfields (see documentation on Flags), this FlagSet represents a disjunction of each flag combination. That is to say, if FlagSet contains:
This represents the following condition on variables:IdAndFlags::PUBLIC, IdAndFlags::NOT_PUBLIC | IdAndFlags::METHOD_FIELD
That is, either any public symbol, or a private method or field.IdAndFlags::PUBLIC ∨ (IdAndFlags::NOT_PUBLIC ∧ IdAndFlags::METHOD_FIELD)
Other examples: [] (empty FlagSet) — matches nothing. [IdAndFlags::PUBLIC | IdAndFlags::METHOD_FIELD] — only public symbols that are methods / fields. More generally, [f] (singleton set) — equivalent to the single contained Flags value f.
Inserting into the FlagSet automatically tries to perform basic simplification to avoid growing the size.
Public Functions
-
FlagSet() = default¶
-
void addDisjunction(Flags excludeFlags)¶
Add a new disjunct (OR) to the set of flag combinations. Automatically performs some deduplication and packing to avoid growing the set if possible.
-
bool noneMatch(Flags match) const¶
Checks that none of the or’ed flag combinations match the given flags.
-
size_t hash() const¶
-
FlagSet() = default¶
-
using Flags = uint16_t¶
-
class InnermostMatch¶
-
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 KindProperties¶
Public Functions
-
void setRef(bool isRef)¶
-
void setParam(bool isParam)¶
-
void setConst(bool isConst)¶
-
void combineWithJoin(const KindProperties &other)¶
-
void combineWithMeet(const KindProperties &other)¶
-
void strictCombineWith(const KindProperties &other)¶
-
types::QualifiedType::Kind toKind() const¶
-
inline bool valid() const¶
Public Static Functions
-
static KindProperties fromKind(types::QualifiedType::Kind kind)¶
-
static types::QualifiedType::Kind combineKindsMeet(types::QualifiedType::Kind kind1, types::QualifiedType::Kind kind2)¶
-
static types::QualifiedType::Kind makeConst(types::QualifiedType::Kind kind)¶
-
void setRef(bool isRef)¶
-
class MatchingIdsWithName¶
Contains IDs with a particular name that matched some filter.
Public Types
-
using const_iterator = std::vector<IdAndFlags>::const_iterator¶
Public Functions
-
inline MatchingIdsWithName()¶
Construct a empty MatchingIdsWithName containing no IDs.
-
inline void append(IdAndFlags idv)¶
Append an IdAndFlags.
-
void removeDuplicateIds()¶
Remove any duplicates IDs present here.
-
void clear()¶
Remove all IDs.
-
inline bool isEmpty() const¶
Returns ‘true’ if this MatchingIdsWithName has no IDs
-
inline int numIds() const¶
Return the number of IDs stored here
-
inline const IdAndFlags &firstIdAndFlags() const¶
Returns the first IdAndFlags in this list.
-
inline const IdAndFlags &idAndFlags(int i) const¶
Return the i’th IdAndFlags in the list
-
inline IdAndFlags &idAndFlags(int i)¶
Return a mutable reference to the i’th IdAndFlags in the list
-
bool containsOnlyMethodsOrFields() const¶
Returns ‘true’ if the list contains only IDs that represent methods or fields.
-
inline MatchingIdsWithNameIter begin() const¶
-
inline MatchingIdsWithNameIter end() const¶
-
inline bool operator==(const MatchingIdsWithName &other) const¶
-
inline bool operator!=(const MatchingIdsWithName &other) const¶
-
inline size_t hash() const¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
Public Static Functions
-
static inline MatchingIdsWithName createWithIdAndFlags(IdAndFlags idv)¶
-
class MatchingIdsWithNameIter¶
Iterator that yields IDs rather than IdAndFlags.
Public Types
-
using difference_type = std::ptrdiff_t¶
-
using iterator_category = std::forward_iterator_tag¶
Public Functions
-
inline bool operator!=(const MatchingIdsWithNameIter &other) const¶
-
inline MatchingIdsWithNameIter &operator++()¶
-
inline const IdAndFlags &curIdAndFlags() const¶
-
using difference_type = std::ptrdiff_t¶
-
using const_iterator = std::vector<IdAndFlags>::const_iterator¶
-
class MethodLookupHelper¶
This type helps lookupNameInScope and related functions by containing the set of scopes that should be searched and by providing a way to evaluate a method candidate according to its method receiver.
This type can apply in two different ways:
When resolving something like ‘x.field’, the resolver can compute a MethodLookupHelper for ‘x’ based on its type and then pass this to the lookup process.
When resolving something like ‘field’ within a method, the lookup process can ask to compute one of these at the right time with a ReceiverScopeHelper.
Subclassed by chpl::resolution::SimpleMethodLookupHelper, chpl::resolution::TypedMethodLookupHelper
-
class ModulePublicSymbols¶
This type collects all public symbols used in a module
Public Functions
-
inline bool lookupInModule(UniqueString name, MatchingIdsWithName &result, IdAndFlags::Flags filterFlags, const IdAndFlags::FlagSet &excludeFlags) const¶
-
inline bool operator==(const ModulePublicSymbols &other) const¶
-
inline bool operator!=(const ModulePublicSymbols &other) const¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
Public Static Functions
-
static inline bool update(owned<ModulePublicSymbols> &keep, owned<ModulePublicSymbols> &addin)¶
-
inline bool lookupInModule(UniqueString name, MatchingIdsWithName &result, IdAndFlags::Flags filterFlags, const IdAndFlags::FlagSet &excludeFlags) const¶
-
class MostSpecificCandidate¶
Stores a function candidate. This information includes both the TypedFnSignature* representing the candidate, as well as information about this candidate’s applicability. In particular, we store whether or not this candidate requires a const ref coercion, which is allowed by the spec, but is not allowed in practice due to the aliasing rules of C.
Public Functions
-
inline MostSpecificCandidate()¶
-
MostSpecificCandidate &operator=(MostSpecificCandidate &&other) = default¶
-
inline MostSpecificCandidate &operator=(const MostSpecificCandidate &other)¶
-
MostSpecificCandidate(MostSpecificCandidate &&other) = default¶
-
inline MostSpecificCandidate(const MostSpecificCandidate &other)¶
-
inline const TypedFnSignature *fn() const¶
-
inline const FormalActualMap &formalActualMap() const¶
-
inline const SubstitutionsMap &promotedFormals() const¶
-
inline int constRefCoercionFormal() const¶
-
inline int constRefCoercionActual() const¶
-
inline bool hasConstRefCoercion() const¶
-
inline operator bool() const¶
-
inline bool operator==(const MostSpecificCandidate &other) const¶
-
inline bool operator!=(const MostSpecificCandidate &other) const¶
-
inline size_t hash() const¶
-
inline void swap(MostSpecificCandidate &other)¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
Public Static Functions
-
static MostSpecificCandidate fromTypedFnSignature(Context *context, const TypedFnSignature *fn, const FormalActualMap &faMap, const SubstitutionsMap &promotedFormals)¶
-
static MostSpecificCandidate fromTypedFnSignature(Context *context, const TypedFnSignature *fn, const CallInfo &info, const SubstitutionsMap &promotedFormals)¶
-
static inline bool update(MostSpecificCandidate &keep, MostSpecificCandidate &addin)¶
-
inline MostSpecificCandidate()¶
-
class MostSpecificCandidates¶
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.
-
void inferOutFormals(ResolutionContext *rc, const PoiScope *instantiationPoiScope)¶
Adjust each candidate signature by inferring generic ‘out’ intent formals if there are any.
-
inline MostSpecificCandidate const *begin() const¶
-
inline MostSpecificCandidate const *end() const¶
-
inline void setBestRef(MostSpecificCandidate c)¶
-
inline void setBestConstRef(MostSpecificCandidate c)¶
-
inline void setBestValue(MostSpecificCandidate c)¶
-
inline void setBestOnly(MostSpecificCandidate c)¶
-
inline const MostSpecificCandidate &bestRef() const¶
-
inline const MostSpecificCandidate &bestConstRef() const¶
-
inline const MostSpecificCandidate &bestValue() const¶
-
inline const MostSpecificCandidate &only() const¶
If there is exactly one candidate, return that candidate. Otherwise, return an empty candidate.
-
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 foundCandidates() const¶
Returns ‘true’ if any candidate was found, including if there was no best candidate due to ambiguity.
-
inline bool operator==(const MostSpecificCandidates &other) const¶
-
inline bool operator!=(const MostSpecificCandidates &other) const¶
-
inline void swap(MostSpecificCandidates &other)¶
-
inline size_t hash() const¶
-
void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
Public Static Functions
-
static inline MostSpecificCandidates getOnly(MostSpecificCandidate c)¶
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()¶
-
template<typename UV>
class MutatingResolvedVisitor¶ Similar to ResolvedVisitor but this one works with a mutable ResolutionResultByPostorderID.
Public Functions
-
inline MutatingResolvedVisitor(ResolutionContext *rc, const uast::AstNode *ast, UV &userVisitor, const ResolutionResultByPostorderID &byPostorder)¶
-
inline ResolutionContext *rc() const¶
Return the ResolutionContext used by this ResolvedVisitor
-
inline Context *context() const¶
Return the context used by this ResolvedVisitor
-
inline const uast::AstNode *ast() const¶
Return the uAST node being visited by this ResolvedVisitor
-
inline UV &userVisitor()¶
Return the user visitor that this ResolvedVisitor invokes
-
inline const UV &userVisitor() const¶
Return the user visitor that this ResolvedVisitor invokes
-
inline ResolutionResultByPostorderID &byPostorder() const¶
Return the current ResolutionResultByPostorderID which can be used to gather type information
-
inline bool hasAst(const uast::AstNode *ast) const¶
Returns if the ResolutionResultByPostorderID has a result for a particular uAST node
-
inline ResolvedExpression &byAst(const uast::AstNode *ast) const¶
Return the ResolvedExpression for a particular uAST node
-
inline bool hasId(const ID &id) const¶
Returns if the ResolutionResultByPostorderID has a result for a particular ID
-
inline ResolvedExpression &byId(const ID &id) const¶
Return the ResolvedExpression for a particular ID
-
inline MutatingResolvedVisitor(ResolutionContext *rc, const uast::AstNode *ast, UV &userVisitor, const ResolutionResultByPostorderID &byPostorder)¶
-
class OuterVariables¶
This type stores the outer variables used by a function. For each mention of an outer variable, it keeps track of the outer variable’s ID and type.
Public Types
-
using QualifiedType = types::QualifiedType¶
-
using TargetAndType = std::pair<const ID, QualifiedType>¶
Public Functions
-
OuterVariables() = default¶
-
~OuterVariables() = default¶
-
inline bool operator==(const OuterVariables &rhs) const¶
-
inline bool operator!=(const OuterVariables &rhs) const¶
-
inline void swap(OuterVariables &rhs)¶
-
inline size_t hash() const¶
-
inline void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
inline void add(const ID &mention, const ID &target, const QualifiedType &qt)¶
Mutating method used to build up state. If either the mention or target IDs are empty then nothing happens.
-
inline const TargetAndType *targetAndTypeOrNull(const ID &mention) const¶
For a given mention, return the target ID and type if it exists.
-
inline bool isEmpty() const¶
Public Static Functions
-
static inline bool update(owned<OuterVariables> &keep, owned<OuterVariables> &addin)¶
-
using QualifiedType = types::QualifiedType¶
-
class OwnedIdsWithName¶
Collects IDs with a particular name.
Public Functions
-
inline OwnedIdsWithName(IdAndFlags idv)¶
Construct an OwnedIdsWithName containing one IdAndFlags
-
inline void appendIdAndFlags(IdAndFlags idv)¶
Append an IdAndFlags to an OwnedIdsWithName.
-
bool gatherMatches(MatchingIdsWithName &dst, IdAndFlags::Flags filterFlags, const IdAndFlags::FlagSet &excludeFlagSet) const¶
Append any entries that match filterFlags and aren’t excluded by excludeFlagSet to a MatchingIdsWithName. Returns ‘true’ if any matches were appended.
-
inline int numIds() const¶
-
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(IdAndFlags idv)¶
-
class PoiInfo¶
Contains information about symbols available from point-of-instantiation in order to implement caching of instantiations.
Public Types
-
using Trace = std::tuple<const TypedFnSignature*, PoiCallIdFnIds, PoiRecursiveCalls>¶
Public Functions
-
PoiInfo() = default¶
-
inline void setResolved(bool resolved)¶
set resolved
-
inline const PoiCallIdFnIds &poiFnIdsUsed() const¶
-
inline const PoiRecursiveCalls &recursiveFnsUsed() const¶
-
inline PoiInfo::Trace createTraceFor(const TypedFnSignature *sig) const¶
-
void accumulateRecursive(const TypedFnSignature *signature, const PoiScope *poiScope)¶
-
inline size_t hash() const¶
-
inline void stringify(std::ostream &ss, chpl::StringifyKind stringKind) const¶
-
using Trace = std::tuple<const TypedFnSignature*, PoiCallIdFnIds, PoiRecursiveCalls>¶
-
class PoiScope¶
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 ReceiverScopeHelper¶
This type helps lookupNameInScope and related functions. When performing name lookup within a method, the name might refer to a field or tertiary method. Such matches are checked for by searching the method receiver scopes at the time that the method signature is encountered in the process of searching parent scopes. This type includes a method that can return an appropriate MethodLookupHelper to handle the method receiver scopes.
Subclassed by chpl::resolution::ReceiverScopeSimpleHelper, chpl::resolution::ReceiverScopeTypedHelper
Public Functions
-
virtual ~ReceiverScopeHelper()¶
-
virtual const MethodLookupHelper *methodLookupForMethodId(Context *context, const ID &methodId) const = 0¶
-
virtual ~ReceiverScopeHelper()¶
-
class ReceiverScopeSimpleHelper : public chpl::resolution::ReceiverScopeHelper¶
Public Functions
-
inline ReceiverScopeSimpleHelper()¶
-
const SimpleMethodLookupHelper *methodLookupForTypeId(Context *context, const ID &typeId) const¶
-
virtual const SimpleMethodLookupHelper *methodLookupForMethodId(Context *context, const ID &methodId) const override¶
-
inline ReceiverScopeSimpleHelper()¶
-
struct ReceiverScopeTypedHelper : public chpl::resolution::ReceiverScopeHelper¶
Public Functions
-
inline ReceiverScopeTypedHelper()¶
-
inline ReceiverScopeTypedHelper(ID resolvingMethodId, types::QualifiedType resolvingMethodReceiverType)¶
-
const TypedMethodLookupHelper *methodLookupForType(Context *context, types::QualifiedType type) const¶
-
virtual const TypedMethodLookupHelper *methodLookupForMethodId(Context *context, const ID &methodId) const override¶
-
inline ReceiverScopeTypedHelper()¶
-
class ResolutionContext¶
This class is used to manage stack frames that may be necessary while resolving. Any resolution function that may require stack frames will take a ‘ResolutionContext*’ as its first argument instead of ‘Context*’.
In the vast majority of cases an end-user of the API can call such a function using the following sort of pattern:
ResolutionContext rcval(context); auto crr = resolveCall(&rcval, …);
The ‘ResolutionContext’ consists of a series of ‘frames’ that roughly correspond to typical stack frames. There are two types of frame, stable frames and unstable frames. Unstable frames are generally created to wrap around a mutable ‘Resolver*’ instance. Stable frames wrap around immutable query results such as ‘const ResolvedFunction*’.
At any point in time, a ‘ResolutionContext*’ is either stable or unstable. It is unstable if it has one or more unstable frames.
When the ‘ResolutionContext*’ is unstable, any ‘CHPL_RESOLUTION_QUERY…’ will consult the passed in query arguments in order to determine if the ‘Context*’ query cache can be used. If the arguments may refer to a nested function, then the computed result is not cached in the global query cache.
Public Functions
-
inline explicit ResolutionContext(Context *context)¶
Create an empty ‘ResolutionContext’.
-
ResolutionContext(const ResolutionContext &rhs) = delete¶
-
ResolutionContext(ResolutionContext &&rhs) = default¶
-
~ResolutionContext() = default¶
-
inline bool isEmpty() const¶
If ‘true’, then this ‘ResolutionContext’ has no state available.
-
inline bool isUnstable() const¶
If ‘true’, then this contains one or more unstable frames.
-
template<typename F>
inline const Frame *findFrameMatching(F predicate) const¶ Find the first stack frame matching a predicate in LIFO order.
-
inline const Frame *findFrameWithId(const ID &id) const¶
Find the first stack frame containing or matching an id.
-
template<typename T>
inline bool canUseGlobalCacheConsidering(const T &t) const¶ Determine if the global query cache stored in the ‘Context*’ can be used. If this ‘ResolutionContext*’ is not unstable, then the global query cache can always be used.
If not, then consider ‘t’. In general, if ‘t’ is a type that refers to a nested function, conservatively return ‘false’.
-
template<typename T1, typename T2, typename ...Ts>
inline bool canUseGlobalCacheConsidering(const T1 &t1, const T2 &t2, const Ts&... ts)¶
-
template<auto F, typename ...InvokeArgs>
inline auto createQueryClass(const char *name, InvokeArgs&&... args)¶ Called to construct an instance of a ‘ResolutionContext::Query’. These implement the ‘CHPL_RESOLUTION_QUERY…’ family of macros defined below.
Public Static Functions
-
template<typename T>
static inline bool canUseGlobalCache(Context *context, const T &t)¶ Can the global query cache can be invoked considering only ‘t’? By default, assume it can be.
-
template<typename T>
static inline bool canUseGlobalCache(Context *context, const std::vector<T> &v)¶
-
static bool canUseGlobalCache(Context *context, const UntypedFnSignature &t)¶
-
static bool canUseGlobalCache(Context *context, const TypedFnSignature &t)¶
-
static bool canUseGlobalCache(Context *context, const MatchingIdsWithName &ids)¶
-
template<auto F, typename InvokeArgsTuple>
struct CanUseGlobalCache¶ Public Functions
-
inline bool operator()(ResolutionContext *rc, const InvokeArgsTuple &args)¶
Consider ‘args’ and determine if the global query cache can be used.
-
inline bool operator()(ResolutionContext *rc, const InvokeArgsTuple &args)¶
-
class Frame¶
This class represents a single ‘frame’ for a symbol. It is currently a thin wrapper around the internal ‘Resolver’ type. Generally, a frame is pushed every time specific resolvers are created, and popped when they are destroyed.
Public Functions
-
~Frame() = default¶
-
inline const Frame *parent(const ResolutionContext *rc) const¶
-
inline Frame *parent(ResolutionContext *rc)¶
-
inline Resolver *rv()¶
-
inline const ResolvedFunction *rf()¶
-
inline bool isEmpty()¶
-
const TypedFnSignature *signature() const¶
-
const ResolutionResultByPostorderID *resolutionById() const¶
-
bool isUnstable() const¶
-
~Frame() = default¶
-
template<auto F, typename InvokeArgsTuple>
struct GlobalComputeSetup¶ Public Functions
-
inline bool enter(ResolutionContext *rc, const InvokeArgsTuple &args)¶
Called before the query is run, returns ‘true’ if prep was done.
-
inline void leave(ResolutionContext *rc, const InvokeArgsTuple &args)¶
Called before the query returns, only if ‘enter’ returned ‘true’.
-
inline bool enter(ResolutionContext *rc, const InvokeArgsTuple &args)¶
-
template<auto F, typename InvokeRet, typename ...InvokeArgs>
class GlobalQuery¶ This is a class-based wrapper around global context queries.
Public Types
-
using InvokeArgsTuple = std::tuple<InvokeArgs...>¶
-
using ArgsByValueTuple = std::tuple<Value<InvokeArgs>...>¶
-
using Wrapper = GlobalQueryWrapper<F, RetByVal, Value<InvokeArgs>...>¶
Public Functions
-
inline GlobalQuery(Context *context, const char *name, InvokeArgs&&... args)¶
-
GlobalQuery(const GlobalQuery &rhs) = delete¶
-
GlobalQuery(GlobalQuery &&rhs) = default¶
-
inline const InvokeArgsTuple &args() const¶
-
inline bool isRunning()¶
-
inline bool hasCurrentResult()¶
Public Static Attributes
-
static bool STOPWATCH_IS_ACTIVE = true¶
-
using InvokeArgsTuple = std::tuple<InvokeArgs...>¶
-
template<auto F, typename RetByVal, typename ...ArgsByValue>
struct GlobalQueryWrapper¶ This struct forms an adapter between queries that work with the ‘ResolutionContext*’ and traditional queries that work with the ‘Context*’ (the global query cache).
The function that contains the user’s query code is the template value ‘F’. The function stored in the global query cache is ‘query’, defined below. The only time ‘query’ should be called is when the ‘Context*’ is recomputing queries after bumping the revision. In that case, ‘query’ creates an empty ‘ResolutionContext’ and uses it to call into ‘F’.
Public Static Functions
-
static inline const RetByVal &query(Context *context, ArgsByValue... args)¶
-
static inline const RetByVal &query(Context *context, ArgsByValue... args)¶
-
template<auto F, typename InvokeRet, typename ...InvokeArgs>
class Query¶
-
inline explicit ResolutionContext(Context *context)¶
-
using CalledFnsSet = std::unordered_map<const ResolvedFunction*, CalledFnOrder>¶