Skip to content

Commit

Permalink
First working version
Browse files Browse the repository at this point in the history
  • Loading branch information
CaelmBleidd committed Sep 19, 2023
1 parent 343a895 commit ceb15dd
Show file tree
Hide file tree
Showing 9 changed files with 459 additions and 371 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ internal class InterprocDistanceCalculator<Method, Statement>(
currentStatement: Statement,
callStack: UCallStack<Method, Statement>
): InterprocDistance {
if (callStack.isEmpty()) {
return InterprocDistance(UInt.MAX_VALUE, ReachabilityKind.NONE)
}

val lastMethod = callStack.lastMethod()
val lastFrameDistance = calculateFrameDistance(lastMethod, currentStatement)

Expand Down
32 changes: 4 additions & 28 deletions usvm-core/src/main/kotlin/org/usvm/targets/UTarget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,8 @@ abstract class UTarget<Statement, Target, TargetController : UTargetController>(
val location: Statement? = null,
) where Target : UTarget<Statement, Target, TargetController> {
private val childrenImpl = mutableListOf<Target>()
private var parent: Target? = null

private var status: Status = Status.UNPROCESSED

// TODO move it
enum class Status {
UNPROCESSED,
PROCESSING,
PROCESSED
}

fun processing() {
require(status == Status.UNPROCESSED)

status = Status.PROCESSING
}

fun processed() {
require(status == Status.PROCESSING)

status = Status.PROCESSED
}
var parent: Target? = null
private set

/**
* List of the child targets which should be reached after this target.
Expand All @@ -60,10 +40,6 @@ abstract class UTarget<Statement, Target, TargetController : UTargetController>(
var isRemoved = false
private set

// TODO add docs
fun <State : UState<*, *, *, *, Target, State>> isReachedBy(state: State): Boolean? =
location?.let { it == state.currentStatement }

/**
* Adds a child target to this target.
* TODO: avoid possible recursion
Expand All @@ -84,9 +60,9 @@ abstract class UTarget<Statement, Target, TargetController : UTargetController>(
* should try to propagate the target. If the target without children has been
* visited, it is logically removed from tree.
*/
protected fun <State : UState<*, *, Statement, *, Target, *>> propagate(byState: State) {
fun <T, State : UState<*, *, Statement, *, T, State>> propagate(byState: State) {
@Suppress("UNCHECKED_CAST")
if (byState.tryPropagateTarget(this as Target) && isTerminal) {
if (byState.tryPropagateTarget(this as T) && isTerminal) {
remove()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package org.usvm.targets

// TODO add self generic for the controller
interface UTargetController {
val targets: MutableCollection<UTarget<*, *, *>>
val targets: MutableCollection<out UTarget<*, *, *>>
}
Loading

0 comments on commit ceb15dd

Please sign in to comment.