home *** CD-ROM | disk | FTP | other *** search
/ Hacker / Hacker.iso / HACKER / DECOMP / DECAF / attribut.adb < prev    next >
Encoding:
Text File  |  1996-09-19  |  2.3 KB  |  67 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 Attribute.Constant_Value;
  18. with Attribute.Source_File;
  19. with Attribute.Code;
  20. with Attribute.Local_Variable_Table;
  21. with Attribute.Exceptions;
  22. with Attribute.Line_Number_Table;
  23.  
  24. package body Attribute is
  25.  
  26.    use Byte_Utilities;
  27.    use CP;
  28.    
  29.    function Read_Attribute
  30.                (From_File : Byte_Utilities.File_Type;
  31.                 Context   : CP.Acc_CP_Infos)      
  32.             return Acc_Attribute is
  33.       Name   : Unsigned_16;
  34.       Answer : Acc_Attribute;
  35.    begin
  36.       -- Read the Name of the Attribute class
  37.       Read (From_File, Name);
  38.  
  39.       -- Instanciate the Attribute correct subclass
  40.       if As_String (Context (Name)) = Source_File.C_Class_Name then
  41.          Answer := new Source_File.Source_File_Attribute;
  42.       elsif As_String (Context (Name)) = Constant_Value.C_Class_Name then
  43.          Answer := new Constant_Value.Constant_Value_Attribute;
  44.       elsif As_String (Context (Name)) = Code.C_Class_Name then
  45.          Answer := new Code.Code_Attribute;
  46.       elsif As_String (Context (Name)) = Exceptions.C_Class_Name then
  47.          Answer := new Exceptions.Exceptions_Attribute;
  48.       elsif As_String (Context (Name)) = Line_Number_Table.C_Class_Name then
  49.          Answer := new Line_Number_Table.Line_Number_Table_Attribute;
  50.       elsif As_String (Context (Name)) = Local_Variable_Table.C_Class_Name then
  51.          Answer := new Local_Variable_Table.Local_Variable_Table_Attribute;
  52.       else
  53.          raise E_Unknown_Attribute;
  54.       end if;
  55.  
  56.       -- Read the Attribute Length
  57.       Read (From_File, Answer.Length);
  58.  
  59.       -- Decode the other informations of the attribute
  60.       -- (implemented by subclasses)
  61.       Decode (Answer, From_File, Context);
  62.  
  63.       return Answer;
  64.    end Read_Attribute;
  65.  
  66. end Attribute;
  67.