-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
338 additions
and
37 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
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
49 changes: 49 additions & 0 deletions
49
usvm-jvm/src/main/kotlin/org/usvm/machine/interpreter/JcCallSiteRegion.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,49 @@ | ||
package org.usvm.machine.interpreter | ||
|
||
import kotlinx.collections.immutable.PersistentMap | ||
import kotlinx.collections.immutable.persistentHashMapOf | ||
import org.jacodb.api.cfg.JcLambdaExpr | ||
import org.usvm.UAddressSort | ||
import org.usvm.UBoolExpr | ||
import org.usvm.UConcreteHeapAddress | ||
import org.usvm.UConcreteHeapRef | ||
import org.usvm.UExpr | ||
import org.usvm.machine.JcContext | ||
import org.usvm.memory.UMemoryRegion | ||
import org.usvm.memory.UMemoryRegionId | ||
|
||
class JcLambdaCallSiteRegionId(private val ctx: JcContext) : UMemoryRegionId<Nothing, UAddressSort> { | ||
override val sort: UAddressSort | ||
get() = ctx.addressSort | ||
|
||
override fun emptyRegion(): UMemoryRegion<Nothing, UAddressSort> = | ||
JcLambdaCallSiteMemoryRegion(ctx) | ||
} | ||
|
||
internal class JcLambdaCallSiteMemoryRegion( | ||
private val ctx: JcContext, | ||
private val callSites: PersistentMap<UConcreteHeapAddress, JcLambdaCallSite> = persistentHashMapOf() | ||
) : UMemoryRegion<Nothing, UAddressSort> { | ||
fun writeCallSite(callSite: JcLambdaCallSite) = | ||
JcLambdaCallSiteMemoryRegion(ctx, callSites.put(callSite.ref.address, callSite)) | ||
|
||
fun findCallSite(ref: UConcreteHeapRef): JcLambdaCallSite? = callSites[ref.address] | ||
|
||
override fun read(key: Nothing): UExpr<UAddressSort> { | ||
error("Unsupported operation for call site region") | ||
} | ||
|
||
override fun write( | ||
key: Nothing, | ||
value: UExpr<UAddressSort>, | ||
guard: UBoolExpr | ||
): UMemoryRegion<Nothing, UAddressSort> { | ||
error("Unsupported operation for call site region") | ||
} | ||
} | ||
|
||
data class JcLambdaCallSite( | ||
val ref: UConcreteHeapRef, | ||
val lambda: JcLambdaExpr, | ||
val callSiteArgs: List<UExpr<*>> | ||
) |
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
Oops, something went wrong.