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 Ada.Tags; use type Ada.Tags.Tag;
-
- with Flags;
- with Attribute;
- with Attribute.Code;
- with Attribute.Exceptions;
-
- package body Field.Method is
-
- function Read_Field
- (From_File : Byte_Utilities.File_Type;
- Context : in CP.Acc_CP_Infos)
- return Acc_Field_Info is
- New_One : Acc_Field_Info;
- begin
- -- creates the Method Info
- New_One := new Method_Info;
-
- -- Decoding inside informations is done by the superclass
- Decode (From_File, New_One, Context);
- return New_One;
- end Read_Field;
-
-
- procedure Display_Java_Spec (Infos : access Method_Info;
- Context : in CP.Acc_CP_Infos;
- For_Class : in Unsigned_16;
- For_Body : in Boolean) is
- Signature : constant String := CP.Java_Decoded_String
- (Context (Infos.Signature_Index),
- Context,
- CP.Method_Signature);
- Method_Name : constant String := CP.Print_String
- (Context (Infos.Name_Index), Context);
- Return_Index : Natural := Signature'First;
- begin
-
- -- gets the type of the method return value
- while Return_Index <= Signature'Last and then
- Signature (Return_Index) /= ')' loop
- Return_Index := Return_Index + 1;
- end loop;
-
- Ada.Text_Io.Put (" ");
-
- -- displays the method access categories
- Flags.Display (Infos.Access_Flags, Flags.Method_Flag);
-
- -- Displays the type of the method return value
- Ada.Text_Io.Put (Signature (Return_Index + 1..Signature'Last) & " ");
-
- -- displays the method name (special treatment for constructors)
- if Method_Name = "<init>" then
- Ada.Text_Io.Put (CP.Java_Decoded_String
- (Context (For_Class),
- Context,
- CP.Class_Name));
- else
- Ada.Text_Io.Put (Method_Name);
- end if;
-
- -- displays the method arguments
- Ada.Text_Io.Put
- (" " & Signature (Signature'First .. Return_Index));
-
- -- displays the exceptions thrown by the method
- if Infos.Attributes_Count > 0 then
- for J in 1 .. Infos.Attributes_Count loop
- if Infos.Attributes (J).all'Tag =
- Attribute.Exceptions.Exceptions_Attribute'Tag then
- Ada.Text_Io.Put (" throws ");
- Attribute.Display (Infos.Attributes (J), Context);
- end if;
- end loop;
- end if;
-
- -- if there is not a body generated, this is the end.
- if not For_Body then
- Ada.Text_Io.Put_Line (";");
- end if;
-
- end Display_Java_Spec;
-
- procedure Display_Ada_Spec (Infos : access Method_Info;
- Context : in CP.Acc_CP_Infos;
- For_Class : in Unsigned_16) is
- begin
- null;
- end Display_Ada_Spec;
-
- procedure Display_Java_Body (Infos : access Method_Info;
- Context : in CP.Acc_CP_Infos;
- For_Class : in Unsigned_16) is
-
- No_Code : Boolean := True;
-
- begin
- -- displays the method definition
- Display_Java_Spec (Infos, Context, For_Class, True);
-
- -- displays the method's code (if applicable)
- if Infos.Attributes_Count > 0 then
- for J in 1 .. Infos.Attributes_Count loop
- if Infos.Attributes (J).all'Tag =
- Attribute.Code.Code_Attribute'Tag then
- Ada.Text_Io.Put_Line (" {");
- Attribute.Display (Infos.Attributes (J), Context);
- Ada.Text_Io.Put_Line (" }");
- No_Code := False;
- end if;
- end loop;
- end if;
-
- if No_Code then
- Ada.Text_Io.Put_Line (";");
- end if;
-
- end Display_Java_Body;
-
- procedure Display_Ada_Body (Infos : access Method_Info;
- Context : in CP.Acc_CP_Infos;
- For_Class : in Unsigned_16) is
- begin
- null;
- end Display_Ada_Body;
-
- end Field.Method;
-