Skip to content

Commit

Permalink
add missing persistance for TypeInference pass
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Jun 1, 2024
1 parent 0b2012b commit 49a702d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import org.enso.compiler.pass.analyse.alias.Graph;
import org.enso.compiler.pass.analyse.alias.Info;
import org.enso.compiler.pass.analyse.types.TypeInference;
import org.enso.compiler.pass.resolve.DocumentationComments;
import org.enso.compiler.pass.resolve.DocumentationComments$;
import org.enso.compiler.pass.resolve.ExpressionAnnotations$;
Expand Down Expand Up @@ -74,6 +75,7 @@
id = 1265,
allowInlining = false)
@Persistable(clazz = Graph.Link.class, id = 1266, allowInlining = false)
@Persistable(clazz = TypeInference.class, id = 1280)
public final class PassPersistance {
private PassPersistance() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@
import scala.jdk.javaapi.CollectionConverters$;

/** Implementation of {@link AtomTypeInterface} that is built from a {@link BindingsMap.Type}. */
record AtomTypeInterfaceFromBindingsMap(BindingsMap.Type type) implements AtomTypeInterface {
// needed for serialization
public final class AtomTypeInterfaceFromBindingsMap implements AtomTypeInterface {
private final BindingsMap.Type type;

public AtomTypeInterfaceFromBindingsMap(BindingsMap.Type type) {
this.type = type;
}

// Needed for Persistable
public BindingsMap.Type type() {
return type;
}

@Override
public List<? extends Constructor> constructors() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.enso.compiler.pass.analyse.types;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.enso.persist.Persistable;
import org.enso.persist.Persistance;
import org.openide.util.lookup.ServiceProvider;

@Persistable(clazz = InferredType.class, id = 34000)
@Persistable(clazz = TypeRepresentation.TopType.class, id = 34001)
@Persistable(clazz = TypeRepresentation.TypeObject.class, id = 34002)
@Persistable(clazz = TypeRepresentation.ArrowType.class, id = 34003)
@Persistable(clazz = TypeRepresentation.AtomType.class, id = 34004)
@Persistable(clazz = TypeRepresentation.IntersectionType.class, id = 34005)
@Persistable(clazz = TypeRepresentation.SumType.class, id = 34006)
@Persistable(clazz = TypeRepresentation.UnresolvedSymbol.class, id = 34007)
@Persistable(clazz = AtomTypeInterfaceFromBindingsMap.class, id = 34010)
public final class TypeInferencePersistance {
private TypeInferencePersistance() {}

@ServiceProvider(service = Persistance.class)
public static final class PersistJavaList extends Persistance<List> {
public PersistJavaList() {
super(List.class, true, 34011);
}

@Override
protected void writeObject(List list, Output out) throws IOException {
var size = list.size();
out.writeInt(size);
for (var i = 0; i < size; i++) {
out.writeObject(list.get(i));
}
}

@Override
protected List readObject(Input in) throws IOException, ClassNotFoundException {
var size = in.readInt();
var list = new ArrayList<>(size);
for (var i = 0; i < size; i++) {
var elem = in.readObject();
list.add(elem);
}
return list;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
@Persistable(clazz = Unused.FunctionArgument.class, id = 787)
@Persistable(clazz = Warning.DuplicatedImport.class, id = 788)
@Persistable(clazz = Warning.WrongBuiltinMethod.class, id = 789)
@Persistable(clazz = Warning.NotInvokable.class, id = 791)
@Persistable(clazz = Warning.TypeMismatch.class, id = 792)
@Persistable(clazz = Operator.Binary.class, id = 790)
public final class IrPersistance {
private IrPersistance() {}
Expand Down

0 comments on commit 49a702d

Please sign in to comment.