requires explicit frame markers for executable PBS projects
This commit is contained in:
+2
-21
@@ -152,9 +152,8 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
entryPointModuleId = wrapperNamesByModule.keySet().iterator().next();
|
||||
entryPointCallableName = wrapperNamesByModule.get(entryPointModuleId);
|
||||
} else {
|
||||
final var legacyEntrypoint = resolveLegacyEntrypoint(baseBackend);
|
||||
entryPointModuleId = legacyEntrypoint.moduleId();
|
||||
entryPointCallableName = legacyEntrypoint.callableName();
|
||||
entryPointModuleId = baseBackend.getEntryPointModuleId();
|
||||
entryPointCallableName = baseBackend.getEntryPointCallableName();
|
||||
}
|
||||
|
||||
final var sortedModuleIds = new ArrayList<ModuleId>();
|
||||
@@ -397,19 +396,6 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
return (int) value;
|
||||
}
|
||||
|
||||
private LegacyEntrypoint resolveLegacyEntrypoint(final IRBackend backend) {
|
||||
for (final var candidateName : List.of("frame", "main")) {
|
||||
final var candidates = backend.getExecutableFunctions().stream()
|
||||
.filter(function -> candidateName.equals(function.callableName()))
|
||||
.filter(function -> function.moduleId() != null && !function.moduleId().isNone())
|
||||
.toList();
|
||||
if (candidates.size() == 1) {
|
||||
return new LegacyEntrypoint(candidates.getFirst().moduleId(), candidateName);
|
||||
}
|
||||
}
|
||||
return new LegacyEntrypoint(backend.getEntryPointModuleId(), backend.getEntryPointCallableName());
|
||||
}
|
||||
|
||||
private Set<ModuleId> blockedModulesByDependency(
|
||||
final Set<ModuleId> failedModuleIds,
|
||||
final Map<ModuleId, Set<ModuleId>> dependenciesByModule) {
|
||||
@@ -440,9 +426,4 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
ModuleId moduleId,
|
||||
p.studio.compiler.models.IRBackendFile irBackendFile) {
|
||||
}
|
||||
|
||||
private record LegacyEntrypoint(
|
||||
ModuleId moduleId,
|
||||
String callableName) {
|
||||
}
|
||||
}
|
||||
|
||||
+4
-7
@@ -13,34 +13,31 @@ final class PbsProjectLifecycleSemanticsValidator {
|
||||
final java.util.List<PbsParsedSourceFile> parsedSourceFiles,
|
||||
final DiagnosticSink diagnostics) {
|
||||
final var frames = new ArrayList<PbsAst.FunctionDecl>();
|
||||
var sawLifecycleMarker = false;
|
||||
var sawExecutableSource = false;
|
||||
|
||||
for (final var parsedSource : parsedSourceFiles) {
|
||||
if (parsedSource.sourceKind() == SourceKind.SDK_INTERFACE) {
|
||||
continue;
|
||||
}
|
||||
sawExecutableSource = true;
|
||||
for (final var topDecl : parsedSource.ast().topDecls()) {
|
||||
if (!(topDecl instanceof PbsAst.FunctionDecl functionDecl)) {
|
||||
continue;
|
||||
}
|
||||
if (functionDecl.lifecycleMarker() == PbsAst.LifecycleMarker.NONE) {
|
||||
continue;
|
||||
}
|
||||
sawLifecycleMarker = true;
|
||||
if (functionDecl.lifecycleMarker() == PbsAst.LifecycleMarker.FRAME) {
|
||||
frames.add(functionDecl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!sawLifecycleMarker) {
|
||||
if (!sawExecutableSource) {
|
||||
return;
|
||||
}
|
||||
if (frames.isEmpty()) {
|
||||
p.studio.compiler.source.diagnostics.Diagnostics.error(
|
||||
diagnostics,
|
||||
PbsSemanticsErrors.E_SEM_MISSING_PROJECT_FRAME.name(),
|
||||
"Lifecycle-marked executable sources must declare exactly one [Frame] function",
|
||||
"Executable projects must declare exactly one [Frame] function",
|
||||
parsedSourceFiles.getFirst().ast().span());
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user