Skip to content

Commit 9a75263

Browse files
sergeypospelovVassiliy-Kudryashov
authored andcommitted
Extract Traverser from UtBotSymbolicEngine (#307)
1 parent edc482a commit 9a75263

30 files changed

+3665
-3534
lines changed

utbot-framework/src/main/java/org/utbot/engine/overrides/UtArrayMock.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
/**
77
* Auxiliary class with static methods without implementation.
8-
* These static methods are just markers for <code>UtBotSymbolicEngine</code>,
8+
* These static methods are just markers for {@link org.utbot.engine.Traverser}.,
99
* to do some corresponding behavior, that can't be represent
1010
* with java instructions.
1111
* <p>
@@ -15,7 +15,7 @@
1515
@SuppressWarnings("unused")
1616
public class UtArrayMock {
1717
/**
18-
* Traversing this instruction by <code>UtBotSymbolicEngine</code> should
18+
* Traversing this instruction by {@link org.utbot.engine.Traverser} should
1919
* behave similar to call of {@link java.util.Arrays#copyOf(Object[], int)}
2020
* if length is less or equals to src.length, otherwise first
2121
* src.length elements are equal to src, but the rest are undefined.
@@ -45,7 +45,7 @@ public static char[] copyOf(char[] src, int length) {
4545
}
4646

4747
/**
48-
* Traversing this instruction by <code>UtBotSymbolicEngine</code> should
48+
* Traversing this instruction by {@link org.utbot.engine.Traverser} should
4949
* behave similar to call of
5050
* {@link java.lang.System#arraycopy(Object, int, Object, int, int)}
5151
* if all the arguments are valid.
@@ -67,7 +67,7 @@ public static void arraycopy(Object[] src, int srcPos, Object[] dst, int destPos
6767
}
6868

6969
/**
70-
* Traversing this instruction by <code>UtBotSymbolicEngine</code> should
70+
* Traversing this instruction by {@link org.utbot.engine.Traverser} should
7171
* behave similar to call of
7272
* {@link java.lang.System#arraycopy(Object, int, Object, int, int)}
7373
* if all the arguments are valid.
@@ -83,7 +83,7 @@ public static void arraycopy(boolean[] src, int srcPos, boolean[] dst, int destP
8383
}
8484

8585
/**
86-
* Traversing this instruction by <code>UtBotSymbolicEngine</code> should
86+
* Traversing this instruction by {@link org.utbot.engine.Traverser} should
8787
* behave similar to call of
8888
* {@link java.lang.System#arraycopy(Object, int, Object, int, int)}
8989
* if all the arguments are valid.
@@ -99,7 +99,7 @@ public static void arraycopy(byte[] src, int srcPos, byte[] dst, int destPos, in
9999
}
100100

101101
/**
102-
* Traversing this instruction by <code>UtBotSymbolicEngine</code> should
102+
* Traversing this instruction by {@link org.utbot.engine.Traverser} should
103103
* behave similar to call of
104104
* {@link java.lang.System#arraycopy(Object, int, Object, int, int)}
105105
* if all the arguments are valid.
@@ -115,7 +115,7 @@ public static void arraycopy(char[] src, int srcPos, char[] dst, int destPos, in
115115
}
116116

117117
/**
118-
* Traversing this instruction by <code>UtBotSymbolicEngine</code> should
118+
* Traversing this instruction by {@link org.utbot.engine.Traverser} should
119119
* behave similar to call of
120120
* {@link java.lang.System#arraycopy(Object, int, Object, int, int)}
121121
* if all the arguments are valid.
@@ -131,7 +131,7 @@ public static void arraycopy(short[] src, int srcPos, short[] dst, int destPos,
131131
}
132132

133133
/**
134-
* Traversing this instruction by <code>UtBotSymbolicEngine</code> should
134+
* Traversing this instruction by {@link org.utbot.engine.Traverser} should
135135
* behave similar to call of
136136
* {@link java.lang.System#arraycopy(Object, int, Object, int, int)}
137137
* if all the arguments are valid.
@@ -147,7 +147,7 @@ public static void arraycopy(int[] src, int srcPos, int[] dst, int destPos, int
147147
}
148148

149149
/**
150-
* Traversing this instruction by <code>UtBotSymbolicEngine</code> should
150+
* Traversing this instruction by {@link org.utbot.engine.Traverser} should
151151
* behave similar to call of
152152
* {@link java.lang.System#arraycopy(Object, int, Object, int, int)}
153153
* if all the arguments are valid.
@@ -163,7 +163,7 @@ public static void arraycopy(long[] src, int srcPos, long[] dst, int destPos, in
163163
}
164164

165165
/**
166-
* Traversing this instruction by <code>UtBotSymbolicEngine</code> should
166+
* Traversing this instruction by {@link org.utbot.engine.Traverser} should
167167
* behave similar to call of
168168
* {@link java.lang.System#arraycopy(Object, int, Object, int, int)}
169169
* if all the arguments are valid.
@@ -179,7 +179,7 @@ public static void arraycopy(float[] src, int srcPos, float[] dst, int destPos,
179179
}
180180

181181
/**
182-
* Traversing this instruction by <code>UtBotSymbolicEngine</code> should
182+
* Traversing this instruction by {@link org.utbot.engine.Traverser} should
183183
* behave similar to call of
184184
* {@link java.lang.System#arraycopy(Object, int, Object, int, int)}
185185
* if all the arguments are valid.

utbot-framework/src/main/java/org/utbot/engine/overrides/UtLogicMock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* Auxiliary class with static methods without implementation.
5-
* These static methods are just markers for <code>UtBotSymbolicEngine</code>,
5+
* These static methods are just markers for {@link org.utbot.engine.Traverser},
66
* to do some corresponding behavior, that can be represented with smt expressions.
77
* <p>
88
* <code>UtLogicMock</code> is used to store bool smt bool expressions in

utbot-framework/src/main/java/org/utbot/engine/overrides/UtOverrideMock.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
/**
44
* Auxiliary class with static methods without implementation.
5-
* These static methods are just markers for UtBotSymbolicEngine,
5+
* These static methods are just markers for {@link org.utbot.engine.Traverser},
66
* to do some corresponding behavior, that can't be represent
77
* with java instructions.
88
*
99
* Set of methods in UtOverrideMock is used in code of classes,
1010
* that override implementation of some standard class by new implementation,
11-
* that is more simple for UtBotSymbolicEngine to traverse.
11+
* that is more simple for {@link org.utbot.engine.Traverser} to traverse.
1212
*/
1313
@SuppressWarnings("unused")
1414
public class UtOverrideMock {
@@ -25,7 +25,7 @@ public static boolean alreadyVisited(Object o) {
2525
}
2626

2727
/**
28-
* If UtBotSymbolicEngine meets invoke of this method in code,
28+
* If {@link org.utbot.engine.Traverser} meets invoke of this method in code,
2929
* then it marks the address of object o in memory as visited
3030
* and creates new MemoryUpdate with parameter isVisited, equal to o.addr
3131
* @param o parameter, that need to be marked as visited.
@@ -34,7 +34,7 @@ public static void visit(Object o) {
3434
}
3535

3636
/**
37-
* If UtBotSymbolicEngine meets invoke of this method in code,
37+
* If {@link org.utbot.engine.Traverser} meets invoke of this method in code,
3838
* then it marks the method, where met instruction is placed,
3939
* and all the methods that will be traversed in nested invokes
4040
* as methods that couldn't throw exceptions.
@@ -44,7 +44,7 @@ public static void doesntThrow() {
4444
}
4545

4646
/**
47-
* If UtBotSymbolicEngine meets invoke of this method in code,
47+
* If {@link org.utbot.engine.Traverser} meets invoke of this method in code,
4848
* then it assumes that the specified object is parameter,
4949
* and need to be marked as parameter.
5050
* As address space of parameters in engine is non-positive, while
@@ -63,7 +63,7 @@ public static void parameter(Object[] objects) {
6363
}
6464

6565
/**
66-
* If UtBotSymbolicEngine meets invoke of this method in code,
66+
* If {@link org.utbot.engine.Traverser} meets invoke of this method in code,
6767
* then it starts concrete execution from this point.
6868
*/
6969
public static void executeConcretely() {

utbot-framework/src/main/java/org/utbot/engine/overrides/collections/UtArrayList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
/**
31-
* Class represents hybrid implementation (java + engine instructions) of List interface for UtBotSymbolicEngine.
31+
* Class represents hybrid implementation (java + engine instructions) of List interface for {@link org.utbot.engine.Traverser}.
3232
* <p>
3333
* Implementation is based on org.utbot.engine.overrides.collections.RangeModifiableArray.
3434
* Should behave similar to {@link java.util.ArrayList}.

utbot-framework/src/main/java/org/utbot/engine/overrides/collections/UtHashMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
/**
26-
* Class represents hybrid implementation (java + engine instructions) of Map interface for UtBotSymbolicEngine.
26+
* Class represents hybrid implementation (java + engine instructions) of Map interface for {@link org.utbot.engine.Traverser}.
2727
* <p>
2828
* Implementation is based on using org.utbot.engine.overrides.collections.RangeModifiableArray as keySet
2929
* and org.utbot.engine.overrides.collections.UtArray as associative array from keys to values.

utbot-framework/src/main/java/org/utbot/engine/overrides/collections/UtHashSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import static org.utbot.engine.overrides.UtOverrideMock.visit;
2121

2222
/**
23-
* Class represents hybrid implementation (java + engine instructions) of Set interface for UtBotSymbolicEngine.
23+
* Class represents hybrid implementation (java + engine instructions) of Set interface for {@link org.utbot.engine.Traverser}.
2424
* <p>
2525
* Implementation is based on RangedModifiableArray, and all operations are linear.
2626
* Should behave similar to

utbot-framework/src/main/java/org/utbot/engine/overrides/collections/UtOptional.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import static org.utbot.engine.overrides.UtOverrideMock.visit;
1414

1515
/**
16-
* Class represents hybrid implementation (java + engine instructions) of Optional for UtBotSymbolicEngine.
16+
* Class represents hybrid implementation (java + engine instructions) of Optional for {@link org.utbot.engine.Traverser}.
1717
* <p>
1818
* Should behave the same as {@link java.util.Optional}.
1919
* @see org.utbot.engine.OptionalWrapper

utbot-framework/src/main/java/org/utbot/engine/overrides/collections/UtOptionalDouble.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import static org.utbot.engine.overrides.UtOverrideMock.visit;
1212

1313
/**
14-
* Class represents hybrid implementation (java + engine instructions) of OptionalDouble for UtBotSymbolicEngine.
14+
* Class represents hybrid implementation (java + engine instructions) of OptionalDouble for {@link org.utbot.engine.Traverser}.
1515
* <p>
1616
* Should behave the same as {@link java.util.OptionalDouble}.
1717
* @see org.utbot.engine.OptionalWrapper

utbot-framework/src/main/java/org/utbot/engine/overrides/collections/UtOptionalInt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import static org.utbot.engine.overrides.UtOverrideMock.visit;
1212

1313
/**
14-
* Class represents hybrid implementation (java + engine instructions) of OptionalInt for UtBotSymbolicEngine.
14+
* Class represents hybrid implementation (java + engine instructions) of OptionalInt for {@link org.utbot.engine.Traverser}.
1515
* <p>
1616
* Should behave the same as {@link java.util.OptionalInt}.
1717
* @see org.utbot.engine.OptionalWrapper

utbot-framework/src/main/java/org/utbot/engine/overrides/collections/UtOptionalLong.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import static org.utbot.engine.overrides.UtOverrideMock.visit;
1111

1212
/**
13-
* Class represents hybrid implementation (java + engine instructions) of Optional for UtBotSymbolicEngine.
13+
* Class represents hybrid implementation (java + engine instructions) of Optional for {@link org.utbot.engine.Traverser}.
1414
* <p>
1515
* Should behave the same as {@link java.util.Optional}.
1616
* @see org.utbot.engine.OptionalWrapper

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import soot.SootMethod
3737
val rangeModifiableArrayId: ClassId = RangeModifiableUnlimitedArray::class.id
3838

3939
class RangeModifiableUnlimitedArrayWrapper : WrapperInterface {
40-
override fun UtBotSymbolicEngine.invoke(
40+
override fun Traverser.invoke(
4141
wrapper: ObjectValue,
4242
method: SootMethod,
4343
parameters: List<SymbolicValue>
@@ -203,10 +203,10 @@ class RangeModifiableUnlimitedArrayWrapper : WrapperInterface {
203203
}
204204
}
205205

206-
private fun UtBotSymbolicEngine.getStorageArrayField(addr: UtAddrExpression) =
206+
private fun Traverser.getStorageArrayField(addr: UtAddrExpression) =
207207
getArrayField(addr, rangeModifiableArrayClass, storageField)
208208

209-
private fun UtBotSymbolicEngine.getStorageArrayExpression(
209+
private fun Traverser.getStorageArrayExpression(
210210
wrapper: ObjectValue
211211
): UtExpression = selectArrayExpressionFromMemory(getStorageArrayField(wrapper.addr))
212212

@@ -285,7 +285,7 @@ class AssociativeArrayWrapper : WrapperInterface {
285285
private val storageField = associativeArrayClass.getField("java.lang.Object[] storage")
286286

287287

288-
override fun UtBotSymbolicEngine.invoke(
288+
override fun Traverser.invoke(
289289
wrapper: ObjectValue,
290290
method: SootMethod,
291291
parameters: List<SymbolicValue>
@@ -414,16 +414,16 @@ class AssociativeArrayWrapper : WrapperInterface {
414414
return model
415415
}
416416

417-
private fun UtBotSymbolicEngine.getStorageArrayField(addr: UtAddrExpression) =
417+
private fun Traverser.getStorageArrayField(addr: UtAddrExpression) =
418418
getArrayField(addr, associativeArrayClass, storageField)
419419

420-
private fun UtBotSymbolicEngine.getTouchedArrayField(addr: UtAddrExpression) =
420+
private fun Traverser.getTouchedArrayField(addr: UtAddrExpression) =
421421
getArrayField(addr, associativeArrayClass, touchedField)
422422

423-
private fun UtBotSymbolicEngine.getTouchedArrayExpression(wrapper: ObjectValue): UtExpression =
423+
private fun Traverser.getTouchedArrayExpression(wrapper: ObjectValue): UtExpression =
424424
selectArrayExpressionFromMemory(getTouchedArrayField(wrapper.addr))
425425

426-
private fun UtBotSymbolicEngine.getStorageArrayExpression(
426+
private fun Traverser.getStorageArrayExpression(
427427
wrapper: ObjectValue
428428
): UtExpression = selectArrayExpressionFromMemory(getStorageArrayField(wrapper.addr))
429429
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ abstract class BaseOverriddenWrapper(protected val overriddenClassName: String)
5050
*
5151
* @see invoke
5252
*/
53-
protected abstract fun UtBotSymbolicEngine.overrideInvoke(
53+
protected abstract fun Traverser.overrideInvoke(
5454
wrapper: ObjectValue,
5555
method: SootMethod,
5656
parameters: List<SymbolicValue>
@@ -65,11 +65,11 @@ abstract class BaseOverriddenWrapper(protected val overriddenClassName: String)
6565
*
6666
* Multiple GraphResults are returned because, we shouldn't substitute invocation of specified
6767
* that was called inside substituted method of object with the same address as specified [wrapper].
68-
* (For example UtArrayList.<init> invokes AbstractList.<init> that also leads to UtBotSymbolicEngine.invoke,
68+
* (For example UtArrayList.<init> invokes AbstractList.<init> that also leads to [Traverser.invoke],
6969
* and shouldn't be substituted with UtArrayList.<init> again). Only one GraphResult is valid, that is
7070
* guaranteed by contradictory to each other sets of constraints, added to them.
7171
*/
72-
override fun UtBotSymbolicEngine.invoke(
72+
override fun Traverser.invoke(
7373
wrapper: ObjectValue,
7474
method: SootMethod,
7575
parameters: List<SymbolicValue>
@@ -162,7 +162,7 @@ abstract class BaseContainerWrapper(containerClassName: String) : BaseOverridden
162162
}
163163

164164
abstract class BaseGenericStorageBasedContainerWrapper(containerClassName: String) : BaseContainerWrapper(containerClassName) {
165-
override fun UtBotSymbolicEngine.overrideInvoke(
165+
override fun Traverser.overrideInvoke(
166166
wrapper: ObjectValue,
167167
method: SootMethod,
168168
parameters: List<SymbolicValue>
@@ -283,7 +283,7 @@ class SetWrapper : BaseGenericStorageBasedContainerWrapper(UtHashSet::class.qual
283283
* entries, then real behavior of generated test can differ from expected and undefined.
284284
*/
285285
class MapWrapper : BaseContainerWrapper(UtHashMap::class.qualifiedName!!) {
286-
override fun UtBotSymbolicEngine.overrideInvoke(
286+
override fun Traverser.overrideInvoke(
287287
wrapper: ObjectValue,
288288
method: SootMethod,
289289
parameters: List<SymbolicValue>
@@ -418,14 +418,14 @@ val HASH_MAP_TYPE: RefType
418418
val STREAM_TYPE: RefType
419419
get() = Scene.v().getSootClass(java.util.stream.Stream::class.java.canonicalName).type
420420

421-
internal fun UtBotSymbolicEngine.getArrayField(
421+
internal fun Traverser.getArrayField(
422422
addr: UtAddrExpression,
423423
wrapperClass: SootClass,
424424
field: SootField
425425
): ArrayValue =
426426
createFieldOrMock(wrapperClass.type, addr, field, mockInfoGenerator = null) as ArrayValue
427427

428-
internal fun UtBotSymbolicEngine.getIntFieldValue(wrapper: ObjectValue, field: SootField): UtExpression {
428+
internal fun Traverser.getIntFieldValue(wrapper: ObjectValue, field: SootField): UtExpression {
429429
val chunkId = hierarchy.chunkIdForField(field.declaringClass.type, field)
430430
val descriptor = MemoryChunkDescriptor(chunkId, field.declaringClass.type, IntType.v())
431431
val array = memory.findArray(descriptor, MemoryState.CURRENT)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ data class OverrideResult(
184184
* there is only one usage of it: to support instanceof for arrays we have to update them in the memory.
185185
*
186186
* @see UtInstanceOfExpression
187-
* @see UtBotSymbolicEngine.resolveIfCondition
187+
* @see Traverser.resolveIfCondition
188188
*/
189189
data class ResolvedCondition(
190190
val condition: UtBoolExpression,

0 commit comments

Comments
 (0)