implements PR-08.3
This commit is contained in:
+28
-3
@@ -296,6 +296,7 @@ public class LowerToIRVMService {
|
||||
IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_DECLARATION_MISSING,
|
||||
"frontend IRBackend entrypoint declaration is missing");
|
||||
}
|
||||
final var entryPointModuleId = backend.getEntryPointModuleId();
|
||||
final var sorted = new ArrayList<>(backend.getExecutableFunctions().asList());
|
||||
sorted.sort((left, right) -> {
|
||||
final var leftModuleKey = moduleSortKey(backend, left.moduleId(), left.moduleKey());
|
||||
@@ -314,15 +315,39 @@ public class LowerToIRVMService {
|
||||
}
|
||||
return Integer.compare(left.sourceStart(), right.sourceStart());
|
||||
});
|
||||
final var entrypoints = sorted.stream()
|
||||
.filter(candidate -> entryPointCallableName.equals(candidate.callableName()))
|
||||
.toList();
|
||||
final java.util.List<IRBackendExecutableFunction> entrypoints;
|
||||
if (entryPointModuleId != null && !entryPointModuleId.isNone()) {
|
||||
final var expectedModuleIndex = entryPointModuleId.getIndex();
|
||||
entrypoints = sorted.stream()
|
||||
.filter(candidate -> entryPointCallableName.equals(candidate.callableName()))
|
||||
.filter(candidate -> !candidate.moduleId().isNone() && candidate.moduleId().getIndex() == expectedModuleIndex)
|
||||
.toList();
|
||||
} else {
|
||||
entrypoints = sorted.stream()
|
||||
.filter(candidate -> entryPointCallableName.equals(candidate.callableName()))
|
||||
.toList();
|
||||
}
|
||||
if (entrypoints.isEmpty()) {
|
||||
if (entryPointModuleId != null && !entryPointModuleId.isNone()) {
|
||||
throw new IRVMLoweringException(
|
||||
IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_MISSING,
|
||||
"missing qualified entrypoint callable '%s' for moduleId=%d".formatted(
|
||||
entryPointCallableName,
|
||||
entryPointModuleId.getIndex()));
|
||||
}
|
||||
throw new IRVMLoweringException(
|
||||
IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_MISSING,
|
||||
"missing entrypoint callable '%s'".formatted(entryPointCallableName));
|
||||
}
|
||||
if (entrypoints.size() > 1) {
|
||||
if (entryPointModuleId != null && !entryPointModuleId.isNone()) {
|
||||
throw new IRVMLoweringException(
|
||||
IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_AMBIGUOUS,
|
||||
"ambiguous qualified entrypoint: found %d callables named '%s' in moduleId=%d".formatted(
|
||||
entrypoints.size(),
|
||||
entryPointCallableName,
|
||||
entryPointModuleId.getIndex()));
|
||||
}
|
||||
throw new IRVMLoweringException(
|
||||
IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_AMBIGUOUS,
|
||||
"ambiguous entrypoint: found %d callables named '%s'".formatted(
|
||||
|
||||
Reference in New Issue
Block a user