Branch: refs/heads/main
Revision: c28d636
Author: dlongnecke-cray
Link: Add primitive PRIM_RESOLVES to test if a given call resolves by dlongnecke-cray · Pull Request #19029 · chapel-lang/chapel · GitHub
Log Message:
Merge pull request #19029 from dlongnecke-cray/rewire-prim-call-resolves
Add primitive PRIM_RESOLVES to test if a given call resolves (#19029)
Add a new primitive called PRIM_RESOLVES
. It can be used to test
if a given expression resolves. Only call expressions may be passed
as actuals for now, but more expression types could be supported
in the future.
For example:
record r1 {
proc doSomething(a) { writeln(a); }
}
record r2 {
var inner = new r1();
}
var x = new r2();
param yes = __primitive("resolves", x.inner.doSomething(a=0));
assert(yes);
The expression passed as an actual argument to PRIM_RESOLVES
is not
normalized, which means that any expression may be passed as an
actual, and the expression may be written exactly as it would appear
elsewhere in Chapel code.
Unlike PRIM_CALL_RESOLVES
and PRIM_METHOD_CALL_RESOLVES
, a call
passed to PRIM_RESOLVES
should be able to contain actuals with any
combination of storage kind (e.g. var
, param
, type
).
This means that PRIM_RESOLVES
can be used to enable Reflection
functions to support type
arguments (see #11802).
In addition, uses of PRIM_RESOLVES
in internal modules enable
more internal modules to be parsed and converted by the new
compiler.
Uses of PRIM_METHOD_CALL_RESOLVES
and PRIM_CALL_RESOLVES
within
internal modules have been replaced with calls to PRIM_RESOLVES
.
ISSUES
- The current implementation cannot resolve nested calls
when the return type of the callee is inferred
FUTURE WORK
- Expand
PRIM_RESOLVES
to work with any expression type - Discuss whether or not all callees should be resolved
- Add a new procedure to the
Reflection
module which makes use
ofPRIM_RESOLVES
TESTING
- [x]
ALL
onlinux64
whenCOMM=none
- [x]
ALL
onlinux64
whenCOMM=gasnet
Reviewed by @mppf. Thanks!
Signed-off-by: David Longnecker dlongnecke-cray@users.noreply.github.com
Modified Files:
A test/library/standard/Reflection/primitives/Resolves.chpl
A test/library/standard/Reflection/primitives/Resolves.good
A test/library/standard/Reflection/primitives/Resolves.noexec
A test/library/standard/Reflection/primitives/ResolvesNestedParenlessMethod.bad
A test/library/standard/Reflection/primitives/ResolvesNestedParenlessMethod.chpl
A test/library/standard/Reflection/primitives/ResolvesNestedParenlessMethod.future
A test/library/standard/Reflection/primitives/ResolvesNestedParenlessMethod.good
M compiler/AST/CallExpr.cpp
M compiler/AST/primitive.cpp
M compiler/include/passes.h
M compiler/next/include/chpl/uast/PrimOpsList.h
M compiler/passes/normalize.cpp
M compiler/resolution/functionResolution.cpp
M compiler/resolution/preFold.cpp
M modules/dists/DSIUtil.chpl
M modules/dists/SparseBlockDist.chpl
M modules/internal/ArrayViewRankChange.chpl
M modules/internal/ArrayViewReindex.chpl
M modules/internal/ArrayViewSlice.chpl
M modules/internal/ChapelArray.chpl
M modules/internal/ChapelDomain.chpl
Compare: https://github.com/chapel-lang/chapel/compare/6d29966aebc2...c28d63676ffe