From a121cdd41941d1ddf4141b30e747e6f25e5fbb60 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Wed, 21 Aug 2024 13:51:08 -0700 Subject: [PATCH] wip get new _domain working Signed-off-by: Anna Rift --- frontend/lib/resolution/Resolver.cpp | 6 ++-- .../lib/resolution/resolution-queries.cpp | 35 ++++++++++--------- frontend/lib/types/Type.cpp | 1 + 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/frontend/lib/resolution/Resolver.cpp b/frontend/lib/resolution/Resolver.cpp index 1059a18d0c3d..16dae5d376bc 100644 --- a/frontend/lib/resolution/Resolver.cpp +++ b/frontend/lib/resolution/Resolver.cpp @@ -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 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); diff --git a/frontend/lib/resolution/resolution-queries.cpp b/frontend/lib/resolution/resolution-queries.cpp index fd3b02979eba..3e843858cd65 100644 --- a/frontend/lib/resolution/resolution-queries.cpp +++ b/frontend/lib/resolution/resolution-queries.cpp @@ -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; } @@ -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); @@ -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(), diff --git a/frontend/lib/types/Type.cpp b/frontend/lib/types/Type.cpp index 712c9a1a3777..0fbf6940659e 100644 --- a/frontend/lib/types/Type.cpp +++ b/frontend/lib/types/Type.cpp @@ -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));