home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / e_old.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  4.8 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_OLD
  17.    --
  18.    -- To store instruction "old ..." usable in an ensure clause.
  19.    --
  20.    
  21. inherit EXPRESSION;
  22.    
  23. creation make
  24.  
  25. feature 
  26.    
  27.    expression: EXPRESSION;
  28.            
  29. feature {NONE}
  30.  
  31.    id: INTEGER;
  32.      -- Used both in C or Java byte code to gives a number to the
  33.      -- the extra local variable.
  34.  
  35. feature
  36.            
  37.    make(exp: like expression) is
  38.       require
  39.      exp /= Void
  40.       do
  41.      expression := exp;
  42.       ensure
  43.      expression = exp;
  44.       end;
  45.    
  46. feature
  47.  
  48.    is_static: BOOLEAN is false;
  49.  
  50.    is_pre_computable: BOOLEAN is false;
  51.  
  52.    can_be_dropped: BOOLEAN is false;
  53.  
  54.    c_simple: BOOLEAN is false;
  55.  
  56.    isa_dca_inline_argument: INTEGER is 0;
  57.    
  58.    dca_inline_argument(formal_arg_type: TYPE) is
  59.       do
  60.       end;
  61.  
  62. feature
  63.  
  64.    result_type: TYPE is
  65.       do
  66.      Result := expression.result_type;
  67.       end;
  68.    
  69.    afd_check is
  70.       do
  71.      expression.afd_check;
  72.       end;
  73.    
  74.    to_runnable(ct: TYPE): like Current is
  75.       local
  76.      exp: like expression;
  77.       do
  78.      if current_type = Void then
  79.         current_type := ct;
  80.         exp := expression.to_runnable(ct);
  81.         if exp = Void then
  82.            error(start_position,"Bad old expression.");
  83.         else
  84.            expression := exp;
  85.         end;
  86.         id_counter.increment;  -- *** NOT INCREMENTAL GCC
  87.         id := id_counter.value;-- ***********************
  88.         Result := Current;
  89.      else
  90.         !!Result.make(expression);
  91.         Result := Result.to_runnable(ct);
  92.      end;
  93.       end;
  94.    
  95.    start_position: POSITION is
  96.       do
  97.      Result := expression.start_position;
  98.       end;
  99.    
  100.    pretty_print is
  101.       do
  102.      fmt.put_string("old ");
  103.      fmt.level_incr;
  104.      expression.pretty_print;
  105.      fmt.level_decr;
  106.       end;
  107.  
  108.    print_as_target is
  109.       do
  110.      fmt.put_character('(');
  111.      pretty_print;
  112.      fmt.put_character(')');
  113.      fmt.put_character('.');
  114.       end;
  115.    
  116.    bracketed_pretty_print is
  117.       do
  118.      fmt.put_character('(');
  119.      pretty_print;
  120.      fmt.put_character(')');
  121.       end;
  122.  
  123.    short is
  124.       do
  125.      short_print.hook_or("old","old ");
  126.      expression.short;
  127.       end;
  128.  
  129.    short_target is
  130.       do
  131.      bracketed_short;
  132.      short_print.a_dot;
  133.       end;
  134.    
  135.    precedence: INTEGER is
  136.       do
  137.      Result := 11;
  138.       end;
  139.    
  140. feature 
  141.    
  142.    frozen mapping_c_target(target_type: TYPE) is
  143.       do
  144.      compile_to_c;
  145.       end;
  146.  
  147.    frozen mapping_c_arg(formal_arg_type: TYPE) is
  148.       do
  149.      compile_to_c;
  150.       end;
  151.  
  152.    compile_to_c_old is 
  153.       local
  154.      t: TYPE;
  155.       do
  156.      t := result_type.run_type;
  157.      tmp_string.clear;
  158.      t.c_type_for_argument_in(tmp_string);
  159.      tmp_string.extend(' ');
  160.      tmp_string.extend('o');
  161.      id.append_in(tmp_string);
  162.      tmp_string.extend('=');
  163.      cpp.put_string(tmp_string);
  164.      expression.mapping_c_arg(t);
  165.      cpp.put_string(fz_00);
  166.       end;
  167.    
  168.    compile_to_c is
  169.       do
  170.      cpp.put_character('o');
  171.      cpp.put_integer(id);
  172.       end;
  173.    
  174.    compile_to_jvm_old is
  175.       local
  176.      e: like expression;
  177.      rt: TYPE;
  178.       do 
  179.      e := expression;
  180.      rt := e.result_type.run_type;
  181.      id := code_attribute.extra_local(rt);
  182.      e.compile_to_jvm;
  183.      rt.jvm_write_local(id);
  184.       end;
  185.  
  186.    compile_to_jvm is
  187.       do
  188.      expression.result_type.jvm_push_local(id);
  189.       end;
  190.    
  191.    compile_target_to_jvm is
  192.       do
  193.      standard_compile_target_to_jvm;
  194.       end;
  195.    
  196.    jvm_branch_if_false: INTEGER is
  197.       do
  198.      Result := jvm_standard_branch_if_false;
  199.       end;
  200.  
  201.    jvm_branch_if_true: INTEGER is
  202.       do
  203.      Result := jvm_standard_branch_if_true;
  204.       end;
  205.    
  206.    compile_to_jvm_into(dest: TYPE): INTEGER is
  207.       do
  208.      Result := standard_compile_to_jvm_into(dest);
  209.       end;
  210.  
  211.    compile_to_jvm_assignment(a: ASSIGNMENT) is
  212.       do
  213.       end;
  214.    
  215.    use_current: BOOLEAN is
  216.       do
  217.      Result := expression.use_current;
  218.       end;
  219.    
  220. feature {NONE}
  221.  
  222.    id_counter: COUNTER is
  223.       once
  224.      !!Result;
  225.       end;
  226.    
  227.    tmp_string: STRING is
  228.       once
  229.      !!Result.make(12);
  230.       end;
  231.  
  232. feature {CREATION_CALL,EXPRESSION_WITH_COMMENT}
  233.       
  234.    jvm_assign is
  235.       do
  236.       end;
  237.  
  238. invariant 
  239.    
  240.    expression /= Void;
  241.    
  242. end -- E_OLD
  243.  
  244.