home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / call.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  5.6 KB  |  228 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://www.loria.fr/SmallEiffel
  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 
  26.    CALL_PROC_CALL
  27.       undefine fill_tagged_out_memory
  28.       end;
  29.    EXPRESSION;      
  30.  
  31. feature  
  32.    
  33.    result_type: TYPE;
  34.      -- When checked, the result_type of the call.
  35.    
  36. feature  
  37.  
  38.    is_static: BOOLEAN is
  39.       deferred
  40.       end;
  41.  
  42.    frozen call_is_static: BOOLEAN is
  43.       local
  44.      rc: RUN_CLASS;
  45.      running: ARRAY[RUN_CLASS];
  46.      rf: like run_feature;
  47.       do
  48.      if run_feature /= Void then
  49.         rc := run_feature.run_class;
  50.         if rc /= Void then
  51.            running := rc.running;
  52.            if running /= Void and then running.count = 1 then
  53.           rf := running.first.dynamic(run_feature);
  54.           if rf.is_static then
  55.              static_value_mem := rf.static_value_mem;
  56.              Result := true;
  57.           end;
  58.            end;
  59.         end;
  60.      end;
  61.       end;
  62.  
  63.    frozen mapping_c_target(target_type: TYPE) is
  64.       local
  65.      flag: BOOLEAN;
  66.      actual_type: like result_type;
  67.       do
  68.      flag := cpp.call_invariant_start(target_type);
  69.      actual_type := result_type.run_type;
  70.      if actual_type.is_reference then
  71.         if target_type.is_reference then
  72.            -- Reference into Reference :
  73.            cpp.put_character('(');
  74.            cpp.put_character('(');
  75.            cpp.put_character('T');
  76.            cpp.put_integer(target_type.id);
  77.            cpp.put_character('*');
  78.            cpp.put_character(')');
  79.            cpp.put_character('(');
  80.            compile_to_c;
  81.            cpp.put_character(')');
  82.            cpp.put_character(')');
  83.         else
  84.            -- Reference into Expanded :
  85.            actual_type.to_expanded;
  86.            cpp.put_character('(');
  87.            compile_to_c;
  88.            cpp.put_character(')');
  89.         end;
  90.      else
  91.         if target_type.is_reference then
  92.            -- Expanded into Reference :
  93.            actual_type.to_reference;
  94.            cpp.put_character('(');
  95.            compile_to_c;
  96.            cpp.put_character(')');
  97.         else
  98.            -- Expanded into Expanded :
  99.            if target_type.need_c_struct then
  100.           cpp.put_character('&');
  101.           cpp.put_character('(');
  102.           compile_to_c;
  103.           cpp.put_character(')');
  104.            else
  105.           compile_to_c;
  106.            end;
  107.         end;
  108.      end;
  109.      if flag then
  110.         cpp.call_invariant_end;
  111.      end;
  112.       end;
  113.  
  114.    frozen mapping_c_arg(formal_arg_type: TYPE) is
  115.       local
  116.      actual_type: like result_type;
  117.       do
  118.      actual_type := result_type.run_type;
  119.      if actual_type.is_reference then
  120.         if formal_arg_type.is_reference then
  121.            -- Reference into Reference :
  122.            compile_to_c;
  123.         else
  124.            -- Reference into Expanded :
  125.            actual_type.to_expanded;
  126.            cpp.put_character('(');
  127.            compile_to_c;
  128.            cpp.put_character(')');
  129.         end;
  130.      else
  131.         if formal_arg_type.is_reference then
  132.            -- Expanded into Reference :
  133.            actual_type.to_reference;
  134.            cpp.put_character('(');
  135.            compile_to_c;
  136.            cpp.put_character(')');
  137.         else
  138.            -- Expanded into Expanded :
  139.            if formal_arg_type.need_c_struct then
  140.           cpp.put_character('&');
  141.           cpp.put_character('(');
  142.           compile_to_c;
  143.           cpp.put_character(')');
  144.            else
  145.           compile_to_c;
  146.            end;
  147.         end;
  148.      end;
  149.       end;
  150.  
  151.    compile_to_c is
  152.       do
  153.      call_proc_call_c2c;
  154.       end;
  155.    
  156.    frozen compile_to_c_old is
  157.       do
  158.      target.compile_to_c_old;
  159.      if arg_count > 0 then
  160.         arguments.compile_to_c_old;
  161.      end;
  162.       end;
  163.    
  164.    frozen compile_to_jvm_old is
  165.       do
  166.      target.compile_to_jvm_old;
  167.      if arg_count > 0 then
  168.         arguments.compile_to_jvm_old;
  169.      end;
  170.       end;
  171.    
  172.    precedence: INTEGER is
  173.       do
  174.      Result := dot_precedence;
  175.       end;
  176.    
  177.    frozen c_simple: BOOLEAN is do end;
  178.    
  179.    print_as_target is
  180.       do
  181.      pretty_print;
  182.      fmt.put_character('.');
  183.       end;
  184.    
  185.    frozen compile_target_to_jvm is
  186.       do
  187.      standard_compile_target_to_jvm;
  188.       end;
  189.  
  190.    frozen compile_to_jvm_assignment(a: ASSIGNMENT) is
  191.       do
  192.       end;
  193.  
  194.    frozen compile_to_jvm_into(dest: TYPE): INTEGER is
  195.       do
  196.      Result := standard_compile_to_jvm_into(dest);
  197.       end;
  198.    
  199. feature {NONE}
  200.    
  201.    frozen to_runnable_0(ct: TYPE) is
  202.       require
  203.      ct /= Void;
  204.      current_type = Void
  205.       do
  206.      current_type := ct;
  207.      cpc_to_runnable(ct);
  208.      result_type := run_feature.result_type;
  209.      if result_type = Void then
  210.         eh.add_position(run_feature.start_position);
  211.         error(feature_name.start_position,
  212.           "Feature found has no result.");
  213.      elseif result_type.is_like_current then
  214.         result_type := target.result_type;
  215.      end;
  216.       ensure
  217.      current_type = ct;
  218.       end;
  219.    
  220. feature {CREATION_CALL,EXPRESSION_WITH_COMMENT}
  221.       
  222.    jvm_assign is
  223.       do
  224.       end;
  225.  
  226. end -- CALL
  227.  
  228.