home *** CD-ROM | disk | FTP | other *** search
- --
- -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
- -- Author: Gilles Demailly
- --
- --
- -- Permission to use, copy, modify, and distribute this software and its
- -- documentation for any purpose and without fee is hereby granted,
- -- provided that the above copyright and authorship notice appear in all
- -- copies and that both that copyright notice and this permission notice
- -- appear in supporting documentation.
- --
- -- The ARA makes no representations about the suitability of this software
- -- for any purpose. It is provided "as is" without express
- -- or implied warranty.
- --
-
- with Ada.Text_Io;
-
- with CP.Utf8;
- with CP.Unicode;
- with CP.Integers;
- with CP.Floats;
- with CP.Long_Integers;
- with CP.Long_Floats;
- with CP.Classes;
- with CP.Strings;
- with CP.Ref_Info;
- with CP.Name_And_Type;
-
- package body CP is
-
- use Byte_Utilities;
-
- function Read_Constant (From_File : Byte_Utilities.File_Type)
- return Acc_CP_Info is
- New_One : Acc_CP_Info;
- CP_Tag : Unsigned_8;
- begin
- -- Read tag first
- Read (From_File, CP_Tag);
-
- -- choose the correct subclass from the Tag
- case CP_Tag is
- when CP.Utf8.C_Class_Tag =>
- New_One := new CP.Utf8.Utf8;
- when CP.Unicode.C_Class_Tag =>
- New_One := new CP.Unicode.Unicode;
- when CP.Integers.C_Class_Tag =>
- New_One := new CP.Integers.Integers;
- when CP.Floats.C_Class_Tag =>
- New_One := new CP.Floats.Floats;
- when CP.Long_Integers.C_Class_Tag =>
- New_One := new CP.Long_Integers.Long_Integers;
- when CP.Long_Floats.C_Class_Tag =>
- New_One := new CP.Long_Floats.Long_Floats;
- when CP.Classes.C_Class_Tag =>
- New_One := new CP.Classes.Classes;
- when CP.Strings.C_Class_Tag =>
- New_One := new CP.Strings.Strings;
- when CP.Ref_Info.C_Class_Tag |
- CP.Ref_Info.C_Class_Tag1 |
- CP.Ref_Info.C_Class_Tag2 =>
- New_One := new CP.Ref_Info.Ref_Info;
- when CP.Name_And_Type.C_Class_Tag =>
- New_One := new CP.Name_And_Type.Name_And_Type;
-
- when others =>
- Ada.Text_Io.Put_Line
- (" Unknown Tag found : " & Unsigned_8'Image (CP_Tag));
- raise E_Unknown_Tag;
-
- end case;
-
- -- decode the informations of the Constant Pool information
- -- (this procedure is implemented by subclasses)
- Decode (From_File, New_One);
-
- return New_One;
-
- end Read_Constant;
-
- function Is_Class
- (Some_Info : access CP_Info) return Boolean is
- begin
- -- if you want True, just overwrite this method
- return False;
- end Is_Class;
-
- function Use_Two_Indexes_In_Table
- (Some_Info : access CP_Info) return Boolean is
- begin
- -- if you want True, just overwrite this method
- return False;
- end Use_Two_Indexes_In_Table;
-
- --
- -- Differents Constant Pool information to string conversion functions
- -- get here a default implementation returning an empty string
- --
-
- function As_String
- (Some_Info : access CP_Info) return Wide_String is
- begin
- return "";
- end As_String;
-
- function Print_String
- (Some_Info : access CP_Info;
- Context : Acc_CP_Infos) return String is
- begin
- return "";
- end Print_String;
-
- function Java_Decoded_String
- (Some_Info : access CP_Info;
- Context : Acc_CP_Infos;
- Purpose : Decoding_Purpose) return String is
- begin
- return Print_String (Some_Info, Context);
- end Java_Decoded_String;
-
- end CP;
-