Add KotlinInfo annotation, serialize classes to bytecode
This commit is contained in:
+24
-10
@@ -17,25 +17,39 @@
|
||||
package org.jetbrains.jet.descriptors.serialization;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class NameSerializationUtil {
|
||||
@NotNull
|
||||
public static NameResolver deserializeNameResolver(@NotNull InputStream in) throws IOException {
|
||||
ProtoBuf.SimpleNameTable simpleNames = ProtoBuf.SimpleNameTable.parseDelimitedFrom(in);
|
||||
ProtoBuf.QualifiedNameTable qualifiedNames = ProtoBuf.QualifiedNameTable.parseDelimitedFrom(in);
|
||||
return new NameResolver(simpleNames, qualifiedNames);
|
||||
private NameSerializationUtil() {
|
||||
}
|
||||
|
||||
public static void serializeNameTable(@NotNull OutputStream out, @NotNull NameTable nameTable) throws IOException {
|
||||
ProtoBuf.SimpleNameTable simpleNamesProto = toSimpleNameTable(nameTable);
|
||||
simpleNamesProto.writeDelimitedTo(out);
|
||||
@NotNull
|
||||
public static NameResolver deserializeNameResolver(@NotNull InputStream in) {
|
||||
try {
|
||||
ProtoBuf.SimpleNameTable simpleNames = ProtoBuf.SimpleNameTable.parseDelimitedFrom(in);
|
||||
ProtoBuf.QualifiedNameTable qualifiedNames = ProtoBuf.QualifiedNameTable.parseDelimitedFrom(in);
|
||||
return new NameResolver(simpleNames, qualifiedNames);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
ProtoBuf.QualifiedNameTable qualifiedNameTable = toQualifiedNameTable(nameTable);
|
||||
qualifiedNameTable.writeDelimitedTo(out);
|
||||
public static void serializeNameTable(@NotNull OutputStream out, @NotNull NameTable nameTable) {
|
||||
try {
|
||||
ProtoBuf.SimpleNameTable simpleNamesProto = toSimpleNameTable(nameTable);
|
||||
simpleNamesProto.writeDelimitedTo(out);
|
||||
|
||||
ProtoBuf.QualifiedNameTable qualifiedNameTable = toQualifiedNameTable(nameTable);
|
||||
qualifiedNameTable.writeDelimitedTo(out);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw ExceptionUtils.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+4
-1
@@ -84,10 +84,13 @@ public class NameTable {
|
||||
NamespaceDescriptor namespaceDescriptor = (NamespaceDescriptor) containingDeclaration;
|
||||
builder.setParentQualifiedName(getFqNameIndex(namespaceDescriptor));
|
||||
}
|
||||
else {
|
||||
else if (containingDeclaration instanceof ClassDescriptor) {
|
||||
ClassDescriptor outerClass = (ClassDescriptor) containingDeclaration;
|
||||
builder.setParentQualifiedName(getFqNameIndex(outerClass));
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("FQ names are only stored for top-level or inner classes: " + classDescriptor);
|
||||
}
|
||||
|
||||
return qualifiedNames.intern(builder);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user