Skip to content

Commit

Permalink
wip use _domain type ctor
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 22, 2024
1 parent 49f22c8 commit 950df4d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion frontend/lib/resolution/Resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,7 @@ bool Resolver::resolveSpecialKeywordCall(const Call* call) {
CHPL_ASSERT(!questionArg);
// TODO: prohibit associative domain with idxType 'domain'
auto ci =
CallInfo(USTR("init"),
CallInfo(UniqueString::get(context, "_domain"),
rCalledExp.type(),
/* isMethodCall */ false,
/* hasQuestionArg */ false,
Expand Down
35 changes: 19 additions & 16 deletions frontend/lib/resolution/resolution-queries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,8 @@ typeConstructorInitialQuery(Context* context, const Type* t)
idTag = uast::asttags::Class;
} else if (t->isRecordType()) {
idTag = uast::asttags::Record;
} else if (t->isDomainType()) {
idTag = uast::asttags::Record;
} else if (t->isUnionType()) {
idTag = uast::asttags::Union;
}
Expand Down Expand Up @@ -3463,22 +3465,22 @@ static bool resolveFnCallSpecialType(Context* context,
//
// TODO: sync, single
if (ci.name() == "domain") {
// TODO: a compiler-generated type constructor would be simpler, but we
// don't support default values on compiler-generated methods because the
// default values require existing AST.

// Note: 'dmapped' is treated like a binary operator at the moment, so
// we don't need to worry about distribution type for 'domain(...)' exprs.

// Transform domain type expressions like `domain(arg1, ...)` into:
// _domain.static_type(arg1, ...)
auto genericDom = DomainType::getGenericDomainType(context);
auto recv = QualifiedType(QualifiedType::TYPE, genericDom);
auto typeCtorName = UniqueString::get(context, "static_type");
auto ctorCall = CallInfo::createWithReceiver(ci, recv, typeCtorName);

result = resolveCall(context, call, ctorCall, inScopes);
return true;
// // TODO: a compiler-generated type constructor would be simpler, but we
// // don't support default values on compiler-generated methods because the
// // default values require existing AST.

// // Note: 'dmapped' is treated like a binary operator at the moment, so
// // we don't need to worry about distribution type for 'domain(...)' exprs.

// // Transform domain type expressions like `domain(arg1, ...)` into:
// // _domain.static_type(arg1, ...)
// auto genericDom = DomainType::getGenericDomainType(context);
// auto recv = QualifiedType(QualifiedType::TYPE, genericDom);
// auto typeCtorName = UniqueString::get(context, "static_type");
// auto ctorCall = CallInfo::createWithReceiver(ci, recv, typeCtorName);

// result = resolveCall(context, call, ctorCall, inScopes);
// return true;
} else if (ci.name() == "atomic") {
auto newName = UniqueString::get(context, "chpl__atomicType");
auto ctorCall = CallInfo::copyAndRename(ci, newName);
Expand Down Expand Up @@ -4275,6 +4277,7 @@ CallResolutionResult resolveFnCall(Context* context,
ci.isMethodCall() == false) {
// handle invocation of a type constructor from a type
// (note that we might have the type through a type alias)
if (ci.name() == "domain" || ci.name() == "_domain") gdbShouldBreakHere();
mostSpecific = resolveFnCallForTypeCtor(context, ci,
inScopes.callScope(),
inScopes.poiScope(),
Expand Down
1 change: 1 addition & 0 deletions frontend/lib/types/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ void Type::gatherBuiltins(Context* context,
gatherType(context, map, "Error", CompositeType::getErrorType(context));

gatherType(context, map, "domain", DomainType::getGenericDomainType(context));
gatherType(context, map, "_domain", DomainType::getGenericDomainType(context));

gatherType(context, map, "class", AnyClassType::get(context));
auto genericBorrowed = ClassType::get(context, AnyClassType::get(context), nullptr, ClassTypeDecorator(ClassTypeDecorator::BORROWED));
Expand Down

0 comments on commit 950df4d

Please sign in to comment.