implements PR022

This commit is contained in:
2026-03-24 13:42:22 +00:00
parent 05258c5363
commit 213c6a2f76
6 changed files with 72 additions and 3 deletions
@@ -7,8 +7,10 @@ import p.studio.compiler.messages.FrontendPhaseContext;
import p.studio.compiler.models.BuildStack;
import p.studio.compiler.models.ProjectDescriptor;
import p.studio.compiler.models.SourceHandle;
import p.studio.compiler.models.SourceKind;
import p.studio.compiler.pbs.linking.PbsLinkErrors;
import p.studio.compiler.source.diagnostics.DiagnosticSink;
import p.studio.compiler.source.identifiers.ProjectId;
import p.studio.compiler.source.tables.FileTable;
import p.studio.compiler.source.tables.ProjectTable;
import p.studio.compiler.utilities.SourceProviderFactory;
@@ -173,8 +175,49 @@ class PBSFrontendPhaseServiceTest {
assertEquals(2, irBackend.getFunctions().size());
}
@Test
void shouldSkipIrLoweringForSourcesMarkedAsSdkInterface() throws IOException {
final var projectRoot = tempDir.resolve("project-sdk-interface");
final var sourceRoot = projectRoot.resolve("src");
final var modulePath = sourceRoot.resolve("gfx");
Files.createDirectories(modulePath);
final var sourceFile = modulePath.resolve("source.pbs");
final var modBarrel = modulePath.resolve("mod.barrel");
Files.writeString(sourceFile, "fn draw() -> int { return 1; }");
Files.writeString(modBarrel, "pub fn draw() -> int;");
final var projectTable = new ProjectTable();
final var fileTable = new FileTable(1);
final var projectId = projectTable.register(ProjectDescriptor.builder()
.rootPath(projectRoot)
.name("gfx-sdk")
.version("1.0.0")
.sourceRoots(ReadOnlyList.wrap(List.of(sourceRoot)))
.sourceKind(SourceKind.SDK_INTERFACE)
.build());
registerFile(projectId, projectRoot, sourceFile, fileTable);
registerFile(projectId, projectRoot, modBarrel, fileTable);
final var ctx = new FrontendPhaseContext(
projectTable,
fileTable,
new BuildStack(ReadOnlyList.wrap(List.of(projectId))));
final var diagnostics = DiagnosticSink.empty();
final var irBackend = new PBSFrontendPhaseService().compile(
ctx,
diagnostics,
LogAggregator.empty(),
BuildingIssueSink.empty());
assertTrue(diagnostics.isEmpty());
assertEquals(0, irBackend.getFunctions().size());
}
private void registerFile(
final p.studio.compiler.source.identifiers.ProjectId projectId,
final ProjectId projectId,
final Path projectRoot,
final Path file,
final FileTable fileTable) throws IOException {
@@ -187,4 +230,5 @@ class PBSFrontendPhaseServiceTest {
attributes.lastModifiedTime().toMillis(),
SourceProviderFactory.filesystem()));
}
}