hardens IRGlobal structural metadata for PBS lifecycle lowering
This commit is contained in:
+39
-24
@@ -4,6 +4,9 @@ import org.junit.jupiter.api.Test;
|
||||
import p.studio.compiler.models.IRBackend;
|
||||
import p.studio.compiler.models.IRBackendExecutableFunction;
|
||||
import p.studio.compiler.models.IRGlobal;
|
||||
import p.studio.compiler.models.IRGlobalOrigin;
|
||||
import p.studio.compiler.models.IRGlobalVisibility;
|
||||
import p.studio.compiler.models.IRHiddenGlobalKind;
|
||||
import p.studio.compiler.models.IRSyntheticCallableKind;
|
||||
import p.studio.compiler.models.IRSyntheticFunction;
|
||||
import p.studio.compiler.models.IRSyntheticOrigin;
|
||||
@@ -66,12 +69,7 @@ class LowerToIRVMServiceTest {
|
||||
final var backend = IRBackend.builder()
|
||||
.entryPointCallableName("__pbs.frame_wrapper$m0")
|
||||
.entryPointModuleId(new ModuleId(0))
|
||||
.globals(ReadOnlyList.from(new IRGlobal(
|
||||
new FileId(0),
|
||||
new ModuleId(0),
|
||||
"__pbs.boot_guard$m0",
|
||||
"bool",
|
||||
Span.none())))
|
||||
.globals(ReadOnlyList.from(hiddenBootGuard(0)))
|
||||
.syntheticFunctions(ReadOnlyList.from(new IRSyntheticFunction(
|
||||
new ModuleId(0),
|
||||
"__pbs.frame_wrapper$m0",
|
||||
@@ -115,12 +113,7 @@ class LowerToIRVMServiceTest {
|
||||
final var backend = IRBackend.builder()
|
||||
.entryPointCallableName("__pbs.frame_wrapper$m0")
|
||||
.entryPointModuleId(new ModuleId(0))
|
||||
.globals(ReadOnlyList.from(new IRGlobal(
|
||||
new FileId(0),
|
||||
new ModuleId(0),
|
||||
"__pbs.boot_guard$m0",
|
||||
"bool",
|
||||
Span.none())))
|
||||
.globals(ReadOnlyList.from(hiddenBootGuard(0)))
|
||||
.syntheticFunctions(ReadOnlyList.from(new IRSyntheticFunction(
|
||||
new ModuleId(0),
|
||||
"__pbs.frame_wrapper$m0",
|
||||
@@ -139,12 +132,7 @@ class LowerToIRVMServiceTest {
|
||||
final var backend = IRBackend.builder()
|
||||
.entryPointCallableName("frame")
|
||||
.entryPointModuleId(new ModuleId(0))
|
||||
.globals(ReadOnlyList.from(new IRGlobal(
|
||||
new FileId(0),
|
||||
new ModuleId(0),
|
||||
"__pbs.boot_guard$m0",
|
||||
"bool",
|
||||
Span.none())))
|
||||
.globals(ReadOnlyList.from(hiddenBootGuard(0)))
|
||||
.syntheticFunctions(ReadOnlyList.from(new IRSyntheticFunction(
|
||||
new ModuleId(0),
|
||||
"__pbs.frame_wrapper$m0",
|
||||
@@ -187,12 +175,7 @@ class LowerToIRVMServiceTest {
|
||||
final var backend = IRBackend.builder()
|
||||
.entryPointCallableName("__pbs.frame_wrapper$m0")
|
||||
.entryPointModuleId(new ModuleId(0))
|
||||
.globals(ReadOnlyList.from(new IRGlobal(
|
||||
new FileId(0),
|
||||
new ModuleId(0),
|
||||
"__pbs.boot_guard$m0",
|
||||
"bool",
|
||||
Span.none())))
|
||||
.globals(ReadOnlyList.from(userVisibleGlobal("__pbs.boot_guard$m0", 0)))
|
||||
.syntheticFunctions(ReadOnlyList.from(new IRSyntheticFunction(
|
||||
new ModuleId(0),
|
||||
"__pbs.frame_wrapper$m0",
|
||||
@@ -419,6 +402,38 @@ class LowerToIRVMServiceTest {
|
||||
assertTrue(thrown.getMessage().contains("qualified entrypoint"));
|
||||
}
|
||||
|
||||
private static IRGlobal hiddenBootGuard(final int moduleId) {
|
||||
final var fileId = new FileId(0);
|
||||
final var ownerModuleId = new ModuleId(moduleId);
|
||||
return new IRGlobal(
|
||||
fileId,
|
||||
ownerModuleId,
|
||||
"__pbs.boot_guard$m" + moduleId,
|
||||
"bool",
|
||||
0,
|
||||
IRGlobalVisibility.MODULE,
|
||||
true,
|
||||
IRHiddenGlobalKind.BOOT_GUARD,
|
||||
new IRGlobalOrigin(fileId, ownerModuleId, "frame", Span.none(), "BOOT_GUARD"),
|
||||
Span.none());
|
||||
}
|
||||
|
||||
private static IRGlobal userVisibleGlobal(final String name, final int moduleId) {
|
||||
final var fileId = new FileId(0);
|
||||
final var ownerModuleId = new ModuleId(moduleId);
|
||||
return new IRGlobal(
|
||||
fileId,
|
||||
ownerModuleId,
|
||||
name,
|
||||
"bool",
|
||||
0,
|
||||
IRGlobalVisibility.MODULE,
|
||||
false,
|
||||
IRHiddenGlobalKind.NONE,
|
||||
new IRGlobalOrigin(fileId, ownerModuleId, name, Span.none(), name),
|
||||
Span.none());
|
||||
}
|
||||
|
||||
private static IRBackendExecutableFunction fn(
|
||||
final String name,
|
||||
final String moduleKey,
|
||||
|
||||
Reference in New Issue
Block a user