implements PR-19.9 conformance fixtures diagnostics and gate closure

This commit is contained in:
2026-03-26 19:47:00 +00:00
parent 58c5ab26d7
commit 459f5e3b87
10 changed files with 322 additions and 12 deletions
@@ -416,6 +416,10 @@ public final class PbsFrontendCompiler {
return "__pbs.frame_wrapper$m" + normalizedModuleIndex(moduleId);
}
public static String bootGuardGlobalName(final ModuleId moduleId) {
return "__pbs.boot_guard$m" + normalizedModuleIndex(moduleId);
}
private static int normalizedModuleIndex(final ModuleId moduleId) {
final var normalized = moduleId == null ? ModuleId.none() : moduleId;
return normalized.isNone() ? -1 : normalized.getIndex();
@@ -119,6 +119,7 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
private IRBackend synthesizePublishedLifecycle(final IRBackend baseBackend) {
final var callableSignatures = new ArrayList<>(baseBackend.getCallableSignatures().asList());
final var executableFunctions = new ArrayList<>(baseBackend.getExecutableFunctions().asList());
final var globals = new ArrayList<>(baseBackend.getGlobals().asList());
final var fileInitFunctionsByModule = new LinkedHashMap<ModuleId, List<IRBackendExecutableFunction>>();
final var projectInitAnchorsByModule = new LinkedHashMap<ModuleId, String>();
final var wrapperNamesByModule = new LinkedHashMap<ModuleId, String>();
@@ -151,8 +152,9 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
entryPointModuleId = wrapperNamesByModule.keySet().iterator().next();
entryPointCallableName = wrapperNamesByModule.get(entryPointModuleId);
} else {
entryPointModuleId = baseBackend.getEntryPointModuleId();
entryPointCallableName = baseBackend.getEntryPointCallableName();
final var legacyEntrypoint = resolveLegacyEntrypoint(baseBackend);
entryPointModuleId = legacyEntrypoint.moduleId();
entryPointCallableName = legacyEntrypoint.callableName();
}
final var sortedModuleIds = new ArrayList<ModuleId>();
@@ -281,6 +283,17 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
1,
ReadOnlyList.wrap(instructions),
frameExecutable.span()));
if (globals.stream().noneMatch(global ->
moduleIdsMatch(entryPointModuleId, global.moduleId())
&& PbsFrontendCompiler.bootGuardGlobalName(entryPointModuleId).equals(global.name()))) {
globals.add(new p.studio.compiler.models.IRGlobal(
frameExecutable.fileId(),
entryPointModuleId,
PbsFrontendCompiler.bootGuardGlobalName(entryPointModuleId),
"bool",
frameExecutable.span()));
}
}
return IRBackend.builder()
@@ -288,7 +301,7 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
.entryPointModuleId(entryPointModuleId)
.functions(baseBackend.getFunctions())
.syntheticFunctions(baseBackend.getSyntheticFunctions())
.globals(baseBackend.getGlobals())
.globals(ReadOnlyList.wrap(globals))
.executableFunctions(ReadOnlyList.wrap(executableFunctions))
.modulePool(baseBackend.getModulePool())
.callableSignatures(ReadOnlyList.wrap(callableSignatures))
@@ -384,6 +397,19 @@ 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) {
@@ -414,4 +440,9 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
ModuleId moduleId,
p.studio.compiler.models.IRBackendFile irBackendFile) {
}
private record LegacyEntrypoint(
ModuleId moduleId,
String callableName) {
}
}