Skip to content

Commit 65c70f9

Browse files
author
Victor Samoilov
committed
Revert engine style
1 parent c76e840 commit 65c70f9

1 file changed

Lines changed: 15 additions & 52 deletions

File tree

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

Lines changed: 15 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,7 @@ class UtBotSymbolicEngine(
472472
}
473473

474474
stateSelectedCount++
475-
pathLogger.trace {
476-
"traverse<$methodUnderTest>: choosing next state($stateSelectedCount), " +
475+
pathLogger.trace { "traverse<$methodUnderTest>: choosing next state($stateSelectedCount), " +
477476
"queue size=${(pathSelector as? NonUniformRandomSearch)?.size ?: -1}"
478477
}
479478

@@ -603,7 +602,7 @@ class UtBotSymbolicEngine(
603602

604603
val isFuzzable = executableId.parameters.all { classId ->
605604
classId != Method::class.java.id && // causes the child process crash at invocation
606-
classId != Class::class.java.id // causes java.lang.IllegalAccessException: java.lang.Class at sun.misc.Unsafe.allocateInstance(Native Method)
605+
classId != Class::class.java.id // causes java.lang.IllegalAccessException: java.lang.Class at sun.misc.Unsafe.allocateInstance(Native Method)
607606
}
608607
if (!isFuzzable) {
609608
return@flow
@@ -1302,12 +1301,7 @@ class UtBotSymbolicEngine(
13021301
?: error("Exception wasn't caught, stmt: $current, line: ${current.lines}")
13031302
val nextState = environment.state.updateQueued(
13041303
globalGraph.succ(current),
1305-
SymbolicStateUpdate(
1306-
localMemoryUpdates = localMemoryUpdate(
1307-
localVariable to value,
1308-
CAUGHT_EXCEPTION to null
1309-
)
1310-
)
1304+
SymbolicStateUpdate(localMemoryUpdates = localMemoryUpdate(localVariable to value, CAUGHT_EXCEPTION to null))
13111305
)
13121306
pathSelector.offer(nextState)
13131307
}
@@ -1520,8 +1514,7 @@ class UtBotSymbolicEngine(
15201514
queuedSymbolicStateUpdates += MemoryUpdate(mockInfos = persistentListOf(MockInfoEnriched(mockInfo)))
15211515

15221516
// add typeConstraint for mocked object. It's a declared type of the object.
1523-
queuedSymbolicStateUpdates += typeRegistry.typeConstraint(addr, mockedObject.typeStorage).all()
1524-
.asHardConstraint()
1517+
queuedSymbolicStateUpdates += typeRegistry.typeConstraint(addr, mockedObject.typeStorage).all().asHardConstraint()
15251518
queuedSymbolicStateUpdates += mkEq(typeRegistry.isMock(mockedObject.addr), UtTrue).asHardConstraint()
15261519

15271520
return mockedObject
@@ -1559,8 +1552,7 @@ class UtBotSymbolicEngine(
15591552
queuedSymbolicStateUpdates += MemoryUpdate(mockInfos = persistentListOf(MockInfoEnriched(mockInfo)))
15601553

15611554
// add typeConstraint for mocked object. It's a declared type of the object.
1562-
queuedSymbolicStateUpdates += typeRegistry.typeConstraint(addr, mockedObject.typeStorage).all()
1563-
.asHardConstraint()
1555+
queuedSymbolicStateUpdates += typeRegistry.typeConstraint(addr, mockedObject.typeStorage).all().asHardConstraint()
15641556
queuedSymbolicStateUpdates += mkEq(typeRegistry.isMock(mockedObject.addr), UtTrue).asHardConstraint()
15651557

15661558
return mockedObject
@@ -1595,8 +1587,7 @@ class UtBotSymbolicEngine(
15951587
createObject(addr, refType, useConcreteType = true)
15961588
}
15971589
} else {
1598-
queuedSymbolicStateUpdates += typeRegistry.typeConstraint(addr, TypeStorage(refType)).all()
1599-
.asHardConstraint()
1590+
queuedSymbolicStateUpdates += typeRegistry.typeConstraint(addr, TypeStorage(refType)).all().asHardConstraint()
16001591

16011592
objectValue(refType, addr, StringWrapper()).also {
16021593
initStringLiteral(it, this.value)
@@ -1715,11 +1706,7 @@ class UtBotSymbolicEngine(
17151706
val arrayType = type.arrayType
17161707
val arrayValue = createNewArray(value.length.toPrimitiveValue(), arrayType, type).also {
17171708
val defaultValue = arrayType.defaultSymValue
1718-
queuedSymbolicStateUpdates += arrayUpdateWithValue(
1719-
it.addr,
1720-
arrayType,
1721-
defaultValue as UtArrayExpressionBase
1722-
)
1709+
queuedSymbolicStateUpdates += arrayUpdateWithValue(it.addr, arrayType, defaultValue as UtArrayExpressionBase)
17231710
}
17241711
queuedSymbolicStateUpdates += objectUpdate(
17251712
stringWrapper.copy(typeStorage = TypeStorage(utStringClass.type)),
@@ -1883,8 +1870,7 @@ class UtBotSymbolicEngine(
18831870
return objectValue.copy(addr = nullObjectAddr)
18841871
}
18851872

1886-
val typeConstraint =
1887-
typeRegistry.typeConstraint(castedObject.addr, castedObject.typeStorage).isOrNullConstraint()
1873+
val typeConstraint = typeRegistry.typeConstraint(castedObject.addr, castedObject.typeStorage).isOrNullConstraint()
18881874

18891875
// When we do downCast, we should add possible equality to null
18901876
// to avoid situation like this:
@@ -2040,8 +2026,7 @@ class UtBotSymbolicEngine(
20402026
)
20412027

20422028
if (objectValue.type.isJavaLangObject()) {
2043-
queuedSymbolicStateUpdates += typeRegistry.zeroDimensionConstraint(objectValue.addr)
2044-
.asSoftConstraint()
2029+
queuedSymbolicStateUpdates += typeRegistry.zeroDimensionConstraint(objectValue.addr).asSoftConstraint()
20452030
}
20462031

20472032
objectValue
@@ -2913,11 +2898,7 @@ class UtBotSymbolicEngine(
29132898
return listOf(
29142899
MethodResult(
29152900
newArray,
2916-
memoryUpdates = arrayUpdateWithValue(
2917-
newArray.addr,
2918-
arrayType,
2919-
selectArrayExpressionFromMemory(src)
2920-
)
2901+
memoryUpdates = arrayUpdateWithValue(newArray.addr, arrayType, selectArrayExpressionFromMemory(src))
29212902
)
29222903
)
29232904
}
@@ -3404,18 +3385,8 @@ class UtBotSymbolicEngine(
34043385
is JMulExpr -> when (sort.type) {
34053386
is ByteType -> lowerIntMulOverflowCheck(left, right, Byte.MIN_VALUE.toInt(), Byte.MAX_VALUE.toInt())
34063387
is ShortType -> lowerIntMulOverflowCheck(left, right, Short.MIN_VALUE.toInt(), Short.MAX_VALUE.toInt())
3407-
is IntType -> higherIntMulOverflowCheck(
3408-
left,
3409-
right,
3410-
Int.SIZE_BITS,
3411-
Int.MIN_VALUE.toLong()
3412-
) { it: UtExpression -> it.toIntValue() }
3413-
is LongType -> higherIntMulOverflowCheck(
3414-
left,
3415-
right,
3416-
Long.SIZE_BITS,
3417-
Long.MIN_VALUE
3418-
) { it: UtExpression -> it.toLongValue() }
3388+
is IntType -> higherIntMulOverflowCheck(left, right, Int.SIZE_BITS, Int.MIN_VALUE.toLong()) { it: UtExpression -> it.toIntValue() }
3389+
is LongType -> higherIntMulOverflowCheck(left, right, Long.SIZE_BITS, Long.MIN_VALUE) { it: UtExpression -> it.toLongValue() }
34193390
else -> null
34203391
}
34213392
else -> null
@@ -3631,19 +3602,11 @@ class UtBotSymbolicEngine(
36313602
//choose types that have biggest priority
36323603
resolvedParameters
36333604
.filterIsInstance<ReferenceValue>()
3634-
.forEach {
3635-
queuedSymbolicStateUpdates += constructConstraintForType(
3636-
it,
3637-
it.possibleConcreteTypes
3638-
).asSoftConstraint()
3639-
}
3605+
.forEach { queuedSymbolicStateUpdates += constructConstraintForType(it, it.possibleConcreteTypes).asSoftConstraint() }
36403606

36413607
val returnValue = (symbolicResult as? SymbolicSuccess)?.value as? ObjectValue
36423608
if (returnValue != null) {
3643-
queuedSymbolicStateUpdates += constructConstraintForType(
3644-
returnValue,
3645-
returnValue.possibleConcreteTypes
3646-
).asSoftConstraint()
3609+
queuedSymbolicStateUpdates += constructConstraintForType(returnValue, returnValue.possibleConcreteTypes).asSoftConstraint()
36473610

36483611
workaround(REMOVE_ANONYMOUS_CLASSES) {
36493612
val sootClass = returnValue.type.sootClass
@@ -3793,7 +3756,7 @@ class UtBotSymbolicEngine(
37933756
queuedSymbolicStateUpdates
37943757
)
37953758
} finally {
3796-
queuedSymbolicStateUpdates = prevSymbolicStateUpdate
3759+
queuedSymbolicStateUpdates = prevSymbolicStateUpdate
37973760
}
37983761
}
37993762
}

0 commit comments

Comments
 (0)