home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / e_ensure.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  3.9 KB  |  146 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. class E_ENSURE
  17.    --
  18.    -- To store a `ensure' clause.
  19.    --
  20.    
  21. inherit ASSERTION_LIST;
  22.          
  23. creation 
  24.    make, from_runnable 
  25.  
  26. feature 
  27.    
  28.    is_ensure_then: BOOLEAN;
  29.            
  30.    set_ensure_then is
  31.       do
  32.      is_ensure_then := true;
  33.       end;
  34.      
  35.    
  36.    name: STRING is
  37.       do
  38.      if is_ensure_then then
  39.         Result := "ensure then";
  40.         else
  41.         Result := "ensure";
  42.      end;
  43.       end;
  44.    
  45.    compile_to_c_old is
  46.      -- Produce declaration and initialization for `old' expressions.
  47.       local
  48.      i: INTEGER;
  49.       do
  50.      if list /= Void then
  51.         from  
  52.            i := list.lower;
  53.         until
  54.            i > list.upper
  55.         loop
  56.            list.item(i).compile_to_c_old;
  57.            i := i + 1;
  58.         end;
  59.      end;
  60.       end;
  61.    
  62.    compile_to_jvm_old is
  63.      -- If needed, add some more local variable to store the 
  64.      -- result of Eiffel "old".
  65.       local
  66.      i: INTEGER;
  67.       do
  68.      if list /= Void then
  69.         from  
  70.            i := list.lower;
  71.         until
  72.            i > list.upper
  73.         loop
  74.            list.item(i).compile_to_jvm_old;
  75.            i := i + 1;
  76.         end;
  77.      end;
  78.       end;
  79.    
  80.    short is
  81.       local
  82.      i: INTEGER;
  83.       do
  84.      short_print.hook_or("hook511","      ensure%N");
  85.      if header_comment = Void then
  86.         short_print.hook_or("hook512","");
  87.      else
  88.         short_print.hook_or("hook513","");
  89.         header_comment.short("hook514","         -- ","hook515","%N");
  90.         short_print.hook_or("hook516","");
  91.      end;
  92.      if list = Void then
  93.         short_print.hook_or("hook517","");
  94.      else
  95.         short_print.hook_or("hook518","");
  96.         from  
  97.            i := 1;
  98.         until
  99.            i = list.upper          
  100.         loop
  101.            list.item(i).short("hook519","         ", -- before each assertion
  102.                   "hook520","", -- no tag
  103.                   "hook521","", -- before tag
  104.                   "hook522",": ", -- after tag
  105.                   "hook523","", -- no expression
  106.                   "hook524","", -- before expression
  107.                   "hook525",";", -- after expression except last
  108.                   "hook526","%N", -- no comment
  109.                   "hook527","", -- before comment
  110.                   "hook528"," -- ", -- comment begin line
  111.                   "hook529","%N", -- comment end of line
  112.                   "hook530","", -- after comment
  113.                   "hook531",""); -- end of each assertion
  114.  
  115.            i := i + 1;
  116.         end;
  117.         list.item(i).short("hook519","         ", -- before each assertion
  118.                    "hook520","", -- no tag
  119.                    "hook521","", -- before tag
  120.                    "hook522",": ", -- after tag
  121.                    "hook523","", -- no expression
  122.                    "hook524","", -- before expression
  123.                    "hook532","", -- after expression except last
  124.                    "hook526","%N", -- no comment
  125.                    "hook527","", -- before comment
  126.                    "hook528"," -- ", -- comment begin line
  127.                    "hook529","%N", -- comment end of line
  128.                    "hook530","", -- after comment
  129.                    "hook531","");
  130.         short_print.hook_or("hook533","");
  131.      end;
  132.      short_print.hook_or("hook534","");
  133.       ensure
  134.      fmt.indent_level = old fmt.indent_level;
  135.       end;
  136.  
  137. feature {NONE}
  138.    
  139.    check_assertion_mode: STRING is
  140.       do
  141.      Result := "ens";
  142.       end;
  143.    
  144. end -- E_ENSURE
  145.  
  146.