

with Asis.Toolkit.ObjectAda;

package Asis.Toolkit.ObjectAda.Declarations is

-----------------------------------------------------------------
-- Toolkit.ObjectAda.Declarations
--
-- This package provides secondary queries for Declarations.
--
-----------------------------------------------------------------

  function Name_Image (Declaration : in Asis.Declaration) return String;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns the string name of the Declaration.
--
-- All Declaration_Kinds are appropriate.
--
-----------------------------------------------------------------

  function Full_Expanded_Name_Image 
		      (Declaration : in Asis.Declaration) return String;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns the string full expanded name of the Declaration.
--
-- All Declaration_Kinds are appropriate.
--
-----------------------------------------------------------------

  function Parent_Full_Expanded_Name_Image 
		      (Declaration : in Asis.Declaration) return String;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns the string full expanded name of the parent declaration
-- that encloses the Declaration.  This is the same as the prefix of
-- the full expanded name.  
--
-- Example: given declaration "A.B.C" returns "A.B".
--
-- All Declaration_Kinds are appropriate.
--
-----------------------------------------------------------------
 
   -- Type_Classes are the language-defined classes for types.
   --
   -- No distinction is made between character, boolean, or other 
   -- enumeration classes.  
   --
   -- No distinction is made between string and other array classes.
   --
   -- A distinction is made between constrained and unconstrained arrays.
   --

   type Type_Classes is 
      (Not_A_Type_Class, 
       A_Signed_Integer_Class,
       A_Modular_Integer_Class,
       An_Enumeration_Class,
       A_Float_Class,
       An_Ordinary_Fixed_Class,
       A_Decimal_Fixed_Class,
       An_Access_To_Object_Class,
       An_Access_To_Subprogram_Class,
       An_Unconstrained_Array_Class,
       A_Constrained_Array_Class,
       An_Untagged_Record_Class,
       A_Tagged_Record_Class,
       A_Task_Class,
       A_Protected_Class);

-----------------------------------------------------------------

  function Type_Class (Declaration : in Asis.Declaration)
		      return Type_Classes;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns the Type_Classes value of the Declaration.
--
-- Subtypes are resolved to their first subtype.
-- Derived types are resolved to their parent subtype.
-- Private types are resolved to their full type.
--
-- Returns Not_A_Type_Class for unexpected elements.

-- Expected Declaration_Kinds: 
--       An_Ordinary_Type_Declaration
--       A_Task_Type_Declaration
--       A_Protected_Type_Declaration
--       A_Private_Type_Declaration
--       A_Private_Extension_Declaration
--       A_Subtype_Declaration
--       A_Formal_Type_Declaration
--
-----------------------------------------------------------------

  function Corresponding_Class_Type (Declaration : in Asis.Declaration)
		      return Asis.Declaration;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns the type that defines the type class.
--
-- Subtypes are resolved to their first subtype.
-- Derived types are resolved to their parent subtype.
-- Private types are resolved to their full type.
--
-- Appropriate Declaration_Kinds: 
--       An_Ordinary_Type_Declaration
--       A_Task_Type_Declaration
--       A_Protected_Type_Declaration
--       A_Private_Type_Declaration
--       A_Private_Extension_Declaration
--       A_Subtype_Declaration
--       A_Formal_Type_Declaration
--
-----------------------------------------------------------------

  function Type_Constraint (Declaration : in Asis.Declaration)
		      return Asis.Constraint;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns the constraint in effect for a type.  If the Declaration
-- has an explicit constraint, it is returned.  Otherwise, the Declaration
-- is resolved until a constraint is either found or not present.

-- Subtypes are resolved to their first subtype.
-- Derived types are resolved to their parent subtype.
-- Private types are resolved to their full type.
-- 
-- Returns Asis.Nil_Element if no constraint applies.
--
-- Appropriate Declaration_Kinds: 
--       An_Ordinary_Type_Declaration
--       A_Task_Type_Declaration
--       A_Protected_Type_Declaration
--       A_Private_Type_Declaration
--       A_Private_Extension_Declaration
--       A_Subtype_Declaration
--       A_Formal_Type_Declaration
--
-----------------------------------------------------------------

  function Object_Subtype (Object : in Asis.Declaration) 
			  return Asis.Declaration;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns the nominal subtype declaration of the object.
--
-- Returns Asis.Nil_Element if the type is an anonymous array.
--
-- Example: I : Integer; returns the type declaration of Integer.
--
-- Appropriate Declaration_Kinds: 
--       A_Variable_Declaration
--       A_Deferred_Constant_Declaration
--       A_Component_Declaration
--       A_Constant_Declaration
--       A_Discriminant_Specification
--       An_Object_Renaming_Declaration
--
-----------------------------------------------------------------

  function Object_Constraint (Object : in Asis.Declaration)
		      return Asis.Constraint;

-----------------------------------------------------------------
-- Declaration - Specifies the object to query
-- 
-- Returns the constraint in effect for the Object.  If the Object
-- has an explicit constraint, it is returned.  Otherwise, the Object
-- is resolved until a constraint is either found or not present.
--
-- Objects of subtypes are resolved to their first subtype.
-- Objects of derived types are resolved to their parent subtype.
-- Objects of private types are resolved to their full type.
-- 
-- Returns Asis.Nil_Element if no constraint applies.
--
-- Appropriate Declaration_Kinds: 
--       A_Variable_Declaration
--       A_Deferred_Constant_Declaration
--       A_Component_Declaration
--       A_Constant_Declaration
--       A_Discriminant_Specification
--
-----------------------------------------------------------------

  function Explicit_Object_Constraint (Object : in Asis.Declaration)
		      return Asis.Constraint;

