| 1234567891011121314151617181920212223242526272829 |
- (**
- * The phase applies the transformations shown below. These transformations are
- * required because the CiviC VM does not offer instructions that perform these
- * operations. Another reason is that conjunction and disjunction require
- * short-circuit evaluation. In the examples below, `b1` and `b2` are
- * expressions of type boolean, `i` is of type int and `f` is of type float.
- *
- * > 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
- *)
- open Ast
- open Util
- let rec bool_op = function
- | node -> transform_children bool_op node
- let rec phase input =
- prerr_endline "- Convert bool operations";
- match input with
- | Ast (node, args) -> Ast (bool_op node, args)
- | _ -> raise (InvalidInput "bool operations")
|