implements PR-05.3
This commit is contained in:
+2
@@ -2,6 +2,8 @@ package p.studio.compiler.backend.irvm;
|
||||
|
||||
public enum IRVMLoweringErrorCode {
|
||||
LOWER_IRVM_EMPTY_EXECUTABLE_INPUT,
|
||||
LOWER_IRVM_ENTRYPOINT_MISSING,
|
||||
LOWER_IRVM_ENTRYPOINT_AMBIGUOUS,
|
||||
LOWER_IRVM_MISSING_CALLEE,
|
||||
LOWER_IRVM_INVALID_INTRINSIC_ID,
|
||||
LOWER_IRVM_CALL_ARG_SLOTS_MISMATCH,
|
||||
|
||||
+13
-6
@@ -217,13 +217,20 @@ public class LowerToIRVMService {
|
||||
final ReadOnlyList<IRBackendExecutableFunction> functions) {
|
||||
final var sorted = new ArrayList<>(functions.asList());
|
||||
sorted.sort(FUNCTION_ORDER);
|
||||
var entrypoint = sorted.getFirst();
|
||||
for (final var candidate : sorted) {
|
||||
if ("main".equals(candidate.callableName())) {
|
||||
entrypoint = candidate;
|
||||
break;
|
||||
}
|
||||
final var entrypoints = sorted.stream()
|
||||
.filter(candidate -> "main".equals(candidate.callableName()))
|
||||
.toList();
|
||||
if (entrypoints.isEmpty()) {
|
||||
throw new IRVMLoweringException(
|
||||
IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_MISSING,
|
||||
"missing entrypoint callable 'main'");
|
||||
}
|
||||
if (entrypoints.size() > 1) {
|
||||
throw new IRVMLoweringException(
|
||||
IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_AMBIGUOUS,
|
||||
"ambiguous entrypoint: found %d callables named 'main'".formatted(entrypoints.size()));
|
||||
}
|
||||
final var entrypoint = entrypoints.getFirst();
|
||||
final var ordered = new ArrayList<IRBackendExecutableFunction>(sorted.size());
|
||||
ordered.add(entrypoint);
|
||||
for (final var fn : sorted) {
|
||||
|
||||
Reference in New Issue
Block a user