Skip to content

Commit

Permalink
Resolve and use real 'defaultDist' type
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Rift <anna.rift@hpe.com>
  • Loading branch information
riftEmber committed Aug 7, 2024
1 parent f3aef28 commit 88f1c73
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions frontend/include/chpl/types/DomainType.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class DomainType final : public CompositeType {
const QualifiedType& idxType,
const QualifiedType& parSafe);

/** Get the default distribution type */
static const RecordType* getDefaultDistType(Context* context);

Kind kind() const {
return kind_;
}
Expand Down
7 changes: 4 additions & 3 deletions frontend/lib/resolution/Resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2266,9 +2266,10 @@ bool Resolver::resolveSpecialKeywordCall(const Call* call) {
const AstNode* questionArg = nullptr;
std::vector<CallInfoActual> actuals;
// Set up 'dist' arg
// TODO: get and use real type of defaultDist here
auto defaultDistArg =
CallInfoActual(QualifiedType(), UniqueString::get(context, "dist"));
auto defaultDistArg = CallInfoActual(
QualifiedType(QualifiedType::CONST_REF,
DomainType::getDefaultDistType(context)),
UniqueString::get(context, "dist"));
actuals.push_back(std::move(defaultDistArg));
// Remaining given args from domain() call as written
prepareCallInfoActuals(call, actuals, questionArg);
Expand Down
3 changes: 2 additions & 1 deletion frontend/lib/types/CompositeType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ bool CompositeType::isMissingBundledRecordType(Context* context, ID id) {
id == CompositeType::getRangeType(context)->id() ||
id == TupleType::getGenericTupleType(context)->id() ||
id == CompositeType::getBytesType(context)->id() ||
id == CompositeType::getDistributionType(context)->id();
id == CompositeType::getDistributionType(context)->id() ||
id == DomainType::getDefaultDistType(context)->id();
}

return false;
Expand Down
10 changes: 10 additions & 0 deletions frontend/lib/types/DomainType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ DomainType::getAssociativeType(Context* context,
DomainType::Kind::Associative).get();
}

const RecordType* DomainType::getDefaultDistType(Context* context) {
auto id = parsing::getSymbolFromTopLevelModule(context, "DefaultRectangular",
"defaultDist");
auto name = id.symbolName(context);

return RecordType::get(context, id, name,
/* instantiatedFrom */ nullptr,
/* subs */ SubstitutionsMap());
}

int DomainType::rankInt() const {
if (kind_ == Kind::Rectangular) {
return rank().param()->toIntParam()->value();
Expand Down

0 comments on commit 88f1c73

Please sign in to comment.