home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / local_var_list.e < prev    next >
Text File  |  1999-06-05  |  4KB  |  180 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_VAR_LIST
  17.    --
  18.    -- To store local variables declaration list.
  19.    --
  20.  
  21. inherit DECLARATION_LIST;
  22.  
  23. creation {EIFFEL_PARSER} make
  24.  
  25. creation {DECLARATION_LIST} runnable_from_current
  26.  
  27. feature {NONE}
  28.  
  29.    make(l: like list) is
  30.       do
  31.          declaration_list_make(l);
  32.       end;
  33.  
  34. feature
  35.  
  36.    name(i: INTEGER): LOCAL_NAME1 is
  37.       do
  38.          Result := flat_list.item(i);
  39.       end;
  40.  
  41.    to_runnable(ct: TYPE): like Current is
  42.       require
  43.          ct.run_type = ct
  44.       do
  45.          if is_runnable(ct) then
  46.             Result := Current;
  47.          else
  48.             Result := twin;
  49.             Result.dynamic_runnable(ct);
  50.             Result.check_name_clash(ct);
  51.          end;
  52.       end;
  53.  
  54.    pretty_print is
  55.       local
  56.          i: INTEGER;
  57.       do
  58.          fmt.set_indent_level(2);
  59.          fmt.indent;
  60.          fmt.keyword("local");
  61.          if fmt.zen_mode and list.count = 1 then
  62.             list.first.pretty_print;
  63.             fmt.put_character(';');
  64.          else
  65.             from
  66.                i := 1;
  67.             until
  68.                i > list.upper
  69.             loop
  70.                fmt.set_indent_level(3);
  71.                fmt.indent;
  72.                list.item(i).pretty_print;
  73.                fmt.put_character(';');
  74.                i := i + 1;
  75.             end;
  76.          end;
  77.          fmt.set_indent_level(2);
  78.          fmt.indent;
  79.       end;
  80.  
  81.    produce_c: BOOLEAN is
  82.       local
  83.          i: INTEGER;
  84.       do
  85.          from
  86.             i := count;
  87.          until
  88.             Result or else i = 0
  89.          loop
  90.             Result := name(i).produce_c;
  91.             i := i - 1;
  92.          end;
  93.       end;
  94.  
  95. feature {RUN_FEATURE}
  96.  
  97.    jvm_initialize is
  98.          -- Produce code in order to initialize variables.
  99.       local
  100.          jvm_offset, i, dummy: INTEGER;
  101.          t: TYPE;
  102.       do
  103.          from
  104.             i := count;
  105.          until
  106.             i = 0
  107.          loop
  108.             jvm_offset := jvm.local_offset_of(name(i));
  109.             t := type(i).run_type;
  110.             dummy := t.jvm_push_default;
  111.             t.jvm_write_local(jvm_offset);
  112.             i := i - 1;
  113.          end;
  114.       end;
  115.  
  116.    c_declare is
  117.       local
  118.          i: INTEGER;
  119.          n: like name;
  120.       do
  121.          from
  122.             i := count;
  123.          until
  124.             i = 0
  125.          loop
  126.             n := name(i)
  127.             n.c_declare;
  128.             if run_control.no_check then
  129.                n.c_frame_descriptor(type(i));
  130.             end;
  131.             i := i - 1;
  132.          end;
  133.       end;
  134.  
  135.    initialize_expanded is
  136.       local
  137.          i: INTEGER;
  138.          t: TYPE;
  139.          rf3: RUN_FEATURE_3;
  140.       do
  141.          from
  142.             i := count;
  143.          until
  144.             i = 0
  145.          loop
  146.             t := type(i).run_type;
  147.             if t.is_expanded then
  148.                if not t.is_basic_eiffel_expanded then
  149.                   rf3 := t.expanded_initializer;
  150.                   if rf3 /= Void then
  151.                      cpp.expanded_writable(rf3,name(i));
  152.                   end;
  153.                end;
  154.             end;
  155.             i := i - 1;
  156.          end;
  157.       end;
  158.  
  159. feature {RUN_FEATURE_3}
  160.  
  161.    inline_one_pc is
  162.       local
  163.          i: INTEGER;
  164.       do
  165.          from
  166.             i := count;
  167.          until
  168.             i = 0
  169.          loop
  170.             cpp.inline_level_incr;
  171.             name(i).c_declare;
  172.             cpp.inline_level_decr;
  173.             i := i - 1;
  174.          end;
  175.       end;
  176.  
  177. end -- LOCAL_VAR_LIST
  178.  
  179.  
  180.