Skip to content

Commit

Permalink
wip get new _domain working
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 8e44543 commit a121cdd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
6 changes: 4 additions & 2 deletions frontend/lib/resolution/Resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2268,17 +2268,19 @@ bool Resolver::resolveSpecialKeywordCall(const Call* call) {
// Copy the result of resolving 'domain' as the called identifier.
r.setType(rCalledExp.type());
} else {
// Get type by resolving the type of corresponding '_domain' init call
// TODO: prohibit associative domain with idxType 'domain'
auto runResult = context->runAndTrackErrors([&](Context* ctx) {
const AstNode* questionArg = nullptr;
std::vector<CallInfoActual> actuals;
// Set up receiver
auto receiverArg = CallInfoActual(rCalledExp.type(), USTR("this"));
actuals.push_back(std::move(receiverArg));
// Set up 'dist' arg
// Set up distribution arg
auto defaultDistArg = CallInfoActual(
QualifiedType(QualifiedType::CONST_REF,
DomainType::getDefaultDistType(context)),
UniqueString::get(context, "dist"));
UniqueString::get(context, "d"));
actuals.push_back(std::move(defaultDistArg));
// Remaining given args from domain() call as written
prepareCallInfoActuals(call, actuals, questionArg);
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 a121cdd

Please sign in to comment.