feat(pbs): add parametric arrays and concrete generic contracts

Support explicit contract type parameters, canonical nominal applications,
recursive substitution, concrete implementations and instantiated editor views.
Complete parametric Array syntax and contextual construction integration.

Preserve type origins across imports and reexports, fix trait argument stack
order, and relocate global slots before lifecycle assembly. Publish specs,
installed examples and consolidated discussion lessons.

Validate frontend, common pipeline, architecture, LSP and installed knowledge
gates, plus the full production VM conformance corpus with 14 generic fixtures.
This commit is contained in:
2026-10-20 11:30:00 +01:00
parent b62db87245
commit 240216170c
70 changed files with 2369 additions and 273 deletions
@@ -68,6 +68,7 @@ public class IRBackend implements IRBackendReader {
}
functions.addAll(backendFile.functions().asList());
final var moduleRemap = reindexModules(backendFile.modulePool());
final var globalRemap = new java.util.HashMap<Integer, Integer>();
for (final var syntheticFunction : backendFile.syntheticFunctions()) {
syntheticFunctions.add(new IRSyntheticFunction(
remapModuleId(syntheticFunction.moduleId(), moduleRemap, "synthetic function"),
@@ -76,12 +77,15 @@ public class IRBackend implements IRBackendReader {
syntheticFunction.origin()));
}
for (final var global : backendFile.globals()) {
final var linkedSlot = globals.size();
if (globalRemap.putIfAbsent(global.slot(), linkedSlot) != null)
throw new IllegalArgumentException("duplicate file-local global slot: " + global.slot());
globals.add(new IRGlobal(
global.fileId(),
remapModuleId(global.moduleId(), moduleRemap, "global"),
global.name(),
global.declaredTypeSurface(),
global.slot(),
linkedSlot,
global.visibility(),
global.isHidden(),
global.hiddenKind(),
@@ -101,7 +105,7 @@ public class IRBackend implements IRBackendReader {
ReadOnlyList.wrap(impl.methods().stream().map(id -> remapCallableId(id, callableRemap, "implementation")).toList())));
}
for (final var function : backendFile.executableFunctions()) {
executableFunctions.add(remapExecutableFunction(function, moduleRemap, callableRemap, intrinsicRemap));
executableFunctions.add(remapExecutableFunction(function, moduleRemap, callableRemap, intrinsicRemap, globalRemap));
}
if (backendFile.lifecycleDeclaration() != null && !backendFile.lifecycleDeclaration().isEmpty()) {
lifecycleFiles.add(remapLifecycleFileDeclaration(
@@ -172,7 +176,8 @@ public class IRBackend implements IRBackendReader {
final IRBackendExecutableFunction function,
final ModuleId[] moduleRemap,
final CallableId[] callableRemap,
final IntrinsicId[] intrinsicRemap) {
final IntrinsicId[] intrinsicRemap,
final java.util.Map<Integer, Integer> globalRemap) {
final var remappedInstructions = new ArrayList<IRBackendExecutableFunction.Instruction>(function.instructions().size());
final var remappedFunctionModuleId = remapModuleId(
function.moduleId(),
@@ -208,7 +213,10 @@ public class IRBackend implements IRBackendReader {
remappedIntrinsic,
instruction.label(),
instruction.targetLabel(),
instruction.expectedArgSlots(),
instruction.kind() == IRBackendExecutableFunction.InstructionKind.GET_GLOBAL
|| instruction.kind() == IRBackendExecutableFunction.InstructionKind.SET_GLOBAL
? globalRemap.getOrDefault(instruction.expectedArgSlots(), instruction.expectedArgSlots())
: instruction.expectedArgSlots(),
instruction.expectedRetSlots(),
instruction.span(), instruction.registryInstruction() == null ? null :
new p.studio.compiler.models.registry.IRRegistryInstruction(instruction.registryInstruction().kind(), instruction.registryInstruction().type(), instruction.registryInstruction().targetType(),