TOC PREV NEXT INDEX DOC LIST MASTER INDEX




Function Body_Stub

Expanded Name Asis.Declarations.Body_Stub

Returns the body-stub declaration from the parent unit corresponding to the specified subunit declaration.

Description

Body stubs and subunits are defined by the following syntax:

Ada83 LRM 10.2, Ada95 LRM 10.1.3 

body_stub ::=
   subprogram_specification is separate;
  | package body package_simple_name
    is separate;
  | task body task_simple_name is separate;

 subunit ::=
  separate (parent_unit_name) proper body

This function returns the body-stub declaration for the specified subunit declaration.

If a non-nil element is returned, the Compilation_Units.Enclosing_Library of the returned element will be the same as the specified library.

Parameters

Specifies the declaration for which the body-stub declaration must be returned. The declaration must represent a subunit (Is_Subunit must return True). The declaration must be of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Body_Declaration
A_Package_Body_Declaration
A_Procedure_Body_Declaration
A_Task_Body_Declaration

Specifies the library from which the declaration must be returned.

If a library is not specified, the Enclosing_Library of the Declaration parameter is assumed. These calls produce identical results:

The returned element is of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Body_Stub
A_Package_Body_Stub
A_Procedure_Body_Stub
A_Task_Body_Stub

If the parent unit does not exist in the implied or specified library, Asis.Nil_Element is returned.

Errors

Asis_Inappropriate_Element is raised and Environment.Status is set to Value_Error if a parameter references a library variable that is no longer open, or a parameter is specified that is not appropriate for the query.

Asis_Inappropriate_Library is raised and Environment.Status is set to Value_Error if a library variable is specified that is no longer open.

Asis_Failed is raised and Environment.Status is set to Obso-
lete_Reference_Error if a parameter is part of an obsolete
compilation unit.

Examples

For example:

The element that represents the separate procedure implementation is a Declaration_Kinds of A_Procedure_Body. When the Body_Stub function is called with this element, it returns an element with a Declaration_Kinds of A_Procedure_Body_Stub. This element represents the separate declaration of the procedure within package Sorting.

Cross-References

Related subprograms:

Related concepts:


Function Corresponding_Body

Expanded Name Asis.Declarations.Corresponding_Body

Returns the corresponding body if the specified declaration is a subprogram, package, or task declaration; returns the expanded generic body template if the specified declaration is a generic instantiation.

Description

If a body declaration is specified, the same element is returned.

If a non-nil element is returned, the Compilation_Units.Enclosing_Library of the returned element will be the same as the specified library.

The specified library need not be the Compilation_Units.Enclosing_Library of the declaration.

If a generic instantiation is specified, the body representing the expanded generic body template is returned as follows:
Input Declaration_Kinds
Returned Declaration_Kinds
A_Function_Instantiation
A_Function_Body_Declaration
A_Package_Instantiation
A_Package_Body_Declaration
A_Procedure_Instantiation
A_Procedure_Body_Declaration

The Elements.Enclosing_Element of the expanded generic body is the generic instantiation. The Compilation_Units.Enclosing-
_Compilation_Unit
of the expanded template is that of the instantiation.

