implements PR-O1.4
This commit is contained in:
+2
-1
@@ -3,5 +3,6 @@ package p.studio.compiler.backend.irvm;
|
||||
public enum IRVMLoweringErrorCode {
|
||||
LOWER_IRVM_EMPTY_EXECUTABLE_INPUT,
|
||||
LOWER_IRVM_MISSING_CALLEE,
|
||||
LOWER_IRVM_CALL_ARG_SLOTS_MISMATCH,
|
||||
LOWER_IRVM_CALL_RET_SLOTS_MISMATCH,
|
||||
}
|
||||
|
||||
|
||||
+19
-1
@@ -65,6 +65,25 @@ public class LowerToIRVMService {
|
||||
IRVMLoweringErrorCode.LOWER_IRVM_MISSING_CALLEE,
|
||||
"missing callee function: " + key);
|
||||
}
|
||||
final var calleeFunction = ordered.get(calleeId);
|
||||
if (instr.expectedArgSlots() != null
|
||||
&& instr.expectedArgSlots() != calleeFunction.paramSlots()) {
|
||||
throw new IRVMLoweringException(
|
||||
IRVMLoweringErrorCode.LOWER_IRVM_CALL_ARG_SLOTS_MISMATCH,
|
||||
"call arg_slots mismatch for %s. expected=%d actual=%d".formatted(
|
||||
key,
|
||||
instr.expectedArgSlots(),
|
||||
calleeFunction.paramSlots()));
|
||||
}
|
||||
if (instr.expectedRetSlots() != null
|
||||
&& instr.expectedRetSlots() != calleeFunction.returnSlots()) {
|
||||
throw new IRVMLoweringException(
|
||||
IRVMLoweringErrorCode.LOWER_IRVM_CALL_RET_SLOTS_MISMATCH,
|
||||
"call ret_slots mismatch for %s. expected=%d actual=%d".formatted(
|
||||
key,
|
||||
instr.expectedRetSlots(),
|
||||
calleeFunction.returnSlots()));
|
||||
}
|
||||
instructions.add(new IRVMInstruction(IRVMOp.CALL, calleeId));
|
||||
operations.add(BytecodeEmitter.Operation.callFunc(calleeId));
|
||||
}
|
||||
@@ -142,4 +161,3 @@ public class LowerToIRVMService {
|
||||
return (moduleKey == null ? "" : moduleKey) + "::" + callableName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user