Skip to content

Commit 72bcfeb

Browse files
authored
Transformer cache extension points (#176)
* Transformer cache extension points * Upgrade version
1 parent 0d5ba1e commit 72bcfeb

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
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.6.3)
14+
[![Maven Central](https://img.shields.io/maven-central/v/io.ksmt/ksmt-core)](https://central.sonatype.com/artifact/io.ksmt/ksmt-core/0.6.4)
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.6.3")
23+
implementation("io.ksmt:ksmt-core:0.6.4")
2424
// z3 solver
25-
implementation("io.ksmt:ksmt-z3:0.6.3")
25+
implementation("io.ksmt:ksmt-z3:0.6.4")
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.6.3"
14+
version = "0.6.4"
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.6.3")
37+
implementation("io.ksmt:ksmt-core:0.6.4")
3838
}
3939
```
4040

@@ -43,9 +43,9 @@ dependencies {
4343
```kotlin
4444
dependencies {
4545
// z3
46-
implementation("io.ksmt:ksmt-z3:0.6.3")
46+
implementation("io.ksmt:ksmt-z3:0.6.4")
4747
// bitwuzla
48-
implementation("io.ksmt:ksmt-bitwuzla:0.6.3")
48+
implementation("io.ksmt:ksmt-bitwuzla:0.6.4")
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.6.3")
12+
implementation("io.ksmt:ksmt-core:0.6.4")
1313
// z3 solver
14-
implementation("io.ksmt:ksmt-z3:0.6.3")
14+
implementation("io.ksmt:ksmt-z3:0.6.4")
1515
// Runner and portfolio solver
16-
implementation("io.ksmt:ksmt-runner:0.6.3")
16+
implementation("io.ksmt:ksmt-runner:0.6.4")
1717
}
1818

1919
java {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ abstract class KNonRecursiveTransformerBase: KTransformer {
5151

5252
if (exprWasTransformed) {
5353
transformed[e] = transformedExpr
54+
55+
@Suppress("UNCHECKED_CAST")
56+
onNewTransformedExpr(e as KExpr<KSort>, transformedExpr as KExpr<KSort>)
5457
}
5558
}
5659
} finally {
@@ -121,13 +124,17 @@ abstract class KNonRecursiveTransformerBase: KTransformer {
121124
* Get [expr] transformation result or
122125
* null if expression was not transformed yet
123126
* */
124-
fun <T : KSort> transformedExpr(expr: KExpr<T>): KExpr<T>? {
127+
open fun <T : KSort> transformedExpr(expr: KExpr<T>): KExpr<T>? {
125128
if (!exprTransformationRequired(expr)) return expr
126129

127130
@Suppress("UNCHECKED_CAST")
128131
return transformed[expr] as? KExpr<T>
129132
}
130133

134+
open fun <T : KSort> onNewTransformedExpr(expr: KExpr<T>, transformed: KExpr<T>) {
135+
// do nothing
136+
}
137+
131138
/**
132139
* Erase [expr] transformation result.
133140
* Useful for transformer auxiliary expressions.

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ abstract class KNonRecursiveVisitorBase<V : Any> : KVisitor<KExprVisitResult<V>>
6363
* Get [expr] visit result.
6464
* Returns null if expression was not visited.
6565
* */
66-
fun <T : KSort> visitResult(expr: KExpr<T>): V? =
66+
open fun <T : KSort> visitResult(expr: KExpr<T>): V? =
6767
visitResults[expr]
6868

69+
open fun <T : KSort> onNewVisitResult(expr: KExpr<T>, result: V) {
70+
// do nothing
71+
}
72+
6973
fun <T : KSort> result(expr: KExpr<T>): V =
7074
visitResult(expr) ?: error("Expr $expr was not properly visited")
7175

@@ -87,6 +91,7 @@ abstract class KNonRecursiveVisitorBase<V : Any> : KVisitor<KExprVisitResult<V>>
8791

8892
if (result.hasResult) {
8993
visitResults[e] = result.result
94+
onNewVisitResult(e, result.result)
9095
}
9196
}
9297
} finally {

0 commit comments

Comments
 (0)