implements PR-08.4

This commit is contained in:
2026-03-24 13:42:33 +00:00
parent 2a68d27eca
commit 505a4f72ce
2 changed files with 97 additions and 3 deletions
@@ -389,6 +389,10 @@ public final class PbsFrontendCompiler {
.add(callableId);
returnSlotsByCallableId.put(callableId, importedCallable.returnSlots());
}
final var callableSignatureByCallableId = new HashMap<CallableId, CallableSignatureRef>();
for (final var callableId : callableIdTable.identifiers()) {
callableSignatureByCallableId.put(callableId, callableIdTable.get(callableId));
}
final var executableFunctions = new ArrayList<IRBackendExecutableFunction>(localCallables.size());
for (final var callable : localCallables) {
@@ -411,6 +415,7 @@ public final class PbsFrontendCompiler {
intrinsicReturnOwnerByCanonical,
builtinConstOwnerByNameId,
callableIdsByNameAndArity,
callableSignatureByCallableId,
returnSlotsByCallableId,
intrinsicIdTable,
localSlotByNameId);
@@ -964,11 +969,16 @@ public final class PbsFrontendCompiler {
return;
}
final var calleeCallableId = callableCandidates.getFirst();
final var calleeSignature = context.callableSignatureByCallableId().get(calleeCallableId);
if (calleeSignature == null) {
reportUnsupportedLowering("executable lowering resolved callable without signature metadata", callExpr.span(), context);
return;
}
context.instructions().add(new IRBackendExecutableFunction.Instruction(
IRBackendExecutableFunction.InstructionKind.CALL_FUNC,
context.moduleId(),
context.moduleKey(),
calleeIdentity.primaryCallableDisplayName(),
calleeSignature.moduleId(),
calleeSignature.moduleKey(),
calleeSignature.callableName(),
calleeCallableId,
null,
null,
@@ -1347,6 +1357,7 @@ public final class PbsFrontendCompiler {
private final Map<IntrinsicCanonicalKey, String> intrinsicReturnOwnerByCanonical;
private final Map<NameId, String> builtinConstOwnerByNameId;
private final Map<CallableResolutionKey, List<CallableId>> callableIdsByNameAndArity;
private final Map<CallableId, CallableSignatureRef> callableSignatureByCallableId;
private final Map<CallableId, Integer> returnSlotsByCallableId;
private final IntrinsicTable intrinsicIdTable;
private final Map<NameId, Integer> localSlotByNameId;
@@ -1364,6 +1375,7 @@ public final class PbsFrontendCompiler {
final Map<IntrinsicCanonicalKey, String> intrinsicReturnOwnerByCanonical,
final Map<NameId, String> builtinConstOwnerByNameId,
final Map<CallableResolutionKey, List<CallableId>> callableIdsByNameAndArity,
final Map<CallableId, CallableSignatureRef> callableSignatureByCallableId,
final Map<CallableId, Integer> returnSlotsByCallableId,
final IntrinsicTable intrinsicIdTable,
final Map<NameId, Integer> localSlotByNameId) {
@@ -1376,6 +1388,7 @@ public final class PbsFrontendCompiler {
this.intrinsicReturnOwnerByCanonical = intrinsicReturnOwnerByCanonical;
this.builtinConstOwnerByNameId = builtinConstOwnerByNameId;
this.callableIdsByNameAndArity = callableIdsByNameAndArity;
this.callableSignatureByCallableId = callableSignatureByCallableId;
this.returnSlotsByCallableId = returnSlotsByCallableId;
this.intrinsicIdTable = intrinsicIdTable;
this.localSlotByNameId = localSlotByNameId == null ? Map.of() : localSlotByNameId;
@@ -1417,6 +1430,10 @@ public final class PbsFrontendCompiler {
return callableIdsByNameAndArity;
}
private Map<CallableId, CallableSignatureRef> callableSignatureByCallableId() {
return callableSignatureByCallableId;
}
private Map<CallableId, Integer> returnSlotsByCallableId() {
return returnSlotsByCallableId;
}