Skip to content

Commit e1d3c77

Browse files
committed
Format
1 parent 163e637 commit e1d3c77

File tree

9 files changed

+28
-21
lines changed

9 files changed

+28
-21
lines changed

usvm-ts/src/main/kotlin/org/usvm/machine/TsContext.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class TsContext(
5252
val voidSort: TsVoidSort by lazy { TsVoidSort(this) }
5353
val voidValue: TsVoidValue by lazy { TsVoidValue(this) }
5454

55-
5655
/**
5756
* In TS we treat undefined value as a null reference in other objects.
5857
* For real null represented in the language we create another reference.

usvm-ts/src/main/kotlin/org/usvm/machine/expr/TsExprResolver.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ class TsExprResolver(
657657

658658
fakeObj
659659
}
660-
661660
}
662661
} else {
663662
val lValue = mkArrayIndexLValue(
@@ -754,7 +753,9 @@ class TsExprResolver(
754753
val fakeRef = if (ref.isFakeObject()) {
755754
ref
756755
} else {
757-
mkFakeValue(scope, bool, fp, ref).also { lValuesToAllocatedFakeObjects += refLValue to it }
756+
mkFakeValue(scope, bool, fp, ref).also {
757+
lValuesToAllocatedFakeObjects += refLValue to it
758+
}
758759
}
759760
memory.write(refLValue, fakeRef.asExpr(addressSort), guard = trueExpr)
760761

usvm-ts/src/main/kotlin/org/usvm/machine/expr/TsExpressions.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,30 @@ class TsVoidSort(ctx: TsContext) : USort(ctx) {
7373
}
7474
}
7575

76-
fun UExpr<out USort>.toConcreteBoolValue(): Boolean = when (this) {
76+
fun UExpr<*>.toConcreteBoolValue(): Boolean = when (this) {
7777
ctx.trueExpr -> true
7878
ctx.falseExpr -> false
79-
else -> error("Cannot extract boolean from $this")
79+
else -> error("Cannot extract Boolean from $this")
8080
}
8181

82-
fun UExpr<out USort>.extractDouble(): Double {
82+
/**
83+
* Extracts a double value from [this] expression if possible.
84+
* Otherwise, throws an error.
85+
*/
86+
fun UExpr<*>.extractDouble(): Double {
8387
if (this@extractDouble is KFp64Value) {
8488
return value
8589
}
86-
error("Cannot extract double from $this")
90+
error("Cannot extract Double from $this")
8791
}
8892

8993
/**
9094
* Extracts an integer value from [this] expression if possible.
9195
* Otherwise, throws an error.
9296
*/
93-
fun UExpr<out USort>.extractInt(): Int {
97+
fun UExpr<*>.extractInt(): Int {
9498
if (this@extractInt is KBitVec32Value) {
9599
return intValue
96100
}
97-
error("Cannot extract int from $this")
101+
error("Cannot extract Int from $this")
98102
}

usvm-ts/src/main/kotlin/org/usvm/machine/operator/TsBinaryOperator.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ sealed interface TsBinaryOperator {
573573
lhsValue = lhs.extractBool(scope)
574574
lhsType.boolTypeExpr
575575
}
576+
576577
fp64Sort -> {
577578
lhsValue = lhs.extractFp(scope)
578579
lhsType.fpTypeExpr
@@ -582,6 +583,7 @@ sealed interface TsBinaryOperator {
582583
lhsValue = lhs.extractRef(scope)
583584
lhsType.refTypeExpr
584585
}
586+
585587
else -> error("Unsupported sort ${rhs.sort}")
586588
}
587589
}
@@ -593,6 +595,7 @@ sealed interface TsBinaryOperator {
593595
rhsValue = rhs.extractBool(scope)
594596
rhsType.boolTypeExpr
595597
}
598+
596599
fp64Sort -> {
597600
rhsValue = rhs.extractFp(scope)
598601
rhsType.fpTypeExpr
@@ -602,6 +605,7 @@ sealed interface TsBinaryOperator {
602605
rhsValue = rhs.extractRef(scope)
603606
rhsType.refTypeExpr
604607
}
608+
605609
else -> error("Unsupported sort ${lhs.sort}")
606610
}
607611
}

