IR: additional callable reference adapter stuff in IR
- IrFunctionReference.reflectionTarget: IrFunctionSymbol? - add separate declaration origin for callable reference adapters - bump IR ABI version
This commit is contained in:
@@ -219,6 +219,7 @@ message IrFunctionReference {
|
||||
required int32 symbol = 1;
|
||||
optional IrStatementOrigin origin = 2;
|
||||
required MemberAccessCommon member_access = 3;
|
||||
optional int32 reflectionTarget = 4;
|
||||
}
|
||||
|
||||
message IrLocalDelegatedPropertyReference {
|
||||
|
||||
+2
@@ -448,6 +448,7 @@ abstract class IrFileDeserializer(
|
||||
|
||||
val symbol = deserializeIrSymbol(proto.symbol) as IrFunctionSymbol
|
||||
val origin = if (proto.hasOrigin()) deserializeIrStatementOrigin(proto.origin) else null
|
||||
val reflectionTarget = if (proto.hasReflectionTarget()) deserializeIrSymbol(proto.reflectionTarget) as IrFunctionSymbol else null
|
||||
val callable = IrFunctionReferenceImpl(
|
||||
start,
|
||||
end,
|
||||
@@ -455,6 +456,7 @@ abstract class IrFileDeserializer(
|
||||
symbol,
|
||||
proto.memberAccess.typeArguments.typeArgumentCount,
|
||||
proto.memberAccess.valueArgumentCount,
|
||||
reflectionTarget,
|
||||
origin
|
||||
)
|
||||
deserializeMemberAccessCommon(callable, proto.memberAccess)
|
||||
|
||||
+9
-3
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.backend.common.serialization
|
||||
import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||
import org.jetbrains.kotlin.backend.common.ir.ir2string
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind.*
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.SourceManager
|
||||
@@ -18,7 +17,6 @@ import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.findTopLevelDeclaration
|
||||
import org.jetbrains.kotlin.ir.util.lineStartOffsets
|
||||
import org.jetbrains.kotlin.ir.util.module
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||
@@ -31,6 +29,7 @@ import org.jetbrains.kotlin.library.impl.IrMemoryDeclarationWriter
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.Actual as ProtoActual
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.ClassKind as ProtoClassKind
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.Coordinates as ProtoCoordinates
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.FieldAccessCommon as ProtoFieldAccessCommon
|
||||
@@ -116,7 +115,6 @@ import org.jetbrains.kotlin.backend.common.serialization.proto.ModalityKind as P
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.NullableIrExpression as ProtoNullableIrExpression
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.TypeArguments as ProtoTypeArguments
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.Visibility as ProtoVisibility
|
||||
import org.jetbrains.kotlin.backend.common.serialization.proto.Actual as ProtoActual
|
||||
|
||||
open class IrFileSerializer(
|
||||
val logger: LoggingContext,
|
||||
@@ -542,6 +540,14 @@ open class IrFileSerializer(
|
||||
val proto = ProtoFunctionReference.newBuilder()
|
||||
.setSymbol(serializeIrSymbol(callable.symbol))
|
||||
.setMemberAccess(serializeMemberAccessCommon(callable))
|
||||
.apply {
|
||||
val reflectionTarget = callable.reflectionTarget
|
||||
if (reflectionTarget != null) {
|
||||
setReflectionTarget(serializeIrSymbol(reflectionTarget))
|
||||
} else {
|
||||
clearReflectionTarget()
|
||||
}
|
||||
}
|
||||
|
||||
callable.origin?.let { proto.setOrigin(serializeIrStatementOrigin(it)) }
|
||||
return proto.build()
|
||||
|
||||
+69
@@ -84,6 +84,11 @@ public final class IrFunctionReference extends
|
||||
bitField0_ |= 0x00000004;
|
||||
break;
|
||||
}
|
||||
case 32: {
|
||||
bitField0_ |= 0x00000008;
|
||||
reflectionTarget_ = input.readInt32();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) {
|
||||
@@ -163,10 +168,26 @@ public final class IrFunctionReference extends
|
||||
return memberAccess_;
|
||||
}
|
||||
|
||||
public static final int REFLECTIONTARGET_FIELD_NUMBER = 4;
|
||||
private int reflectionTarget_;
|
||||
/**
|
||||
* <code>optional int32 reflectionTarget = 4;</code>
|
||||
*/
|
||||
public boolean hasReflectionTarget() {
|
||||
return ((bitField0_ & 0x00000008) == 0x00000008);
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 reflectionTarget = 4;</code>
|
||||
*/
|
||||
public int getReflectionTarget() {
|
||||
return reflectionTarget_;
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
symbol_ = 0;
|
||||
origin_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrStatementOrigin.getDefaultInstance();
|
||||
memberAccess_ = org.jetbrains.kotlin.backend.common.serialization.proto.MemberAccessCommon.getDefaultInstance();
|
||||
reflectionTarget_ = 0;
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
@@ -208,6 +229,9 @@ public final class IrFunctionReference extends
|
||||
if (((bitField0_ & 0x00000004) == 0x00000004)) {
|
||||
output.writeMessage(3, memberAccess_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
output.writeInt32(4, reflectionTarget_);
|
||||
}
|
||||
output.writeRawBytes(unknownFields);
|
||||
}
|
||||
|
||||
@@ -229,6 +253,10 @@ public final class IrFunctionReference extends
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeMessageSize(3, memberAccess_);
|
||||
}
|
||||
if (((bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
size += org.jetbrains.kotlin.protobuf.CodedOutputStream
|
||||
.computeInt32Size(4, reflectionTarget_);
|
||||
}
|
||||
size += unknownFields.size();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
@@ -329,6 +357,8 @@ public final class IrFunctionReference extends
|
||||
bitField0_ = (bitField0_ & ~0x00000002);
|
||||
memberAccess_ = org.jetbrains.kotlin.backend.common.serialization.proto.MemberAccessCommon.getDefaultInstance();
|
||||
bitField0_ = (bitField0_ & ~0x00000004);
|
||||
reflectionTarget_ = 0;
|
||||
bitField0_ = (bitField0_ & ~0x00000008);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -364,6 +394,10 @@ public final class IrFunctionReference extends
|
||||
to_bitField0_ |= 0x00000004;
|
||||
}
|
||||
result.memberAccess_ = memberAccess_;
|
||||
if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
|
||||
to_bitField0_ |= 0x00000008;
|
||||
}
|
||||
result.reflectionTarget_ = reflectionTarget_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
return result;
|
||||
}
|
||||
@@ -379,6 +413,9 @@ public final class IrFunctionReference extends
|
||||
if (other.hasMemberAccess()) {
|
||||
mergeMemberAccess(other.getMemberAccess());
|
||||
}
|
||||
if (other.hasReflectionTarget()) {
|
||||
setReflectionTarget(other.getReflectionTarget());
|
||||
}
|
||||
setUnknownFields(
|
||||
getUnknownFields().concat(other.unknownFields));
|
||||
return this;
|
||||
@@ -577,6 +614,38 @@ public final class IrFunctionReference extends
|
||||
return this;
|
||||
}
|
||||
|
||||
private int reflectionTarget_ ;
|
||||
/**
|
||||
* <code>optional int32 reflectionTarget = 4;</code>
|
||||
*/
|
||||
public boolean hasReflectionTarget() {
|
||||
return ((bitField0_ & 0x00000008) == 0x00000008);
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 reflectionTarget = 4;</code>
|
||||
*/
|
||||
public int getReflectionTarget() {
|
||||
return reflectionTarget_;
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 reflectionTarget = 4;</code>
|
||||
*/
|
||||
public Builder setReflectionTarget(int value) {
|
||||
bitField0_ |= 0x00000008;
|
||||
reflectionTarget_ = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 reflectionTarget = 4;</code>
|
||||
*/
|
||||
public Builder clearReflectionTarget() {
|
||||
bitField0_ = (bitField0_ & ~0x00000008);
|
||||
reflectionTarget_ = 0;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrFunctionReference)
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -33,4 +33,13 @@ public interface IrFunctionReferenceOrBuilder extends
|
||||
* <code>required .org.jetbrains.kotlin.backend.common.serialization.proto.MemberAccessCommon member_access = 3;</code>
|
||||
*/
|
||||
org.jetbrains.kotlin.backend.common.serialization.proto.MemberAccessCommon getMemberAccess();
|
||||
|
||||
/**
|
||||
* <code>optional int32 reflectionTarget = 4;</code>
|
||||
*/
|
||||
boolean hasReflectionTarget();
|
||||
/**
|
||||
* <code>optional int32 reflectionTarget = 4;</code>
|
||||
*/
|
||||
int getReflectionTarget();
|
||||
}
|
||||
Reference in New Issue
Block a user