Code coverage for itm_local.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_LOCAL;

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


  - author      := "Sonntag Benoit (bsonntag@loria.fr)";
  - comment     := "Local declaration slot";

Section Inherit

  + parent_itm_object:Expanded ITM_OBJECT;

Section Public

  //
  // Data
  //

  + type:ITM_TYPE_MONO;

  + name:STRING_CONSTANT;

  //
  // Constructor
  //

  - create p:POSITION name n:STRING_CONSTANT :SELF <-
  ( + result:SELF;
    result := clone;
    result.make p name n;
    result
  );

  - create p:POSITION name n:STRING_CONSTANT type t:ITM_TYPE_MONO :SELF <-
  ( + result:SELF;
    result := clone;
    result.make p name n;
    result.set_type t;
    result
  );

  - make p:POSITION name n:STRING_CONSTANT <-
  (
    name     := n;
    position := p;
  );

  //
  // Set
  //

  - set_type t:ITM_TYPE_MONO <-
  (
    type := t;
  );

  //
  // Runnable
  //

  - to_run:LOCAL <-
  ( + pos:POSITION;
    + result:LOCAL;

    last_position := position;
    result := LOCAL.create position name name style '+' type (type.to_run_for profil_slot);
    last_position := pos;
    result
  );

  - to_run_static:LOCAL <-
  // Static local slot.
  ( + result:LOCAL;
    + slot:ITM_SLOT;
    + larg:FAST_ARRAY(ITM_ARGUMENT);
    + arg:ITM_ARGUMENT;
    + proto:PROTOTYPE;

    (type = ITM_TYPE_SIMPLE.type_self).if {
      semantic_error (position,"Type `SELF' is not possible for `-' style local.");
    };
    result := LOCAL.create position name name style '-' type (type.to_run_for profil_slot);
    //
    proto := position.prototype;
    slot := proto.first_slot;
    {(slot != NULL)    {slot.position != position}}.while_do {
      slot := slot.next;
    };
    (slot = NULL).if {
      slot := ITM_SLOT.create position name (result.intern_name)
      feature (SECTION_.get_name (ALIAS_STR.section_private));
      slot.set_style '-';
      slot.set_result_type type;
      larg := ALIAS_ARRAY(ITM_ARGUMENT).new;
      arg := ITM_ARG.create position name (ALIAS_STR.variable_self)
      type (ITM_TYPE_SIMPLE.type_self);
      larg.add_last arg;
      larg := ALIAS_ARRAY(ITM_ARGUMENT).copy larg;
      slot.set_argument_list larg;
      proto.add_slot slot;
    } else {
      result.set_intern_name (slot.name);
    };
    //
    result
  );

  //
  // Display.
  //

  - append_in buffer:STRING <-
  (
    buffer.append name;
    buffer.add_last ':';
    type.append_in buffer;
  );