home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sa104os2.zip / SATHR104.ZIP / SATHER / COMPILER / CS.SA < prev    next >
Text File  |  1994-12-10  |  3KB  |  87 lines

  1. -- Copyright (C) International Computer Science Institute, 1994.  COPYRIGHT  --
  2. -- NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY and is subject --
  3. -- to the terms of the SATHER LIBRARY GENERAL PUBLIC LICENSE contained in    --
  4. -- the file "Doc/License" of the Sather distribution.  The license is also   --
  5. -- available from ICSI, 1947 Center St., Suite 600, Berkeley CA 94704, USA.  --
  6. --------> Please email comments to "sather-bugs@icsi.berkeley.edu". <----------
  7.  
  8. class CS is
  9.    -- The 1.0 compiler.
  10.    
  11.    main(a:ARRAY{STR}):INT is
  12.       -- Compile a program. The the first command line arguments should 
  13.       -- be the name of the class with `main' in it. The rest should be
  14.       -- the names of the source files to look at. 
  15.  
  16.       p:PROG:=PROG::create; 
  17.  
  18.       -- Handle the command line options and SATHER_COMMANDS
  19.       p.options.interpret(a);
  20.  
  21.       if p.options.force_all or ~p.options.force_routines.is_empty then
  22.       p.err("-force options not implemented");
  23.       end;
  24.  
  25.       if ~p.options.externals.is_empty then
  26.       p.err("-external option not implemented");
  27.       end;
  28.  
  29.       if p.options.verbose then #OUT + p.options.str +"\n\n"; end;
  30.  
  31.       p.create_back_end;
  32.  
  33.       if p.options.verbose then #OUT + "Parsing...\n"; end;
  34.       loop
  35.       fn::=p.options.sather_files.elt!;
  36.       if ~p.options.known_files.test(fn) then
  37.           p.prog_parse.parse(fn);
  38.       end;
  39.       end;
  40.       if p.err_seen then return 1 end;
  41.       if p.options.only_parse then return 0; end;
  42.  
  43.       if p.options.verbose then #OUT + "Finding types...\n"; end;
  44.       p.do_find_types_phase;
  45.       if p.err_seen then return 2 end;
  46.  
  47.       if p.options.verbose then #OUT + "Constructing type graph...\n"; end;
  48.       p.do_type_graph_phase;
  49.       if p.err_seen then return 3 end;      
  50.  
  51.       if p.options.verbose then #OUT + "Checking conformance...\n"; end;
  52.       p.do_ifc_conformance_phase;
  53.       if p.err_seen then return 4 end;            
  54.  
  55.       if p.options.verbose then #OUT + "Finding main...\n"; end;
  56.       p.do_get_main_phase(p.options.main_class);
  57.       if p.err_seen then return 5 end;                  
  58.  
  59.       if ~p.options.only_check then
  60.       if p.options.verbose then #OUT + "Generating structs...\n"; end;
  61.       p.back_end.init;
  62.       if p.err_seen then return 6 end;                  
  63.       end;
  64.  
  65.       if p.options.verbose then #OUT + "Type check and generate...\n"; end;
  66.       p.do_am_generate_phase;
  67.       if p.err_seen then return 7 end;                        
  68.  
  69.       if ~p.options.only_check then
  70.       if p.options.verbose then #OUT + "Cleaning up...\n"; end;
  71.       p.finalize_back_end;      
  72.       if p.err_seen then return 8 end;                        
  73.       end;
  74.       if p.options.only_reachable then return 0; end;
  75.  
  76.       if p.options.verbose then #OUT + "Checking unreachable code...\n"; end;
  77.       p.do_am_check_phase;
  78.       if p.err_seen then return 9 end;                        
  79.  
  80.       if p.options.verbose then #OUT + "Compilation complete.\n"; end;
  81.       return 0;
  82.    end;
  83.    
  84. end; 
  85.    
  86. -------------------------------------------------------------------   
  87.