implements PR-08.2

This commit is contained in:
2026-03-24 13:42:32 +00:00
parent 40188b67ab
commit 0490f64870
11 changed files with 520 additions and 23 deletions
@@ -1,7 +1,17 @@
package p.studio.compiler.source.identifiers;
public class ModuleId extends SourceIdentifier {
public static final ModuleId NONE = new ModuleId(-1);
public ModuleId(int id) {
super(id);
}
public static ModuleId none() {
return NONE;
}
public boolean isNone() {
return this == NONE;
}
}
@@ -1,14 +1,29 @@
package p.studio.compiler.source.tables;
import p.studio.compiler.source.identifiers.ModuleId;
import java.util.Objects;
public record CallableSignatureRef(
ModuleId moduleId,
String moduleKey,
String callableName,
int arity,
String typeShape) {
public CallableSignatureRef(
final String moduleKey,
final String callableName,
final int arity,
final String typeShape) {
this(ModuleId.none(), moduleKey, callableName, arity, typeShape);
}
public CallableSignatureRef {
moduleId = moduleId == null ? ModuleId.none() : moduleId;
if (!moduleId.isNone()) {
moduleId.getIndex();
}
moduleKey = moduleKey == null ? "" : moduleKey;
callableName = Objects.requireNonNull(callableName, "callableName");
typeShape = typeShape == null ? "" : typeShape;
@@ -1,6 +1,7 @@
package p.studio.compiler.source.tables;
import p.studio.compiler.source.identifiers.CallableId;
import p.studio.compiler.source.identifiers.ModuleId;
public class CallableTable extends InternTable<CallableId, CallableSignatureRef> implements CallableTableReader {
@@ -13,6 +14,15 @@ public class CallableTable extends InternTable<CallableId, CallableSignatureRef>
final String callableName,
final int arity,
final String typeShape) {
return register(new CallableSignatureRef(moduleKey, callableName, arity, typeShape));
return register(new CallableSignatureRef(ModuleId.none(), moduleKey, callableName, arity, typeShape));
}
public CallableId register(
final ModuleId moduleId,
final String moduleKey,
final String callableName,
final int arity,
final String typeShape) {
return register(new CallableSignatureRef(moduleId, moduleKey, callableName, arity, typeShape));
}
}