home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / e_check.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  3.0 KB  |  129 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_CHECK
  17.    --
  18.    -- Instruction "check ... end;".
  19.    --
  20.    
  21. inherit INSTRUCTION redefine is_pre_computable end;
  22.  
  23. creation make
  24.  
  25. feature 
  26.       
  27.    check_invariant: CHECK_INVARIANT;
  28.    
  29. feature 
  30.       
  31.    make(sp: like start_position; hc: COMMENT; l: ARRAY[ASSERTION]) is
  32.       require
  33.      sp /= Void;
  34.      not l.empty;
  35.       do
  36.      !!check_invariant.make(sp,hc,l);
  37.       ensure
  38.      start_position = sp;
  39.      check_invariant.list = l;
  40.       end; 
  41.    
  42. feature
  43.  
  44.    end_mark_comment: BOOLEAN is true;
  45.  
  46. feature
  47.    
  48.    start_position: POSITION is
  49.      -- Of keyword "check".
  50.       do
  51.      Result := check_invariant.start_position;
  52.       end;
  53.    
  54.    to_runnable(rc: like run_compound): like Current is
  55.       local
  56.      al: like check_invariant;
  57.       do
  58.      if run_compound = Void then
  59.         run_compound := rc;
  60.         if run_control.all_check then
  61.            al := check_invariant.to_runnable(rc.current_type);
  62.            if al = Void then
  63.           error(start_position,"Bad check list.");
  64.            else
  65.           check_invariant := al;
  66.           Result := Current;
  67.            end;
  68.         else
  69.            Result := Current;
  70.         end;
  71.      else
  72.         !!Result.make(start_position,Void,check_invariant.list);
  73.         Result := Result.to_runnable(rc);
  74.      end;
  75.       end;
  76.    
  77.    afd_check is   
  78.       do
  79.      if run_control.all_check then
  80.         check_invariant.afd_check;
  81.      end;
  82.       end;
  83.    
  84.    compile_to_c is   
  85.       do
  86.      if run_control.all_check then
  87.         check_invariant.compile_to_c;
  88.      end;
  89.       end;
  90.    
  91.    compile_to_jvm is
  92.       do
  93.      if run_control.all_check then
  94.         check_invariant.compile_to_jvm(true);
  95.      end;
  96.       end;
  97.    
  98.    is_pre_computable: BOOLEAN is 
  99.       do
  100.      if run_control.all_check then
  101.         Result := check_invariant.is_pre_computable;
  102.      else
  103.         Result := true;
  104.      end;
  105.       end;
  106.  
  107.    use_current: BOOLEAN is   
  108.       do
  109.      if run_control.all_check then
  110.         Result := check_invariant.use_current;
  111.      end;
  112.       end;
  113.    
  114.    pretty_print is
  115.       do
  116.      check_invariant.pretty_print;
  117.      fmt.put_string("end;");
  118.      if fmt.print_end_check then
  119.         fmt.put_end("check");
  120.      end;
  121.       end;
  122.  
  123. invariant
  124.    
  125.    check_invariant /= Void;
  126.  
  127. end -- E_CHECK
  128.  
  129.