home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / local_argument.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  3.9 KB  |  191 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 LOCAL_ARGUMENT
  17.    --
  18.    -- Common root to handle local variables (LOCAL_NAME) or formal
  19.    -- argument names (ARGUMENT_NAME).
  20.    --
  21.  
  22. inherit 
  23.    NAME;
  24.    EXPRESSION undefine is_writable end;
  25.  
  26. feature
  27.  
  28.    start_position: POSITION;
  29.      -- Of the first character of the name.
  30.    
  31.    rank: INTEGER;
  32.      -- Of in the corresponding Eiffel flat list.
  33.    
  34.    result_type: TYPE;
  35.      -- Type declaration mark.
  36.  
  37. feature
  38.  
  39.    can_be_dropped: BOOLEAN is true;
  40.     
  41.    frozen to_key: STRING is
  42.       do
  43.      Result := to_string;
  44.       end;
  45.  
  46.    is_pre_computable: BOOLEAN is false;
  47.  
  48. feature {NONE} -- Parsing Creation procedures :
  49.  
  50.    make(sp: POSITION; n: STRING) is
  51.      -- At declaration place.
  52.       require
  53.      sp /= Void;
  54.      n /= Void;
  55.       do
  56.      start_position := sp;
  57.      to_string := unique_string.item(n);
  58.       ensure
  59.      start_position = sp;
  60.      to_string = unique_string.item(n)
  61.       end;
  62.  
  63.    refer_to(sp: POSITION; dcl: DECLARATION_LIST; r: like rank) is
  64.      -- Using name `r' of `dcl' at place `sp'.
  65.       require
  66.      sp /= Void;
  67.      dcl /= Void;
  68.      r >= 1;
  69.      r <= dcl.count;
  70.       deferred
  71.       ensure
  72.      dcl.rank_of(to_string) = r;
  73.      rank = r
  74.       end;
  75.  
  76. feature {DECLARATION_LIST}
  77.  
  78.    name_clash is
  79.      -- Check name clash between argument/feature or name clash
  80.      -- between local/feature.
  81.      -- Note : clash between local/argument are checked during
  82.      --        parsing.
  83.       require
  84.      current_type /= Void
  85.       deferred
  86.       end;
  87.       
  88. feature
  89.  
  90.    is_static: BOOLEAN is false;
  91.    
  92.    use_current: BOOLEAN is false;
  93.  
  94. feature
  95.  
  96.    frozen compile_to_c_old is
  97.       do 
  98.       end;
  99.       
  100.    frozen compile_to_jvm_old is
  101.       do 
  102.       end;
  103.       
  104.    frozen compile_target_to_jvm is
  105.       do
  106.      standard_compile_target_to_jvm;
  107.       end;
  108.  
  109.    precedence: INTEGER is
  110.       do
  111.      Result := atomic_precedence;
  112.       end;
  113.  
  114.    print_as_target is
  115.       do
  116.      fmt.put_string(to_string);
  117.      fmt.put_character('.');
  118.       end;
  119.  
  120.    frozen short is
  121.       local
  122.      i: INTEGER;
  123.      c: CHARACTER;
  124.       do
  125.      short_print.hook("Ban");
  126.      from
  127.         i := 1;
  128.      until
  129.         i > to_string.count
  130.      loop
  131.         c := to_string.item(i);
  132.         if c = '_' then
  133.            short_print.hook_or("Uan","_");
  134.         else
  135.            short_print.a_character(c);
  136.         end;
  137.         i := i + 1;
  138.      end;
  139.      short_print.hook("Aan");
  140.       end;
  141.  
  142.    frozen short_target is
  143.       do
  144.      short;
  145.      short_print.a_dot;
  146.       end;
  147.  
  148. feature {DECLARATION_LIST}
  149.  
  150.    set_rank(r: like rank) is
  151.       require
  152.      r >= 1
  153.       do
  154.      rank := r;
  155.       ensure
  156.      rank = r
  157.       end;
  158.  
  159. feature {DECLARATION_LIST,DECLARATION}
  160.  
  161.    set_result_type(rt: like result_type) is
  162.       require
  163.      rt /= Void
  164.       do
  165.      result_type := rt;
  166.       ensure 
  167.      result_type = rt
  168.       end;
  169.  
  170. feature {NONE}
  171.  
  172.    make_runnable(model: like Current; ct, rt: TYPE) is
  173.       do
  174.      standard_copy(model);
  175.      current_type := ct;
  176.      result_type := rt;
  177.       end;
  178.  
  179. feature {NONE}
  180.  
  181.    em_ba: STRING is "Bad argument.";
  182.  
  183.    em_bl: STRING is "Bad local variable.";
  184.  
  185. invariant
  186.  
  187.    start_position /= Void;
  188.  
  189. end -- LOCAL_ARGUMENT
  190.  
  191.