implements PR-06.1
This commit is contained in:
+44
@@ -246,4 +246,48 @@ class IRBackendExecutableContractTest {
|
||||
assertEquals(firstIntrinsicId, secondIntrinsicId);
|
||||
assertEquals("core.color.pack", backend.getIntrinsicPool().getFirst().canonicalName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aggregatorMustPreserveExecutableSourceAttribution() {
|
||||
final var instructionSpan = new Span(new FileId(7), 21, 34);
|
||||
final var functionSpan = new Span(new FileId(7), 10, 40);
|
||||
final var file = new IRBackendFile(
|
||||
new FileId(7),
|
||||
ReadOnlyList.empty(),
|
||||
ReadOnlyList.from(new IRBackendExecutableFunction(
|
||||
new FileId(7),
|
||||
"app/main",
|
||||
"main",
|
||||
new CallableId(0),
|
||||
10,
|
||||
40,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
ReadOnlyList.from(new IRBackendExecutableFunction.Instruction(
|
||||
IRBackendExecutableFunction.InstructionKind.RET,
|
||||
"",
|
||||
"",
|
||||
null,
|
||||
null,
|
||||
instructionSpan)),
|
||||
functionSpan)),
|
||||
IRReservedMetadata.empty(),
|
||||
ReadOnlyList.from(new CallableSignatureRef("app/main", "main", 0, "() -> unit")),
|
||||
ReadOnlyList.empty());
|
||||
|
||||
final var aggregator = IRBackend.aggregator();
|
||||
aggregator.merge(file);
|
||||
final var backend = aggregator.emit();
|
||||
final var executable = backend.getExecutableFunctions().getFirst();
|
||||
final var emittedInstructionSpan = executable.instructions().getFirst().span();
|
||||
|
||||
assertEquals(new FileId(7), executable.fileId());
|
||||
assertEquals(10, executable.sourceStart());
|
||||
assertEquals(40, executable.sourceEnd());
|
||||
assertEquals(7, emittedInstructionSpan.getFileId().getId());
|
||||
assertEquals(21, emittedInstructionSpan.getStart());
|
||||
assertEquals(34, emittedInstructionSpan.getEnd());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user