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