home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / call_proc_call.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  3.9 KB  |  174 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 CALL_PROC_CALL
  17. --
  18. -- Common root for CALL and PROC_CALL.
  19. --
  20.  
  21. inherit GLOBALS;
  22.  
  23. feature -- Common attributes :
  24.  
  25.    target: EXPRESSION;
  26.      -- Target of the call.
  27.    
  28.    feature_name: FEATURE_NAME;
  29.      -- Selector name of the call.
  30.  
  31.    run_feature: RUN_FEATURE;
  32.      -- When checked, corresponding (static) run feature.
  33.  
  34. feature -- Common deferred :
  35.  
  36.    arg_count: INTEGER is
  37.       deferred
  38.       ensure 
  39.      Result >= 0
  40.       end;
  41.    
  42.    arguments: EFFECTIVE_ARG_LIST is
  43.      -- Arguments of the call if any.
  44.       deferred
  45.       ensure
  46.      Result = Void or else Result.count > 0
  47.       end;
  48.  
  49.    current_type: TYPE is
  50.       deferred
  51.       end;
  52.  
  53.    is_checked: BOOLEAN is
  54.       deferred
  55.       end;
  56.  
  57. feature 
  58.  
  59.    start_position: POSITION is
  60.       do
  61.      Result := feature_name.start_position; 
  62.       end;
  63.  
  64.    use_current, frozen standard_use_current: BOOLEAN is
  65.       do
  66.      if arg_count > 0 then
  67.         Result := arguments.use_current;
  68.      end;
  69.      if Result then
  70.      elseif target.is_current then
  71.         Result := run_feature.use_current;
  72.      else
  73.         Result := target.use_current;
  74.      end;
  75.       end;
  76.  
  77. feature 
  78.  
  79.    afd_check is
  80.       local
  81.      rc: RUN_CLASS;
  82.      running: ARRAY[RUN_CLASS];
  83.       do
  84.      rc := target.result_type.run_class;
  85.      running := rc.running;
  86.      if running = Void then
  87.         eh.add_position(target.start_position);
  88.         eh.append("Call on a Void target in the living Eiffel code. %
  89.               %No instance of type ");
  90.         eh.append(rc.current_type.run_time_mark);
  91.         eh.append(fz_07)
  92.         eh.print_as_warning;
  93.         rc.set_at_run_time;
  94.      elseif running.count > 0 then
  95.         switch_collection.update(target,run_feature);
  96.      end;
  97.      target.afd_check;
  98.      if arg_count > 0 then
  99.         arguments.afd_check;
  100.      end;
  101.       end;
  102.  
  103. feature {RUN_FEATURE_3,RUN_FEATURE_4}
  104.  
  105.    finalize is
  106.      -- For inlining of direct calls on an attribute.
  107.       require
  108.      is_checked;
  109.      small_eiffel.is_ready;
  110.      run_control.boost;
  111.      current_type.run_class.running.count = 1
  112.       local
  113.      ct: TYPE;
  114.      rc: RUN_CLASS;
  115.      rf: RUN_FEATURE;
  116.      r: ARRAY[RUN_CLASS];
  117.       do
  118.      rf := run_feature;
  119.      rc := rf.current_type.run_class;
  120.      if not rc.at_run_time then
  121.         rf := rc.running.first.dynamic(rf);
  122.         run_feature := rf;
  123.      end;
  124.       ensure
  125.      run_feature.current_type.run_class.at_run_time
  126.       end;
  127.  
  128. feature {NONE}
  129.    
  130.    cpc_to_runnable(ct: TYPE) is
  131.       require
  132.      ct /= Void;
  133.       local
  134.      t: like target;
  135.      rc: RUN_CLASS;
  136.       do
  137.      t := target.to_runnable(ct);
  138.      if t = Void then
  139.         eh.add_position(target.start_position);
  140.         fatal_error("Bad target.");
  141.      end;
  142.      target := t;
  143.      check
  144.         target.current_type = ct
  145.      end;
  146.      rc := target.result_type.run_class;
  147.      run_feature := rc.get_rf(Current);
  148.      switch_collection.update(target,run_feature);
  149.       ensure
  150.      target.is_checked;
  151.      run_feature /= Void
  152.       end;
  153.  
  154. feature {NONE}
  155.  
  156.    frozen call_proc_call_c2c is
  157.       do
  158.      cpp.put_cpc(Current);
  159.       end;
  160.    
  161.    frozen call_proc_call_c2jvm is
  162.       do
  163.      jvm.b_put_cpc(Current);
  164.       end;
  165.  
  166. invariant
  167.  
  168.    target /= Void;
  169.    
  170.    feature_name /= Void
  171.    
  172. end -- CALL_PROC_CALL
  173.  
  174.