Implicit predefined operations and attributes (for example, +, –, 'Image, and so on) do not typically have unit bodies. Explicitly specified overloading of predefined operations will have corresponding bodies.

Predefined operators, attributes, packages, subprograms, and so on, or derived instances of these entities, do not have bodies.

Parameters

Specifies the declaration for which the corresponding body should be returned. The declaration must be of the following kinds for the return of the corresponding specification:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Declaration
A_Function_Instantiation
A_Generic_Function_Declaration
A_Generic_Package_Declaration
A_Generic_Procedure_Declaration
A_Package_Declaration
A_Package_Instantiation
A_Procedure_Declaration
A_Procedure_Instantiation
A_Task_Declaration
A_Task_Type_Declaration

If the declaration represents a body, the same element is returned. The declaration must be of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Body_Declaration
A_Function_Body_Stub
A_Function_Rename_Declaration
A_Package_Body_Declaration
A_Package_Body_Stub
A_Package_Rename_Declaration
A_Procedure_Body_Declaration
A_Procedure_Body_Stub
A_Procedure_Rename_Declaration
A_Task_Body_Declaration
A_Task_Body_Stub

Specifies the library from which the declaration must be returned.

If a library is not specified, the Enclosing_Library of the declaration parameter is assumed. These calls produce identical results:

The returned element is of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Body
_Declaration
A_Function_Body_Stub
A_Function_Rename_Declaration
A_Package_Body_Declaration
A_Package_Body_Stub
A_Package_Rename_Declaration
A_Procedure_Body_Declaration
A_Procedure_Body_Stub
A_Procedure_Rename_Declaration
A_Task_Body_Declaration
A_Task_Body_Stub

If a corresponding body does not exist in the implied or specified library, Asis.Nil_Element is returned.

Errors

Asis_Inappropriate_Element is raised and Environment.Status is set to Value_Error if a parameter references a library variable that is no longer open, or a parameter is specified that is not appropriate for the query.

Asis_Inappropriate_Library is raised and Environment.Status is set to Value_Error if a library variable is specified that is no longer open.

Asis_Failed is raised and Environment.Status is set to Obso-
lete_Reference_Error if a parameter is part of an obsolete
compilation unit.

Examples

Cross-References

Related subprograms:

Related concept:


Function Corresponding_Constant_Declaration

Expanded Name Asis.Declarations.Corresponding_Constant_Declaration

Returns the full constant declaration corresponding to the specified name from a deferred constant declaration or the deferred constant declaration corresponding to the specified name from a full constant declaration.

Description

The name of a declaration can be obtained from the Names or Expressions.Name_Definition functions.

Parameters

Specifies the constant or deferred constant declaration for which the corresponding declaration must be returned. The name must be of the following kinds:
Element_Kinds

An_Entity_Name_Definition

The returned element is of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Constant_Declaration
A_Deferred_Constant_Declaration

If a full constant declaration is specified and a deferred constant declaration does not exist, Asis.Nil_Element is returned.

Errors

Asis_Inappropriate_Element is raised and Environment.Status is set to Value_Error if a parameter references a library variable that is no longer open, or a parameter is specified that is not appropriate for the query.

Asis_Failed is raised and Environment.Status is set to Obso-
lete_Reference_Error if a parameter is part of an obsolete
compilation unit.

Examples

Cross-References

Related subprograms:

Related concept:


Function Corresponding_Equality_Operator

Expanded Name Asis.Declarations.Corresponding_Equality_Operator

Returns the complementary operator function declaration for the specified equality or inequality declaration.

Description

Given an equality (=) operator declaration, this function returns the corresponding inequality (/=) operator declaration; given an inequality (/=) operator declaration, this function returns the corresponding equality (=) operator declaration.

Parameters

Specifies the equality operator function declaration for which the corresponding declaration must be returned. The declaration must be of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Declaration (/= or =)

The returned element is of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Declaration (/= or =)

If the underlying Ada implementation does not define an implicit inequality operator, Asis.Nil_Element is returned. For a description of the variations in the implementation of equality private-type operators, see "Equality Operators."

Errors

Asis_Inappropriate_Element is raised and Environment.Status is set to Value_Error if a parameter references a library variable that is no longer open, or a parameter is specified that is not appropriate for the query.

Asis_Failed is raised and Environment.Status is set to Obso-
lete_Reference_Error if a parameter is part of an obsolete
compilation unit.

Examples

Cross-References

Related subprograms:

Related concepts:


Function Corresponding_Generic_Element

Expanded Name Asis.Declarations.Corresponding_Generic_Element

Returns the entity-name definition in a generic template for the specified generic instantiation entity reference.

Description

A generic instantiation creates, implicitly, an expanded generic instance. The instance is created by substituting actual parameters for the formal parameters in the generic template. This function returns the corresponding declaration in the template given an entity from a generic instance.

This function returns the An_Entity_Name_Definition from the generic template that corresponds to the entity referenced. The entity may refer to a subprogram declaration, a derived subprogram declaration, or an implicit operator, attribute, or subprogram declaration.

If the reference does not refer to an entity declared as a subcomponent of a generic package instantiation, Asis.Nil_Element is returned.

Parameters

Specifies an expression that references an entity declared within the implicit specification or body of a generic instantiation. The corresponding generic element is returned for this reference. The reference must be of the following kinds:
Element_Kinds
Expression_Kinds
An_Expression
A_Character_Literal
A_Simple_Name
An_Enumeration_Literal
An_Operator_Symbol

The returned element is of the following kind:
Element_Kinds

An_Entity_Name_Definition

Errors

Asis_Inappropriate_Element is raised and Environment.Status is set to Value_Error if a parameter references a library variable that is no longer open, or a parameter is specified that is not appropriate for the query.

Asis_Failed is raised and Environment.Status is set to Obso-
lete_Reference_Error if a parameter is part of an obsolete
compilation unit.

Examples

The Abc of A_Specific.Abc is a reference to the Abc that is implicitly declared by the expanded generic instance of A_Generic. Given the reference to A_Specific.Abc, this function returns An_Entity_Name_Definition of Abc in the generic template.

Cross-References

Related subprograms:

Related concept:


Function Corresponding_Specification

Expanded Name Asis.Declarations.Corresponding_Specification

Returns the corresponding specification for the specified subprogram, package, or task-body declaration; returns the expanded generic specification template for the specified generic
instantiation.

Description

If a specification is specified, the same element is returned.

If the corresponding body does not exist in the implied or specified library, Asis.Nil_Element is returned. If a non-nil element is returned, the Compilation_Units.Enclosing_Library of the returned element will be the same as the specified library.

If a specification does not exist, Asis.Nil_Element is returned. This occurs when a subprogram body is specified without a corresponding subprogram specification.

If the specification is the proper body of a subunit, Asis.Nil_Element is returned. The Subunit function can be called to obtain the specification corresponding to the body.

The specified library need not be the Compilation_Units.Enclosing_Library of the declaration.

If a generic instantiation is specified, the specification representing the instantiation is returned as follows:
Input Declaration_Kinds
Returned Declaration_Kinds
A_Function_Instantiation
A_Function_Declaration
A_Package_Instantiation
A_Package_Declaration
A_Procedure_Instantiation
A_Procedure_Declaration

The Elements.Enclosing_Element of the expanded specification is the generic instantiation. The Compilation_Units.Enclosing-
_Compilation_Unit
of the expanded template is that of the instantiation.

Parameters

Specifies the declaration for which the corresponding specification should be returned.

The declaration must be of the following kinds for the return of the corresponding specification:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Body_Declaration
A_Function_Body_Stub
A_Function_Instantiation
A_Package_Body_Declaration
A_Package_Body_Stub
A_Package_Instantiation
A_Procedure_Body_Declaration
A_Procedure_Body_Stub
A_Procedure_Instantiation
A_Task_Body_Declaration
A_Task_Body_Stub

If the declaration represents a specification, the same element is returned. The declaration must be of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Declaration
A_Function_Rename_Declaration
A_Generic_Function_Declaration
A_Generic_Package_Declaration
A_Generic_Procedure_Declaration
A_Package_Declaration
A_Package_Rename_Declaration
A_Procedure_Declaration
A_Procedure_Rename_Declaration
A_Task_Declaration
A_Task_Type_Declaration

Specifies the library from which the declaration must be returned.

If a library is not specified, the Enclosing_Library of the Declaration parameter is assumed. These calls produce identical results:

return Asis.Declaration;

The returned element is of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Declaration
A_Function_Rename_Declaration
A_Generic_Function_Declaration
A_Generic_Package_Declaration
A_Generic_Procedure_Declaration
A_Package_Declaration
A_Package_Rename_Declaration
A_Procedure_Declaration
A_Procedure_Rename_Declaration
A_Task_Declaration
A_Task_Type_Declaration

Errors

Asis_Inappropriate_Element is raised and Environment.Status is set to Value_Error if a parameter references a library variable that is no longer open, or a parameter is specified that is not appropriate for the query.

Asis_Inappropriate_Library is raised and Environment.Status is set to Value_Error if a library variable is specified that is no longer open.

Asis_Failed is raised and Environment.Status is set to Obso-
lete_Reference_Error if a parameter is part of an obsolete
compilation unit.

Examples

Cross-References

Related subprograms:

Related concept:


Function Corresponding_Type

Expanded Name Asis.Declarations.Corresponding_Type

Returns the type definition for which the specified declaration is a subprogram, operator, or attribute-function declaration.

Description

The result of this function is often a derived type.

Subprograms have a corresponding type only when they are implicitly declared as the result of the declaration of a derived type, where there is a subprogram declared in the same scope as the parent type, and the subprogram has a parameter or a return value that is of the parent type. If a corresponding type does not exist, Asis.Nil_Element is returned.

Parameters

Specifies the subprogram, operator, or attribute-function declaration for which the corresponding type declaration must be returned. The declaration must be Is_Part_Of_Implicit. The declaration must be of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Function_Declaration
A_Procedure_Declaration

The returned element is of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
Any Type_Definition_Kinds except A_Subtype_Declaration

Errors

Asis_Inappropriate_Element is raised and Environment.Status is set to Value_Error if a parameter references a library variable that is no longer open, or a parameter is specified that is not appropriate for the query.

Asis_Failed is raised and Environment.Status is set to Obso-
lete_Reference_Error if a parameter is part of an obsolete
compilation unit.

Examples

Cross-References

Related subprograms:

Related concept:


Function Corresponding_Type_Declaration

Expanded Name Asis.Declarations.Corresponding_Type_Declaration

Returns the full-type declaration corresponding to the specified private- or incomplete-type declaration, or returns the private- or incomplete-type declaration corresponding to the specified full- type declaration.

Description

If the specified type declaration does not have a corresponding private or incomplete type declaration, Asis.Nil_Element is returned.

The value of the Library parameter is always checked for validity but otherwise is not used unless the full-type declaration corresponding to an incomplete type is in a corresponding package body (Ada83 LRM 3.8.1, Ada95 LRM 3.10.1).

If the corresponding type definition does not exist in the implied or specified library, Asis.Nil_Element is returned. If a non-nil element is returned, the Compilation_Units.Enclosing_Library of the returned element will be the same as the specified library.

If a non-nil result is returned, the Compilation_Units.Enclosing_Library of the result is the same as the specified library.

Parameters

Specifies the declaration for which the corresponding type declaration must be returned. The declaration must be of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Full_Type_Declaration
A_Private_Type_Declaration
A_Task_Type_Declaration
An_Incomplete_Type_Declaration

Specifies the library from which the corresponding declaration must be returned.

If a library is not specified, the Enclosing_Library of the Declaration parameter is assumed. These calls produce identical results:

The returned element is of the following kinds:
Element_Kinds
Declaration_Kinds
A_Declaration
A_Full_Type_Declaration
A_Private_Type_Declaration
A_Task_Type_Declaration
An_Incomplete_Type_Declaration

Errors

Asis_Inappropriate_Element is raised and Environment.Status is set to Value_Error if a parameter references a library variable that is no longer open, or a parameter is specified that is not appropriate for the query.

Asis_Inappropriate_Library is raised and Environment.Status is set to Value_Error if a library variable is specified that is no longer open.

Asis_Failed is raised and Environment.Status is set to Obso-
lete_Reference_Error if a parameter is part of an obsolete
compilation unit.

Examples

Cross-References

Related subprograms:

Related concepts:


Rational Software Corporation  http://www.rational.com
support@rational.com
techpubs@rational.com
Copyright © 1993-2001, Rational Software Corporation. All rights reserved.
TOC PREV NEXT INDEX DOC LIST MASTER INDEX TECHNOTES APEX TIPS