Skip to content

Commit

Permalink
get vars assignstmt fix
Browse files Browse the repository at this point in the history
  • Loading branch information
csanadtelbisz committed Nov 6, 2023
1 parent 43395cc commit ef55998
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ private fun List<VarAccessMap>.mergeAndCollect(): VarAccessMap = this.fold(mapOf
(acc.keys + next.keys).associateWith { acc[it].merge(next[it]) }
}

private operator fun VarAccessMap?.plus(other: VarAccessMap?): VarAccessMap =
listOfNotNull(this, other).mergeAndCollect()

/**
* The list of mutexes acquired by the label.
*/
Expand Down Expand Up @@ -150,17 +153,17 @@ fun XcfaLabel.collectVarsWithAccessType(): VarAccessMap = when (this) {
is StmtLabel -> {
when (stmt) {
is HavocStmt<*> -> mapOf(stmt.varDecl to WRITE)
is AssignStmt<*> -> StmtUtils.getVars(stmt).associateWith { READ } + mapOf(stmt.varDecl to WRITE)
is AssignStmt<*> -> ExprUtils.getVars(stmt.expr).associateWith { READ } + mapOf(stmt.varDecl to WRITE)
else -> StmtUtils.getVars(stmt).associateWith { READ }
}
}

is NondetLabel -> labels.map { it.collectVarsWithAccessType() }.mergeAndCollect()
is SequenceLabel -> labels.map { it.collectVarsWithAccessType() }.mergeAndCollect()
is InvokeLabel -> params.map { ExprUtils.getVars(it) }.flatten().associateWith { READ }
is StartLabel -> params.map { ExprUtils.getVars(it) }.flatten().associateWith { READ } + mapOf(pidVar to READ)
is JoinLabel -> mapOf(pidVar to READ)
is ReadLabel -> mapOf(global to READ, local to READ)
is StartLabel -> params.map { ExprUtils.getVars(it) }.flatten().associateWith { READ } + mapOf(pidVar to READ)
is WriteLabel -> mapOf(global to WRITE, local to WRITE)
else -> emptyMap()
}
Expand Down

0 comments on commit ef55998

Please sign in to comment.