home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / call_n.e < prev    next >
Text File  |  1999-06-05  |  6KB  |  243 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 CALL_N
  17.    --
  18.    -- For calls with more than one argument : "bar.foo(...)".
  19.    -- For other calls, use CALL_0 or CALL_1.
  20.    --
  21.  
  22. inherit CALL;
  23.  
  24. creation make, with
  25.  
  26. feature
  27.  
  28.    arguments: EFFECTIVE_ARG_LIST;
  29.  
  30.    run_feature: RUN_FEATURE;
  31.  
  32. feature
  33.  
  34.    is_pre_computable: BOOLEAN is false;
  35.  
  36.    can_be_dropped: BOOLEAN is false;
  37.  
  38. feature {NONE}
  39.  
  40.    make(t: like target; sn: like feature_name; a: like arguments) is
  41.       require
  42.          t /= void;
  43.          sn /= void;
  44.          a.count > 1;
  45.       do
  46.          target := t;
  47.          feature_name := sn;
  48.          arguments := a;
  49.       ensure
  50.          target = t;
  51.          feature_name = sn;
  52.          arguments = a
  53.       end;
  54.  
  55.    with(t: like target; sn: like feature_name; a: like arguments;
  56.         rf: RUN_FEATURE; ct: TYPE) is
  57.       require
  58.          t /= void;
  59.          sn /= void;
  60.          a.count > 1;
  61.          rf /= Void;
  62.          ct /= Void
  63.       do
  64.          target := t;
  65.          feature_name := sn;
  66.          arguments := a;
  67.          run_feature := rf;
  68.          run_feature_match(ct);
  69.       ensure
  70.          target = t;
  71.          feature_name = sn;
  72.          arguments = a;
  73.          run_feature = rf
  74.       end;
  75.  
  76. feature
  77.  
  78.    result_type: TYPE is
  79.       local
  80.          tla: TYPE_LIKE_ARGUMENT;
  81.          e: EXPRESSION;
  82.       do
  83.          Result := run_feature.result_type;
  84.          if Result.is_like_current then
  85.             Result := run_feature.current_type;
  86.          else
  87.             tla ?= Result;
  88.             if tla /= Void then
  89.                e := arguments.expression(tla.rank);
  90.                Result := e.result_type.run_type;
  91.             end;
  92.          end;
  93.       end;
  94.  
  95.    precedence: INTEGER is
  96.       do
  97.          Result := dot_precedence;
  98.       end;
  99.  
  100.    compile_to_c is
  101.       do
  102.          call_proc_call_c2c;
  103.       end;
  104.  
  105.    isa_dca_inline_argument: INTEGER is
  106.       do
  107.       end;
  108.  
  109.    dca_inline_argument(formal_arg_type: TYPE) is
  110.       do
  111.       end;
  112.  
  113.    arg_count: INTEGER is
  114.       do
  115.          Result := arguments.count;
  116.       end;
  117.  
  118.    to_runnable(ct: TYPE): like Current is
  119.       local
  120.          t: like target;
  121.          a: like arguments;
  122.          rf: RUN_FEATURE;
  123.       do
  124.          t := runnable_expression(target,ct);
  125.          a := runnable_args(arguments,ct);
  126.          rf := run_feature_for(t,ct);
  127.          if run_feature = Void then
  128.             target := t;
  129.             arguments := a;
  130.             run_feature := rf;
  131.             run_feature_match(ct);
  132.             Result := Current;
  133.          elseif t = target and then a = arguments then
  134.             check
  135.                run_feature = rf
  136.             end;
  137.             Result := Current;
  138.          else
  139.             !!Result.with(t,feature_name,a,rf,ct);
  140.          end;
  141.       end;
  142.  
  143.    bracketed_pretty_print, pretty_print is
  144.       do
  145.          target.print_as_target;
  146.          fmt.put_string(feature_name.to_string);
  147.          fmt.level_incr;
  148.          arguments.pretty_print;
  149.          fmt.level_decr;
  150.       end;
  151.  
  152.    short is
  153.       do
  154.          target.short_target;
  155.          run_feature.name.short;
  156.          arguments.short;
  157.       end;
  158.  
  159.    short_target is
  160.       do
  161.          short;
  162.          short_print.a_dot;
  163.       end;
  164.  
  165.    compile_to_jvm is
  166.       do
  167.          call_proc_call_c2jvm;
  168.       end;
  169.  
  170.    jvm_branch_if_false: INTEGER is
  171.       do
  172.          Result := jvm_standard_branch_if_false;
  173.       end;
  174.  
  175.    jvm_branch_if_true: INTEGER is
  176.       do
  177.          Result := jvm_standard_branch_if_true;
  178.       end;
  179.  
  180.    assertion_check(tag: CHARACTER) is
  181.       do
  182.          if tag = 'R' then
  183.             run_feature.vape_check_from(start_position);
  184.          end;
  185.          target.assertion_check(tag);
  186.          arguments.assertion_check(tag);
  187.       end;
  188.  
  189.    is_static: BOOLEAN is
  190.       local
  191.          running: ARRAY[RUN_CLASS];
  192.          rf: like run_feature;
  193.       do
  194.          running := run_feature.run_class.running;
  195.          if running /= Void and then running.count = 1 then
  196.             rf := running.first.dynamic(run_feature);
  197.             if rf.is_static then
  198.                Result := true;
  199.             end;
  200.          end;
  201.       end;
  202.  
  203.    static_value: INTEGER is
  204.       local
  205.          running: ARRAY[RUN_CLASS];
  206.          rf: like run_feature;
  207.       do
  208.          running := run_feature.run_class.running;
  209.          if running /= Void and then running.count = 1 then
  210.             rf := running.first.dynamic(run_feature);
  211.             if rf.is_static then
  212.                Result := rf.static_value_mem;
  213.             end;
  214.          end;
  215.       end;
  216.  
  217. feature {RUN_FEATURE_3,RUN_FEATURE_4}
  218.  
  219.    finalize is
  220.       local
  221.          rc: RUN_CLASS;
  222.          rf: RUN_FEATURE;
  223.       do
  224.          rf := run_feature;
  225.          rc := rf.current_type.run_class;
  226.          run_feature := rc.running.first.dynamic(rf);
  227.       end;
  228.  
  229. feature {NONE}
  230.  
  231.    run_feature_match(ct: TYPE) is
  232.       do
  233.          run_feature_has_result;
  234.          arguments.match_with(run_feature,ct);
  235.       end;
  236.  
  237. invariant
  238.  
  239.    arguments.count > 1;
  240.  
  241. end -- CALL_N
  242.  
  243.