home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / local_name2.e < prev    next >
Text File  |  1999-06-05  |  2KB  |  88 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_NAME2
  17.    --
  18.    -- A local name used somewhere.
  19.    --
  20.  
  21. inherit LOCAL_NAME;
  22.  
  23. creation refer_to
  24.  
  25. feature
  26.  
  27.    rank: INTEGER;
  28.  
  29. feature {NONE}
  30.  
  31.    local_var_list: LOCAL_VAR_LIST;
  32.  
  33. feature {NONE}
  34.  
  35.    refer_to(sp: POSITION; lvl: LOCAL_VAR_LIST; r: like rank) is
  36.          -- Using name `r' of `dcl' at place `sp'.
  37.       require
  38.          sp /= Void;
  39.          r.in_range(1,lvl.count)
  40.       do
  41.          start_position := sp;
  42.          local_var_list := lvl;
  43.          rank := r;
  44.       ensure
  45.          start_position = sp;
  46.          local_var_list = lvl;
  47.          rank = r
  48.       end;
  49.  
  50. feature
  51.  
  52.    assertion_check(tag: CHARACTER) is
  53.       do
  54.          check tag /= 'R' end;
  55.          if tag = 'E' then
  56.             eh.add_position(start_position);
  57.             fatal_error("Cannot use local variable here (VEEN).");
  58.          end;
  59.       end;
  60.  
  61.    to_string: STRING is
  62.       do
  63.          Result := local_var_list.name(rank).to_string;
  64.       end;
  65.  
  66.    result_type: TYPE is
  67.       do
  68.          Result := local_var_list.type(rank);
  69.       end;
  70.  
  71.    to_runnable(ct: TYPE): like Current is
  72.       local
  73.          rf: RUN_FEATURE;
  74.          lvl: LOCAL_VAR_LIST;
  75.       do
  76.          rf := small_eiffel.top_rf;
  77.          lvl := rf.local_vars;
  78.          if local_var_list = lvl then
  79.             Result := Current;
  80.          else
  81.             !!Result.refer_to(start_position,lvl,rank);
  82.          end;
  83.          lvl.name(rank).set_is_used;
  84.       end;
  85.  
  86. end -- LOCAL_NAME2
  87.  
  88.