home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / globals.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  22.8 KB  |  1,035 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. deferred class GLOBALS
  17.    --   
  18.    -- Global Tools for the SmallEiffel system.
  19.    --
  20.  
  21. inherit 
  22.    UNIQUE_STRING_LIST;
  23.    FROZEN_STRING_LIST;
  24.    
  25. feature {NONE} -- Unique Globals objects :
  26.       
  27.    frozen small_eiffel: SMALL_EIFFEL is
  28.      -- The SmallEiffel system himself.
  29.       once
  30.      !!Result.make;
  31.       end; 
  32.    
  33.    frozen parser_buffer: PARSER_BUFFER is
  34.       once
  35.      !!Result.make;
  36.       end;
  37.  
  38.    frozen eiffel_parser : EIFFEL_PARSER is
  39.      -- The Eiffel Parser.
  40.       once
  41.      !!Result.make;
  42.       end; 
  43.  
  44.    frozen unique_string: UNIQUE_STRING is 
  45.      -- To share STRINGs.
  46.       once
  47.      !!Result.make;
  48.       end;
  49.  
  50.    frozen id_provider: ID_PROVIDER is 
  51.       once
  52.      !!Result.make;
  53.       end;
  54.  
  55.    frozen manifest_string_pool: MANIFEST_STRING_POOL is 
  56.       once 
  57.      !!Result;
  58.       end;
  59.  
  60.    frozen manifest_array_pool: MANIFEST_ARRAY_POOL is 
  61.       once 
  62.      !!Result;
  63.       end;
  64.  
  65.    frozen once_routine_pool: ONCE_ROUTINE_POOL is 
  66.       once 
  67.      !!Result;
  68.       end;
  69.  
  70.    frozen cecil_pool: CECIL_POOL is 
  71.       once 
  72.      !!Result;
  73.       end;
  74.  
  75.    frozen fmt: FMT is
  76.       -- For the command `pretty'.
  77.       once
  78.      !!Result.make;
  79.       end;
  80.  
  81.    frozen short_print: SHORT_PRINT is
  82.       once
  83.      !!Result.make;
  84.       end;
  85.    
  86.    frozen eh: ERROR_HANDLER is
  87.      -- To report errors or warning in Eiffel code.
  88.       once
  89.      !!Result.make
  90.       end;
  91.  
  92.    frozen echo: ECHO is
  93.      -- To report errors during a process.
  94.       once
  95.      !!Result.make;
  96.       end;
  97.    
  98.    frozen run_control: RUN_CONTROL is
  99.      -- To set or to know run-time options.
  100.       once
  101.      !!Result.make;
  102.       end;
  103.    
  104.    frozen switch_collection: SWITCH_COLLECTION is
  105.      -- Handling of the switch collection.
  106.       once 
  107.       end;
  108.  
  109.    frozen cpp: C_PRETTY_PRINTER is
  110.      -- To print the C code.
  111.       once
  112.      !!Result.make;
  113.       end;
  114.    
  115.    frozen gc_handler: GC_HANDLER is
  116.       once
  117.      !!Result.make;
  118.       end;
  119.  
  120.    frozen jvm: JVM is
  121.      -- To print the Java Virtual Machine code.
  122.       once
  123.      !!Result.make;
  124.       end;
  125.  
  126.    frozen constant_pool: CONSTANT_POOL is
  127.      -- To print the Java Virtual Machine code.
  128.       once
  129.      !!Result;
  130.       end;
  131.  
  132.    frozen field_info: FIELD_INFO is
  133.      -- To handle a JVM field_info.
  134.       once
  135.      !!Result;
  136.       end;
  137.  
  138.    frozen code_attribute: CODE_ATTRIBUTE is
  139.      -- To handle a JVM Code_attribute_info.
  140.       once
  141.      !!Result;
  142.       end;
  143.  
  144.    frozen method_info: METHOD_INFO is
  145.      -- To handle a JVM method_info.
  146.       once
  147.      !!Result;
  148.       end;
  149.  
  150. feature {NONE} ------------------------------------------------------------
  151.    -- Warning/Error/Fatal Error handling.
  152.    --
  153.    
  154.    nb_errors: INTEGER is
  155.       do
  156.      Result := eh.nb_errors;
  157.       ensure
  158.      Result >= 0
  159.       end;
  160.    
  161.    nb_warnings: INTEGER is
  162.       do
  163.      Result := eh.nb_warnings;
  164.       ensure
  165.      Result >= 0
  166.       end;
  167.    
  168.    warning(p: POSITION; msg: STRING) is
  169.      -- Warning `msg' at position `p'.
  170.       require
  171.      not msg.empty
  172.       do
  173.      eh.add_position(p);
  174.      eh.warning(msg);
  175.       ensure
  176.      nb_warnings = old nb_warnings + 1
  177.       end;
  178.    
  179.    error(p: POSITION; msg: STRING) is
  180.      -- When error `msg' occurs at position `p'.
  181.       require
  182.      not msg.empty
  183.       do
  184.      eh.add_position(p);
  185.      eh.error(msg);
  186.       ensure
  187.      nb_errors = old nb_errors + 1
  188.       end;
  189.    
  190.    fatal_error(msg: STRING) is
  191.      -- Should not append but it is better to know :-)
  192.       require
  193.      not msg.empty
  194.       do
  195.      eh.fatal_error(msg);
  196.       end;
  197.    
  198. feature {NONE} -- Miscellaneous information :
  199.    
  200.    small_eiffel_directory: STRING is
  201.      -- Compute the good one using the environment 
  202.      -- variable if any.
  203.       local
  204.      i: INTEGER;
  205.      slash: CHARACTER;
  206.       once
  207.      Result := get_environment_variable(fz_se);
  208.      if Result = Void then
  209.         Result := fz_se.twin;
  210.         Result.to_upper;
  211.         Result := get_environment_variable(Result);
  212.         if Result /= Void then
  213.            fz_se.to_upper;
  214.         end;
  215.      end;
  216.      if Result = Void then
  217.         Result := "/usr/local/logiciel/SmallEiffel";
  218.      end;
  219.      from  
  220.         i := Result.count;
  221.      until
  222.         i < 0
  223.      loop
  224.         slash := Result.item(i);
  225.         if slash.is_letter or else slash.is_digit then
  226.            i := i - 1;
  227.         else
  228.            i := -1;
  229.         end;
  230.      end;
  231.      if i = 0 then
  232.         Result.extend('/');
  233.      elseif not (Result.last = slash) then
  234.         Result.extend(slash);
  235.      end;
  236.       ensure
  237.      not Result.last.is_letter;
  238.      not Result.last.is_digit;
  239.       end;
  240.    
  241.    add_directory(path, dir: STRING) is
  242.       require
  243.      path.count > 0;
  244.      dir.count > 0
  245.       do
  246.      if unix_system = system_name then
  247.         path.set_last('/');
  248.         path.append(dir);
  249.         path.set_last('/');
  250.      elseif windows_system = system_name then
  251.         path.set_last('\');
  252.         path.append(dir);
  253.         path.set_last('\');
  254.      elseif macintosh_system = system_name then
  255.         path.set_last(':');
  256.         path.append(dir);
  257.         path.set_last(':');
  258.      elseif dos_system = system_name then
  259.         path.set_last('\');
  260.         path.append(dir);
  261.         path.set_last('\');
  262.      elseif os2_system = system_name then
  263.         path.set_last('\');
  264.         path.append(dir);
  265.         path.set_last('\');
  266.      elseif amiga_system = system_name then
  267.         path.set_last('/');
  268.         path.append(dir);
  269.         path.set_last('/');
  270.      elseif vms_system = system_name then
  271.         path.set_last(']');
  272.         path.remove_last(1);
  273.         path.set_last('.');
  274.         path.append(dir);
  275.         path.set_last(']');
  276.      end;
  277.       end;
  278.       
  279.      start_directory(path, dir: STRING) is
  280.          -- Start a new path from scratch.
  281.       require
  282.      path /= Void;
  283.      dir.count > 0
  284.       do
  285.      path.clear;
  286.      if unix_system = system_name then
  287.         path.append(dir);
  288.         path.set_last('/');
  289.      elseif windows_system = system_name then
  290.         path.append(dir);
  291.         path.set_last('\');
  292.      elseif macintosh_system = system_name then
  293.         path.append(dir);
  294.         path.set_last(':');
  295.      elseif dos_system = system_name then
  296.         path.append(dir);
  297.         path.set_last('\');
  298.      elseif os2_system = system_name then
  299.         path.append(dir);
  300.         path.set_last('\');
  301.      elseif amiga_system = system_name then
  302.         path.append(dir);
  303.         path.set_last('/');
  304.      elseif vms_system = system_name then
  305.         path.set_last('[');
  306.         path.append(dir);
  307.         path.set_last(']');
  308.      end;
  309.       end;
  310.       
  311. feature {NONE} -- Common globals buffers :
  312.  
  313.    tmp_path: STRING is
  314.       once
  315.      !!Result.make(256);
  316.       end;
  317.  
  318.    tmp_file_read: STD_FILE_READ is
  319.       once
  320.      !!Result.make;
  321.       end;
  322.    
  323.    help_file_name: STRING is
  324.       once
  325.      !!Result.make(256);
  326.       end;
  327.  
  328.    print_help(name: STRING) is
  329.       do
  330.      help_file_name.copy(small_eiffel_directory);
  331.      add_directory(help_file_name,"man");
  332.      help_file_name.append(name);
  333.      if not help_file_name.has_suffix(help_suffix) then
  334.         help_file_name.append(help_suffix);
  335.      end;
  336.      if not file_exists(help_file_name) then
  337.         echo.w_put_string("Unable to find help file %"");
  338.         echo.w_put_string(help_file_name);
  339.         echo.w_put_string(fz_b0);
  340.         die_with_code(exit_failure_code);
  341.      end;
  342.      std_output.append_file(help_file_name);
  343.       end;
  344.    
  345.    more_help(cmd: STRING) is
  346.       do
  347.      echo.w_put_string("Type help file for :");
  348.      echo.w_put_string(cmd);
  349.      echo.w_put_string(" (y/n) ? ");
  350.      std_input.read_character;
  351.      inspect
  352.         std_input.last_character
  353.      when 'y','Y' then
  354.         print_help(cmd);
  355.      else
  356.      end;
  357.       end;
  358.  
  359. feature {NONE} -- Globals implicits expressions :
  360.    
  361.    e_void: E_VOID is
  362.       once
  363.      !!implicit;
  364.       end;
  365.    
  366.    class_with(str: STRING): BASE_CLASS is
  367.       require
  368.      not str.empty;
  369.       do
  370.      Result := small_eiffel.get_class(str);
  371.       end;
  372.    
  373.    class_any: BASE_CLASS is
  374.       once
  375.      Result := class_with(us_any);
  376.       end;
  377.    
  378.    class_general: BASE_CLASS is
  379.       once
  380.      Result := class_with(us_general);
  381.       end;
  382.    
  383. feature {NONE} -- Globals implicits types :
  384.    
  385.    type_boolean_ref: TYPE_CLASS is
  386.       local
  387.      boolean_ref: CLASS_NAME;
  388.       once
  389.      !!boolean_ref.make(us_boolean_ref,Void);
  390.      !!Result.make(boolean_ref);
  391.       end;
  392.    
  393.    type_character_ref: TYPE_CLASS is
  394.       local
  395.      character_ref: CLASS_NAME;
  396.       once
  397.      !!character_ref.make(us_character_ref,Void);
  398.      !!Result.make(character_ref);
  399.       end;
  400.    
  401.    type_integer_ref: TYPE_CLASS is
  402.       local
  403.      integer_ref: CLASS_NAME;
  404.       once
  405.      !!integer_ref.make(us_integer_ref,Void);
  406.      !!Result.make(integer_ref);
  407.       end;
  408.    
  409.    type_real_ref: TYPE_CLASS is
  410.       local
  411.      real_ref: CLASS_NAME;
  412.       once
  413.      !!real_ref.make(us_real_ref,Void);
  414.      !!Result.make(real_ref);
  415.       end;
  416.    
  417.    type_double_ref: TYPE_CLASS is
  418.       local
  419.      double_ref: CLASS_NAME;
  420.       once
  421.      !!double_ref.make(us_double_ref,Void);
  422.      !!Result.make(double_ref);
  423.       end;
  424.    
  425.    type_pointer_ref: TYPE_CLASS is
  426.       local
  427.      pointer_ref: CLASS_NAME;
  428.       once
  429.      !!pointer_ref.make(us_pointer_ref,Void);
  430.      !!Result.make(pointer_ref);
  431.       end;
  432.    
  433.    type_boolean: TYPE_BOOLEAN is
  434.       once
  435.      !!Result.make(Void);
  436.       end;
  437.    
  438.    type_string: TYPE_STRING is
  439.       once
  440.      !!Result.make(Void);
  441.       end;
  442.    
  443.    type_any: TYPE_ANY is
  444.       once
  445.      !!Result.make(Void);
  446.       end;
  447.  
  448.    type_general: TYPE_CLASS is
  449.       once
  450.      !!Result.make(class_with(us_general).base_class_name);
  451.       end;
  452.  
  453.    type_none: TYPE_NONE is
  454.       once
  455.      !!Result.make(Void);
  456.       end;
  457.  
  458.    type_pointer: TYPE_POINTER is
  459.       once
  460.      !!Result.make(Void);
  461.       end;
  462.    
  463. feature {NONE} -- Globals procedures/functions :
  464.    
  465.    sort_running(run: ARRAY[RUN_CLASS]) is
  466.      -- Sort `run' to put small `id' first.
  467.       require
  468.      run.lower = 1;
  469.      run.upper >= 2;
  470.       local
  471.      min, max, buble: INTEGER;
  472.      moved: BOOLEAN;
  473.       do
  474.      from  
  475.         max := run.upper;
  476.         min := 1;
  477.         moved := true;
  478.      until
  479.         not moved
  480.      loop
  481.         moved := false;
  482.         if max - min > 0 then
  483.            from  
  484.           buble := min + 1;
  485.            until
  486.           buble > max
  487.            loop
  488.           if run.item(buble - 1).id > run.item(buble).id then
  489.              run.swap(buble - 1,buble);
  490.              moved := true;
  491.           end;
  492.           buble := buble + 1;
  493.            end;
  494.            max := max - 1;
  495.         end;
  496.         if moved and then max - min > 0 then
  497.            from  
  498.           moved := false;
  499.           buble := max - 1;
  500.            until
  501.           buble < min
  502.            loop
  503.           if run.item(buble).id > run.item(buble + 1).id then
  504.              run.swap(buble,buble + 1);
  505.              moved := true;
  506.           end;
  507.           buble := buble - 1;
  508.            end;
  509.            min := min + 1;
  510.         end;
  511.      end;
  512.       end;
  513.    
  514. feature {NONE}
  515.       
  516.    pos(line, column: INTEGER): POSITION is
  517.       require
  518.      line >= 1;
  519.      column >= 1;
  520.       do
  521.      !!Result.make(line,column);
  522.       end;
  523.    
  524. feature {NONE}
  525.    
  526.    to_bcn(rc: STRING): STRING is
  527.      -- Compute the root class name using command argument `rc'.
  528.       require
  529.      rc /= Void
  530.       local
  531.      i: INTEGER;
  532.      c: CHARACTER;
  533.       do
  534.      Result := rc.twin;
  535.      if Result.has_suffix(eiffel_suffix) then 
  536.         Result.remove_last(2);
  537.      end;
  538.      from  
  539.         i := Result.count;
  540.      until
  541.         i = 0
  542.      loop
  543.         c := Result.item(i);
  544.         if c.is_letter then
  545.            i := i - 1;
  546.         elseif c = '_' then
  547.            i := i - 1;
  548.         elseif c.is_digit then
  549.            i := i - 1;
  550.         else
  551.            Result.remove_first(i);
  552.            i := 0;
  553.         end;
  554.      end;
  555.      Result.to_upper;
  556.       ensure
  557.      Result.count <= rc.count
  558.       end;
  559.    
  560. feature {NONE}
  561.    
  562.    no_errors: BOOLEAN is
  563.       do
  564.      Result := nb_errors = 0;
  565.       end;
  566.    
  567.    code_require, code_ensure: INTEGER is unique;
  568.    
  569. feature {NONE}
  570.    
  571.    character_coding(c: CHARACTER; str: STRING) is
  572.      -- Append in `str' the Eiffel coding of the character (Table 
  573.      -- in chapter 25 of ETL, page 423).
  574.      -- When letter notation exists, it is returned in priority : 
  575.      --  '%N' gives "%N", '%T' gives "%T", ... 
  576.      -- When letter notation does not exists (not in ETL table), 
  577.      -- numbered coding is used ("%/1/", "%/2/" etc).
  578.       local
  579.      special: CHARACTER
  580.       do
  581.      inspect
  582.         c
  583.      when '%A' then
  584.         special := 'A';
  585.      when '%B' then
  586.         special := 'B';
  587.      when '%C' then
  588.         special := 'C';
  589.      when '%D' then
  590.         special := 'D';
  591.      when '%F' then
  592.         special := 'F';
  593.      when '%H' then
  594.         special := 'H';
  595.      when '%L' then
  596.         special := 'L';
  597.      when '%N' then
  598.         special := 'N';
  599.      when '%Q' then
  600.         special := 'Q';
  601.      when '%R' then
  602.         special := 'R';
  603.      when '%S' then
  604.         special := 'S';
  605.      when '%T' then
  606.         special := 'T';
  607.      when '%U' then
  608.         special := 'U';
  609.      when '%V' then
  610.         special := 'V';
  611.      when '%%' then
  612.         special := '%%';
  613.      when '%'' then
  614.         special := '%'';
  615.      when '%"' then
  616.         special := '"';
  617.      when '%(' then
  618.         special := '(';
  619.      when '%)' then
  620.         special := ')';
  621.      when '%<' then
  622.         special := '<';
  623.      when '%>' then
  624.         special := '>';
  625.      else
  626.      end;
  627.      str.extend('%%');
  628.      if special = '%U' then
  629.         str.extend('/');
  630.         c.code.append_in(str);
  631.         str.extend('/');
  632.      else
  633.         str.extend(special);
  634.      end;
  635.       end;
  636.    
  637. feature {NONE}   
  638.    
  639.    runnable(collected: ARRAY[ASSERTION]; ct: TYPE; 
  640.         for:RUN_FEATURE): ARRAY[ASSERTION] is
  641.      -- Produce a runnable `collected'.
  642.       require
  643.      collected.lower = 1;
  644.      for /= Void implies ct = for.current_type;
  645.       local
  646.      i: INTEGER;
  647.      a: ASSERTION;
  648.       do
  649.      if not collected.empty then
  650.         from  
  651.            Result := collected.twin;
  652.            i := Result.upper;
  653.         until
  654.            i = 0
  655.         loop
  656.            small_eiffel.push(for);
  657.            a := Result.item(i).to_runnable(ct);
  658.            if a = Void then
  659.           error(Result.item(i).start_position,fz_bad_assertion);
  660.            else
  661.           Result.put(a,i);
  662.            end;
  663.            small_eiffel.pop;
  664.            i := i - 1;
  665.         end;
  666.      end;
  667.       end;
  668.    
  669. feature {NONE}
  670.  
  671.    sfw_connect(sfw: STD_FILE_WRITE; path: STRING) is
  672.       require
  673.      not sfw.is_connected;
  674.      path /= Void
  675.       do
  676.      sfw.connect_to(path);
  677.      if sfw.is_connected then
  678.         echo.put_string("Writing %"");
  679.         echo.put_string(path);
  680.         echo.put_string("%" file.%N");
  681.      else
  682.         echo.w_put_string("Cannot write file %"");
  683.         echo.w_put_string(path);
  684.         echo.w_put_string(fz_b0);
  685.         die_with_code(exit_failure_code);
  686.      end;
  687.       ensure
  688.      sfw.is_connected
  689.       end;
  690.  
  691.    bfw_connect(bfw: BINARY_FILE_WRITE; path: STRING) is
  692.       require
  693.      not bfw.is_connected;
  694.      path /= Void
  695.       do
  696.      bfw.connect_to(path);
  697.      if bfw.is_connected then
  698.         echo.put_string("Writing %"");
  699.         echo.put_string(path);
  700.         echo.put_string("%" file.%N");
  701.      else
  702.         echo.w_put_string("Cannot write file %"");
  703.         echo.w_put_string(path);
  704.         echo.w_put_string(fz_b0);
  705.         die_with_code(exit_failure_code);
  706.      end;
  707.       ensure
  708.      bfw.is_connected
  709.       end;
  710.  
  711. feature {NONE}   
  712.  
  713.    fatal_error_vtec_2 is
  714.       do
  715.      fatal_error("Expanded class must have no creation procedure,% 
  716.               % or only one creation procedure with%
  717.               % no arguments (VTEC.2).");
  718.       end;
  719.    
  720. feature {NONE} -- System List :
  721.    
  722.    amiga_system:       STRING is "Amiga";
  723.    dos_system:         STRING is "DOS";
  724.    macintosh_system:   STRING is "Macintosh";
  725.    os2_system:         STRING is "OS2";
  726.    unix_system:        STRING is "UNIX";
  727.    vms_system:         STRING is "VMS";
  728.    windows_system:     STRING is "Windows";
  729.  
  730.    system_list: ARRAY[STRING] is
  731.       once
  732.      Result := <<amiga_system, dos_system, macintosh_system, 
  733.              os2_system, unix_system, vms_system, 
  734.              windows_system>>;
  735.       end;
  736.    
  737.    system_name: STRING is
  738.       local
  739.      i: INTEGER;
  740.       once
  741.      tmp_path.copy(small_eiffel_directory);
  742.      if tmp_path.has('/') then
  743.         tmp_path.set_last('/');
  744.         tmp_path.append(fz_sys);
  745.         tmp_path.extend('/');
  746.         tmp_path.append(fz_system_se);
  747.         echo.sfr_connect(tmp_file_read,tmp_path);
  748.      end;
  749.      if not tmp_file_read.is_connected then
  750.         tmp_path.copy(small_eiffel_directory);
  751.         if tmp_path.has('\') then
  752.            tmp_path.set_last('\');
  753.            tmp_path.append(fz_sys);
  754.            tmp_path.extend('\');
  755.            tmp_path.append(fz_system_se);
  756.            echo.sfr_connect(tmp_file_read,tmp_path);
  757.         end;
  758.      end;
  759.      if not tmp_file_read.is_connected then
  760.         tmp_path.copy(small_eiffel_directory);
  761.         if tmp_path.has(':') then
  762.            tmp_path.set_last(':');
  763.            tmp_path.append(fz_sys);
  764.            tmp_path.extend(':');
  765.            tmp_path.append(fz_system_se);
  766.            echo.sfr_connect(tmp_file_read,tmp_path);
  767.         end;
  768.      end;
  769.      if not tmp_file_read.is_connected then
  770.         tmp_path.copy(small_eiffel_directory);
  771.         if tmp_path.has(']') then
  772.            tmp_path.set_last(']');
  773.            tmp_path.remove_last(1);
  774.            tmp_path.extend('.');
  775.            tmp_path.append(fz_sys);
  776.            tmp_path.extend(']');
  777.            tmp_path.append(fz_system_se);
  778.            echo.sfr_connect(tmp_file_read,tmp_path);
  779.         end;
  780.      end;
  781.      if not tmp_file_read.is_connected then
  782.         tmp_path.copy(small_eiffel_directory);
  783.         tmp_path.append(fz_system_se);
  784.         echo.sfr_connect(tmp_file_read,tmp_path);
  785.      end;
  786.      if not tmp_file_read.is_connected then
  787.         echo.w_put_string("Unable to find file%N%"");
  788.         echo.w_put_string(fz_system_se);
  789.         echo.w_put_string("%" using path %"");
  790.         echo.w_put_string(small_eiffel_directory);
  791.         echo.w_put_string(fz_b0);
  792.         die_with_code(exit_failure_code);
  793.      end;
  794.      tmp_file_read.read_line;
  795.      Result := tmp_file_read.last_string;
  796.      i := system_list.index_of(Result);
  797.      tmp_file_read.disconnect;
  798.      if i > system_list.upper then
  799.         echo.w_put_string("Unknown system name in file%N%"");
  800.         echo.w_put_string(tmp_path);
  801.         echo.w_put_string("%".%NCurrently handled system names :%N");
  802.         from
  803.            i := 1;
  804.         until
  805.            i > system_list.upper
  806.         loop
  807.            echo.w_put_string(system_list.item(i));
  808.            echo.w_put_character('%N');
  809.            i := i + 1;
  810.         end;
  811.      else
  812.         Result := system_list.item(i);
  813.         echo.put_string("System is %"");
  814.         echo.put_string(Result);
  815.         echo.put_string(fz_b0);
  816.      end;
  817.       end;
  818.    
  819. feature {NONE} -- Handling of Files Suffix Names :
  820.    
  821.    eiffel_suffix: STRING is ".e";
  822.      -- Eiffel Source file suffix.
  823.  
  824.    c_suffix: STRING is ".c";
  825.      -- C files suffix.
  826.  
  827.    h_suffix: STRING is ".h";
  828.      -- Heading C files suffix.
  829.  
  830.    o_suffix: STRING is 
  831.      -- Object File produced by the C Compiler.
  832.       local
  833.      sn: STRING;
  834.       once
  835.      sn := system_name;
  836.      !!Result.make(4);
  837.      tmp_path.copy(small_eiffel_directory);
  838.      add_directory(tmp_path,fz_sys);
  839.      tmp_path.append("o_suffix.");
  840.      tmp_path.append(sn);
  841.      echo.sfr_connect(tmp_file_read,tmp_path);
  842.      tmp_file_read.read_line_in(Result);
  843.      tmp_file_read.disconnect;
  844.       end;
  845.  
  846.    x_suffix: STRING is 
  847.      -- Executable files suffix.
  848.       once
  849.      if dos_system = system_name or else
  850.         vms_system = system_name
  851.       then
  852.         Result := ".EXE";
  853.      elseif os2_system = system_name then
  854.         Result := ".exe";
  855.      elseif windows_system = system_name then
  856.         Result := ".exe";
  857.      else
  858.         Result := "";
  859.      end;
  860.       end;
  861.  
  862.    make_suffix: STRING is
  863.       -- Suffix for make file produced by `compile_to_c'.
  864.       once
  865.      if dos_system = system_name then
  866.         Result := ".BAT";
  867.      elseif windows_system = system_name then
  868.         Result := ".bat";
  869.      elseif vms_system = system_name then
  870.         Result := ".COM";
  871.      elseif os2_system = system_name then
  872.         Result := ".CMD";
  873.      else
  874.         Result := ".make";
  875.      end;
  876.       end;
  877.  
  878.    backup_suffix: STRING is ".bak";
  879.      -- Backup suffix for command `pretty'.
  880.  
  881.    help_suffix: STRING is ".txt";
  882.      -- Suffix for SmallEiffel On-line Help Files.
  883.  
  884.    class_suffix: STRING is ".class";
  885.  
  886. feature {NONE}
  887.  
  888.    echo_rename_file(path1, path2: STRING) is
  889.       do
  890.      if file_exists(path1) then
  891.         echo.put_string("Renaming %"");
  892.         echo.put_string(path1);
  893.         echo.put_string("%" as %"");
  894.         echo.put_string(path2);
  895.         echo.put_string(fz_18);
  896.         rename_file(path1,path2);
  897.      end;
  898.       end;
  899.  
  900.    empty_eh_check: BOOLEAN is
  901.       do
  902.      if eh.empty then
  903.         Result := true;
  904.      else
  905.         eh.append(" Internal Warning : EH not empty.");
  906.         eh.print_as_warning;
  907.         Result := true;
  908.      end;
  909.       end;
  910.  
  911. feature {NONE}
  912.  
  913.    dot_precedence: INTEGER is 12; 
  914.      -- The highest precedence value according to ETL.
  915.    
  916.    atomic_precedence: INTEGER is 13;
  917.      -- Used for atomic elements. 
  918.  
  919. feature {NONE}
  920.  
  921.    jvm_root_class: STRING is
  922.      -- Fully qualified name for the jvm SmallEiffel object's
  923.      -- added root : "<Package>/<fz_jvm_root>".
  924.       once
  925.      !!Result.make(12);
  926.      Result.copy(jvm.output_name);
  927.      Result.extend('/');
  928.      Result.append(fz_jvm_root);
  929.       end;
  930.    
  931.    jvm_root_descriptor: STRING is
  932.            -- Descriptor for `jvm_root_class': "L<jvm_root_class>;"
  933.       once
  934.      !!Result.make(12);
  935.      Result.extend('L');
  936.      Result.append(jvm_root_class);
  937.      Result.extend(';');
  938.       end;
  939.  
  940. feature {NONE}
  941.  
  942.    append_u1(str: STRING; u1: INTEGER) is
  943.       require
  944.      0 <= u1;
  945.      u1 <= 255
  946.       do
  947.      str.extend(u1.to_character);
  948.       end;
  949.  
  950.    append_u2(str: STRING; u2: INTEGER) is
  951.       require
  952.      0 <= u2;
  953.      u2 <= 65536
  954.       do
  955.      append_u1(str,u2 // 256);
  956.      append_u1(str,u2 \\ 256);
  957.       end;
  958.  
  959.    append_u4(str: STRING; u4: INTEGER) is
  960.       require
  961.      0 <= u4;
  962.      u4 <= ((2 ^ 31) - 1)
  963.       do
  964.      append_u2(str,u4 // 65536);
  965.      append_u2(str,u4 \\ 65536);
  966.       end;
  967.  
  968. feature {NONE}
  969.  
  970.    jvm_standard_is_equal_aux(rc: RUN_CLASS; wa: ARRAY[RUN_FEATURE_2]) is
  971.       require
  972.      rc /= Void
  973.       local
  974.      ca: like code_attribute;
  975.      rf2: RUN_FEATURE_2;
  976.      point1, point2, idx, space, i: INTEGER;
  977.       do
  978.      ca := code_attribute;
  979.      if wa = Void then
  980.         if rc.current_type.is_expanded then
  981.            ca.opcode_pop;
  982.            ca.opcode_pop;
  983.            ca.opcode_iconst_1;
  984.         else
  985.            ca.opcode_swap;
  986.            ca.opcode_pop;
  987.            idx := rc.fully_qualified_constant_pool_index;
  988.            ca.opcode_instanceof(idx);
  989.         end;
  990.      else
  991.         ca.branches.clear;
  992.         ca.opcode_dup;
  993.         idx := rc.fully_qualified_constant_pool_index;
  994.         ca.opcode_instanceof(idx);
  995.         ca.branches.add_last(ca.opcode_ifeq);
  996.         from
  997.            i := wa.upper;
  998.         until
  999.            i = 0
  1000.         loop
  1001.            rf2 := wa.item(i);
  1002.            idx := constant_pool.idx_fieldref(rf2);
  1003.            space := rf2.result_type.jvm_stack_space - 1;
  1004.            if i > 1 then
  1005.           ca.opcode_dup2;
  1006.            end;
  1007.            ca.opcode_getfield(idx,space);
  1008.            if space = 0 then
  1009.           ca.opcode_swap;
  1010.            else
  1011.           ca.opcode_dup2_x1;
  1012.           ca.opcode_pop2;
  1013.            end;
  1014.            ca.opcode_getfield(idx,space);
  1015.            if i > 1 then
  1016.           ca.branches.add_last(rf2.result_type.jvm_if_x_ne);
  1017.            else
  1018.           point1 := rf2.result_type.jvm_if_x_ne;
  1019.            end;
  1020.            i := i - 1;
  1021.         end;
  1022.         ca.opcode_iconst_1;
  1023.         point2 := ca.opcode_goto;
  1024.         ca.resolve_branches;
  1025.         ca.opcode_pop;
  1026.         ca.opcode_pop;
  1027.         ca.resolve_u2_branch(point1);
  1028.         ca.opcode_iconst_0;
  1029.         ca.resolve_u2_branch(point2);
  1030.      end;
  1031.       end;
  1032.  
  1033. end -- GLOBALS
  1034.  
  1035.