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;
-
- package body Flags is
-
- --
- -- Category masks are used for flag correctness checking
- --
-
- Class_Mask : constant Unsigned_16 := 16#0611#;
-
- Method_Mask : constant Unsigned_16 := 16#053F#;
-
- Variable_Mask : constant Unsigned_16 := 16#00DF#;
-
- --
- -- Bit position of different flag values
- --
-
- Public_Bit : constant Natural := 15;
- Private_Bit : constant Natural := 14;
- Protected_Bit : constant Natural := 13;
- Static_Bit : constant Natural := 12;
- Final_Bit : constant Natural := 11;
- Synchronized_Bit : constant Natural := 10;
- Volatile_Bit : constant Natural := 9;
- Transient_Bit : constant Natural := 8;
- Native_Bit : constant Natural := 7;
- Interface_Bit : constant Natural := 6;
- Abstract_Bit : constant Natural := 5;
-
- --
- -- flag access functions
- --
-
- function Is_Public (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Public_Bit);
- end Is_Public;
-
- function Is_Private (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Private_Bit);
- end Is_Private;
-
- function Is_Protected (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Protected_Bit);
- end Is_Protected;
-
- function Is_Static (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Static_Bit);
- end Is_Static;
-
- function Is_Final (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Final_Bit);
- end Is_Final;
-
- function Is_Synchronized (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Synchronized_Bit);
- end Is_Synchronized;
-
- function Is_Volatile (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Volatile_Bit);
- end Is_Volatile;
-
- function Is_Transient (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Transient_Bit);
- end Is_Transient;
-
- function Is_Native (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Native_Bit);
- end Is_Native;
-
- function Is_Interface (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Interface_Bit);
- end Is_Interface;
-
- function Is_Abstract (Flag : Unsigned_16) return Boolean is
- begin
- return Bit_At (Flag, Abstract_Bit);
- end Is_Abstract;
-
-
- -- This function is used for file checking.
- -- it returns True if the Flag corresponds to the
- -- flag category.
- -------------------------------------------------
- function Is_Correct (Flag : Unsigned_16;
- Category : Flag_Category) return Boolean is
- begin
- case Category is
- when Class_Flag =>
- return (Flag or Class_Mask) = Class_Mask;
- when Method_Flag =>
- return (Flag or Method_Mask) = Method_Mask;
- when Variable_Flag =>
- return (Flag or Variable_Mask) = Variable_Mask;
- end case;
- end Is_Correct;
-
-
- procedure Display (Flag : Unsigned_16;
- Category : Flag_Category) is
- begin
- -- displays the name of each access right corresponding
- -- to the input Flag value
- case Category is
- when Class_Flag =>
- if Is_Public (Flag) then
- Ada.Text_Io.Put ("public ");
- end if;
- if Is_Final (Flag) then
- Ada.Text_Io.Put ("final ");
- end if;
- if Is_Interface (Flag) then
- Ada.Text_Io.Put ("interface ");
- end if;
- if Is_Abstract (Flag) then
- Ada.Text_Io.Put ("abstract ");
- end if;
- when Method_Flag =>
- if Is_Public (Flag) then
- Ada.Text_Io.Put ("public ");
- end if;
- if Is_Private (Flag) then
- Ada.Text_Io.Put ("private ");
- end if;
- if Is_Protected (Flag) then
- Ada.Text_Io.Put ("protected ");
- end if;
- if Is_Static (Flag) then
- Ada.Text_Io.Put ("static ");
- end if;
- if Is_Final (Flag) then
- Ada.Text_Io.Put ("final ");
- end if;
- if Is_Synchronized (Flag) then
- Ada.Text_Io.Put ("synchronized ");
- end if;
- if Is_Native (Flag) then
- Ada.Text_Io.Put ("native ");
- end if;
- if Is_Abstract (Flag) then
- Ada.Text_Io.Put ("abstract ");
- end if;
- when Variable_Flag =>
- if Is_Public (Flag) then
- Ada.Text_Io.Put ("public ");
- end if;
- if Is_Private (Flag) then
- Ada.Text_Io.Put ("private ");
- end if;
- if Is_Protected (Flag) then
- Ada.Text_Io.Put ("protected ");
- end if;
- if Is_Static (Flag) then
- Ada.Text_Io.Put ("static ");
- end if;
- if Is_Final (Flag) then
- Ada.Text_Io.Put ("final ");
- end if;
- if Is_Volatile (Flag) then
- Ada.Text_Io.Put ("volatile ");
- end if;
- if Is_Transient (Flag) then
- Ada.Text_Io.Put ("transient ");
- end if;
- end case;
- end Display;
-
-
-
- end Flags;
-