home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / call.e < prev    next >
Text File  |  1999-06-05  |  6KB  |  203 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
  17.    --
  18.    -- For all sort of feature calls with result value.
  19.    -- So it does not include procedure calls (see PROC_CALL).
  20.    --
  21.    -- Classification: CALL_0 when 0 argument, CALL_1 when
  22.    -- 1 argument and CALL_N when N arguments.
  23.    --
  24.  
  25. inherit CALL_PROC_CALL; EXPRESSION;
  26.  
  27. feature
  28.  
  29.    is_writable: BOOLEAN is false;
  30.  
  31.    is_current: BOOLEAN is false;
  32.  
  33.    is_manifest_string: BOOLEAN is false;
  34.  
  35.    is_result: BOOLEAN is false;
  36.  
  37.    is_void: BOOLEAN is false;
  38.  
  39.    c_simple: BOOLEAN is false;
  40.  
  41. feature
  42.  
  43.    static_result_base_class: BASE_CLASS is
  44.       local
  45.          bc: BASE_CLASS;
  46.          e_feature: E_FEATURE;
  47.          rt: TYPE;
  48.          cn: CLASS_NAME;
  49.       do
  50.          bc := target.static_result_base_class;
  51.          if bc /= Void then
  52.             e_feature := bc.e_feature(feature_name);
  53.             if e_feature /= Void then
  54.                rt := e_feature.result_type;
  55.                if rt /= Void then
  56.                   cn := rt.static_base_class_name;
  57.                   if cn /= Void then
  58.                      Result := cn.base_class;
  59.                   end;
  60.                end;
  61.             end;
  62.          end;
  63.       end;
  64.          
  65.    frozen mapping_c_target(formal_type: TYPE) is
  66.       local
  67.          flag: BOOLEAN;
  68.          actual_type: like result_type;
  69.       do
  70.          flag := cpp.call_invariant_start(formal_type);
  71.          actual_type := result_type.run_type;
  72.          if actual_type.is_reference then
  73.             if formal_type.is_reference then
  74.                -- Reference into Reference :
  75.                formal_type.mapping_cast;
  76.                cpp.put_character('(');
  77.                compile_to_c;
  78.                cpp.put_character(')');
  79.             else
  80.                -- Reference into Expanded :
  81.                actual_type.to_expanded;
  82.                cpp.put_character('(');
  83.                compile_to_c;
  84.                cpp.put_character(')');
  85.             end;
  86.          else
  87.             if formal_type.is_reference then
  88.                -- Expanded into Reference :
  89.                actual_type.to_reference;
  90.                cpp.put_character('(');
  91.                compile_to_c;
  92.                cpp.put_character(')');
  93.             else
  94.                -- Expanded into Expanded :
  95.                if formal_type.need_c_struct then
  96.                   cpp.put_character('&');
  97.                   cpp.put_character('(');
  98.                   compile_to_c;
  99.                   cpp.put_character(')');
  100.                else
  101.                   compile_to_c;
  102.                end;
  103.             end;
  104.          end;
  105.          if flag then
  106.             cpp.call_invariant_end;
  107.          end;
  108.       end;
  109.  
  110.    frozen mapping_c_arg(formal_arg_type: TYPE) is
  111.       local
  112.          actual_type: like result_type;
  113.       do
  114.          actual_type := result_type.run_type;
  115.          if actual_type.is_reference then
  116.             if formal_arg_type.is_reference then
  117.                -- Reference into Reference :
  118.                compile_to_c;
  119.             else
  120.                -- Reference into Expanded :
  121.                actual_type.to_expanded;
  122.                cpp.put_character('(');
  123.                compile_to_c;
  124.                cpp.put_character(')');
  125.             end;
  126.          else
  127.             if formal_arg_type.is_reference then
  128.                -- Expanded into Reference :
  129.                actual_type.to_reference;
  130.                cpp.put_character('(');
  131.                compile_to_c;
  132.                cpp.put_character(')');
  133.             else
  134.                -- Expanded into Expanded :
  135.                if formal_arg_type.need_c_struct then
  136.                   cpp.put_character('&');
  137.                   cpp.put_character('(');
  138.                   compile_to_c;
  139.                   cpp.put_character(')');
  140.                else
  141.                   compile_to_c;
  142.                end;
  143.             end;
  144.          end;
  145.       end;
  146.  
  147.    frozen c_declare_for_old is
  148.       do
  149.          target.c_declare_for_old;
  150.          if arg_count > 0 then
  151.             arguments.c_declare_for_old;
  152.          end;
  153.       end;
  154.  
  155.    frozen compile_to_c_old is
  156.       do
  157.          target.compile_to_c_old;
  158.          if arg_count > 0 then
  159.             arguments.compile_to_c_old;
  160.          end;
  161.       end;
  162.  
  163.    frozen compile_to_jvm_old is
  164.       do
  165.          target.compile_to_jvm_old;
  166.          if arg_count > 0 then
  167.             arguments.compile_to_jvm_old;
  168.          end;
  169.       end;
  170.  
  171.    print_as_target is
  172.       do
  173.          pretty_print;
  174.          fmt.put_character('.');
  175.       end;
  176.  
  177.    frozen compile_target_to_jvm is
  178.       do
  179.          standard_compile_target_to_jvm;
  180.       end;
  181.  
  182.    frozen compile_to_jvm_into(dest: TYPE): INTEGER is
  183.       do
  184.          Result := standard_compile_to_jvm_into(dest);
  185.       end;
  186.  
  187.    frozen jvm_assign is
  188.       do
  189.       end;
  190.  
  191. feature {NONE}
  192.  
  193.    frozen run_feature_has_result is
  194.       do
  195.          if run_feature.result_type = Void then
  196.             eh.add_position(run_feature.start_position);
  197.             eh.add_position(feature_name.start_position);
  198.             fatal_error("Feature found is a procedure.");
  199.          end;
  200.       end;
  201.  
  202. end -- CALL
  203.