Skip to content

Commit c5fee2c

Browse files
authored
Expression visitor (#122)
* Expression visitor * Visit expressions in more intuitive order * Better cache reuse in visitor/transformer * Upgrade version to 0.5.5
1 parent 856cbfe commit c5fee2c

File tree

9 files changed

+1929
-15
lines changed

9 files changed

+1929
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Get the most out of SMT solving with KSMT features:
1111
* Streamlined [solver delivery](#ksmt-distribution) with no need for building a solver or implementing JVM bindings
1212

1313
[![KSMT: build](https://github.com/UnitTestBot/ksmt/actions/workflows/build-and-run-tests.yml/badge.svg)](https://github.com/UnitTestBot/ksmt/actions/workflows/build-and-run-tests.yml)
14-
[![Maven Central](https://img.shields.io/maven-central/v/io.ksmt/ksmt-core)](https://central.sonatype.com/artifact/io.ksmt/ksmt-core/0.5.4)
14+
[![Maven Central](https://img.shields.io/maven-central/v/io.ksmt/ksmt-core)](https://central.sonatype.com/artifact/io.ksmt/ksmt-core/0.5.5)
1515
[![javadoc](https://javadoc.io/badge2/io.ksmt/ksmt-core/javadoc.svg)](https://javadoc.io/doc/io.ksmt/ksmt-core)
1616

1717
## Get started
@@ -20,9 +20,9 @@ To start using KSMT, install it via [Gradle](https://gradle.org/):
2020

2121
```kotlin
2222
// core
23-
implementation("io.ksmt:ksmt-core:0.5.4")
23+
implementation("io.ksmt:ksmt-core:0.5.5")
2424
// z3 solver
25-
implementation("io.ksmt:ksmt-z3:0.5.4")
25+
implementation("io.ksmt:ksmt-z3:0.5.5")
2626
```
2727

2828
Find basic instructions in the [Getting started](docs/getting-started.md) guide and try it out with the

buildSrc/src/main/kotlin/io.ksmt.ksmt-base.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
}
1212

1313
group = "io.ksmt"
14-
version = "0.5.4"
14+
version = "0.5.5"
1515

1616
repositories {
1717
mavenCentral()

docs/getting-started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repositories {
3434
```kotlin
3535
dependencies {
3636
// core
37-
implementation("io.ksmt:ksmt-core:0.5.4")
37+
implementation("io.ksmt:ksmt-core:0.5.5")
3838
}
3939
```
4040

@@ -43,9 +43,9 @@ dependencies {
4343
```kotlin
4444
dependencies {
4545
// z3
46-
implementation("io.ksmt:ksmt-z3:0.5.4")
46+
implementation("io.ksmt:ksmt-z3:0.5.5")
4747
// bitwuzla
48-
implementation("io.ksmt:ksmt-bitwuzla:0.5.4")
48+
implementation("io.ksmt:ksmt-bitwuzla:0.5.5")
4949
}
5050
```
5151

examples/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ repositories {
99

1010
dependencies {
1111
// core
12-
implementation("io.ksmt:ksmt-core:0.5.4")
12+
implementation("io.ksmt:ksmt-core:0.5.5")
1313
// z3 solver
14-
implementation("io.ksmt:ksmt-z3:0.5.4")
14+
implementation("io.ksmt:ksmt-z3:0.5.5")
1515
// Runner and portfolio solver
16-
implementation("io.ksmt:ksmt-runner:0.5.4")
16+
implementation("io.ksmt:ksmt-runner:0.5.5")
1717
}
1818

1919
java {

ksmt-core/src/main/kotlin/io/ksmt/expr/transformer/KNonRecursiveTransformerBase.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ abstract class KNonRecursiveTransformerBase: KTransformer {
3535
* Transform [expr] and all it sub-expressions non-recursively.
3636
* */
3737
override fun <T : KSort> apply(expr: KExpr<T>): KExpr<T> {
38-
val cachedExpr = transformedExpr(expr)
39-
if (cachedExpr != null) {
40-
return cachedExpr
41-
}
42-
4338
val initialStackSize = exprStack.size
4439
try {
4540
exprStack.add(expr)
4641
while (exprStack.size > initialStackSize) {
4742
val e = exprStack.removeLast()
43+
44+
val cachedExpr = transformedExpr(expr)
45+
if (cachedExpr != null) {
46+
continue
47+
}
48+
4849
exprWasTransformed = true
4950
val transformedExpr = e.accept(this)
5051

0 commit comments

Comments
 (0)