Skip to content

Commit

Permalink
fix some quodana stuff, ide sorted navigator
Browse files Browse the repository at this point in the history
  • Loading branch information
wadoon committed Dec 10, 2023
1 parent 6ed62c4 commit a0192be
Show file tree
Hide file tree
Showing 29 changed files with 233 additions and 277 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions exec/src/main/kotlin/edu/kit/iti/formal/automation/Kastel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ object KastelDemonstrator {
object AssignmentDScratch : STCodeTransformation, AstMutableVisitor() {
override fun transform(stBody: StatementList): StatementList = stBody.accept(this) as StatementList
override fun visit(assignmentStatement: AssignmentStatement): Statement {
if ((assignmentStatement.location as SymbolicReference).identifier == "dScratch") {
if (assignmentStatement.location.identifier == "dScratch") {
return StatementList()
}
return assignmentStatement
Expand Down Expand Up @@ -322,7 +322,7 @@ object SeqParamsActiveStep : CodeTransformation, AstMutableVisitor() {
if (sub.identifier == "Sequence" && sub.sub?.identifier == "iActStep") {
return SymbolicReference("ActStep", symbolicReference.sub)
}
} catch (e: ClassCastException) {
} catch (_: ClassCastException) {

}
}
Expand Down Expand Up @@ -361,7 +361,7 @@ object RemoveVSObj : STCodeTransformation, AstMutableVisitor() {
override fun transform(stBody: StatementList) = stBody.accept(this) as StatementList

override fun visit(assignmentStatement: AssignmentStatement): Statement {
val ident = (assignmentStatement.location as SymbolicReference).identifier
val ident = assignmentStatement.location.identifier
return if (ident == "VSObj_McFaultDescription")
return StatementList()
else assignmentStatement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import edu.kit.iti.formal.automation.testtables.model.ConstraintVariable
import edu.kit.iti.formal.automation.testtables.monitor.*
import edu.kit.iti.formal.util.info
import java.io.File
import java.util.*

/**
*
Expand Down Expand Up @@ -39,7 +40,7 @@ class MonitorApp : CliktCommand(name = "ttmonitor",

val format by option("--format", "-f", help = "code format, possible values: " +
CodeOutput.entries.joinToString(",") { it.name })
.convert { CodeOutput.valueOf(it.toUpperCase()) }
.convert { CodeOutput.valueOf(it.uppercase(Locale.getDefault())) }
.default(CodeOutput.CPP)

val disableCombinedMonitor by option("--disable-combined",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import edu.kit.iti.formal.automation.testtables.print.LatexTablePrinter
import edu.kit.iti.formal.automation.testtables.print.TextTablePrinter
import edu.kit.iti.formal.util.CodeWriter
import java.io.OutputStreamWriter
import java.util.*

/**
*
Expand All @@ -29,7 +30,7 @@ class PrinterApp : CliktCommand(name="ttprint", help = "generate print files for
enum class Format { HTML, LATEX, TEXT }

val format by option("-f", "--format")
.convert { Format.valueOf(it.toUpperCase()) }
.convert { Format.valueOf(it.uppercase(Locale.getDefault())) }
.default(Format.LATEX)

val output by option("--output",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import org.antlr.v4.runtime.CharStreams
import org.antlr.v4.runtime.CommonTokenStream
import java.io.File
import java.nio.file.Paths
import java.util.*
import kotlin.collections.HashMap
import kotlin.math.max

/**
Expand Down Expand Up @@ -65,7 +67,7 @@ class SynthesisApp : CliktCommand(

private val outputFunctionStrategy by option("--row-selection-strategy",
help = "Strategy for choosing output function when multiple rows are active")
.choice(enumValues<OutputFunctionStrategy>().associateBy { it.name.toLowerCase() })
.choice(enumValues<OutputFunctionStrategy>().associateBy { it.name.lowercase(Locale.getDefault()) })
.default(OutputFunctionStrategy.ASSUME_ORTHOGONAL)

override fun run() {
Expand Down Expand Up @@ -881,11 +883,11 @@ class ExpressionSynthesizer(private val pythonExecutable: String = "python") {
"${ctx.identifier().accept(this)} = ${ctx.expr().accept(this)}"

override fun visitExpr(ctx: IteLanguageParser.ExprContext): String =
ctx.iteExpr()?.accept(this)
?: ctx.expr()?.let { "(not ${it.accept(this)})" }
?: ctx.identifier()?.accept(this)
?: ctx.BOOLEAN()?.text?.toLowerCase()
?: ctx.INTEGER()!!.text
ctx.iteExpr()?.accept(this)
?: ctx.expr()?.let { "(not ${it.accept(this)})" }
?: ctx.identifier()?.accept(this)
?: ctx.BOOLEAN()?.text?.lowercase(Locale.getDefault())
?: ctx.INTEGER()!!.text

override fun visitIteExpr(ctx: IteLanguageParser.IteExprContext): String =
iteExprCache.getOrPut(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import edu.kit.iti.formal.util.CodeWriter
import edu.kit.iti.formal.util.meta
import java.io.File
import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.abs

data class ReactiveProgram(
Expand All @@ -52,7 +55,7 @@ private fun createNext(t: Transition): SMVExpr {
} else {

val inputExpr = (t.from as RowState).row.inputExpr.values.conjunction(SLiteral.TRUE)
val outputExpr = (t.from as RowState).row.outputExpr.values.conjunction(SLiteral.TRUE)
val outputExpr = t.from.row.outputExpr.values.conjunction(SLiteral.TRUE)

when (t.type) {
TransitionType.ACCEPT ->
Expand Down Expand Up @@ -152,7 +155,7 @@ class GttMiterConstruction(val gtt: GeneralizedTestTable,
.or(SVariable(err.name, SMVTypes.BOOLEAN).not())
target.body.add("__INV__" assignTo invAssign.translateToSt())
val assert = SpecialCommentFactory
.createAssert(SymbolicReference("__INV__"));
.createAssert(SymbolicReference("__INV__"))
target.body.add(assert)
}

Expand Down Expand Up @@ -255,19 +258,20 @@ class ProgMiterConstruction(val exec: PouExecutable) {
is EnumerationTypeDeclaration -> {
td.allowedValues.forEachIndexed { i, value ->
val vd = VariableDeclaration(
"${td.name}__${value.text.toUpperCase()}",
"${td.name}__${value.text.uppercase()}",
VariableDeclaration.CONSTANT,
SimpleTypeDeclaration(INT, IntegerLit(i)))
target.scope.topLevel.add(vd)
}

val fdecl = FunctionDeclaration("nondet_${td.name.toLowerCase()}",
val fdecl = FunctionDeclaration(
"nondet_${td.name.lowercase()}",
returnType = RefTo(INT))
fdecl.scope.add(VariableDeclaration("x", VariableDeclaration.LOCAL, INT))
fdecl.stBody = StatementList().also {
val x = SymbolicReference("x")
val assume = td.values.map {
x eq IntegerLit(INT, it.toBigInteger())
val assume = td.values.map { int ->
x eq IntegerLit(INT, int.toBigInteger())
}.disjunction()
it.add(SpecialCommentFactory.createHavoc("x", INT))
it.add(SpecialCommentFactory.createAssume(assume))
Expand Down Expand Up @@ -307,8 +311,8 @@ class ExpressionConversion(val enumValues: EnumValueTable) : SMVAstVisitor<Expre
is SMVTypes.BOOLEAN -> BooleanLit(l.value == true)
is SMVWordType -> IntegerLit(INT, l.value.toString().toBigInteger())
is EnumType -> {
val et = enumValues[l.value.toString().toUpperCase()]
?: error("No enum defined which contains ${l.value}. Defined values: ${enumValues.keys}")
val et = enumValues[l.value.toString().uppercase(Locale.getDefault())]
?: error("No enum defined which contains ${l.value}. Defined values: ${enumValues.keys}")
EnumLit(et, l.value.toString())
}
else -> error("Literals of type '${l.javaClass} are not supported")
Expand Down Expand Up @@ -391,7 +395,11 @@ class InvocationBasedProductProgramBuilder(name: String = "main") {
}

private fun createInstance(p: ReactiveProgram, fbd: FunctionBlockDeclaration): VariableDeclaration {
val vd = VariableDeclaration(p.name.toLowerCase(), VariableDeclaration.LOCAL, FunctionBlockDataType(fbd))
val vd = VariableDeclaration(
p.name.lowercase(Locale.getDefault()),
VariableDeclaration.LOCAL,
FunctionBlockDataType(fbd)
)
target.scope.add(vd)
return vd

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SpecificationInterfaceMisMatchException : GetetaException {
var computed: MutableMap<String, Int> = HashMap()

init {
this.reference = name.toLowerCase()
this.reference = name.lowercase(Locale.getDefault())
}


Expand All @@ -79,8 +79,13 @@ class SpecificationInterfaceMisMatchException : GetetaException {
}

private fun getLevenstheinToRef(o1: String): Int {
val k = o1.toLowerCase()
return (computed as java.util.Map<String, Int>).computeIfAbsent(k) { s -> levenshteinDistance(reference, s) }
val k = o1.lowercase(Locale.getDefault())
return (computed as java.util.Map<String, Int>).computeIfAbsent(k) { s ->
levenshteinDistance(
reference,
s
)
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class TblLanguageToSmv(private val columnVariable: SVariable,
if (isReference)
throw IllegalExpressionException("You referenced a variable $varText, " +
"but it is not found as a defined program variable.")
SEnumLiteral(varText.toUpperCase())
SEnumLiteral(varText.uppercase(Locale.getDefault()))
}
}

Expand Down
Loading

0 comments on commit a0192be

Please sign in to comment.