home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / effective_routine.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  101 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 EFFECTIVE_ROUTINE
  17.    --
  18.    -- Such a routine can have local variables.
  19.    --
  20.  
  21. inherit ROUTINE;
  22.  
  23. feature
  24.  
  25.    is_deferred: BOOLEAN is false;
  26.  
  27. feature
  28.  
  29.    local_vars: LOCAL_VAR_LIST;
  30.  
  31.    routine_body: COMPOUND;
  32.  
  33.    rescue_compound: COMPOUND;
  34.  
  35. feature
  36.  
  37.    frozen set_rescue_compound(c: like rescue_compound) is
  38.       do
  39.          rescue_compound := c;
  40.       ensure
  41.          rescue_compound = c;
  42.       end;
  43.  
  44. feature {NONE}
  45.  
  46.    use_current_state: INTEGER;
  47.  
  48.    computed_true: INTEGER is unique;
  49.  
  50.    computed_false: INTEGER is unique;
  51.  
  52.    not_computed: INTEGER is unique;
  53.  
  54.    in_computation: INTEGER is unique;
  55.  
  56.    pretty_print_routine_body is
  57.       do
  58.          if local_vars /= Void then
  59.             local_vars.pretty_print;
  60.          end;
  61.          fmt.indent;
  62.          pretty_print_once_or_do;
  63.          fmt.put_character(' ');
  64.          if routine_body /= Void then
  65.             routine_body.pretty_print;
  66.          end;
  67.       end;
  68.  
  69.    pretty_print_once_or_do is
  70.       deferred
  71.       end;
  72.  
  73.    pretty_print_rescue is
  74.       do
  75.          if rescue_compound /= Void then
  76.             fmt.set_indent_level(2);
  77.             fmt.indent;
  78.             fmt.keyword(fz_rescue);
  79.             rescue_compound.pretty_print;
  80.          end;
  81.       end;
  82.  
  83.    make_effective_routine(n: like names;
  84.                           fa: like arguments;
  85.                           om: like obsolete_mark;
  86.                           hc: like header_comment;
  87.                           ra: like require_assertion;
  88.                           lv: like local_vars;
  89.                           rb: like routine_body) is
  90.       do
  91.          make_routine(n,fa,om,hc,ra);
  92.          local_vars := lv;
  93.          routine_body := rb;
  94.          use_current_state := not_computed;
  95.       ensure
  96.          local_vars = lv;
  97.          routine_body = rb;
  98.       end;
  99.  
  100. end -- EFFECTIVE_ROUTINE
  101.