(** 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 thiese are still expressions. A transformation into actual if-else statements would retuire adding additional statements, which creates other problems which we will not discuss here. 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