Skip to content

Pass actual condition value to ctrlif instead of a logical true/false #19

@Schlevidon

Description

@Schlevidon

Context

Ctrlifs are used to monitor conditions which may cause model switches. When IFDIFF detects a statement which may induce control flow (i.e. explicit if-statements, but also discontinuous functions like abs), the underlying condition of the statement is first transformed into a normalized form (condition_value >= 0) and then the logical (true/false) result of this comparison is passed to a ctrlif as its first argument.

Proposed Improvement

We are losing a lot of useful information by only passing the logical result of the comparison to a ctrlif. Instead, we would like to pass the actual value before performing the >= 0 comparison (i.e. the condition_value mentioned in the previous section). The >= 0-check would then be performed inside the ctrlif call. One advantage is that ctrlifs may react differently depending on how close the condition_value is to zero:
For example, one could set a threshold which needs to be exceeded for a switch to be recognized. Or there could be a warning message if the condition_value is very close to zero. In any case, this would allow us to more easily extend the capabilities of ctrlifs in the future without any real drawbacks.

Implementation

The main mechanism to extract a condition_value should already be implemented in IFDIFF, since it is used to transform control flow statements into a normalized form. The remaining task would then be to simply:

  • In the preprocessing: Remove the >= 0-comparison from the first argument of ctrlif calls.
  • In the ctrlif: Replace all occurences of the first argument (called condition) with a >= 0-comparison.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions