(** Convert boolean operations to equivalent operations on different CiviC data types. *) (** This phase transforms operations on boolean values to equivalent operations on different data types. This transformation is necessary, because the CiviC VM does not define some operations for boolean arguments. This phase also handles the first step of short-circuit evaluation, by transforming conjunction and disjunction operators into conditional operations of the form [a ? b : c]. This operation is supported by the assembly phase, which handles them similarly to if-else statements. The benefit of using conditional operations, is that they are still expressions. A transformation into actual if-else statements would require adding additional statements, which is not only more difficult to implement, but also changes the evaluation order, which (however in agreement with the C standard) may lead to confusing behaviour. The applied transformations are as follows: {v b1 == b2 ==> (int)b1 == (int)b2 b1 != b2 ==> (int)b1 != (int)b2 b1 && b2 ==> b1 ? b2 : false b1 || b2 ==> b1 ? true : b2 b1 + b2 ==> (bool)((int)b1 + (int)b2) b1 * b2 ==> (bool)((int)b1 * (int)b2) (bool)i ==> i != 0 (bool)f ==> f != 0.0 (int)b1 ==> b1 ? 1 : 0 (float)b1 ==> b1 ? 1.0 : 0.0 v} *) (** Main phase function, called by {!Main}. *) val phase : Main.phase_func