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