home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / e_result.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  5.5 KB  |  244 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. class E_RESULT
  17. --
  18. -- Handling of the pseudo variable `Result'.
  19. --
  20.  
  21. inherit 
  22.    NAME;
  23.    EXPRESSION
  24.       redefine is_writable, is_result
  25.       end;
  26.    
  27. creation make
  28.    
  29. feature 
  30.    
  31.    start_position: POSITION;
  32.    
  33.    result_type: TYPE;
  34.    
  35.    make(sp: like start_position) is
  36.       require
  37.      sp /= Void;
  38.       do
  39.      to_string := us_result;
  40.      start_position := sp;
  41.       end;
  42.    
  43.    is_result, is_writable, can_be_dropped: BOOLEAN is true;
  44.    
  45.    is_static: BOOLEAN is false;
  46.  
  47.    is_pre_computable: BOOLEAN is false;
  48.  
  49.    isa_dca_inline_argument: INTEGER is 0;
  50.      -- *** A FAIRE ***
  51.  
  52.    to_key: STRING is
  53.       do
  54.      Result := to_string;
  55.       end;
  56.  
  57.    dca_inline_argument(formal_arg_type: TYPE) is
  58.      -- *** FAIRE ***
  59.       do
  60.       end;
  61.  
  62.    print_as_target is
  63.       do
  64.      fmt.put_string(us_result);
  65.      fmt.put_character('.');
  66.       end;
  67.    
  68.    short is
  69.       do
  70.      short_print.hook_or(us_result,us_result);
  71.       end;
  72.  
  73.    short_target is
  74.       do
  75.      short;
  76.      short_print.a_dot;
  77.       end;
  78.  
  79.    to_runnable(ct: TYPE): E_RESULT is
  80.       do
  81.      if current_type = Void then
  82.         current_type := ct;
  83.         result_type := small_eiffel.top_rf.result_type;
  84.         Result := Current;
  85.      else
  86.         !!Result.make(start_position);
  87.         Result := Result.to_runnable(ct);
  88.      end;
  89.       end;
  90.    
  91.    use_current: BOOLEAN is false;
  92.       
  93.    frozen mapping_c_target(target_type: TYPE) is
  94.       local
  95.      flag: BOOLEAN;
  96.      rt: like result_type;
  97.       do
  98.      flag := cpp.call_invariant_start(target_type);
  99.      rt := result_type.run_type;
  100.      if rt.is_reference then
  101.         if target_type.is_reference then
  102.            -- Reference into Reference :
  103.            cpp.put_character('(');
  104.            cpp.put_character('(');
  105.            cpp.put_character('T');
  106.            cpp.put_integer(target_type.id);
  107.            cpp.put_character('*');
  108.            cpp.put_character(')');
  109.            compile_to_c;
  110.            cpp.put_character(')');
  111.         else
  112.            -- Reference into Expanded :
  113.            rt.to_expanded;
  114.            cpp.put_character('(');
  115.            compile_to_c;
  116.            cpp.put_character(')');
  117.         end;
  118.      else
  119.         if target_type.is_reference then
  120.            -- Expanded into Reference :
  121.            rt.to_reference;
  122.            cpp.put_character('(');
  123.            compile_to_c;
  124.            cpp.put_character(')');
  125.         else
  126.            -- Expanded into Expanded :
  127.            if rt.need_c_struct then
  128.           cpp.put_character('&');
  129.            end;
  130.            compile_to_c;
  131.         end;
  132.      end;
  133.      if flag then
  134.         cpp.call_invariant_end;
  135.      end;
  136.       end;
  137.  
  138.    frozen mapping_c_arg(formal_arg_type: TYPE) is
  139.       local
  140.      rt: like result_type;
  141.       do
  142.      rt := result_type.run_type;
  143.      if rt.is_reference then
  144.         if formal_arg_type.is_reference then
  145.            -- Reference into Reference :
  146.            compile_to_c;
  147.         else
  148.            -- Reference into Expanded :
  149.            rt.to_expanded;
  150.            cpp.put_character('(');
  151.            compile_to_c;
  152.            cpp.put_character(')');
  153.         end;
  154.      else
  155.         if formal_arg_type.is_reference then
  156.            -- Expanded into Reference :
  157.            rt.to_reference;
  158.            cpp.put_character('(');
  159.            compile_to_c;
  160.            cpp.put_character(')');
  161.         else
  162.            -- Expanded into Expanded :
  163.            if rt.need_c_struct then
  164.           cpp.put_character('&');
  165.            end;
  166.            compile_to_c;
  167.         end;
  168.      end;
  169.       end;
  170.  
  171.    compile_to_c is
  172.       do
  173.      cpp.put_character('R');
  174.       end;
  175.  
  176.    compile_to_c_old is
  177.       do 
  178.       end;
  179.       
  180.    compile_to_jvm_old is
  181.       do 
  182.       end;
  183.    
  184.    compile_to_jvm is
  185.       local
  186.      jvm_offset: INTEGER;
  187.       do
  188.      jvm_offset := jvm.result_offset;
  189.      result_type.run_type.jvm_push_local(jvm_offset);
  190.       end;
  191.    
  192.    compile_target_to_jvm is
  193.       do
  194.      standard_compile_target_to_jvm;
  195.       end;
  196.    
  197.    compile_to_jvm_assignment(a: ASSIGNMENT) is
  198.       local
  199.      space, jvm_offset: INTEGER;
  200.       do
  201.      jvm_offset := jvm.result_offset;
  202.      space := a.right_side.compile_to_jvm_into(result_type.run_type);
  203.      result_type.run_type.jvm_write_local(jvm_offset)
  204.       end;
  205.    
  206.    jvm_branch_if_false: INTEGER is
  207.       do
  208.      compile_to_jvm;
  209.      Result := code_attribute.opcode_ifeq;
  210.       end;
  211.  
  212.    jvm_branch_if_true: INTEGER is
  213.       do
  214.      compile_to_jvm;
  215.      Result := code_attribute.opcode_ifne;
  216.       end;
  217.  
  218.    compile_to_jvm_into(dest: TYPE): INTEGER is
  219.       do
  220.      Result := standard_compile_to_jvm_into(dest);
  221.       end;
  222.  
  223.    precedence: INTEGER is
  224.       do
  225.      Result := atomic_precedence;
  226.       end;
  227.  
  228. feature {CREATION_CALL,EXPRESSION_WITH_COMMENT}
  229.       
  230.    jvm_assign is
  231.       local
  232.      jvm_offset: INTEGER;
  233.       do
  234.      jvm_offset := jvm.result_offset;
  235.      result_type.run_type.jvm_write_local(jvm_offset)
  236.       end;
  237.  
  238. invariant
  239.    
  240.    start_position /= Void
  241.    
  242. end -- E_RESULT
  243.  
  244.