home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / local_name1.e < prev    next >
Text File  |  1999-06-05  |  4KB  |  138 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://SmallEiffel.loria.fr
  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_ARGUMENT1; LOCAL_NAME;
  22.  
  23. creation make
  24.  
  25. feature {NONE}
  26.  
  27.    is_used: BOOLEAN;
  28.          -- Is the local name really used inside the living
  29.          -- code ?
  30.  
  31. feature {NONE}
  32.  
  33.    make(sp: POSITION; n: STRING) is
  34.       require
  35.          sp /= Void;
  36.          n = string_aliaser.item(n)
  37.       do
  38.          start_position := sp;
  39.          to_string := n;
  40.       ensure
  41.          start_position = sp;
  42.          to_string = n
  43.       end;
  44.  
  45. feature
  46.  
  47.    assertion_check(tag: CHARACTER) is
  48.       do
  49.       end;
  50.  
  51.    to_runnable(ct: TYPE): like Current is
  52.       local
  53.          rt: TYPE;
  54.       do
  55.          rt := result_type.to_runnable(ct);
  56.          if rt = Void then
  57.             eh.add_position(result_type.start_position);
  58.             error(start_position,"Bad local variable.");
  59.          elseif rt.run_class = Void then
  60.          end;
  61.          if rt = result_type then
  62.             Result := Current;
  63.          else
  64.             Result := twin;
  65.             Result.set_result_type(rt);
  66.          end;
  67.       end;
  68.  
  69.    produce_c: BOOLEAN is
  70.          -- True if C code must be produced (local is really
  71.          -- used or it is a user expanded with possibles
  72.          -- side effects).
  73.       local
  74.          t: TYPE;
  75.       do
  76.          if is_used then
  77.             Result := true;
  78.          else
  79.             t := result_type.run_type;
  80.             if t.is_expanded then
  81.                Result := not t.is_basic_eiffel_expanded;
  82.             end;
  83.          end;
  84.       end;
  85.  
  86. feature {LOCAL_VAR_LIST}
  87.  
  88.    c_declare is
  89.          -- C declaration of the local.
  90.       local
  91.          t: TYPE;
  92.       do
  93.          if produce_c then
  94.             t := result_type.run_type;
  95.             tmp_string.clear;
  96.             t.c_type_for_result_in(tmp_string);
  97.             tmp_string.extend(' ');
  98.             cpp.put_string(tmp_string);
  99.             cpp.print_local(to_string);
  100.             cpp.put_character('=');
  101.             t.c_initialize;
  102.             cpp.put_string(fz_00);
  103.          elseif run_control.debug_check then
  104.             warning(start_position,"Unused local variable.");
  105.          end;
  106.       end;
  107.  
  108.    c_frame_descriptor(t: TYPE) is
  109.       require
  110.          run_control.no_check
  111.       do
  112.          if produce_c then
  113.             c_frame_descriptor_local_count.increment;
  114.             c_frame_descriptor_format.append(to_string);
  115.             c_frame_descriptor_locals.append("(void**)&_");
  116.             c_frame_descriptor_locals.append(to_string);
  117.             c_frame_descriptor_locals.extend(',');
  118.             t.c_frame_descriptor;
  119.          end;
  120.       end;
  121.  
  122. feature {DECLARATION_LIST}
  123.  
  124.    name_clash(ct: TYPE) is
  125.       do
  126.          name_clash_for(ct,"Conflict between local/feature name (VRLE).");
  127.       end;
  128.  
  129. feature {LOCAL_NAME2}
  130.  
  131.    set_is_used is
  132.       do
  133.          is_used := true;
  134.       end;
  135.  
  136. end -- LOCAL_NAME1
  137.  
  138.