home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / procedure.e < prev    next >
Text File  |  1999-06-05  |  5KB  |  153 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 PROCEDURE
  17.  
  18. inherit
  19.    EFFECTIVE_ROUTINE
  20.       rename make_effective_routine as make
  21.       export {ANY} make
  22.       end;
  23.  
  24. creation make
  25.  
  26. feature
  27.  
  28.    result_type: TYPE is
  29.       do
  30.       end;
  31.  
  32.    to_run_feature(t: TYPE; fn: FEATURE_NAME): RUN_FEATURE_3 is
  33.       do
  34.          !!Result.make(t,fn,Current);
  35.       end;
  36.  
  37. feature {C_PRETTY_PRINTER}
  38.  
  39.    stupid_switch(up_rf: RUN_FEATURE; r: ARRAY[RUN_CLASS]): BOOLEAN is
  40.       local
  41.          rf3a, rf3b: RUN_FEATURE_3;
  42.          rf2a, rf2b: RUN_FEATURE_2;
  43.          offseta, offsetb: INTEGER;
  44.          rta, rtb: TYPE;
  45.          rc: RUN_CLASS;
  46.          i: INTEGER;
  47.       do
  48.          rf3a ?= r.first.dynamic(up_rf);
  49.          Result := rf3a.is_empty_or_null_body;
  50.          if Result then
  51.             cpp.put_comment("SSP1");
  52.          end;
  53.          if not Result then
  54.             from
  55.                Result := true;
  56.                i := r.upper;
  57.             until
  58.                not Result or else i = 0
  59.             loop
  60.                rc := r.item(i);
  61.                rf3b ?= rc.dynamic(up_rf);
  62.                rf2b := rf3b.is_attribute_writer;
  63.                if rf2b /= Void then
  64.                   offsetb := rc.offset_of(rf2b);
  65.                end;
  66.                if rf2a = Void then
  67.                   rf3a := rf3b;
  68.                   rf2a := rf2b;
  69.                   offseta := offsetb;
  70.                end;
  71.                if rf2b = Void then
  72.                   Result := false;
  73.                elseif rf2a.name.to_string /= rf2b.name.to_string then
  74.                   Result := false;
  75.                elseif offseta /= offsetb then
  76.                   Result := false;
  77.                else
  78.                   rta := rf2a.result_type;
  79.                   rtb := rf2b.result_type;
  80.                   if rta.is_reference then
  81.                      Result := rtb.is_reference;
  82.                   elseif rta.run_time_mark = rtb.run_time_mark then
  83.                   elseif rta.is_native_array then
  84.                      if rta.generic_list.first.is_reference then
  85.                         Result := rtb.generic_list.first.is_reference;
  86.                      end;
  87.                   else
  88.                      Result := false;
  89.                   end;
  90.                end;
  91.                i := i - 1;
  92.             end;
  93.             if Result then
  94.                cpp.put_comment("SSP2");
  95.             end;
  96.          end;
  97.          if not Result then
  98.             Result := stupid_switch_for_collection(up_rf,r);
  99.             if Result then
  100.                cpp.put_comment("SSP3");
  101.             end;
  102.          end;
  103.       end;
  104.  
  105. feature {NONE}
  106.  
  107.    stupid_switch_for_collection(up_rf: RUN_FEATURE; r: ARRAY[RUN_CLASS]): BOOLEAN is
  108.          -- I think it is a little bit dirty to handle these features
  109.          -- specifically.
  110.       local
  111.          fns, bcn: STRING;
  112.          i: INTEGER;
  113.          rf: RUN_FEATURE;
  114.       do
  115.          bcn := up_rf.current_type.base_class.name.to_string;
  116.          if as_array = bcn or else as_fixed_array = bcn then
  117.             fns := up_rf.name.to_string;
  118.             if as_put = fns or else as_add_last = fns then
  119.                from
  120.                   i := r.upper;
  121.                   Result := true;
  122.                until
  123.                   not Result or else i = 0
  124.                loop
  125.                   rf := r.item(i).dynamic(up_rf);
  126.                   if rf.arguments.type(1).is_expanded then
  127.                      Result := false;
  128.                   end;
  129.                   i := i - 1;
  130.                end;
  131.             end;
  132.          end;
  133.       end;
  134.  
  135.    try_to_undefine_aux(fn: FEATURE_NAME;
  136.                        bc: BASE_CLASS): DEFERRED_ROUTINE is
  137.       do
  138.          !DEFERRED_PROCEDURE!Result.from_effective(fn,arguments,
  139.                                                    require_assertion,
  140.                                                    ensure_assertion,
  141.                                                    bc);
  142.       end;
  143.  
  144. feature {NONE}
  145.  
  146.    pretty_print_once_or_do is
  147.       do
  148.          fmt.keyword(fz_do);
  149.       end;
  150.  
  151. end -- PROCEDURE
  152.  
  153.