home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / routine.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  4.1 KB  |  166 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://www.loria.fr/SmallEiffel
  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
  25.    E_FEATURE
  26.       redefine pretty_print_arguments, set_header_comment 
  27.       end;
  28.  
  29. feature {ANY}
  30.  
  31.    arguments: FORMAL_ARG_LIST;
  32.    
  33.    obsolete_mark: MANIFEST_STRING;
  34.       
  35.    require_assertion: E_REQUIRE;
  36.    
  37.    ensure_assertion: E_ENSURE;
  38.    
  39.    rescue_compound: COMPOUND;
  40.    
  41.    end_comment: COMMENT;
  42.    
  43.    pretty_print is
  44.       local
  45.      fn: FEATURE_NAME;
  46.       do
  47.      fmt.set_indent_level(1);
  48.      fmt.indent;
  49.      pretty_print_profile;
  50.      fmt.keyword("is");
  51.      if obsolete_mark /= Void then
  52.         fmt.set_indent_level(2);
  53.         fmt.indent;
  54.         fmt.keyword("obsolete");
  55.         obsolete_mark.pretty_print;
  56.      end;
  57.      fmt.set_indent_level(2);
  58.      fmt.indent;
  59.      if header_comment /= Void then
  60.         header_comment.pretty_print;
  61.      end;
  62.      if require_assertion /= Void then
  63.         fmt.set_indent_level(2);
  64.         require_assertion.pretty_print;
  65.      end;
  66.      fmt.set_indent_level(2);
  67.      fmt.indent;
  68.      pretty_print_routine_body;
  69.      if ensure_assertion /= Void then
  70.         fmt.set_indent_level(2);
  71.         ensure_assertion.pretty_print;
  72.      end;
  73.      if rescue_compound /= Void then
  74.         fmt.set_indent_level(2);
  75.         fmt.indent;
  76.         fmt.keyword("rescue");
  77.         rescue_compound.pretty_print;
  78.      end;
  79.      fmt.set_indent_level(2);
  80.      fmt.indent;
  81.      fmt.keyword("end;");
  82.      if end_comment /= Void and then not end_comment.dummy then
  83.         end_comment.pretty_print;
  84.      elseif fmt.print_end_routine then
  85.         fmt.put_string("-- ");
  86.         fn := first_name;
  87.         fn.definition_pretty_print;
  88.      end;
  89.      fmt.put_character('%N');
  90.       end;
  91.    
  92.    set_header_comment(hc: like header_comment) is
  93.       -- Is the `end_comment' for routines.
  94.       do
  95.      if hc /= Void and then hc.count > 1 then
  96.         end_comment := hc;
  97.      end;
  98.       end;
  99.    
  100. feature {EIFFEL_PARSER}
  101.    
  102.    set_ensure_assertion(ea: like ensure_assertion) is
  103.       do
  104.      ensure_assertion := ea;
  105.       ensure
  106.      ensure_assertion = ea;
  107.       end; 
  108.    
  109.    set_rescue_compound(rc: like rescue_compound) is
  110.       do
  111.      if rc /= Void and then is_deferred then
  112.         error(start_position,
  113.           "Deferred feature must not have rescue compound.");
  114.      end;
  115.      rescue_compound := rc;
  116.       ensure
  117.      rescue_compound = rc;
  118.       end;
  119.  
  120. feature {NONE}
  121.    
  122.    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. feature {NONE}
  136.    
  137.    make_routine(n: like names;
  138.         fa: like arguments; 
  139.         om: like obsolete_mark;
  140.         hc: like header_comment;
  141.         ra: like require_assertion) is
  142.       do
  143.      make_e_feature(n,void);
  144.      header_comment := hc;
  145.      arguments := fa;
  146.      obsolete_mark := om;
  147.          require_assertion := ra;
  148.       end;
  149.  
  150. feature {NONE}
  151.  
  152.    check_obsolete is
  153.       do
  154.      if not small_eiffel.short_flag then
  155.         if obsolete_mark /= Void then
  156.            eh.append("This feature is obsolete :%N%"");
  157.            eh.append(obsolete_mark.to_string);
  158.            warning(start_position,fz_03);
  159.         end
  160.      end;
  161.       end;
  162.  
  163.    
  164. end -- ROUTINE
  165.  
  166.