home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / creation_clause_list.e < prev    next >
Text File  |  1999-06-05  |  4KB  |  149 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  4. --                       http://SmallEiffel.loria.fr
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
  11. -- for  more  details.  You  should  have  received a copy of the GNU General
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class CREATION_CLAUSE_LIST
  17.  
  18. inherit GLOBALS;
  19.  
  20. creation {BASE_CLASS} make
  21.  
  22. feature {CREATION_CLAUSE_LIST}
  23.  
  24.    list: ARRAY[CREATION_CLAUSE];
  25.  
  26. feature {NONE}
  27.  
  28.    make(l: like list) is
  29.       require
  30.          l.lower = 1;
  31.          not l.empty;
  32.       do
  33.          list := l;
  34.       ensure
  35.          list = l;
  36.       end;
  37.  
  38. feature
  39.  
  40.    start_position: POSITION is
  41.       do
  42.          Result := list.first.start_position;
  43.       end;
  44.  
  45.    pretty_print is
  46.       local
  47.          i: INTEGER;
  48.       do
  49.          from
  50.             i := 1;
  51.          until
  52.             i > list.upper
  53.          loop
  54.             list.item(i).pretty_print;
  55.             if not fmt.zen_mode then
  56.                fmt.set_indent_level(0);
  57.                fmt.skip(1);
  58.             end;
  59.             i := i + 1;
  60.          end;
  61.       end;
  62.  
  63.    short: BOOLEAN is
  64.          -- True when at least one creation list is printed.
  65.       local
  66.          i: INTEGER;
  67.       do
  68.          from
  69.             i := 1;
  70.          until
  71.             i > list.upper
  72.          loop
  73.             Result := list.item(i).short(Result) or else Result;
  74.             i := i + 1;
  75.          end;
  76.       end;
  77.  
  78.    get_clause(fn: FEATURE_NAME): CREATION_CLAUSE is
  79.       local
  80.          i: INTEGER;
  81.       do
  82.          from
  83.             i := 1;
  84.          until
  85.             i > list.upper or else list.item(i).has(fn)
  86.          loop
  87.             i := i + 1;
  88.          end;
  89.          if i <= list.upper then
  90.             Result := list.item(i);
  91.          end;
  92.       end;
  93.  
  94. feature {BASE_CLASS}
  95.  
  96.    root_procedure_name(procedure_name: STRING): SIMPLE_FEATURE_NAME is
  97.       local
  98.          i: INTEGER;
  99.       do
  100.          from
  101.             i := list.upper;
  102.          until
  103.             i = 0 or else Result /= Void
  104.          loop
  105.             Result := list.item(i).root_procedure_name(procedure_name);
  106.             i := i - 1;
  107.          end;
  108.       end;
  109.  
  110.    add_last(cc: CREATION_CLAUSE) is
  111.       require
  112.          cc /= Void;
  113.       do
  114.          list.add_last(cc);
  115.       end;
  116.  
  117.    check_expanded_with(t: TYPE) is
  118.       require
  119.          t.is_expanded;
  120.       do
  121.          if list.upper > 1 then
  122.             eh.add_type(t,fz_cbe);
  123.             eh.add_position(list.item(1).start_position);
  124.             eh.add_position(list.item(2).start_position);
  125.             fatal_error_vtec_2;
  126.          end;
  127.          list.item(1).check_expanded_with(t);
  128.       end;
  129.  
  130.    expanded_initializer(t: TYPE): RUN_FEATURE_3 is
  131.       require
  132.          t.is_expanded;
  133.          not t.is_basic_eiffel_expanded
  134.       do
  135.          check
  136.             list.count = 1
  137.          end;
  138.          Result := list.item(1).expanded_initializer(t);
  139.       end;
  140.  
  141. invariant
  142.  
  143.    list.lower = 1;
  144.  
  145.    not list.empty;
  146.  
  147. end -- CREATION_CLAUSE_LIST
  148.  
  149.