usvm-ts/src/main/kotlin/org/usvm/machine/state/TsState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TsState(
4747
val localToSortStack: MutableList<UPersistentHashMap<Int, USort>> = mutableListOf(persistentHashMapOf()),
4848
var staticStorage: UPersistentHashMap<EtsClass, UConcreteHeapRef> = persistentHashMapOf(),
4949
val globalObject: UConcreteHeapRef = memory.allocStatic(EtsClassType(EtsClassSignature.UNKNOWN)),
50-
val addedArtificialLocals: MutableSet<String> = hashSetOf<String>(),
50+
val addedArtificialLocals: MutableSet<String> = hashSetOf(),
5151
val lValuesToAllocatedFakeObjects: MutableList<Pair<ULValue<*, *>, UConcreteHeapRef>> = mutableListOf(),
5252
) : UState<EtsType, EtsMethod, EtsStmt, TsContext, TsTarget, TsState>(
5353
ctx = ctx,

usvm-ts/src/main/kotlin/org/usvm/machine/types/TsTypeSystem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,4 @@ fun EtsClassType.toAuxiliaryType(hierarchy: EtsHierarchy): EtsAuxiliaryType? {
328328
return EtsAuxiliaryType(
329329
properties = fieldsIntersection + methodsIntersection
330330
)
331-
}
331+
}

usvm-ts/src/main/kotlin/org/usvm/util/EtsHierarchy.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ class EtsHierarchy(private val scene: EtsScene) {
108108
return suitableClasses.values
109109
}
110110

111-
112111
companion object {
113112
// TODO use real one
114113
val OBJECT_CLASS = EtsClassType(
@@ -135,4 +134,4 @@ fun ClassName.removeTrashFromTheName(): ClassName {
135134
} else {
136135
nameWithoutGenerics().removePrefixWithDots()
137136
}
138-
}
137+
}

usvm-ts/src/main/kotlin/org/usvm/util/Utils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fun EtsType.isResolved(): Boolean =
4141
this !is EtsUnclearRefType && (this as? EtsClassType)?.signature?.file != EtsFileSignature.UNKNOWN
4242

4343
fun EtsType.getClassesForType(
44-
scene: EtsScene
44+
scene: EtsScene,
4545
): List<EtsClass> = if (isResolved()) {
4646
scene
4747
.projectAndSdkClasses
@@ -74,4 +74,4 @@ fun UHeapRef.createFakeField(fieldName: String, scope: TsStepScope): UConcreteHe
7474
}
7575

7676
return fakeObject
77-
}
77+
}

usvm-ts/src/test/kotlin/org/usvm/util/TsTestResolver.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,21 @@ class TsTestResolver {
9292
when (lValue) {
9393
is UFieldLValue<*, *> -> {
9494
val resolvedRef = state.models.first().eval(lValue.ref)
95-
resolvedLValuesToFakeObjects += UFieldLValue(lValue.sort, resolvedRef, lValue.field) to fakeObject
95+
val fieldLValue = UFieldLValue(lValue.sort, resolvedRef, lValue.field)
96+
resolvedLValuesToFakeObjects += fieldLValue to fakeObject
9697
}
9798

9899
is UArrayIndexLValue<*, *, *> -> {
99100
val model = state.models.first()
100101
val resolvedRef = model.eval(lValue.ref)
101102
val resolvedIndex = model.eval(lValue.index)
102-
103-
val uArrayIndexLValue = UArrayIndexLValue(
103+
val arrayIndexLValue = UArrayIndexLValue(
104104
lValue.sort,
105105
resolvedRef,
106106
resolvedIndex,
107107
lValue.arrayType,
108108
)
109-
resolvedLValuesToFakeObjects += uArrayIndexLValue to fakeObject
109+
resolvedLValuesToFakeObjects += arrayIndexLValue to fakeObject
110110
}
111111

112112
else -> error("Unexpected lValue type: ${lValue::class.java.name}")
@@ -235,8 +235,8 @@ open class TsTestStateResolver(
235235
val arrayLength = mkArrayLengthLValue(heapRef, type)
236236
val length = resolveLValue(arrayLength) as TsTestValue.TsNumber
237237

238-
val values = (0 until length.number.toInt()).map {
239-
val index = mkSizeExpr(it)
238+
val values = (0 until length.number.toInt()).map { i ->
239+
val index = mkSizeExpr(i)
240240
val sort = typeToSort(type.elementType)
241241

242242
if (sort is TsUnresolvedSort) {

0 commit comments

Comments
 (0)