Code coverage for itm_type_simple.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_TYPE_SIMPLE;

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


  - author    := "Sonntag Benoit (bsonntag@loria.fr)";
  - comment   := "Simple type";

Section Inherit

  + parent_itm_type_mono:Expanded ITM_TYPE_MONO;

Section ITM_TYPE_SIMPLE, ITM_TYPE_SELF

  - dico:HASHED_DICTIONARY(ITM_TYPE_SIMPLE,STRING_CONSTANT) :=
  HASHED_DICTIONARY(ITM_TYPE_SIMPLE,STRING_CONSTANT).create;

Section ITM_TYPE_SIMPLE

  - create n:STRING_CONSTANT :SELF <-
  ( + result:SELF;

    result := clone;
    result.make n;
    result
  );

  - make n:STRING_CONSTANT <-
  (
    name := n;
    dico.fast_put Self to n;
  );

Section Public

  - type_null:ITM_TYPE_SIMPLE := ITM_TYPE_SIMPLE.get (ALIAS_STR.variable_null);
  - type_void:ITM_TYPE_SIMPLE := ITM_TYPE_SIMPLE.get (ALIAS_STR.variable_void);
  - type_self:ITM_TYPE_SIMPLE := ITM_TYPE_PARAMETER.create (ALIAS_STR.prototype_self);

  - hash_code:INTEGER <- name.hash_code;

  + name:STRING_CONSTANT;

  - style:STRING_CONSTANT; // NULL

  - get n:STRING_CONSTANT :ITM_TYPE_SIMPLE <-
  [
    -? {n != NULL};
  ]
  ( + result:ITM_TYPE_SIMPLE;

    result := dico.fast_reference_at n;
    (result = NULL).if {
      result := create n;
    };
    result
  );

  - to_run_for p:PARAMETER_TO_TYPE :TYPE_FULL <-
  ( + result:TYPE_FULL;
    + path:STRING_CONSTANT;

    (Self = type_null).if {
      result := TYPE_NULL.default;
    }.elseif {Self = type_void} then {
      result := TYPE_VOID.default;
    } else {
      (p != NULL).if {
        path := p.position.prototype.filename;
      } else {
        path := input_path;
      };
      result := TYPE.get (path,Self);
    };
    result
  );

  - append_in buffer:STRING <-
  (
    (style != NULL).if {
      buffer.append style;
      buffer.add_last ' ';
    };
    buffer.append name;
  );

  - shorter_in buf:STRING <-
  (
    (style != NULL).if {
      put style to buf like (ALIAS_STR.short_keyword);
      buf.add_last ' ';
    };
    put name to buf like (ALIAS_STR.short_prototype);
  );

  //
  // Cast.
  //

  - append_cast_name_in buf:STRING <-
  (
    (name.lower).to (name.upper) do { j:INTEGER;
      buf.add_last (name.item j.to_lower);
    };
  );