home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / method_info.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  102 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. class METHOD_INFO
  17.    --
  18.    -- Unique Global Object in charge of a method_info as
  19.    -- describe in the JVM specification.
  20.    -- Obviously, the same object is recycled.
  21.    --
  22. inherit GLOBALS;
  23.  
  24. feature {NONE}
  25.  
  26.    count: INTEGER;
  27.          -- Number of methods.
  28.  
  29.    storage: STRING is
  30.          -- To store the final JVM `method_info'.
  31.       once
  32.          !!Result.make(4096);
  33.       end;
  34.  
  35.    access_flags: INTEGER;
  36.  
  37.    name_index: INTEGER;
  38.          -- Memorize the name_index in the `constant_pool'.
  39.  
  40.    descriptor_index: INTEGER;
  41.          -- Memorize the descriptor_index in the `constant_pool'.
  42.  
  43. feature {JVM}
  44.  
  45.    clear is
  46.       do
  47.          count := 0;
  48.          storage.clear;
  49.       end;
  50.  
  51.    write_bytes is
  52.       do
  53.          echo.print_count("method",count);
  54.          jvm.b_put_u2(count);
  55.          jvm.b_put_byte_string(storage);
  56.       end;
  57.  
  58.  
  59. feature {RUN_FEATURE,JVM,SWITCH}
  60.  
  61.    start(flags: INTEGER; name_key, descriptor: STRING;) is
  62.       require
  63.          not name_key.empty;
  64.          not descriptor.empty
  65.       do
  66.          code_attribute.clear;
  67.          count := count + 1;
  68.          access_flags := flags;
  69.          name_index := constant_pool.idx_utf8(name_key);
  70.          descriptor_index := constant_pool.idx_utf8(descriptor);
  71.       ensure
  72.          access_flags = flags
  73.       end;
  74.  
  75.    finish is
  76.       do
  77.          -- access_flag :
  78.          append_u2(storage,access_flags);
  79.          append_u2(storage,name_index);
  80.          append_u2(storage,descriptor_index);
  81.          -- attributes_count :
  82.          append_u2(storage,1);
  83.          code_attribute.store_in(storage);
  84.       end;
  85.  
  86.    add_init(super: STRING) is
  87.       local
  88.          ca: like code_attribute;
  89.          idx: INTEGER;
  90.       do
  91.          start(1,fz_35,fz_29);
  92.          ca := code_attribute;
  93.          ca.opcode_aload_0;
  94.          idx := constant_pool.idx_methodref3(super,fz_35,fz_29);
  95.          ca.opcode_invokespecial(idx,-1);
  96.          ca.opcode_return;
  97.          finish;
  98.       end;
  99.  
  100. end -- METHOD_INFO
  101.  
  102.