home *** CD-ROM | disk | FTP | other *** search
/ Hacker / Hacker.iso / HACKER / DECOMP / DECAF / cp.adb < prev    next >
Encoding:
Text File  |  1996-09-19  |  3.6 KB  |  123 lines

  1. --
  2. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  3. -- Author: Gilles Demailly
  4. --
  5. --
  6. -- Permission to use, copy, modify, and distribute this software and its
  7. -- documentation for any purpose and without fee is hereby granted,
  8. -- provided that the above copyright and authorship notice appear in all
  9. -- copies and that both that copyright notice and this permission notice
  10. -- appear in supporting documentation.
  11. -- 
  12. -- The ARA makes no representations about the suitability of this software
  13. -- for any purpose.  It is provided "as is" without express
  14. -- or implied warranty.
  15. -- 
  16.  
  17. with Ada.Text_Io;
  18.  
  19. with CP.Utf8;
  20. with CP.Unicode;
  21. with CP.Integers;
  22. with CP.Floats;
  23. with CP.Long_Integers;
  24. with CP.Long_Floats;
  25. with CP.Classes;
  26. with CP.Strings;
  27. with CP.Ref_Info;
  28. with CP.Name_And_Type;
  29.  
  30. package body CP is
  31.  
  32.    use Byte_Utilities;
  33.  
  34.    function Read_Constant (From_File : Byte_Utilities.File_Type)      
  35.             return Acc_CP_Info is
  36.       New_One : Acc_CP_Info;
  37.       CP_Tag  : Unsigned_8;
  38.    begin
  39.       -- Read tag first
  40.       Read (From_File, CP_Tag);
  41.  
  42.       -- choose the correct subclass from the Tag 
  43.       case CP_Tag is
  44.          when CP.Utf8.C_Class_Tag =>
  45.             New_One := new CP.Utf8.Utf8;
  46.          when CP.Unicode.C_Class_Tag =>
  47.             New_One := new CP.Unicode.Unicode;
  48.          when CP.Integers.C_Class_Tag =>
  49.             New_One := new CP.Integers.Integers;
  50.          when CP.Floats.C_Class_Tag =>
  51.             New_One := new CP.Floats.Floats;
  52.          when CP.Long_Integers.C_Class_Tag =>
  53.             New_One := new CP.Long_Integers.Long_Integers;
  54.          when CP.Long_Floats.C_Class_Tag =>
  55.             New_One := new CP.Long_Floats.Long_Floats;
  56.          when CP.Classes.C_Class_Tag =>
  57.             New_One := new CP.Classes.Classes;
  58.          when CP.Strings.C_Class_Tag =>
  59.             New_One := new CP.Strings.Strings;
  60.          when CP.Ref_Info.C_Class_Tag  | 
  61.               CP.Ref_Info.C_Class_Tag1 | 
  62.               CP.Ref_Info.C_Class_Tag2  =>
  63.             New_One := new CP.Ref_Info.Ref_Info;
  64.          when CP.Name_And_Type.C_Class_Tag =>
  65.             New_One := new CP.Name_And_Type.Name_And_Type;
  66.  
  67.          when others =>
  68.             Ada.Text_Io.Put_Line
  69.                (" Unknown Tag found : " & Unsigned_8'Image (CP_Tag));
  70.             raise E_Unknown_Tag;
  71.  
  72.       end case;
  73.       
  74.       -- decode the informations of the Constant Pool information
  75.       -- (this procedure is implemented by subclasses)
  76.       Decode (From_File, New_One);
  77.  
  78.       return New_One;
  79.  
  80.    end Read_Constant;
  81.  
  82.    function Is_Class
  83.                (Some_Info : access CP_Info) return Boolean is
  84.    begin
  85.       -- if you want True, just overwrite this method
  86.       return False;
  87.    end Is_Class;
  88.  
  89.    function Use_Two_Indexes_In_Table
  90.                (Some_Info : access CP_Info) return Boolean is
  91.    begin
  92.       -- if you want True, just overwrite this method
  93.       return False;
  94.    end Use_Two_Indexes_In_Table;
  95.  
  96.    --
  97.    -- Differents Constant Pool information to string conversion functions
  98.    -- get here a default implementation returning an empty string
  99.    --
  100.     
  101.    function As_String
  102.                (Some_Info : access CP_Info) return Wide_String is
  103.    begin
  104.       return "";
  105.    end As_String;
  106.  
  107.    function Print_String
  108.                (Some_Info : access CP_Info;
  109.                 Context   : Acc_CP_Infos) return String is
  110.    begin
  111.       return "";
  112.    end Print_String;
  113.  
  114.    function Java_Decoded_String
  115.                (Some_Info : access CP_Info;
  116.                 Context   : Acc_CP_Infos;
  117.                 Purpose   : Decoding_Purpose) return String is
  118.    begin
  119.       return Print_String (Some_Info, Context);
  120.    end Java_Decoded_String;
  121.  
  122. end CP;
  123.