home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / compile_to_jvm.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  4.3 KB  |  171 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 COMPILE_TO_JVM -- The command.
  17.  
  18. inherit COMPILE_TO;
  19.    
  20. creation make
  21.    
  22. feature 
  23.    
  24.    make is
  25.       do
  26.      start_proc := us_make;
  27.      eiffel_parser.set_drop_comments;
  28.      if argument_count < 1 then
  29.         std_error.put_string("Bad use of command `compile_to_jvm'.%N");
  30.         print_help("compile_to_jvm");
  31.         die_with_code(exit_failure_code);
  32.      else
  33.         automat;
  34.      end;
  35.       end;
  36.    
  37. feature {NONE}
  38.    
  39.    automat is
  40.       local
  41.      arg: INTEGER;
  42.      a: STRING;
  43.      -- state 0  : nothing done.
  44.      -- state 1  : Root class name read.
  45.      -- state 2  : "-cecil" read.
  46.      -- state 3  : "-o" read.
  47.      -- ...
  48.      -- ...
  49.      -- state 8  : end.
  50.      -- state 9  : error.
  51.       do
  52.      from  
  53.         arg := 1;
  54.      until
  55.         arg > argument_count or else state > 7
  56.      loop
  57.         a := argument(arg);
  58.         inspect 
  59.            state
  60.         when 0 then
  61.            if a.item(1) /= '-' then
  62.           root_class := a;
  63.           run_control.set_root_class(a);
  64.           state := 1;
  65.            elseif ("-boost").is_equal(a) then
  66.           if level /= Void then
  67.              error_level(a);
  68.           else
  69.              run_control.set_boost;
  70.              level := a;
  71.           end;
  72.            elseif ("-no_check").is_equal(a) then
  73.           if level /= Void then
  74.              error_level(a);
  75.           else
  76.              run_control.set_no_check;
  77.              level := a;
  78.           end;
  79.            elseif ("-require_check").is_equal(a) then
  80.           if level /= Void then
  81.              error_level(a);
  82.           else
  83.              run_control.set_require_check;
  84.              level := a;
  85.           end;
  86.            elseif ("-ensure_check").is_equal(a) then
  87.           if level /= Void then
  88.              error_level(a);
  89.           else
  90.              run_control.set_ensure_check;
  91.              level := a;
  92.           end;
  93.            elseif ("-invariant_check").is_equal(a) then
  94.           if level /= Void then
  95.              error_level(a);
  96.           else
  97.              run_control.set_invariant_check;
  98.              level := a;
  99.           end;
  100.            elseif ("-loop_check").is_equal(a) then
  101.           if level /= Void then
  102.              error_level(a);
  103.           else
  104.              run_control.set_loop_check;
  105.              level := a;
  106.           end;
  107.            elseif ("-all_check").is_equal(a) then
  108.           if level /= Void then
  109.              error_level(a);
  110.           else
  111.              run_control.set_all_check;
  112.              level := a;
  113.           end;
  114.            elseif ("-debug_check").is_equal(a) then
  115.           if level /= Void then
  116.              error_level(a);
  117.           else
  118.              run_control.set_debug_check;
  119.              level := a;
  120.           end;
  121.            elseif ("-no_warning").is_equal(a) then
  122.           eh.set_no_warning;
  123.            elseif ("-verbose").is_equal(a) then
  124.           echo.set_verbose;
  125.            elseif ("-trace").is_equal(a) then
  126.           run_control.set_trace;
  127.            elseif ("-cecil").is_equal(a) then
  128.           state := 2;
  129.            elseif ("-o").is_equal(a) then
  130.           state := 3;
  131.            else
  132.           eh.append("compile_to_jvm: unknown flag %"");
  133.           eh.append(a);
  134.           eh.append("%".");
  135.           eh.print_as_error;
  136.           state := 9;
  137.            end;
  138.         when 1 then
  139.            if a.item(1) = '-' then
  140.           arg := arg - 1;
  141.            else
  142.           start_proc := a;
  143.            end;
  144.            state := 0;
  145.         when 2 then
  146.            run_control.set_cecil_path(a);
  147.            state := 0;
  148.         when 3 then
  149.            jvm.set_output_name(a);
  150.            state := 0;
  151.         end;
  152.         arg := arg + 1;
  153.      end;
  154.      if nb_errors = 0 then
  155.         if run_control.trace then 
  156.            if run_control.boost then
  157.           run_control.set_no_check
  158.            end;
  159.         end;
  160.         small_eiffel.compile_to_jvm(root_class,start_proc);
  161.      end;
  162.       end;
  163.  
  164.    command_name: STRING is
  165.       do
  166.      Result := us_compile_to_jvm;
  167.       end;
  168.  
  169. end -- COMPILE_TO_JVM -- The command.
  170.  
  171.