Skip to content

Commit

Permalink
Added SBEPass with test
Browse files Browse the repository at this point in the history
  • Loading branch information
leventeBajczi committed Nov 28, 2024
1 parent 9796038 commit 0be641c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2024 Budapest University of Technology and Economics
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package hu.bme.mit.theta.xcfa.passes

import hu.bme.mit.theta.xcfa.model.*

/**
* Transforms all sequence labels to consequtive edges. Requires the ProcedureBuilder be
* `deterministic`.
*/
class SBEPass() : ProcedurePass {

override fun run(builder: XcfaProcedureBuilder): XcfaProcedureBuilder {
checkNotNull(builder.metaData["deterministic"])
for (edge in ArrayList(builder.getEdges())) {
val edges = edge.splitIf(this::predicate)
if (
edges.size > 1 ||
(edges.size == 1 && predicate((edges[0].label as SequenceLabel).labels[0]))
) {
builder.removeEdge(edge)
edges.forEach { builder.addEdge(it) }
}
}
return builder
}

private fun predicate(it: XcfaLabel): Boolean {
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,20 @@ class PassTests {
input = { ("L1" to "L1") { assume("1 == 1") } },
output = null,
),
PassTestData(
global = {},
passes = listOf(NormalizePass(), DeterministicPass(), SBEPass()),
input = {
("L1" to "L2") {
assume("1 == 1")
assume("2 == 2")
}
},
output = {
("L1" to "loc3") { assume("1 == 1") }
("loc3" to "L2") { assume("2 == 2") }
},
),
)
}

Expand Down

0 comments on commit 0be641c

Please sign in to comment.