-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
transformer that adds basic invariants every time
- Loading branch information
1 parent
e5ed69a
commit 81ca8c2
Showing
9 changed files
with
67 additions
and
34 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
core/src/main/kotlin/org/vorpal/research/kex/state/transformer/BasicInvariantsTransformer.kt
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,33 @@ | ||
package org.vorpal.research.kex.state.transformer | ||
|
||
import org.vorpal.research.kex.ktype.KexRtManager.rtMapped | ||
import org.vorpal.research.kex.ktype.kexType | ||
import org.vorpal.research.kex.state.PredicateState | ||
import org.vorpal.research.kex.state.StateBuilder | ||
import org.vorpal.research.kex.state.predicate.assume | ||
import org.vorpal.research.kex.state.term.term | ||
import org.vorpal.research.kfg.ir.Method | ||
import org.vorpal.research.kthelper.collection.dequeOf | ||
|
||
class BasicInvariantsTransformer( | ||
val method: Method | ||
) : RecollectingTransformer<BasicInvariantsTransformer> { | ||
override val builders = dequeOf(StateBuilder()) | ||
|
||
override fun apply(ps: PredicateState): PredicateState { | ||
val thisType = method.klass.kexType.rtMapped | ||
val thisTerm = run { | ||
val (thisTerm, _) = collectArguments(ps) | ||
when { | ||
thisTerm != null -> thisTerm | ||
!method.isStatic -> term { `this`(thisType) } | ||
else -> null | ||
} | ||
} | ||
if (thisTerm != null) { | ||
currentBuilder += assume { thisTerm inequality null } | ||
currentBuilder += assume { (thisTerm `is` thisType) equality true } | ||
} | ||
return super.apply(ps) | ||
} | ||
} |
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
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
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
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
1 change: 1 addition & 0 deletions
1
kex-test/src/main/kotlin/org/vorpal/research/kex/test/javadebug/Stack.java
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