implements PR-09.2: migrate PBS frontend lowering to ModuleId-only
This commit is contained in:
parent
32ab6d7a76
commit
5c69a02973
@ -79,7 +79,6 @@ public final class PbsFrontendCompiler {
|
||||
diagnostics,
|
||||
sourceKind,
|
||||
ModuleId.none(),
|
||||
"",
|
||||
ReadOnlyList.empty(),
|
||||
hostAdmissionContext,
|
||||
nameTable);
|
||||
@ -93,7 +92,7 @@ public final class PbsFrontendCompiler {
|
||||
final FileId fileId,
|
||||
final PbsAst.File ast,
|
||||
final DiagnosticSink diagnostics) {
|
||||
return compileParsedFile(fileId, ast, diagnostics, SourceKind.PROJECT, "", HostAdmissionContext.permissiveDefault());
|
||||
return compileParsedFile(fileId, ast, diagnostics, SourceKind.PROJECT, HostAdmissionContext.permissiveDefault());
|
||||
}
|
||||
|
||||
public IRBackendFile compileParsedFile(
|
||||
@ -101,7 +100,7 @@ public final class PbsFrontendCompiler {
|
||||
final PbsAst.File ast,
|
||||
final DiagnosticSink diagnostics,
|
||||
final SourceKind sourceKind) {
|
||||
return compileParsedFile(fileId, ast, diagnostics, sourceKind, "", HostAdmissionContext.permissiveDefault());
|
||||
return compileParsedFile(fileId, ast, diagnostics, sourceKind, HostAdmissionContext.permissiveDefault());
|
||||
}
|
||||
|
||||
public IRBackendFile compileParsedFile(
|
||||
@ -116,26 +115,6 @@ public final class PbsFrontendCompiler {
|
||||
diagnostics,
|
||||
sourceKind,
|
||||
ModuleId.none(),
|
||||
"",
|
||||
ReadOnlyList.empty(),
|
||||
hostAdmissionContext,
|
||||
new NameTable());
|
||||
}
|
||||
|
||||
public IRBackendFile compileParsedFile(
|
||||
final FileId fileId,
|
||||
final PbsAst.File ast,
|
||||
final DiagnosticSink diagnostics,
|
||||
final SourceKind sourceKind,
|
||||
final String moduleKey,
|
||||
final HostAdmissionContext hostAdmissionContext) {
|
||||
return compileParsedFile(
|
||||
fileId,
|
||||
ast,
|
||||
diagnostics,
|
||||
sourceKind,
|
||||
ModuleId.none(),
|
||||
moduleKey,
|
||||
ReadOnlyList.empty(),
|
||||
hostAdmissionContext,
|
||||
new NameTable());
|
||||
@ -147,7 +126,6 @@ public final class PbsFrontendCompiler {
|
||||
final DiagnosticSink diagnostics,
|
||||
final SourceKind sourceKind,
|
||||
final ModuleId moduleId,
|
||||
final String moduleKey,
|
||||
final ReadOnlyList<ModuleReference> modulePool,
|
||||
final HostAdmissionContext hostAdmissionContext,
|
||||
final NameTable nameTable) {
|
||||
@ -157,7 +135,6 @@ public final class PbsFrontendCompiler {
|
||||
diagnostics,
|
||||
sourceKind,
|
||||
moduleId,
|
||||
moduleKey,
|
||||
modulePool,
|
||||
hostAdmissionContext,
|
||||
nameTable,
|
||||
@ -172,7 +149,6 @@ public final class PbsFrontendCompiler {
|
||||
final DiagnosticSink diagnostics,
|
||||
final SourceKind sourceKind,
|
||||
final ModuleId moduleId,
|
||||
final String moduleKey,
|
||||
final ReadOnlyList<ModuleReference> modulePool,
|
||||
final HostAdmissionContext hostAdmissionContext,
|
||||
final NameTable nameTable,
|
||||
@ -225,7 +201,6 @@ public final class PbsFrontendCompiler {
|
||||
ast,
|
||||
effectiveSupplementalTopDecls,
|
||||
effectiveModuleId,
|
||||
moduleKey,
|
||||
effectiveReservedMetadata,
|
||||
effectiveNameTable,
|
||||
diagnostics,
|
||||
@ -261,12 +236,10 @@ public final class PbsFrontendCompiler {
|
||||
final PbsAst.File ast,
|
||||
final ReadOnlyList<PbsAst.TopDecl> supplementalTopDecls,
|
||||
final ModuleId moduleId,
|
||||
final String moduleKey,
|
||||
final IRReservedMetadata reservedMetadata,
|
||||
final NameTable nameTable,
|
||||
final DiagnosticSink diagnostics,
|
||||
final ReadOnlyList<ImportedCallableSurface> importedCallables) {
|
||||
final var normalizedModuleKey = moduleKey == null ? "" : moduleKey;
|
||||
final var normalizedModuleId = moduleId == null ? ModuleId.none() : moduleId;
|
||||
final var hostByMethodName = new HashMap<NameId, List<IRReservedMetadata.HostMethodBinding>>();
|
||||
for (final var hostBinding : reservedMetadata.hostMethodBindings()) {
|
||||
@ -405,7 +378,6 @@ public final class PbsFrontendCompiler {
|
||||
}
|
||||
final var loweringContext = new ExecutableLoweringContext(
|
||||
normalizedModuleId,
|
||||
normalizedModuleKey,
|
||||
diagnostics,
|
||||
nameTable,
|
||||
hostByMethodName,
|
||||
@ -1341,7 +1313,6 @@ public final class PbsFrontendCompiler {
|
||||
|
||||
private static final class ExecutableLoweringContext {
|
||||
private final ModuleId moduleId;
|
||||
private final String moduleKey;
|
||||
private final DiagnosticSink diagnostics;
|
||||
private final NameTable nameTable;
|
||||
private final Map<NameId, List<IRReservedMetadata.HostMethodBinding>> hostByMethodName;
|
||||
@ -1359,7 +1330,6 @@ public final class PbsFrontendCompiler {
|
||||
|
||||
private ExecutableLoweringContext(
|
||||
final ModuleId moduleId,
|
||||
final String moduleKey,
|
||||
final DiagnosticSink diagnostics,
|
||||
final NameTable nameTable,
|
||||
final Map<NameId, List<IRReservedMetadata.HostMethodBinding>> hostByMethodName,
|
||||
@ -1372,7 +1342,6 @@ public final class PbsFrontendCompiler {
|
||||
final IntrinsicTable intrinsicIdTable,
|
||||
final Map<NameId, Integer> localSlotByNameId) {
|
||||
this.moduleId = moduleId == null ? ModuleId.none() : moduleId;
|
||||
this.moduleKey = moduleKey;
|
||||
this.diagnostics = diagnostics;
|
||||
this.nameTable = nameTable;
|
||||
this.hostByMethodName = hostByMethodName;
|
||||
@ -1390,10 +1359,6 @@ public final class PbsFrontendCompiler {
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
private String moduleKey() {
|
||||
return moduleKey;
|
||||
}
|
||||
|
||||
private DiagnosticSink diagnostics() {
|
||||
return diagnostics;
|
||||
}
|
||||
@ -1503,7 +1468,6 @@ public final class PbsFrontendCompiler {
|
||||
|
||||
public record ImportedCallableSurface(
|
||||
ModuleId moduleId,
|
||||
String moduleKey,
|
||||
String callableName,
|
||||
int arity,
|
||||
int returnSlots,
|
||||
|
||||
@ -178,7 +178,6 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
diagnostics,
|
||||
parsedSource.sourceKind(),
|
||||
parsedSource.moduleId(),
|
||||
renderModuleKey(moduleTable, parsedSource.moduleId()),
|
||||
canonicalModulePool,
|
||||
ctx.hostAdmissionContext(),
|
||||
nameTable,
|
||||
@ -430,7 +429,6 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
if (importedTopDeclsByName == null) {
|
||||
continue;
|
||||
}
|
||||
final var importedModuleKey = renderModuleKey(moduleTable, importedModuleId);
|
||||
importedReservedMetadata = mergeReservedMetadata(
|
||||
importedReservedMetadata,
|
||||
reservedMetadataByModule.getOrDefault(importedModuleId, IRReservedMetadata.empty()));
|
||||
@ -449,7 +447,6 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
importedCallableKeys,
|
||||
new PbsFrontendCompiler.ImportedCallableSurface(
|
||||
importedModuleId,
|
||||
importedModuleKey,
|
||||
localName + "." + method.name(),
|
||||
method.parameters().size(),
|
||||
returnSlotsFor(method),
|
||||
@ -463,7 +460,6 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
importedCallableKeys,
|
||||
new PbsFrontendCompiler.ImportedCallableSurface(
|
||||
importedModuleId,
|
||||
importedModuleKey,
|
||||
localName,
|
||||
functionDecl.parameters().size(),
|
||||
returnSlotsFor(functionDecl),
|
||||
@ -672,7 +668,7 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
final ArrayList<PbsFrontendCompiler.ImportedCallableSurface> importedCallables,
|
||||
final Set<String> importedCallableKeys,
|
||||
final PbsFrontendCompiler.ImportedCallableSurface importedCallableSurface) {
|
||||
final var callableKey = importedCallableSurface.moduleKey()
|
||||
final var callableKey = importedCallableSurface.moduleId().getIndex()
|
||||
+ "#"
|
||||
+ importedCallableSurface.callableName()
|
||||
+ "#"
|
||||
@ -805,13 +801,6 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
|
||||
return moduleTable.register(new ModuleReference(project, pathSegments));
|
||||
}
|
||||
|
||||
private String renderModuleKey(
|
||||
final ModuleTable moduleTable,
|
||||
final ModuleId moduleId) {
|
||||
final var moduleReference = moduleTable.get(moduleId);
|
||||
return moduleReference.project() + ":" + String.join("/", moduleReference.pathSegments().asList());
|
||||
}
|
||||
|
||||
private ReadOnlyList<ModuleReference> emitModulePool(final ModuleTable moduleTable) {
|
||||
final var pool = new ArrayList<ModuleReference>(moduleTable.size());
|
||||
for (final var moduleId : moduleTable.identifiers()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user