@@ -45,6 +45,13 @@ import org.usvm.model.UModelBase
45
45
46
46
private val logger = KotlinLogging .logger {}
47
47
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
+
48
55
/* *
49
56
* A class, responsible for resolving a single [JcExecution] for a specific method from a symbolic state.
50
57
*
@@ -55,13 +62,8 @@ class JcTestExecutor(
55
62
val classpath : JcClasspath ,
56
63
private val runner : UTestConcreteExecutor
57
64
) {
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
+
65
67
/* *
66
68
* Resolves a [JcTest] from a [method] from a [state].
67
69
*/
@@ -72,8 +74,9 @@ class JcTestExecutor(
72
74
classConstants : Map <JcType , UConcreteHeapRef >,
73
75
allowSymbolicResult : Boolean
74
76
): JcExecution ? {
75
- val uTest = createUTest (method, state, stringConstants, classConstants)
77
+ val memoryScopeDescriptor = MemoryScopeDescriptor (method, state, stringConstants, classConstants)
76
78
79
+ val uTest = createUTest(memoryScopeDescriptor)
77
80
val concreteResult = runCatching {
78
81
runBlocking {
79
82
UTestConcreteExecutionResult (runner.executeAsync(uTest))
@@ -84,7 +87,6 @@ class JcTestExecutor(
84
87
}
85
88
.getOrNull()
86
89
87
- val memoryScopeDescriptor = MemoryScopeDescriptor (method, state, stringConstants, classConstants)
88
90
89
91
val symbolicResult by lazy {
90
92
if (allowSymbolicResult) {
@@ -132,42 +134,35 @@ class JcTestExecutor(
132
134
)
133
135
}
134
136
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 {
142
138
val memoryScope = createMemoryScope(memoryScopeDescriptor)
143
-
144
139
return memoryScope.createUTest()
145
140
}
146
141
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
+
171
166
172
167
@Suppress(" UNUSED_PARAMETER" )
173
168
private fun resolveCoverage (method : JcTypedMethod , state : JcState ): JcCoverage {
0 commit comments