home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / call_proc_call.e < prev    next >
Text File  |  1999-06-05  |  5KB  |  182 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. 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.          -- Written selector name of the call.
  30.  
  31. feature -- Common deferred :
  32.  
  33.    run_feature: RUN_FEATURE is
  34.          -- Non void when runnable if any `run_feature'.
  35.       deferred
  36.       end;
  37.  
  38.    arguments: EFFECTIVE_ARG_LIST is
  39.          -- Arguments of the call if any.
  40.       deferred
  41.       ensure
  42.          Result = Void or else Result.count > 0
  43.       end;
  44.  
  45.    arg_count: INTEGER is
  46.          -- The `arguments' count or 0.
  47.       deferred
  48.       ensure
  49.          Result >= 0
  50.       end;
  51.  
  52. feature -- Common frozen :
  53.  
  54.    frozen collect_c_tmp is
  55.       do
  56.          if run_feature /= Void then
  57.             run_feature.collect_c_tmp;
  58.          end;
  59.          target.collect_c_tmp;
  60.          if arguments /= Void then
  61.             arguments.collect_c_tmp;
  62.          end;
  63.       end;
  64.  
  65.    frozen start_position: POSITION is
  66.       do
  67.          Result := feature_name.start_position;
  68.       end;
  69.  
  70.    use_current, frozen standard_use_current: BOOLEAN is
  71.       do
  72.          if arg_count > 0 then
  73.             Result := arguments.use_current;
  74.          end;
  75.          if Result then
  76.          elseif target.is_current then
  77.             Result := run_feature.use_current;
  78.          else
  79.             Result := target.use_current;
  80.          end;
  81.       end;
  82.  
  83. feature
  84.  
  85.    afd_check is
  86.       local
  87.          rc: RUN_CLASS;
  88.          running: ARRAY[RUN_CLASS];
  89.       do
  90.          rc := target.result_type.run_class;
  91.          running := rc.running;
  92.          if running = Void then
  93.             eh.add_position(target.start_position);
  94.             eh.append("Call on a Void target in the living Eiffel code. %
  95.                       %No instance of type ");
  96.             eh.append(rc.current_type.run_time_mark);
  97.             eh.append(fz_07)
  98.             eh.print_as_warning;
  99.             rc.set_at_run_time;
  100.          elseif running.count > 1 then
  101.             switch_collection.update(target,run_feature);
  102.          end;
  103.          target.afd_check;
  104.          if arg_count > 0 then
  105.             arguments.afd_check;
  106.          end;
  107.       end;
  108.  
  109. feature {RUN_FEATURE_3,RUN_FEATURE_4}
  110.  
  111.    finalize is
  112.          -- For inlining of direct calls on an attribute.
  113.       require
  114.          run_control.boost;
  115.          small_eiffel.is_ready;
  116.          run_feature.current_type.run_class.running.count = 1
  117.       deferred
  118.       ensure
  119.          run_feature.current_type.run_class.at_run_time
  120.       end;
  121.  
  122. feature {NONE}
  123.  
  124.    frozen call_proc_call_c2c is
  125.       do
  126.          cpp.put_cpc(Current);
  127.       end;
  128.  
  129.    frozen call_proc_call_c2jvm is
  130.       do
  131.          jvm.call_proc_call_mapping(Current);
  132.       end;
  133.  
  134.    frozen runnable_expression(expression: EXPRESSION; ct: TYPE): EXPRESSION is
  135.       require
  136.          expression /= Void;
  137.          ct /= Void
  138.       do
  139.          Result := expression.to_runnable(ct);
  140.          if Result = Void then
  141.             eh.add_position(expression.start_position);
  142.             fatal_error("Bad expression.");
  143.          end;
  144.       ensure
  145.          Result /= Void
  146.       end;
  147.  
  148.    frozen runnable_args(args: like arguments; ct: TYPE): like arguments is
  149.       require
  150.          args /= Void;
  151.          ct /= Void
  152.       do
  153.          Result := args.to_runnable(ct);
  154.          if Result = Void then
  155.             eh.add_position(args.start_position);
  156.             fatal_error(fz_bad_argument);
  157.          end;
  158.       ensure
  159.          Result /= Void
  160.       end;
  161.  
  162.    frozen run_feature_for(targ: EXPRESSION; ct: TYPE): RUN_FEATURE is
  163.       require
  164.          targ /= Void
  165.       local
  166.          rc: RUN_CLASS;
  167.       do
  168.          rc := targ.result_type.run_class;
  169.          Result := rc.base_class.run_feature_for(rc,targ,feature_name,ct);
  170.       ensure
  171.          Result /= Void
  172.       end;
  173.  
  174. invariant
  175.  
  176.    target /= Void;
  177.  
  178.    feature_name /= Void;
  179.  
  180. end -- CALL_PROC_CALL
  181.  
  182.