Skip to content

More fixes for real applications #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Input arrays support
  • Loading branch information
CaelmBleidd committed Jun 18, 2025
commit 545887c50cc60ef7cdf5cb4531de2972668cff7c
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,7 @@ class TsExprResolver(
val fakeRef = if (ref.isFakeObject()) {
ref
} else {
mkFakeValue(scope, bool, fp, ref).also {
lValuesToAllocatedFakeObjects += refLValue to it
}
mkFakeValue(scope, bool, fp, ref).also { lValuesToAllocatedFakeObjects += refLValue to it }
}

// TODO ambiguous enum fields resolution
Expand Down
11 changes: 11 additions & 0 deletions usvm-ts/src/main/kotlin/org/usvm/machine/expr/TsExpressions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,14 @@ fun UExpr<*>.extractInt(): Int {
}
error("Cannot extract Int from $this")
}

/**
* Extracts an integer value from [this] expression if possible.
* Otherwise, throws an error.
*/
fun UExpr<out USort>.extractInt(): Int {
if (this@extractInt is KBitVec32Value) {
return intValue
}
error("Cannot extract int from $this")
}
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ sealed interface TsBinaryOperator {
lhsValue = lhs.extractBool(scope)
lhsType.boolTypeExpr
}
}

fp64Sort -> {
lhsValue = lhs.extractFp(scope)
Expand All @@ -583,7 +584,6 @@ sealed interface TsBinaryOperator {
lhsValue = lhs.extractRef(scope)
lhsType.refTypeExpr
}

else -> error("Unsupported sort ${rhs.sort}")
}
}
Expand All @@ -595,6 +595,7 @@ sealed interface TsBinaryOperator {
rhsValue = rhs.extractBool(scope)
rhsType.boolTypeExpr
}
}

fp64Sort -> {
rhsValue = rhs.extractFp(scope)
Expand All @@ -605,7 +606,6 @@ sealed interface TsBinaryOperator {
rhsValue = rhs.extractRef(scope)
rhsType.refTypeExpr
}

else -> error("Unsupported sort ${lhs.sort}")
}
}
Expand Down
1 change: 1 addition & 0 deletions usvm-ts/src/main/kotlin/org/usvm/machine/state/TsState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TsState(
val globalObject: UConcreteHeapRef = memory.allocStatic(EtsClassType(EtsClassSignature.UNKNOWN)),
val addedArtificialLocals: MutableSet<String> = hashSetOf(),
val lValuesToAllocatedFakeObjects: MutableList<Pair<ULValue<*, *>, UConcreteHeapRef>> = mutableListOf(),
val lValuesToAllocatedFakeObjects: MutableList<Pair<ULValue<*, *>, UConcreteHeapRef>> = mutableListOf(),
) : UState<EtsType, EtsMethod, EtsStmt, TsContext, TsTarget, TsState>(
ctx = ctx,
initOwnership = ownership,
Expand Down