-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TS symbolic machine expansion (#201)
* [WIP] TSTypeSystem * Enhance TSTypeSystem + jacodb version update * TSTypeSystem + TSInterpreter skeleton + TSSimpleValueResolver * Version hotfix * Minor polishing * Remove TSTypeSystem * Remove redundant class * Remove unfinished types processing * Detekt fix * [WIP] Args location tests * Implement parameters resolver with tests * Remove EtsMethod.localIdx method * [WIP] Dev sync * Implement property matchers * Detekt fix * Refactor comment * TypeTransformer change with null * Auto conversion for tests * Remove check * Update jacodb version * Fix if branch index order * Update CI --------- Co-authored-by: Alexey Menshutin <alex.menshutin99@gmail.com>
- Loading branch information
1 parent
8601d83
commit afd0be3
Showing
18 changed files
with
1,013 additions
and
671 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.usvm | ||
|
||
import io.ksmt.utils.cast | ||
|
||
sealed class TSBinaryOperator( | ||
val onBool: TSContext.(UExpr<UBoolSort>, UExpr<UBoolSort>) -> UExpr<out USort> = shouldNotBeCalled, | ||
val onBv: TSContext.(UExpr<UBvSort>, UExpr<UBvSort>) -> UExpr<out USort> = shouldNotBeCalled, | ||
val onFp: TSContext.(UExpr<UFpSort>, UExpr<UFpSort>) -> UExpr<out USort> = shouldNotBeCalled, | ||
) { | ||
|
||
object Eq : TSBinaryOperator( | ||
onBool = UContext<TSSizeSort>::mkEq, | ||
onBv = UContext<TSSizeSort>::mkEq, | ||
onFp = UContext<TSSizeSort>::mkFpEqualExpr, | ||
) | ||
|
||
object Neq : TSBinaryOperator( | ||
onBool = { lhs, rhs -> lhs.neq(rhs) }, | ||
onBv = { lhs, rhs -> lhs.neq(rhs) }, | ||
onFp = { lhs, rhs -> mkFpEqualExpr(lhs, rhs).not() }, | ||
) | ||
|
||
internal operator fun invoke(lhs: UExpr<out USort>, rhs: UExpr<out USort>): UExpr<out USort> { | ||
val lhsSort = lhs.sort | ||
val rhsSort = rhs.sort | ||
|
||
if (lhsSort != rhsSort) TODO("Implement type coercion") | ||
|
||
return when { | ||
lhsSort is UBoolSort -> lhs.tctx.onBool(lhs.cast(), rhs.cast()) | ||
lhsSort is UBvSort -> lhs.tctx.onBv(lhs.cast(), rhs.cast()) | ||
lhsSort is UFpSort -> lhs.tctx.onFp(lhs.cast(), rhs.cast()) | ||
|
||
else -> error("Unexpected sorts: $lhsSort, $rhsSort") | ||
} | ||
} | ||
|
||
companion object { | ||
private val shouldNotBeCalled: TSContext.(UExpr<out USort>, UExpr<out USort>) -> UExpr<out USort> = | ||
{ _, _ -> error("Should not be called") } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
package org.usvm | ||
|
||
import org.jacodb.ets.base.EtsBooleanType | ||
import org.jacodb.ets.base.EtsNumberType | ||
import org.jacodb.ets.base.EtsRefType | ||
import org.jacodb.ets.base.EtsType | ||
|
||
typealias TSSizeSort = UBv32Sort | ||
|
||
class TSContext(components: TSComponents) : UContext<TSSizeSort>(components) | ||
class TSContext(components: TSComponents) : UContext<TSSizeSort>(components) { | ||
|
||
val undefinedSort: TSUndefinedSort by lazy { TSUndefinedSort(this) } | ||
|
||
private val undefinedValue by lazy { TSUndefinedValue(this) } | ||
|
||
fun typeToSort(type: EtsType): USort = when (type) { | ||
is EtsBooleanType -> boolSort | ||
is EtsNumberType -> fp64Sort | ||
is EtsRefType -> addressSort | ||
else -> TODO("Support all JacoDB types") | ||
} | ||
|
||
fun mkUndefinedValue(): TSUndefinedValue = undefinedValue | ||
} |
Oops, something went wrong.