Code coverage for expr_binary_cmp.li

///////////////////////////////////////////////////////////////////////////////
//                             Lisaac Compiler                               //
//                                                                           //
//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
//                                                                           //
//   This program is free software: you can redistribute it and/or modify    //
//   it under the terms of the GNU General Public License as published by    //
//   the Free Software Foundation, either version 3 of the License, or       //
//   (at your option) any later version.                                     //
//                                                                           //
//   This program is distributed in the hope that it will be useful,         //
//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//   GNU General Public License for more details.                            //
//                                                                           //
//   You should have received a copy of the GNU General Public License       //
//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                           //
//                     http://isaacproject.u-strasbg.fr/                     //
///////////////////////////////////////////////////////////////////////////////
Section Header

  + name        := EXPR_BINARY_CMP;

  - copyright   := "2003-2007 Benoit Sonntag";


  - author      := "Sonntag Benoit (bsonntag@loria.fr)";
  - comment     := "Binary comparison expression.";

Section Inherit

  + parent_expr:Expanded EXPR;

Section Public

  - is_invariant:BOOLEAN <- left.is_invariant    {right.is_invariant};

  + left:EXPR;

  + right:EXPR;

  - set_left l:EXPR and_right r:EXPR <-
  (
    left  := l;
    right := r;
  );

  - symbol:STRING_CONSTANT <-
  (
    deferred;
    NULL
  );

  - static_type:TYPE_FULL <- type_boolean.default;

  - get_type t:TYPES_TMP <-
  (
    t.add type_true;
    t.add type_false;
  );

  //
  // Creation.
  //

  - create p:POSITION with l:EXPR and r:EXPR :SELF <-
  ( + result:SELF;


    ((symbol == "==") || {symbol == "!="}).if {
      (is_executing_pass).if_false {
        count_equal_live := count_equal_live + 1;
      };
      count_equal_creat := count_equal_creat + 1;
    };
    result := clone;
    result.make p with l and r;
    result
  );

  - make p:POSITION with l:EXPR and r:EXPR <-
  (
    position := p;
    left     := l;
    right    := r;
  );

  - my_copy:SELF <- SELF.create position with (left.my_copy) and (right.my_copy);

  //
  // Comparaison.
  //

  - Self:SELF '~=' Right 60 other:EXPR :BOOLEAN <-
  ( + same:SELF;

    same ?= other;
    (same != NULL)    {left ~= same.left}    {right ~= same.right}
  );

  //
  // Remove
  //

  - remove <-
  (
    left .remove;
    right.remove;

    ((symbol == "==") || {symbol == "!="}).if {
      count_equal_remov := count_equal_remov + 1;
    };
  );

  //
  // Execute
  //

  - execute_unlink:INSTR <-
  ( + instr:INSTR;
    instr  := left.execute_unlink;
    (instr != NULL).if {
      list_current.insert_before instr;
    };

    ((symbol == "==") || {symbol == "!="}).if {
      count_equal_remov := count_equal_remov + 1;
    };

    right.execute_unlink
  );

  - execute_link:EXPR <-
  ( + result:EXPR;
    + old_seq:UINTEGER_32;
    + left_cst,right_cst:INTEGER_CST;

    old_seq := seq_call_and_loop;
    left  := left .execute_link;
    right := right.execute_link;
    //
    left_cst  ?= left;
    right_cst ?= right;
    // Conservator transformation.
    result := exec_conservator;
    ((result = NULL)    {left_cst != NULL}).if {
      result := exec_conservator_left left_cst;
    };
    ((result = NULL)    {right_cst != NULL}).if {
      result := exec_conservator_right right_cst;
    };
    (
      (result = NULL)       
      {right_cst != NULL}   
      {left_cst  != NULL}
    ).if {
      result := exec left_cst and right_cst;
    };
    ((result = NULL)    {old_seq = seq_call_and_loop}).if {
      // No conservator transformation.
      result := exec;
      ((result = NULL)    {left_cst != NULL}).if {
	result := exec_left left_cst;
      };
      ((result = NULL)    {right_cst != NULL}).if {
	result := exec_right right_cst;
      };
    };
    //
    (result = NULL).if {
      result := Self;
    } else {
      result.set_position position;
      new_execute_pass;
    };

    result
  );

  - exec_conservator:EXPR <- NULL;
  - exec_conservator_left  left_cst :INTEGER_CST :EXPR <- NULL;
  - exec_conservator_right right_cst:INTEGER_CST :EXPR <- NULL;

  - exec left_cst:INTEGER_CST and right_cst:INTEGER_CST :EXPR <- NULL;

  - exec:EXPR <- NULL;
  - exec_left  left_cst :INTEGER_CST :EXPR <- NULL;
  - exec_right right_cst:INTEGER_CST :EXPR <- NULL;

  //
  // Genere.
  //

  - genere buffer:STRING <-
  (
    buffer.add_last '(';
    (
      (left.static_type.raw = type_pointer)   
      {ALIAS_STR.is_integer (right.static_type.raw.name)}
    ).if {
      buffer.append "(unsigned long)";
    }.elseif {! left.static_type.is_expanded} then {
      buffer.append "(void *)"; // BSBS: A virer quand tu auras optim '=='
    };
    ((left.static_type.raw = TYPE_NULL)    {right.static_type.raw.is_block}).if {
      buffer.add_last '0';
    } else {
      (left.static_type.raw.is_block).if {
        buffer.append "(long)";
      };
      left.genere buffer;
      (left.static_type.raw.is_block).if {
	buffer.append ".__id";
      };
    };
    buffer.add_last ' ';
    buffer.append symbol;
    buffer.add_last ' ';

    (
      (ALIAS_STR.is_integer (left.static_type.raw.name))   
      {right.static_type.raw = type_pointer}
    ).if {
      buffer.append "(unsigned long)";
    }.elseif {! right.static_type.is_expanded} then {
      buffer.append "(void *)"; // BSBS: A virer quand tu auras optim '=='
    };
    ((right.static_type.raw = TYPE_NULL)    {left.static_type.raw.is_block}).if {
      buffer.add_last '0';
    } else {
      right.genere buffer;
      (right.static_type.raw.is_block).if {
	buffer.append ".__id";
      };
    };
    buffer.add_last ')';
  );

  //
  // Display.
  //

  - display buffer:STRING <-
  (
    buffer.add_last '(';
    left.static_type.append_name_in buffer;
    buffer.add_last ' ';
    left.display buffer;
    buffer.append symbol;
    right.display buffer;
    buffer.add_last ')';
  );