Skip to content

Commit 62b17f8

Browse files
authored
Support OR operator (#245)
1 parent a682a99 commit 62b17f8

File tree

6 files changed

+384
-72
lines changed

6 files changed

+384
-72
lines changed

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object Versions {
66
const val clikt = "5.0.0"
77
const val detekt = "1.23.7"
88
const val ini4j = "0.5.4"
9-
const val jacodb = "deeaae6dbf"
9+
const val jacodb = "ad9d0475be"
1010
const val juliet = "1.3.2"
1111
const val junit = "5.9.3"
1212
const val kotlin = "2.1.0"

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ class TSExprResolver(
170170
return resolveBinaryOperator(TSBinaryOperator.And, expr)
171171
}
172172

173+
override fun visit(expr: EtsOrExpr): UExpr<out USort>? {
174+
return resolveBinaryOperator(TSBinaryOperator.Or, expr)
175+
}
176+
173177
override fun visit(expr: EtsNotEqExpr): UExpr<out USort>? {
174178
return resolveBinaryOperator(TSBinaryOperator.Neq, expr)
175179
}
@@ -319,11 +323,6 @@ class TSExprResolver(
319323
error("Not supported $expr")
320324
}
321325

322-
override fun visit(expr: EtsOrExpr): UExpr<out USort>? {
323-
logger.warn { "visit(${expr::class.simpleName}) is not implemented yet" }
324-
error("Not supported $expr")
325-
}
326-
327326
override fun visit(expr: EtsPostDecExpr): UExpr<out USort>? {
328327
logger.warn { "visit(${expr::class.simpleName}) is not implemented yet" }
329328
error("Not supported $expr")

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,4 +508,56 @@ sealed interface TSBinaryOperator {
508508
}
509509
}
510510
}
511+
512+
data object Or : TSBinaryOperator {
513+
override fun TSContext.onBool(
514+
lhs: UExpr<UBoolSort>,
515+
rhs: UExpr<UBoolSort>,
516+
scope: TSStepScope,
517+
): UExpr<out USort> {
518+
return mkOr(lhs, rhs)
519+
}
520+
521+
override fun TSContext.onFp(
522+
lhs: UExpr<KFp64Sort>,
523+
rhs: UExpr<KFp64Sort>,
524+
scope: TSStepScope,
525+
): UExpr<out USort> {
526+
return internalResolve(lhs, rhs, scope)
527+
}
528+
529+
override fun TSContext.onRef(
530+
lhs: UExpr<UAddressSort>,
531+
rhs: UExpr<UAddressSort>,
532+
scope: TSStepScope,
533+
): UExpr<out USort> {
534+
return internalResolve(lhs, rhs, scope)
535+
}
536+
537+
override fun resolveFakeObject(
538+
lhs: UExpr<out USort>,
539+
rhs: UExpr<out USort>,
540+
scope: TSStepScope,
541+
): UExpr<out USort> = with(lhs.tctx) {
542+
check(lhs.isFakeObject() || rhs.isFakeObject())
543+
544+
scope.calcOnState {
545+
val lhsTruthyExpr = mkTruthyExpr(lhs, scope)
546+
iteWriteIntoFakeObject(scope, lhsTruthyExpr, lhs, rhs)
547+
}
548+
}
549+
550+
override fun internalResolve(
551+
lhs: UExpr<out USort>,
552+
rhs: UExpr<out USort>,
553+
scope: TSStepScope,
554+
): UExpr<out USort> = with(lhs.tctx) {
555+
check(!lhs.isFakeObject() && !rhs.isFakeObject())
556+
557+
val lhsTruthyExpr = mkTruthyExpr(lhs, scope)
558+
scope.calcOnState {
559+
iteWriteIntoFakeObject(scope, lhsTruthyExpr, lhs, rhs)
560+
}
561+
}
562+
}
511563
}

0 commit comments

Comments
 (0)