Skip to content

Commit

Permalink
Remove workaround for BIR serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
heshanpadmasiri committed Dec 17, 2024
1 parent 06e31a7 commit 534f7b4
Showing 1 changed file with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -566,29 +566,19 @@ SemType readonlyType() {
// Due to some reason SpotBug thinks this method is overrideable if we don't put final here as well.
final void initializeEnv(Env env) {
assert initialized.get() : "PredefinedTypeEnv has not fully initialized, check concurrency issues";
fillRecAtoms(env.recListAtoms, initializedRecListAtoms);
fillRecAtoms(env.recMappingAtoms, initializedRecMappingAtoms);
fillRecAtoms(env.recListAtoms, initializedRecListAtoms, initializedRecListAtoms.size());
fillRecAtoms(env.recMappingAtoms, initializedRecMappingAtoms, initializedRecMappingAtoms.size());
initializedCellAtoms.forEach(each -> env.cellAtom(each.atomicType()));
initializedListAtoms.forEach(each -> env.listAtom(each.atomicType()));
}

private <E extends AtomicType> void fillRecAtoms(List<E> envRecAtomList, List<E> initializedRecAtoms) {
int count = reservedRecAtomCount();
for (int i = 0; i < count; i++) {
if (i < initializedRecAtoms.size()) {
envRecAtomList.add(initializedRecAtoms.get(i));
} else {
// This is mainly to help with bir serialization/deserialization logic. Given the number of such atoms
// will be small this shouldn't be a problem.
envRecAtomList.add(null);
}
private <E extends AtomicType> void fillRecAtoms(List<E> envRecAtomList, List<E> initializedRecAtoms,
int reservedAtomCount) {
for (int i = 0; i < reservedAtomCount; i++) {
envRecAtomList.add(initializedRecAtoms.get(i));
}
}

private int reservedRecAtomCount() {
return Integer.max(initializedRecListAtoms.size(), initializedRecMappingAtoms.size());
}

SemType cellSemTypeInner() {
return cellSemTypeInner.get();
}
Expand Down

0 comments on commit 534f7b4

Please sign in to comment.