@@ -13,16 +13,20 @@ import org.usvm.instrumentation.testcase.descriptor.UTestObjectDescriptor
13
13
import org.usvm.instrumentation.testcase.descriptor.UTestRefDescriptor
14
14
import org.usvm.instrumentation.testcase.descriptor.UTestValueDescriptor
15
15
import org.usvm.instrumentation.util.InstrumentationModuleConstants.nameForExistingButNullString
16
+ import org.utbot.framework.plugin.api.ClassId
16
17
import org.utbot.framework.plugin.api.FieldId
17
18
import org.utbot.framework.plugin.api.UtArrayModel
18
19
import org.utbot.framework.plugin.api.UtAssembleModel
19
20
import org.utbot.framework.plugin.api.UtClassRefModel
20
21
import org.utbot.framework.plugin.api.UtCompositeModel
22
+ import org.utbot.framework.plugin.api.UtCustomModel
21
23
import org.utbot.framework.plugin.api.UtEnumConstantModel
22
24
import org.utbot.framework.plugin.api.UtModel
23
25
import org.utbot.framework.plugin.api.UtNullModel
24
26
import org.utbot.framework.plugin.api.UtPrimitiveModel
25
27
import org.utbot.framework.plugin.api.UtReferenceModel
28
+ import org.utbot.framework.plugin.api.mapper.UtModelDeepMapper
29
+ import org.utbot.framework.plugin.api.mapper.UtModelMapper
26
30
import org.utbot.framework.plugin.api.util.classClassId
27
31
import org.utbot.framework.plugin.api.util.id
28
32
import org.utbot.framework.plugin.api.util.jClass
@@ -33,6 +37,15 @@ enum class EnvironmentStateKind {
33
37
INITIAL , FINAL
34
38
}
35
39
40
+ data class UtCyclicReferenceModel (
41
+ override val id : Int? ,
42
+ override val classId : ClassId ,
43
+ val refId : Int ,
44
+ val stateKind : EnvironmentStateKind ,
45
+ ) : UtCustomModel(id, classId) {
46
+ override fun shallowMap (mapper : UtModelMapper ): UtCustomModel = this
47
+ }
48
+
36
49
class JcToUtModelConverter (
37
50
private val idGenerator : IdGenerator <Int >,
38
51
private val jcClasspath : JcClasspath ,
@@ -42,6 +55,13 @@ class JcToUtModelConverter(
42
55
mutableMapOf<Pair <UTestValueDescriptor , EnvironmentStateKind >, UtModel > ()
43
56
private val refIdAndStateKindToDescriptorCache =
44
57
mutableMapOf<Pair <Int , EnvironmentStateKind >, UTestValueDescriptor > ()
58
+ val utCyclicReferenceModelResolver = UtModelDeepMapper { model ->
59
+ when (model) {
60
+ is UtCyclicReferenceModel -> getModelByRefIdAndStateKind(model.refId, model.stateKind)
61
+ ? : error(" Invalid UTestCyclicReferenceDescriptor: $model " )
62
+ else -> model
63
+ }
64
+ }
45
65
46
66
fun convert (
47
67
valueDescriptor : UTestValueDescriptor ,
@@ -149,7 +169,12 @@ class JcToUtModelConverter(
149
169
is UTestConstantDescriptor .String -> constructString(valueDescriptor.value)
150
170
151
171
is UTestCyclicReferenceDescriptor -> getModelByRefIdAndStateKind(valueDescriptor.refId, stateKind)
152
- ? : error(" Invalid UTestCyclicReferenceDescriptor: $valueDescriptor " )
172
+ ? : UtCyclicReferenceModel (
173
+ id = curModelId,
174
+ classId = valueDescriptor.type.classId,
175
+ refId = valueDescriptor.refId,
176
+ stateKind = stateKind
177
+ )
153
178
154
179
is UTestEnumValueDescriptor -> UtEnumConstantModel (
155
180
id = curModelId,
0 commit comments