Skip to content

Commit

Permalink
Expression visitor (#122)
Browse files Browse the repository at this point in the history
* Expression visitor

* Visit expressions in more intuitive order

* Better cache reuse in visitor/transformer

* Upgrade version to 0.5.5
  • Loading branch information
Saloed authored Jul 21, 2023
1 parent 856cbfe commit c5fee2c
Show file tree
Hide file tree
Showing 9 changed files with 1,929 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Get the most out of SMT solving with KSMT features:
* Streamlined [solver delivery](#ksmt-distribution) with no need for building a solver or implementing JVM bindings

[![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)
[![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)
[![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)
[![javadoc](https://javadoc.io/badge2/io.ksmt/ksmt-core/javadoc.svg)](https://javadoc.io/doc/io.ksmt/ksmt-core)

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

```kotlin
// core
implementation("io.ksmt:ksmt-core:0.5.4")
implementation("io.ksmt:ksmt-core:0.5.5")
// z3 solver
implementation("io.ksmt:ksmt-z3:0.5.4")
implementation("io.ksmt:ksmt-z3:0.5.5")
```

Find basic instructions in the [Getting started](docs/getting-started.md) guide and try it out with the
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/io.ksmt.ksmt-base.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group = "io.ksmt"
version = "0.5.4"
version = "0.5.5"

repositories {
mavenCentral()
Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repositories {
```kotlin
dependencies {
// core
implementation("io.ksmt:ksmt-core:0.5.4")
implementation("io.ksmt:ksmt-core:0.5.5")
}
```

Expand All @@ -43,9 +43,9 @@ dependencies {
```kotlin
dependencies {
// z3
implementation("io.ksmt:ksmt-z3:0.5.4")
implementation("io.ksmt:ksmt-z3:0.5.5")
// bitwuzla
implementation("io.ksmt:ksmt-bitwuzla:0.5.4")
implementation("io.ksmt:ksmt-bitwuzla:0.5.5")
}
```

Expand Down
6 changes: 3 additions & 3 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ repositories {

dependencies {
// core
implementation("io.ksmt:ksmt-core:0.5.4")
implementation("io.ksmt:ksmt-core:0.5.5")
// z3 solver
implementation("io.ksmt:ksmt-z3:0.5.4")
implementation("io.ksmt:ksmt-z3:0.5.5")
// Runner and portfolio solver
implementation("io.ksmt:ksmt-runner:0.5.4")
implementation("io.ksmt:ksmt-runner:0.5.5")
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ abstract class KNonRecursiveTransformerBase: KTransformer {
* Transform [expr] and all it sub-expressions non-recursively.
* */
override fun <T : KSort> apply(expr: KExpr<T>): KExpr<T> {
val cachedExpr = transformedExpr(expr)
if (cachedExpr != null) {
return cachedExpr
}

val initialStackSize = exprStack.size
try {
exprStack.add(expr)
while (exprStack.size > initialStackSize) {
val e = exprStack.removeLast()

val cachedExpr = transformedExpr(expr)
if (cachedExpr != null) {
continue
}

exprWasTransformed = true
val transformedExpr = e.accept(this)

Expand Down
Loading

0 comments on commit c5fee2c

Please sign in to comment.