Skip to content

Commit

Permalink
fix ownership inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
oveeernight committed Jul 25, 2024
1 parent 0c31856 commit 2e639dc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.usvm.uctx
*/
open class UPathConstraints<Type>(
protected val ctx: UContext<*>,
private var ownership: MutabilityOwnership,
protected open var ownership: MutabilityOwnership,
protected val logicalConstraints: ULogicalConstraints = ULogicalConstraints.empty(),
/**
* Specially represented equalities and disequalities between objects, used in various part of constraints management.
Expand Down Expand Up @@ -52,7 +52,7 @@ open class UPathConstraints<Type>(
/**
* Recursively changes ownership for all nested data structures that use persistent maps.
*/
fun setOwnership(ownership: MutabilityOwnership) {
fun changeOwnership(ownership: MutabilityOwnership) {
this.ownership = ownership
numericConstraints.ownership = ownership
equalityConstraints.ownership = ownership
Expand Down
4 changes: 2 additions & 2 deletions usvm-jvm/src/main/kotlin/org/usvm/machine/state/JcState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class JcState(
val newThisOwnership = MutabilityOwnership()
val cloneOwnership = MutabilityOwnership()
val clonedConstraints = newConstraints?.also {
this.pathConstraints.setOwnership(newThisOwnership)
it.setOwnership(cloneOwnership)
this.pathConstraints.changeOwnership(newThisOwnership)
it.changeOwnership(cloneOwnership)
} ?: pathConstraints.clone(newThisOwnership, cloneOwnership)
this.ownership = newThisOwnership
return JcState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.usvm.machine.types.PythonType

class PyPathConstraints(
ctx: UContext<*>,
private var ownership: MutabilityOwnership,
override var ownership: MutabilityOwnership,
logicalConstraints: ULogicalConstraints = ULogicalConstraints.empty(),
equalityConstraints: UEqualityConstraints = UEqualityConstraints(ctx, ownership),
typeConstraints: UTypeConstraints<PythonType> = UTypeConstraints(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class PyState(
val newThisOwnership = MutabilityOwnership()
val cloneOwnership = MutabilityOwnership()
val newPathConstraints = newConstraints?.also {
this.pathConstraints.setOwnership(newThisOwnership)
it.setOwnership(cloneOwnership)
this.pathConstraints.changeOwnership(newThisOwnership)
it.changeOwnership(cloneOwnership)
} ?: pathConstraints.clone(newThisOwnership, cloneOwnership)
val newMemory = memory.clone(newPathConstraints.typeConstraints, newThisOwnership, cloneOwnership)
return PyState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class SampleState(
val newThisOwnership = MutabilityOwnership()
val cloneOwnership = MutabilityOwnership()
val clonedConstraints = newConstraints?.also {
this.pathConstraints.setOwnership(newThisOwnership)
it.setOwnership(cloneOwnership)
this.pathConstraints.changeOwnership(newThisOwnership)
it.changeOwnership(cloneOwnership)
} ?: pathConstraints.clone(newThisOwnership, cloneOwnership)
return SampleState(
ctx,
Expand Down
4 changes: 2 additions & 2 deletions usvm-ts/src/main/kotlin/org/usvm/state/TSState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class TSState(
val newThisOwnership = MutabilityOwnership()
val cloneOwnership = MutabilityOwnership()
val clonedConstraints = newConstraints?.also {
this.pathConstraints.setOwnership(newThisOwnership)
it.setOwnership(cloneOwnership)
this.pathConstraints.changeOwnership(newThisOwnership)
it.changeOwnership(cloneOwnership)
} ?: pathConstraints.clone(newThisOwnership, cloneOwnership)
this.ownership = newThisOwnership

Expand Down

0 comments on commit 2e639dc

Please sign in to comment.