implements PR-08.2
This commit is contained in:
+45
@@ -7,7 +7,9 @@ import p.studio.compiler.source.Span;
|
||||
import p.studio.compiler.source.identifiers.CallableId;
|
||||
import p.studio.compiler.source.identifiers.FileId;
|
||||
import p.studio.compiler.source.identifiers.IntrinsicId;
|
||||
import p.studio.compiler.source.identifiers.ModuleId;
|
||||
import p.studio.compiler.source.tables.IntrinsicReference;
|
||||
import p.studio.compiler.source.tables.ModuleReference;
|
||||
import p.studio.utilities.structures.ReadOnlyList;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -199,6 +201,27 @@ class LowerToIRVMServiceTest {
|
||||
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_AMBIGUOUS, thrown.code());
|
||||
}
|
||||
|
||||
@Test
|
||||
void lowerMustUseModulePoolCanonicalIdentityForNonEntrypointOrdering() {
|
||||
final var backend = IRBackend.builder()
|
||||
.entryPointCallableName("frame")
|
||||
.modulePool(ReadOnlyList.from(
|
||||
new ModuleReference("app", ReadOnlyList.from("alpha")),
|
||||
new ModuleReference("app", ReadOnlyList.from("zeta"))))
|
||||
.executableFunctions(ReadOnlyList.from(
|
||||
fnWithModule("helper_in_zeta", "legacy/zeta", 1, 21, ReadOnlyList.from(ret())),
|
||||
fnWithModule("frame", "legacy/zeta", 1, 20, ReadOnlyList.from(ret())),
|
||||
fnWithModule("helper_in_alpha", "legacy/alpha", 0, 22, ReadOnlyList.from(ret()))))
|
||||
.build();
|
||||
|
||||
final var lowered = new LowerToIRVMService().lower(backend);
|
||||
|
||||
assertEquals(3, lowered.module().functions().size());
|
||||
assertEquals("frame", lowered.module().functions().get(0).name());
|
||||
assertEquals("helper_in_alpha", lowered.module().functions().get(1).name());
|
||||
assertEquals("helper_in_zeta", lowered.module().functions().get(2).name());
|
||||
}
|
||||
|
||||
private static IRBackendExecutableFunction fn(
|
||||
final String name,
|
||||
final String moduleKey,
|
||||
@@ -219,6 +242,28 @@ class LowerToIRVMServiceTest {
|
||||
Span.none());
|
||||
}
|
||||
|
||||
private static IRBackendExecutableFunction fnWithModule(
|
||||
final String name,
|
||||
final String moduleKey,
|
||||
final int moduleId,
|
||||
final int callableId,
|
||||
final ReadOnlyList<IRBackendExecutableFunction.Instruction> instructions) {
|
||||
return new IRBackendExecutableFunction(
|
||||
new FileId(0),
|
||||
new ModuleId(moduleId),
|
||||
moduleKey,
|
||||
name,
|
||||
new CallableId(callableId),
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
instructions,
|
||||
Span.none());
|
||||
}
|
||||
|
||||
private static IRBackendExecutableFunction.Instruction ret() {
|
||||
return new IRBackendExecutableFunction.Instruction(
|
||||
IRBackendExecutableFunction.InstructionKind.RET,
|
||||
|
||||
Reference in New Issue
Block a user