home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / run_require.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  3.5 KB  |  161 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 RUN_REQUIRE
  17.    -- 
  18.    -- A RUN_REQUIRE is composed with all inherited E_REQUIRE.
  19.    --
  20.    
  21. inherit GLOBALS;
  22.    
  23. creation make
  24.    
  25. feature {NONE}
  26.    
  27.    list: ARRAY[E_REQUIRE];
  28.      -- From bottom to the top of the inheritance graph.
  29.      -- Order is important because one at least must be true 
  30.      -- following bottom up order.
  31.      
  32. feature
  33.  
  34.    make(l: like list) is
  35.       require
  36.      l.lower = 1;
  37.      l.upper >= 1;
  38.       do
  39.      list := l;
  40.       ensure
  41.      list = l;
  42.       end;
  43.  
  44. feature
  45.  
  46.    short is
  47.       local
  48.      i: INTEGER;
  49.       do
  50.      from
  51.         list.item(1).short("hook401","      require%N");
  52.         i := 2;
  53.      until
  54.         i > list.upper
  55.      loop
  56.         list.item(i).short("hook402","      require else %N");
  57.         i := i + 1;
  58.      end;
  59.      short_print.hook("hook403");
  60.       end;
  61.  
  62.    use_current: BOOLEAN is
  63.       local
  64.      i: INTEGER;
  65.       do
  66.      from  
  67.         i := 1;
  68.      until
  69.         Result or else i > list.upper
  70.      loop
  71.         Result := list.item(i).use_current;
  72.         i := i + 1;
  73.      end;
  74.       end;
  75.    
  76.    afd_check is
  77.       local
  78.      i: INTEGER;
  79.       do
  80.      from
  81.         i := list.upper;
  82.      until
  83.         i = 0
  84.      loop
  85.         list.item(i).afd_check;
  86.         i := i - 1;
  87.      end;
  88.       end;
  89.  
  90.    compile_to_c is
  91.       local
  92.      i: INTEGER;
  93.       do
  94.      if run_control.require_check then
  95.         if list.upper = 1 then
  96.            cpp.put_string("se_af_rlc=1;%N")
  97.            list.first.compile_to_c;
  98.         else
  99.            cpp.put_string("se_af_rlc=0;%N")
  100.            cpp.put_string("se_af_rlr=1;%N")
  101.            list.first.compile_to_c; -- ****** 2 fois de suite ??? ****
  102.            from  
  103.           i := 1;
  104.            until
  105.           i > list.upper
  106.            loop
  107.           cpp.put_string("if(!se_af_rlr){se_af_rlr=1;%N")
  108.           list.item(i).compile_to_c;
  109.           cpp.put_string(fz_12)
  110.           i := i + 1;
  111.           if i = list.upper then
  112.              cpp.put_string("se_af_rlc=1;%N")
  113.           end;
  114.            end;
  115.         end;
  116.      end;
  117.       end;
  118.  
  119.    compile_to_jvm is
  120.       local
  121.      i: INTEGER;
  122.      ca: like code_attribute;
  123.       do
  124.      if run_control.require_check then
  125.         ca := code_attribute;
  126.         if list.upper = 1 then
  127.            list.first.compile_to_jvm(true);
  128.         else
  129.            points1.clear;
  130.            from  
  131.           i := 1;
  132.            until
  133.           i > (list.upper - 1)
  134.            loop
  135.           list.item(i).compile_to_jvm(false);
  136.           points1.add_last(ca.opcode_ifne);
  137.           i := i + 1;
  138.            end;
  139.            list.item(i).compile_to_jvm(true);
  140.            ca.resolve_with(points1);
  141.         end;
  142.      end;
  143.       end;
  144.  
  145. feature {NONE}
  146.  
  147.    points1: FIXED_ARRAY[INTEGER] is
  148.      -- To reach the sucessful code.
  149.       once
  150.      !!Result.with_capacity(4);
  151.       end;
  152.    
  153. invariant
  154.    
  155.    list.lower = 1;
  156.    
  157.    not list.empty;
  158.    
  159. end -- RUN_REQUIRE
  160.  
  161.