Skip to content

Commit

Permalink
Merge pull request #348 from alex999990009/fixes
Browse files Browse the repository at this point in the history
Add the function for deserialization
  • Loading branch information
sxhya authored Sep 30, 2024
2 parents 90915d5 + 07d5fde commit 4bee850
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions base/src/main/java/org/arend/source/StreamBinarySource.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import org.arend.ext.module.ModulePath;
import org.arend.ext.typechecking.DefinitionListener;
import org.arend.extImpl.SerializableKeyRegistryImpl;
import org.arend.library.LibraryManager;
import org.arend.library.SourceLibrary;
import org.arend.library.error.LibraryError;
import org.arend.library.error.PartialModuleError;
import org.arend.module.ModuleLocation;
import org.arend.module.error.DeserializationError;
import org.arend.module.error.ExceptionError;
import org.arend.ext.serialization.DeserializationException;
import org.arend.module.scopeprovider.ModuleScopeProvider;
import org.arend.module.serialization.ModuleDeserialization;
import org.arend.module.serialization.ModuleProtos;
import org.arend.module.serialization.ModuleSerialization;
Expand Down Expand Up @@ -75,6 +77,21 @@ public void setDefinitionListener(DefinitionListener definitionListener) {
return myDependencies;
}

public static Group getGroup(InputStream inputStream, LibraryManager libraryManager, SourceLibrary library) throws IOException, DeserializationException {
CodedInputStream codedInputStream = CodedInputStream.newInstance(inputStream);
codedInputStream.setRecursionLimit(Integer.MAX_VALUE);
ModuleProtos.Module moduleProto = ModuleProtos.Module.parseFrom(codedInputStream);

ModuleDeserialization moduleDeserialization = new ModuleDeserialization(moduleProto, library.getReferableConverter(), null, libraryManager.getDefinitionListener(), false);

ChildGroup group = moduleDeserialization.readGroup(new ModuleLocation(library, ModuleLocation.LocationKind.GENERATED, new ModulePath()));

ModuleScopeProvider moduleScopeProvider = libraryManager.getAvailableModuleScopeProvider(library);
moduleDeserialization.readModule(moduleScopeProvider, library.getDependencyListener());

return group;
}

@Override
public @NotNull LoadResult load(SourceLoader sourceLoader) {
SourceLibrary library = sourceLoader.getLibrary();
Expand Down

0 comments on commit 4bee850

Please sign in to comment.