home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / local_name.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  4.7 KB  |  188 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 LOCAL_NAME
  17.    --
  18.    -- Handling of local variables.
  19.    --
  20.  
  21. inherit LOCAL_ARGUMENT;
  22.  
  23. feature
  24.  
  25.    is_writable: BOOLEAN is true;
  26.    
  27.    isa_dca_inline_argument: INTEGER is 0;
  28.      -- A voir ....
  29.  
  30.    dca_inline_argument(formal_arg_type: TYPE) is
  31.      -- *** FAIRE ***
  32.       do
  33.       end;
  34.  
  35.    frozen mapping_c_target(target_type: TYPE) is
  36.       local
  37.      flag: BOOLEAN;
  38.      rt: like result_type;
  39.       do
  40.      flag := cpp.call_invariant_start(target_type);
  41.      rt := result_type.run_type;
  42.      if rt.is_reference then
  43.         if target_type.is_reference then
  44.            -- Reference into Reference :
  45.            cpp.put_character('(');
  46.            cpp.put_character('(');
  47.            cpp.put_character('T');
  48.            cpp.put_integer(target_type.id);
  49.            cpp.put_character('*');
  50.            cpp.put_character(')');
  51.            compile_to_c;
  52.            cpp.put_character(')');
  53.         else
  54.            -- Reference into Expanded :
  55.            rt.to_expanded;
  56.            cpp.put_character('(');
  57.            compile_to_c;
  58.            cpp.put_character(')');
  59.         end;
  60.      elseif target_type.is_reference then
  61.         -- Expanded into Reference :
  62.         rt.to_reference;
  63.         cpp.put_character('(');
  64.         compile_to_c;
  65.         cpp.put_character(')');
  66.      else
  67.         -- Expanded into Expanded :
  68.         if rt.need_c_struct then
  69.            cpp.put_character('&');
  70.         end;
  71.         compile_to_c;
  72.      end;
  73.      if flag then
  74.         cpp.call_invariant_end;
  75.      end;
  76.       end;
  77.  
  78.    frozen mapping_c_arg(formal_arg_type: TYPE) is
  79.       local
  80.      rt: like result_type;
  81.       do
  82.      rt := result_type.run_type;
  83.      if rt.is_reference then
  84.         if formal_arg_type.is_reference then
  85.            -- Reference into Reference :
  86.            compile_to_c;
  87.         else
  88.            -- Reference into Expanded :
  89.            rt.to_expanded;
  90.            cpp.put_character('(');
  91.            compile_to_c;
  92.            cpp.put_character(')');
  93.         end;
  94.      elseif formal_arg_type.is_reference then
  95.         -- Expanded into Reference :
  96.         rt.to_reference;
  97.         cpp.put_character('(');
  98.         compile_to_c;
  99.         cpp.put_character(')');
  100.      else
  101.         -- Expanded into Expanded :
  102.         if rt.need_c_struct then
  103.            cpp.put_character('&');
  104.         end;
  105.         compile_to_c;
  106.      end;
  107.       end;
  108.  
  109.    compile_to_c is
  110.      -- Using a local.
  111.       do
  112.      cpp.print_local(to_string);
  113.       end;
  114.    
  115. feature
  116.  
  117.    compile_to_jvm is
  118.       local
  119.      jvm_offset: INTEGER;
  120.       do
  121.      jvm_offset := jvm.local_offset_of(Current);
  122.      result_type.run_type.jvm_push_local(jvm_offset);
  123.       end;
  124.    
  125.    compile_to_jvm_assignment(a: ASSIGNMENT) is
  126.       local
  127.      space, jvm_offset: INTEGER;
  128.       do
  129.      jvm_offset := jvm.local_offset_of(Current);
  130.      space := a.right_side.compile_to_jvm_into(result_type.run_type);
  131.      result_type.run_type.jvm_write_local(jvm_offset);
  132.       end;
  133.    
  134.    jvm_branch_if_false: INTEGER is
  135.       do
  136.      compile_to_jvm;
  137.      Result := code_attribute.opcode_ifeq;
  138.       end;
  139.  
  140.    jvm_branch_if_true: INTEGER is
  141.       do
  142.      compile_to_jvm;
  143.      Result := code_attribute.opcode_ifne;
  144.       end;
  145.  
  146.    compile_to_jvm_into(dest: TYPE): INTEGER is
  147.       do
  148.      Result := standard_compile_to_jvm_into(dest);
  149.       end;
  150.  
  151. feature {DECLARATION_LIST}
  152.  
  153.    name_clash is
  154.       local
  155.      rc: RUN_CLASS;
  156.      rf: RUN_FEATURE;
  157.       do
  158.      if base_class_written.has_feature(to_string) then
  159.         rc := current_type.run_class;
  160.         rf := rc.get_feature_with(to_string)
  161.         if rf /= Void then
  162.            eh.add_position(rf.start_position);
  163.         end;
  164.         eh.add_position(start_position);
  165.         fatal_error("Conflict between local/feature name (VRLE).");
  166.      end;
  167.       end;
  168.    
  169. feature {NONE}
  170.  
  171.    tmp_string: STRING is
  172.       once
  173.      !!Result.make(256);
  174.       end;
  175.  
  176. feature {CREATION_CALL,EXPRESSION_WITH_COMMENT}
  177.       
  178.    jvm_assign is
  179.       local
  180.      jvm_offset: INTEGER;
  181.       do
  182.      jvm_offset := jvm.local_offset_of(Current);
  183.      result_type.run_type.jvm_write_local(jvm_offset);
  184.       end;
  185.  
  186. end -- LOCAL_NAME
  187.  
  188.