home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / routine.e < prev    next >
Text File  |  1999-06-05  |  4KB  |  141 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. deferred class ROUTINE
  17. --
  18. -- Root class for all sort of routines : function, procedure,
  19. -- external function/procedure, deferred function/procedure and
  20. -- once function/procedure.
  21. --
  22. --
  23.  
  24. inherit E_FEATURE redefine  set_header_comment end;
  25.  
  26. feature
  27.  
  28.    arguments: FORMAL_ARG_LIST;
  29.  
  30.    obsolete_mark: MANIFEST_STRING;
  31.  
  32.    require_assertion: E_REQUIRE;
  33.  
  34.    ensure_assertion: E_ENSURE;
  35.  
  36.    end_comment: COMMENT;
  37.  
  38. feature {NONE}
  39.  
  40.    make_routine(n: like names;
  41.                 fa: like arguments;
  42.                 om: like obsolete_mark;
  43.                 hc: like header_comment;
  44.                 ra: like require_assertion) is
  45.       do
  46.          make_e_feature(n);
  47.          header_comment := hc;
  48.          arguments := fa;
  49.          obsolete_mark := om;
  50.          require_assertion := ra;
  51.       end;
  52.  
  53. feature
  54.  
  55.    pretty_print is
  56.       local
  57.          fn: FEATURE_NAME;
  58.       do
  59.          fmt.indent;
  60.          pretty_print_profile;
  61.          fmt.keyword(fz_is);
  62.          if obsolete_mark /= Void then
  63.             fmt.set_indent_level(2);
  64.             fmt.indent;
  65.             fmt.keyword(fz_obsolete);
  66.             obsolete_mark.pretty_print;
  67.          end;
  68.          fmt.set_indent_level(2);
  69.          fmt.indent;
  70.          if header_comment /= Void then
  71.             header_comment.pretty_print;
  72.          end;
  73.          if require_assertion /= Void then
  74.             fmt.set_indent_level(2);
  75.             require_assertion.pretty_print;
  76.          end;
  77.          fmt.set_indent_level(2);
  78.          fmt.indent;
  79.          pretty_print_routine_body;
  80.          if ensure_assertion /= Void then
  81.             fmt.set_indent_level(2);
  82.             ensure_assertion.pretty_print;
  83.          end;
  84.          pretty_print_rescue;
  85.          fmt.set_indent_level(2);
  86.          fmt.indent;
  87.          fmt.keyword(fz_end);
  88.          if end_comment /= Void and then not end_comment.dummy then
  89.             end_comment.pretty_print;
  90.          elseif fmt.print_end_routine then
  91.             fmt.put_string("-- ");
  92.             fn := first_name;
  93.             fn.declaration_pretty_print;
  94.          end;
  95.          fmt.set_indent_level(1);
  96.          fmt.put_character('%N');
  97.       end;
  98.  
  99.    set_header_comment(hc: like header_comment) is
  100.       -- Is the `end_comment' for routines.
  101.       do
  102.          if hc /= Void and then hc.count > 1 then
  103.             end_comment := hc;
  104.          end;
  105.       end;
  106.  
  107. feature {EIFFEL_PARSER}
  108.  
  109.    set_ensure_assertion(ea: like ensure_assertion) is
  110.       do
  111.          ensure_assertion := ea;
  112.       ensure
  113.          ensure_assertion = ea;
  114.       end;
  115.  
  116.    set_rescue_compound(c: COMPOUND) is
  117.       deferred
  118.       end;
  119.  
  120. feature {NONE}
  121.  
  122.    frozen pretty_print_arguments is
  123.       do
  124.          if arguments /= Void then
  125.             arguments.pretty_print;
  126.          end;
  127.       end;
  128.  
  129.    pretty_print_routine_body is
  130.       require
  131.          fmt.indent_level = 2;
  132.       deferred
  133.       end;
  134.  
  135.    pretty_print_rescue is
  136.       deferred
  137.       end;
  138.  
  139. end -- ROUTINE
  140.  
  141.