[cls] more compact representation for contract stubs

distinguish boolean parameters
This commit is contained in:
Anna Kozlova
2023-04-25 12:13:39 +02:00
committed by Space Team
parent 50f5fadfd8
commit 20661d1f95
2 changed files with 19 additions and 6 deletions
@@ -23,12 +23,12 @@ object KotlinStubVersions {
// Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version
// if you are not 100% sure it can be avoided.
// Increasing this version will lead to reindexing of all kotlin source files on the first IDE startup with the new version.
const val SOURCE_STUB_VERSION = 150
const val SOURCE_STUB_VERSION = 151
// Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
// Increasing this version will lead to reindexing of all binary files that are potentially kotlin binaries (including all class files).
private const val BINARY_STUB_VERSION = 86
private const val BINARY_STUB_VERSION = 87
// Classfile stub version should be increased if changes are made to classfile stub building subsystem (org.jetbrains.kotlin.idea.decompiler.classFile)
// Increasing this version will lead to reindexing of all classfiles.
@@ -79,6 +79,11 @@ enum class KotlinContractEffectType {
return KtValueParameterReference(dataStream.readInt(), IGNORE_REFERENCE_PARAMETER_NAME)
}
},
BOOLEAN_PARAMETER_REFERENCE {
override fun deserialize(dataStream: StubInputStream): KtValueParameterReference<KotlinTypeBean, Nothing?> {
return KtBooleanValueParameterReference(dataStream.readInt(), IGNORE_REFERENCE_PARAMETER_NAME)
}
},
CONSTANT {
override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> {
return when (val str = dataStream.readNameString()!!) {
@@ -112,12 +117,12 @@ class KotlinContractSerializationVisitor(val dataStream: StubOutputStream) :
override fun visitReturnsEffectDeclaration(returnsEffect: KtReturnsEffectDeclaration<KotlinTypeBean, Nothing?>, data: Nothing?) {
dataStream.writeInt(KotlinContractEffectType.RETURNS.ordinal)
returnsEffect.value.accept(this, data)
dataStream.writeName(returnsEffect.value.name)
}
override fun visitCallsEffectDeclaration(callsEffect: KtCallsEffectDeclaration<KotlinTypeBean, Nothing?>, data: Nothing?) {
dataStream.writeInt(KotlinContractEffectType.CALLS.ordinal)
callsEffect.valueParameterReference.accept(this, data)
dataStream.writeInt(callsEffect.valueParameterReference.parameterIndex)
dataStream.writeInt(callsEffect.kind.ordinal)
}
@@ -138,14 +143,14 @@ class KotlinContractSerializationVisitor(val dataStream: StubOutputStream) :
override fun visitIsInstancePredicate(isInstancePredicate: KtIsInstancePredicate<KotlinTypeBean, Nothing?>, data: Nothing?) {
dataStream.writeInt(KotlinContractEffectType.IS_INSTANCE.ordinal)
isInstancePredicate.arg.accept(this, data)
dataStream.writeInt(isInstancePredicate.arg.parameterIndex)
serializeType(dataStream, isInstancePredicate.type)
dataStream.writeBoolean(isInstancePredicate.isNegated)
}
override fun visitIsNullPredicate(isNullPredicate: KtIsNullPredicate<KotlinTypeBean, Nothing?>, data: Nothing?) {
dataStream.writeInt(KotlinContractEffectType.IS_NULL.ordinal)
isNullPredicate.arg.accept(this, data)
dataStream.writeInt(isNullPredicate.arg.parameterIndex)
dataStream.writeBoolean(isNullPredicate.isNegated)
}
@@ -159,6 +164,14 @@ class KotlinContractSerializationVisitor(val dataStream: StubOutputStream) :
dataStream.writeInt(KotlinContractEffectType.PARAMETER_REFERENCE.ordinal)
dataStream.writeInt(valueParameterReference.parameterIndex)
}
override fun visitBooleanValueParameterReference(
booleanValueParameterReference: KtBooleanValueParameterReference<KotlinTypeBean, Nothing?>,
data: Nothing?
) {
dataStream.writeInt(KotlinContractEffectType.BOOLEAN_PARAMETER_REFERENCE.ordinal)
dataStream.writeInt(booleanValueParameterReference.parameterIndex)
}
}
object KotlinContractConstantValues {