home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / local_name.e < prev    next >
Text File  |  1999-06-05  |  5KB  |  163 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://SmallEiffel.loria.fr
  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_current: BOOLEAN is false;
  26.  
  27.    is_writable: BOOLEAN is true;
  28.  
  29.    isa_dca_inline_argument: INTEGER is 0;
  30.  
  31. feature
  32.  
  33.    dca_inline_argument(formal_arg_type: TYPE) is
  34.       do
  35.       end;
  36.  
  37.    frozen mapping_c_target(target_type: TYPE) is
  38.       local
  39.          flag: BOOLEAN;
  40.          rt: like result_type;
  41.       do
  42.          flag := cpp.call_invariant_start(target_type);
  43.          rt := result_type.run_type;
  44.          if rt.is_reference then
  45.             if target_type.is_reference then
  46.                -- Reference into Reference :
  47.                cpp.put_character('(');
  48.                cpp.put_character('(');
  49.                cpp.put_character('T');
  50.                cpp.put_integer(target_type.id);
  51.                cpp.put_character('*');
  52.                cpp.put_character(')');
  53.                compile_to_c;
  54.                cpp.put_character(')');
  55.             else
  56.                -- Reference into Expanded :
  57.                rt.to_expanded;
  58.                cpp.put_character('(');
  59.                compile_to_c;
  60.                cpp.put_character(')');
  61.             end;
  62.          elseif target_type.is_reference then
  63.             -- Expanded into Reference :
  64.             rt.to_reference;
  65.             cpp.put_character('(');
  66.             compile_to_c;
  67.             cpp.put_character(')');
  68.          else
  69.             -- Expanded into Expanded :
  70.             if rt.need_c_struct then
  71.                cpp.put_character('&');
  72.             end;
  73.             compile_to_c;
  74.          end;
  75.          if flag then
  76.             cpp.call_invariant_end;
  77.          end;
  78.       end;
  79.  
  80.    frozen mapping_c_arg(formal_arg_type: TYPE) is
  81.       local
  82.          rt: like result_type;
  83.       do
  84.          rt := result_type.run_type;
  85.          if rt.is_reference then
  86.             if formal_arg_type.is_reference then
  87.                -- Reference into Reference :
  88.                compile_to_c;
  89.             else
  90.                -- Reference into Expanded :
  91.                rt.to_expanded;
  92.                cpp.put_character('(');
  93.                compile_to_c;
  94.                cpp.put_character(')');
  95.             end;
  96.          elseif formal_arg_type.is_reference then
  97.             -- Expanded into Reference :
  98.             rt.to_reference;
  99.             cpp.put_character('(');
  100.             compile_to_c;
  101.             cpp.put_character(')');
  102.          else
  103.             -- Expanded into Expanded :
  104.             if rt.need_c_struct then
  105.                cpp.put_character('&');
  106.             end;
  107.             compile_to_c;
  108.          end;
  109.       end;
  110.  
  111.    compile_to_c is
  112.       do
  113.          cpp.print_local(to_string);
  114.       end;
  115.  
  116.    compile_to_jvm is
  117.       local
  118.          jvm_offset: INTEGER;
  119.       do
  120.          jvm_offset := jvm.local_offset_of(Current);
  121.          result_type.run_type.jvm_push_local(jvm_offset);
  122.       end;
  123.  
  124.    jvm_branch_if_false: INTEGER is
  125.       do
  126.          compile_to_jvm;
  127.          Result := code_attribute.opcode_ifeq;
  128.       end;
  129.  
  130.    jvm_branch_if_true: INTEGER is
  131.       do
  132.          compile_to_jvm;
  133.          Result := code_attribute.opcode_ifne;
  134.       end;
  135.  
  136.    compile_to_jvm_into(dest: TYPE): INTEGER is
  137.       do
  138.          Result := standard_compile_to_jvm_into(dest);
  139.       end;
  140.  
  141.    frozen jvm_assign is
  142.       local
  143.          jvm_offset: INTEGER;
  144.       do
  145.          jvm_offset := jvm.local_offset_of(Current);
  146.          result_type.run_type.jvm_write_local(jvm_offset);
  147.       end;
  148.  
  149.    frozen pretty_print is
  150.       do
  151.          fmt.put_string(to_string);
  152.       end;
  153.  
  154. feature {NONE}
  155.  
  156.    tmp_string: STRING is
  157.       once
  158.          !!Result.make(256);
  159.       end;
  160.  
  161. end -- LOCAL_NAME
  162.  
  163.