home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / local_name1.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  2.7 KB  |  108 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 LOCAL_NAME1
  17.    --
  18.    -- A local name in some declaration list.
  19.    --
  20.  
  21. inherit LOCAL_NAME;
  22.  
  23. creation {TMP_NAME} make
  24.  
  25. creation {LOCAL_NAME1} make_runnable
  26.  
  27. feature {NONE}
  28.  
  29.    is_used: BOOLEAN;
  30.      -- Is the local name really used inside the living
  31.      -- code ?
  32.  
  33. feature
  34.  
  35.    to_runnable(ct: TYPE): like Current is
  36.       local
  37.      t1, t2: TYPE;
  38.       do
  39.      t1 := result_type;
  40.      t2 := t1.to_runnable(ct);
  41.      if t2 = Void then
  42.         eh.add_position(t1.start_position);
  43.         error(start_position,em_bl);
  44.      end;
  45.      if current_type = Void then
  46.         current_type := ct;
  47.         result_type := t2;
  48.         Result := Current;
  49.      else
  50.         !!Result.make_runnable(Current,ct,t2);
  51.      end;
  52.       end;
  53.  
  54.    produce_c: BOOLEAN is
  55.      -- True if C code must be produced (local is really
  56.      -- used or it is a user expanded with possibles
  57.      -- side effects).
  58.       local
  59.      t: TYPE;
  60.       do
  61.      if is_used then
  62.         Result := true;
  63.      else
  64.         t := result_type.run_type;
  65.         if t.is_expanded then
  66.            Result := not t.is_basic_eiffel_expanded;
  67.         end;
  68.      end;
  69.       end;
  70.  
  71.    c_declare is
  72.      -- C declaration of the local.
  73.       local
  74.      t: TYPE;
  75.       do
  76.      if produce_c then
  77.         t := result_type.run_type;
  78.         tmp_string.clear;
  79.         t.c_type_for_result_in(tmp_string);
  80.         tmp_string.extend(' ');
  81.         cpp.put_string(tmp_string);
  82.         cpp.print_local(to_string);
  83.         cpp.put_character('=');
  84.         t.c_initialize;
  85.         cpp.put_string(fz_00);
  86.      elseif run_control.debug_check then
  87.         warning(start_position,"Unused local variable.");
  88.      end;
  89.       end;
  90.  
  91.    c_trace is
  92.       -- Add C code for stack trace.
  93.       do
  94.      if produce_c then
  95.         cpp.rs_push_local(to_string,result_type.run_type);
  96.      end;
  97.       end;
  98.  
  99. feature {LOCAL_NAME2}
  100.  
  101.    set_is_used is
  102.       do
  103.      is_used := true;
  104.       end;
  105.  
  106. end -- LOCAL_NAME1
  107.  
  108.