Code coverage for itm_write_cast.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_WRITE_CAST;

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


  - author      := "Sonntag Benoit (bsonntag@loria.fr)";
  - comment     := "Assignment slot `?=' style";

Section Inherit

  + parent_itm_write:Expanded ITM_WRITE;

Section Public

  - type:STRING_CONSTANT <- "?=";

  //
  // Runnable
  //

  - to_run_expr:EXPR <-
  ( + val:EXPR;
    + loc:LOCAL;
    + node:NODE;
    + nm:STRING_CONSTANT;
    + typ_cast:TYPE_FULL;
    + slot:SLOT;
    + ts:ITM_TYPE_SIMPLE;

    // Value -> local.
    val := value.to_run_expr;
    loc := val.static_type.get_temporary position;
    list_current.add_last (loc.write position value val);
    val := loc.read position;
    // Assign.
    nm  := get_simple_name;
    loc := lookup nm;
    (loc != NULL).if {
      typ_cast := loc.type;
    } else {
      slot := profil_slot.type_self.get_slot nm;
      (slot = NULL).if {
	string_tmp.copy "Slot `";
	string_tmp.append nm;
	string_tmp.append "' not found in static type ";
	profil_slot.type_self.append_name_in string_tmp;
	string_tmp.add_last '.';
	semantic_error (position,string_tmp);
      };
      ts ?= slot.result_type;
      typ_cast := ts.to_run_for profil_slot;
    };
    (verify).if {
      ((typ_cast.affect_with (val.static_type))    {! val.static_type.is_generic}).if {
	warning_error (position,"`?=' is not necessary, use `:='.");
      };
    };
    // Dispatch case.
    node := NODE.new_cast position type typ_cast with val;
    list_current.add_last node;
    // Assignment result.
    affect nm with (node.result_expr)
    // Value result.
    //assign.to_run_expr
  );