home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / type_like_argument.e < prev    next >
Text File  |  1999-06-05  |  4KB  |  161 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 TYPE_LIKE_ARGUMENT
  17.    --
  18.    -- For an anchored declaration type mark using a formal argument.
  19.    --
  20.    -- See also TYPE_LIKE and TYPE_LIKE_CURRENT.
  21.    --
  22.  
  23. inherit TYPE_ANCHORED;
  24.  
  25. creation make, with
  26.  
  27. feature
  28.  
  29.    like_what: ARGUMENT_NAME2;
  30.  
  31.    written_mark: STRING;
  32.  
  33. feature {NONE}
  34.  
  35.    run_feature: RUN_FEATURE;
  36.  
  37. feature
  38.  
  39.    is_like_current: BOOLEAN is false;
  40.  
  41.    is_like_argument: BOOLEAN is true;
  42.  
  43.    is_like_feature: BOOLEAN is false;
  44.  
  45.  
  46. feature {NONE}
  47.  
  48.    make(sp: like start_position; lw: like like_what) is
  49.       require
  50.          sp /= Void;
  51.          lw /= Void;
  52.       do
  53.          start_position := sp;
  54.          like_what := lw;
  55.          tmp_written_mark.copy(fz_like);
  56.          tmp_written_mark.extend(' ');
  57.          tmp_written_mark.append(like_what.to_string);
  58.          written_mark := string_aliaser.item(tmp_written_mark);
  59.       ensure
  60.          start_position = sp;
  61.          like_what = lw;
  62.       end;
  63.  
  64.    with(model: like Current; rf: RUN_FEATURE) is
  65.       require
  66.          model /= Void;
  67.          rf /= Void
  68.       do
  69.          start_position := model.start_position;
  70.          like_what := model.like_what;
  71.          written_mark := model.written_mark;
  72.          run_feature := rf;
  73.       ensure
  74.          start_position = model.start_position;
  75.          like_what = model.like_what;
  76.          written_mark = model.written_mark;
  77.          run_feature = rf
  78.       end;
  79.  
  80. feature
  81.  
  82.    static_base_class_name: CLASS_NAME is
  83.       local
  84.          bc: BASE_CLASS;
  85.       do
  86.          bc := like_what.static_result_base_class;
  87.          if bc /= Void then
  88.             Result := bc.name;
  89.          end;
  90.       end;
  91.  
  92.    is_run_type: BOOLEAN is
  93.       do
  94.          if run_feature /= Void then
  95.             Result := run_type.is_run_type;
  96.          end;
  97.       end;
  98.  
  99.    run_type: TYPE is
  100.       local
  101.          fal: FORMAL_ARG_LIST;
  102.       do
  103.          fal := run_feature.arguments;
  104.          Result := fal.type(rank);
  105.          if Result.is_run_type then
  106.             Result := Result.run_type;
  107.          end;
  108.       end;
  109.  
  110.    to_runnable(ct: TYPE): like Current is
  111.       local
  112.          rf: RUN_FEATURE;
  113.          rt: TYPE;
  114.       do
  115.          anchor_cycle_start;
  116.          rf := small_eiffel.top_rf;
  117.          if rf.arguments = Void then
  118.             eh.add_position(start_position);
  119.             eh.add_position(rf.start_position);
  120.             fatal_error(fz_bad_anchor);
  121.          end;
  122.          if run_feature = Void then
  123.             run_feature := rf;
  124.             Result := Current;
  125.          elseif run_feature = rf then
  126.             Result := Current;
  127.          else
  128.             !!Result.with(Current,rf);
  129.          end;
  130.          rt := Result.run_type;
  131.          if rt.is_anchored then
  132.             rt := rt.to_runnable(ct);
  133.          end;
  134.          anchor_cycle_end;
  135.       end;
  136.  
  137.    rank: INTEGER is
  138.       do
  139.          Result := like_what.rank;
  140.       end;
  141.  
  142.    is_a(other: TYPE): BOOLEAN is
  143.       do
  144.          Result := run_type.is_a(other)
  145.       end;
  146.  
  147. feature {TYPE}
  148.  
  149.    short_hook is
  150.       do
  151.          short_print.hook_or("like","like ");
  152.          like_what.short;
  153.       end;
  154.  
  155. invariant
  156.  
  157.    as_current /= like_what.to_string;
  158.  
  159. end -- TYPE_LIKE_ARGUMENT
  160.  
  161.