@@ -45,6 +45,13 @@ import org.usvm.model.UModelBase
4545
4646private val logger = KotlinLogging .logger {}
4747
48+ data class MemoryScopeDescriptor (
49+ val method : JcTypedMethod ,
50+ val state : JcState ,
51+ val stringConstants : Map <String , UConcreteHeapRef >,
52+ val classConstants : Map <JcType , UConcreteHeapRef >,
53+ )
54+
4855/* *
4956 * A class, responsible for resolving a single [JcExecution] for a specific method from a symbolic state.
5057 *
@@ -55,13 +62,8 @@ class JcTestExecutor(
5562 val classpath : JcClasspath ,
5663 private val runner : UTestConcreteExecutor
5764) {
58- private val memoryScopeCache = mutableMapOf<MemoryScopeDescriptor , MemoryScope >()
59- data class MemoryScopeDescriptor (
60- val method : JcTypedMethod ,
61- val state : JcState ,
62- val stringConstants : Map <String , UConcreteHeapRef >,
63- val classConstants : Map <JcType , UConcreteHeapRef >,
64- )
65+
66+
6567 /* *
6668 * Resolves a [JcTest] from a [method] from a [state].
6769 */
@@ -72,8 +74,9 @@ class JcTestExecutor(
7274 classConstants : Map <JcType , UConcreteHeapRef >,
7375 allowSymbolicResult : Boolean
7476 ): JcExecution ? {
75- val uTest = createUTest (method, state, stringConstants, classConstants)
77+ val memoryScopeDescriptor = MemoryScopeDescriptor (method, state, stringConstants, classConstants)
7678
79+ val uTest = createUTest(memoryScopeDescriptor)
7780 val concreteResult = runCatching {
7881 runBlocking {
7982 UTestConcreteExecutionResult (runner.executeAsync(uTest))
@@ -84,7 +87,6 @@ class JcTestExecutor(
8487 }
8588 .getOrNull()
8689
87- val memoryScopeDescriptor = MemoryScopeDescriptor (method, state, stringConstants, classConstants)
8890
8991 val symbolicResult by lazy {
9092 if (allowSymbolicResult) {
@@ -132,42 +134,35 @@ class JcTestExecutor(
132134 )
133135 }
134136
135- fun createUTest (
136- method : JcTypedMethod ,
137- state : JcState ,
138- stringConstants : Map <String , UConcreteHeapRef >,
139- classConstants : Map <JcType , UConcreteHeapRef >,
140- ): UTest {
141- val memoryScopeDescriptor = MemoryScopeDescriptor (method, state, stringConstants, classConstants)
137+ fun createUTest (memoryScopeDescriptor : MemoryScopeDescriptor ): UTest {
142138 val memoryScope = createMemoryScope(memoryScopeDescriptor)
143-
144139 return memoryScope.createUTest()
145140 }
146141
147- private fun createMemoryScope (descriptor : MemoryScopeDescriptor ): MemoryScope =
148- memoryScopeCache.getOrPut(descriptor) {
149- val model = descriptor.state.models.first()
150- val ctx = descriptor.state.ctx
151-
152- val mocker = descriptor.state.memory. mocker as JcMocker
153- // val staticMethodMocks = mocker.statics TODO global mocks?????????????????????????
154- val methodMocks = mocker.symbols
155-
156- val resolvedMethodMocks = methodMocks
157- .entries
158- .groupBy({ model.eval(it.key) }, { it.value })
159- .mapValues { it.value.flatten() }
160-
161- MemoryScope (
162- ctx ,
163- model,
164- model ,
165- descriptor.stringConstants ,
166- descriptor.classConstants ,
167- resolvedMethodMocks ,
168- descriptor.method,
169- )
170- }
142+ private fun createMemoryScope (descriptor : MemoryScopeDescriptor ): MemoryScope {
143+ val model = descriptor.state.models.first()
144+ val ctx = descriptor.state.ctx
145+
146+ val mocker = descriptor.state.memory.mocker as JcMocker
147+ // val staticMethodMocks = mocker.statics TODO global mocks?????????????????????????
148+ val methodMocks = mocker.symbols
149+
150+ val resolvedMethodMocks = methodMocks
151+ .entries
152+ .groupBy({ model.eval(it.key) }, { it.value })
153+ .mapValues { it.value.flatten() }
154+
155+ return MemoryScope (
156+ ctx,
157+ model ,
158+ model,
159+ descriptor.stringConstants ,
160+ descriptor.classConstants ,
161+ resolvedMethodMocks ,
162+ descriptor.method ,
163+ )
164+ }
165+
171166
172167 @Suppress(" UNUSED_PARAMETER" )
173168 private fun resolveCoverage (method : JcTypedMethod , state : JcState ): JcCoverage {
0 commit comments