Code coverage for itm_read_arg2.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        := ITM_READ_ARG2;

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


  - author      := "Sonntag Benoit (bsonntag@loria.fr)";
  - comment     := "For send message with two argument (receiver + argument)\
  \ or simple binary message";

Section Inherit

  + parent_itm_read:Expanded ITM_READ;

Section Public

  - is_affect:POSITION <-
  ( + result:POSITION;

    (arg_first != NULL).if {
      result := arg_first.position;
    }
 else {
      result := arg_second.is_affect;
    }
;
    result
  )
;

  //
  // Data
  //

  + arg_first:ITM_CODE;

  + arg_second:ITM_CODE;

  //
  // Constructor
  //

  - create p:POSITION name n:STRING_CONSTANT args (a1,a2:ITM_CODE) :SELF <-
  ( + result:SELF;
    result := clone;
    result.make p name n args (a1,a2);
    result
  )
;

  - make p:POSITION name n:STRING_CONSTANT args (a1,a2:ITM_CODE) <-
  (
    ? { a2 != NULL };
    position   := p;
    name       := n;
    arg_first  := a1;
    arg_second := a2;
  )
;

  //
  // Runnable
  //

  - to_run_expr:EXPR <-
  ( + result:EXPR;
    + l_arg:FAST_ARRAY(ITM_CODE);
    + v1,v2:EXPR;
    + t1,t2:TYPE_FULL;
    + em1,em2:EXPR_MULTIPLE;

    (
      (name = ALIAS_STR.operator_equal) ||
      {name = ALIAS_STR.operator_not_equal}
    )
.if {
      v1 := arg_first .to_run_expr;
      v2 := arg_second.to_run_expr;
      (verify).if {
        t1 := v1.static_type;
        t2 := v2.static_type;
        (
          (! t1.is_expanded) &&
          {! t2.is_expanded} &&
          {! t1.is_sub_type t2} &&
          {! t2.is_sub_type t1}
        )
.if {
          string_tmp.clear;
          t1.append_name_in string_tmp;
          string_tmp.append " and ";
          t2.append_name_in string_tmp;
          string_tmp.append " are not comparable.";
          warning_error (position,string_tmp);
        }
;
      }
;
      em1 ?= v1;
      (em1 != NULL).if {
        em2 ?= v2;
        result := product_cmp (em1.first) with (em2.first);
        (em1.lower+1).to (em1.upper) do { j:INTEGER;
          v2 := product_cmp (em1.item j) with (em2.item j);
          (name = ALIAS_STR.operator_equal).if {
            result := EXPR_AND_AND_LOGIC.create position with result and v2;
          }
 else {
            result := EXPR_OR_OR_LOGIC.create position with result and v2;
          }
;
        }
;
      }
 else {
        result := product_cmp v1 with v2;
      }
;
    }
 else {
      l_arg := ALIAS_ARRAY(ITM_CODE).new;
      l_arg.add_last arg_second;
      result := to_run_with arg_first args l_arg;
    }
;
    result
  )
;

Section Private

  - product_cmp v1:EXPR with v2:EXPR :EXPR <-
  ( + result:EXPR;
    (name = ALIAS_STR.operator_equal).if {
      result := EXPR_EQUAL.create position with v1 and v2;
    }
 else {
      result := EXPR_NOT_EQUAL.create position with v1 and v2;
    }
;
    result
  )
;