Skip to content

Commit 1c5d1e5

Browse files
Add a common Simplificator in the Traverser (#1261)
1 parent 4398ff2 commit 1c5d1e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+685
-365
lines changed

utbot-analytics/src/main/kotlin/org/utbot/features/FeatureExtractorImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.utbot.features
22

33
import org.utbot.analytics.FeatureExtractor
4-
import org.utbot.engine.ExecutionState
4+
import org.utbot.engine.state.ExecutionState
55
import org.utbot.engine.InterProceduralUnitGraph
66
import org.utbot.engine.selectors.strategies.StatementsStatistics
77
import org.utbot.engine.selectors.strategies.SubpathStatistics

utbot-analytics/src/main/kotlin/org/utbot/features/FeatureProcessorWithStatesRepetition.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package org.utbot.features
22

33
import org.utbot.analytics.EngineAnalyticsContext
44
import org.utbot.analytics.FeatureProcessor
5-
import org.utbot.engine.ExecutionState
5+
import org.utbot.engine.state.ExecutionState
66
import org.utbot.engine.InterProceduralUnitGraph
77
import org.utbot.framework.UtSettings
88
import soot.jimple.Stmt

utbot-framework/src/main/kotlin/org/utbot/analytics/FeatureExtractor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.utbot.analytics
22

3-
import org.utbot.engine.ExecutionState
3+
import org.utbot.engine.state.ExecutionState
44

55
/**
66
* Class that encapsulates work with FeatureExtractor during symbolic execution.

utbot-framework/src/main/kotlin/org/utbot/engine/DataClasses.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.utbot.engine.pc.UtIsExpression
1111
import org.utbot.engine.pc.UtTrue
1212
import org.utbot.engine.pc.mkAnd
1313
import org.utbot.engine.pc.mkOr
14+
import org.utbot.engine.state.ExecutionState
1415
import org.utbot.engine.symbolic.*
1516
import org.utbot.engine.types.TypeResolver
1617
import org.utbot.framework.plugin.api.FieldId
@@ -160,8 +161,6 @@ data class MethodResult(
160161
val symbolicResult: SymbolicResult,
161162
val symbolicStateUpdate: SymbolicStateUpdate = SymbolicStateUpdate()
162163
) : InvokeResult() {
163-
val memoryUpdates by symbolicStateUpdate::memoryUpdates
164-
165164
constructor(
166165
symbolicResult: SymbolicResult,
167166
hardConstraints: HardConstraint = emptyHardConstraint(),

utbot-framework/src/main/kotlin/org/utbot/engine/Extensions.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import org.utbot.engine.pc.mkInt
2929
import org.utbot.engine.pc.mkLong
3030
import org.utbot.engine.pc.mkShort
3131
import org.utbot.engine.pc.toSort
32+
import org.utbot.engine.state.ExecutionState
3233
import org.utbot.framework.UtSettings.checkNpeInNestedMethods
3334
import org.utbot.framework.UtSettings.checkNpeInNestedNotPrivateMethods
3435
import org.utbot.framework.plugin.api.FieldId

utbot-framework/src/main/kotlin/org/utbot/engine/InterProceduralUnitGraph.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package org.utbot.engine
22

33
import org.utbot.engine.selectors.strategies.TraverseGraphStatistics
4+
import org.utbot.engine.state.CALL_DECISION_NUM
5+
import org.utbot.engine.state.Edge
6+
import org.utbot.engine.state.ExecutionState
47
import soot.SootClass
58
import soot.SootMethod
69
import soot.jimple.Stmt

utbot-framework/src/main/kotlin/org/utbot/engine/Memory.kt

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.utbot.engine
33
import org.utbot.engine.MemoryState.CURRENT
44
import org.utbot.engine.MemoryState.INITIAL
55
import org.utbot.engine.MemoryState.STATIC_INITIAL
6-
import org.utbot.engine.pc.RewritingVisitor
76
import org.utbot.engine.pc.UtAddrExpression
87
import org.utbot.engine.pc.UtAddrSort
98
import org.utbot.engine.pc.UtArrayExpressionBase
@@ -49,28 +48,6 @@ import soot.Scene
4948
import soot.Type
5049

5150

52-
/**
53-
* Represents a memory associated with a certain method call. For now consists only of local variables mapping.
54-
* TODO: think on other fields later
55-
*
56-
* @param [locals] represents a mapping from [LocalVariable]s of a specific method call to [SymbolicValue]s.
57-
*/
58-
data class LocalVariableMemory(
59-
private val locals: PersistentMap<LocalVariable, SymbolicValue> = persistentHashMapOf()
60-
) {
61-
fun memoryForNestedMethod(): LocalVariableMemory = this.copy(locals = persistentHashMapOf())
62-
63-
fun update(update: LocalMemoryUpdate): LocalVariableMemory = this.copy(locals = locals.update(update.locals))
64-
65-
/**
66-
* Returns local variable value.
67-
*/
68-
fun local(variable: LocalVariable): SymbolicValue? = locals[variable]
69-
70-
val localValues: Set<SymbolicValue>
71-
get() = locals.values.toSet()
72-
}
73-
7451
/**
7552
* Local memory implementation based on arrays.
7653
*
@@ -439,20 +416,20 @@ data class UtNamedStore(
439416
)
440417

441418
/**
442-
* Create [UtNamedStore] with simplified [index] and [value] expressions.
419+
* Create [UtNamedStore] with unsimplified [index] and [value] expressions.
443420
*
444-
* @see RewritingVisitor
421+
* @note simplifications occur explicitly in [Traverser]
445422
*/
446-
fun simplifiedNamedStore(
423+
fun namedStore(
447424
chunkDescriptor: MemoryChunkDescriptor,
448425
index: UtExpression,
449426
value: UtExpression
450-
) = RewritingVisitor().let { visitor -> UtNamedStore(chunkDescriptor, index.accept(visitor), value.accept(visitor)) }
427+
) = UtNamedStore(chunkDescriptor, index, value)
451428

452429
/**
453430
* Updates persistent map where value = null in update means deletion of original key-value
454431
*/
455-
private fun <K, V> PersistentMap<K, V>.update(update: Map<K, V?>): PersistentMap<K, V> {
432+
fun <K, V> PersistentMap<K, V>.update(update: Map<K, V?>): PersistentMap<K, V> {
456433
if (update.isEmpty()) return this
457434
val deletions = mutableListOf<K>()
458435
val updates = mutableMapOf<K, V>()

utbot-framework/src/main/kotlin/org/utbot/engine/Resolver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ private fun Traverser.arrayToMethodResult(
12721272
}
12731273

12741274
val memoryUpdate = MemoryUpdate(
1275-
stores = persistentListOf(simplifiedNamedStore(descriptor, newAddr, updatedArray)),
1275+
stores = persistentListOf(namedStore(descriptor, newAddr, updatedArray)),
12761276
touchedChunkDescriptors = persistentSetOf(descriptor),
12771277
)
12781278

utbot-framework/src/main/kotlin/org/utbot/engine/Strings.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import com.github.curiousoddman.rgxgen.RgxGen
44
import org.utbot.engine.overrides.strings.UtString
55
import org.utbot.engine.overrides.strings.UtStringBuffer
66
import org.utbot.engine.overrides.strings.UtStringBuilder
7-
import org.utbot.engine.pc.RewritingVisitor
87
import org.utbot.engine.pc.UtAddrExpression
98
import org.utbot.engine.pc.UtBoolExpression
109
import org.utbot.engine.pc.UtFalse
@@ -122,17 +121,17 @@ class StringWrapper : BaseOverriddenWrapper(utStringClass.name) {
122121
parameters: List<SymbolicValue>
123122
): List<InvokeResult>? {
124123
val arg = parameters[0] as ObjectValue
125-
val matchingLengthExpr = getIntFieldValue(arg, STRING_LENGTH).accept(RewritingVisitor())
124+
val matchingLengthExpr = getIntFieldValue(arg, STRING_LENGTH).accept(this.simplificator)
126125

127126
if (!matchingLengthExpr.isConcrete) return null
128127

129128
val matchingValueExpr =
130-
selectArrayExpressionFromMemory(getValueArray(arg.addr)).accept(RewritingVisitor())
129+
selectArrayExpressionFromMemory(getValueArray(arg.addr)).accept(this.simplificator)
131130
val matchingLength = matchingLengthExpr.toConcrete() as Int
132131
val matchingValue = CharArray(matchingLength)
133132

134133
for (i in 0 until matchingLength) {
135-
val charExpr = matchingValueExpr.select(mkInt(i)).accept(RewritingVisitor())
134+
val charExpr = matchingValueExpr.select(mkInt(i)).accept(this.simplificator)
136135

137136
if (!charExpr.isConcrete) return null
138137

utbot-framework/src/main/kotlin/org/utbot/engine/TraversalContext.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.utbot.engine
22

3+
import org.utbot.engine.state.ExecutionState
4+
35
/**
46
* Represents a mutable _Context_ during the [ExecutionState] traversing. This _Context_ consists of all mutable and
57
* immutable properties and fields which are created and updated during analysis of a **single** Jimple instruction.

0 commit comments

Comments
 (0)