-----------------------------------------------------------------
-- Declaration - Specifies the object to query
-- 
-- Returns the constraint in effect for the Object.
--
-- Returns Asis.Nil_Element if the Object has no explicit constraint.
-- 
-- Appropriate Declaration_Kinds: 
--       A_Variable_Declaration
--       A_Deferred_Constant_Declaration
--       A_Component_Declaration
--       A_Constant_Declaration
--       A_Discriminant_Specification
--
-----------------------------------------------------------------

  function Is_Record_Subtype (Declaration : in Asis.Declaration)
		             return Boolean;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns True if first_subtype, root type, parent type, ancestor,
-- or full type of the Declaration is a record subtype.
--
-- Returns False for any unexpected Element.
--
-- Expected Declaration_Kinds: 
--       An_Ordinary_Type_Declaration
--       A_Task_Type_Declaration
--       A_Protected_Type_Declaration
--       A_Private_Type_Declaration
--       A_Private_Extension_Declaration
--       A_Subtype_Declaration
--       A_Formal_Type_Declaration
--
-----------------------------------------------------------------

  function All_Record_Components (Declaration : in Asis.Declaration)
		             return Asis.Element_List;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns all discriminant_specifications and component_declarations
-- of the Is_Record_Subtype(Declaration).
--
-- Returns an Asis.Nil_Element_List for appropriate declarations that
-- are not Is_Record_Subtype(Declaration);
--
-- Appropriate Declaration_Kinds: 
--       An_Ordinary_Type_Declaration
--       A_Task_Type_Declaration
--       A_Protected_Type_Declaration
--       A_Private_Type_Declaration
--       A_Private_Extension_Declaration
--       A_Subtype_Declaration
--       A_Formal_Type_Declaration
--
-----------------------------------------------------------------

  function Discriminants (Declaration : in Asis.Declaration)
		             return Asis.Element_List;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns all discriminant_specifications of the Declaration.
--
-- Returns an Asis.Nil_Element_List for appropriate declarations that
-- have no discriminants.
--
-- Appropriate Declaration_Kinds: 
--       An_Ordinary_Type_Declaration
--       A_Task_Type_Declaration
--       A_Protected_Type_Declaration
--       A_Private_Type_Declaration
--       A_Private_Extension_Declaration
--       A_Formal_Type_Declaration
--
-----------------------------------------------------------------

  function Is_Package (Declaration : in Asis.Declaration) return Boolean;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns True if Declaration_Kind(Declaration) is:
--      A_Package_Declaration
--      A_Package_Body_Declaration
--      A_Package_Renaming_Declaration
--      A_Generic_Package_Renaming_Declaration
--      A_Package_Body_Stub
--      A_Generic_Package_Declaration
--      A_Package_Instantiation
--      A_Formal_Package_Declaration
--      A_Formal_Package_Declaration_With_Box
--
-- Returns False for any unexpected Element.
--
-- All Declaration_Kinds are expected.
--
-----------------------------------------------------------------

  function Is_Generic (Declaration : in Asis.Declaration) return Boolean;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
--
-- Returns True if the Declaration is a declaration or the completion 
-- of a generic.

-- Returns True if Declaration_Kind(Declaration) is:
--      A_Generic_Procedure_Declaration
--      A_Generic_Function_Declaration
--      A_Generic_Package_Declaration
--      A_Generic_Procedure_Renaming_Declaration
--      A_Generic_Function_Renaming_Declaration
--      A_Generic_Package_Renaming_Declaration
--
-- Returns True if Declaration_Kind(Declaration) is the completion
-- of a generic declaration:
--      A_Procedure_Body_Declaration
--      A_Function_Body_Declaration
--      A_Package_Body_Declaration
--      A_Procedure_Body_Stub
--      A_Function_Body_Stub
--      A_Package_Body_Stub
--
-- Returns False for any unexpected Element.
--
-- All Declaration_Kinds are expected.
--
-----------------------------------------------------------------

  function Is_Part_Of_Generic (Element : in Asis.Element) 
			      return Boolean;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
-- 
-- Returns True if the Element is a generic declaration or occurs 
-- within the declarative region of a generic declaration.  
-- The declarative region includes the completion of the generic 
-- and any child units and subunits.
--
-- All Element_Kinds are expected.
--
-----------------------------------------------------------------

  function Is_Global (Declaration : in Asis.Declaration) return Boolean;

-----------------------------------------------------------------
-- Declaration - Specifies the declaration to query
--
-- Returns True if the declaration is global when it is 
-- part of a partition.
--
-- Global declarations are declarations that occur immediately 
-- within the declarative region of a global package, generic package, 
-- or an instantiation of a package.  The declarative region includes the 
-- completion of the package and any child units and subunits.
--
-- Returns False for any unexpected Element.
--
-- All Declaration_Kinds are expected.
--
-----------------------------------------------------------------

private

end Asis.Toolkit.ObjectAda.Declarations;

