home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / proc_call_1.e < prev    next >
Text File  |  1999-06-05  |  5KB  |  171 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 PROC_CALL_1
  17.    --
  18.    -- For a procedure call with only one argument.
  19.    --
  20.  
  21. inherit PROC_CALL redefine use_current end;
  22.  
  23. creation make, with
  24.  
  25. feature
  26.  
  27.    arguments: EFFECTIVE_ARG_LIST;
  28.  
  29. feature {NONE}
  30.  
  31.    make(t: like target; pn: like feature_name; a: like arguments) is
  32.       require
  33.          t /= Void;
  34.          pn /= Void;
  35.          a /= Void;
  36.       do
  37.          target := t;
  38.          feature_name := pn;
  39.          arguments := a;
  40.       ensure
  41.          target = t;
  42.          feature_name = pn;
  43.          arguments = a;
  44.       end;
  45.  
  46.    with(t: like target; pn: like feature_name; a: like arguments;
  47.         rf: RUN_FEATURE; ct: TYPE) is
  48.       require
  49.          t /= Void;
  50.          pn /= Void;
  51.          a /= Void;
  52.          rf /= Void;
  53.          ct /= Void
  54.       do
  55.          target := t;
  56.          feature_name := pn;
  57.          arguments := a;
  58.          run_feature := rf;
  59.          run_feature_match(ct);
  60.       ensure
  61.          target = t;
  62.          feature_name = pn;
  63.          arguments = a;
  64.          run_feature = rf
  65.       end;
  66.  
  67. feature
  68.  
  69.    arg_count: INTEGER is 1;
  70.  
  71.    arg1: EXPRESSION is
  72.       do
  73.          Result := arguments.first;
  74.       end;
  75.  
  76.    to_runnable(ct: TYPE): like Current is
  77.       local
  78.          t: like target;
  79.          a: like arguments;
  80.          rf: RUN_FEATURE;
  81.       do
  82.          t := runnable_expression(target,ct);
  83.          a := runnable_args(arguments,ct);
  84.          rf := run_feature_for(t,ct);
  85.          if run_feature = Void then
  86.             target := t;
  87.             arguments := a;
  88.             run_feature := rf;
  89.             run_feature_match(ct);
  90.             Result := Current;
  91.          elseif t = target and then a = arguments then
  92.             check
  93.                run_feature = rf
  94.             end;
  95.             Result := Current;
  96.          else
  97.             !!Result.with(t,feature_name,a,rf,ct);
  98.          end;
  99.       end;
  100.  
  101.    compile_to_jvm is
  102.       do
  103.          if as_c_inline_c = feature_name.to_string then
  104.             eh.add_position(start_position);
  105.             fatal_error(
  106.                "Cannot use %"c_inline_c%" to produce Java byte code.");
  107.          else
  108.             call_proc_call_c2jvm;
  109.          end;
  110.       end;
  111.  
  112.    use_current: BOOLEAN is
  113.       local
  114.          ms: MANIFEST_STRING;
  115.          s: STRING;
  116.       do
  117.          if as_c_inline_c = feature_name.to_string then
  118.             ms ?= arg1;
  119.             if ms /= Void then
  120.                manifest_string_pool.used_for_c_inline(ms);
  121.                s := ms.to_string;
  122.                Result := s.has('C');
  123.             end;
  124.          else
  125.             Result := standard_use_current;
  126.          end;
  127.       end;
  128.  
  129.    pretty_print is
  130.       do
  131.          target.print_as_target;
  132.          fmt.put_string(feature_name.to_string);
  133.          fmt.put_character('(');
  134.          arg1.pretty_print;
  135.          fmt.put_character(')');
  136.          if fmt.semi_colon_flag then
  137.             fmt.put_character(';');
  138.          end;
  139.       end;
  140.  
  141. feature {CREATION_CALL}
  142.  
  143.    make_runnable(w: like target; a: like arguments;
  144.                  rf: RUN_FEATURE): like Current is
  145.       do
  146.          if run_feature = Void then
  147.             target := w;
  148.             arguments := a;
  149.             run_feature := rf;
  150.             Result := Current;
  151.          else
  152.             !!Result.make(w,feature_name,a);
  153.             Result.set_run_feature(rf);
  154.          end;
  155.       end;
  156.  
  157. feature {NONE}
  158.  
  159.    run_feature_match(ct: TYPE) is
  160.       do
  161.          run_feature_has_no_result;
  162.          arguments.match_with(run_feature,ct);
  163.       end;
  164.  
  165. invariant
  166.  
  167.    arguments.count = 1
  168.  
  169. end -- PROC_CALL_1
  170.  
  171.