![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Function Name
function Name (Name : in Asis.Element) return String;Expanded Name Asis.Expressions.Name
Returns the text image of the name associated with the specified Name parameter.
Description
If the Name parameter represents A_Character_Literal, the returned image includes the enclosing apostrophes. For example, 'x' will be returned for the character literal `x'.
If the Name parameter represents An_Operator_Symbol, the quotation marks will be doubled. For example, ""abs"" will be returned for the operator "abs".
To obtain the text image of integer and real literals, you must call the Static_Value function.
The case of names returned by this function will vary among vendors. Vendors are encouraged, but not required, to return names in the same case used in the original compilation text.
It has not yet been determined whether Rational Apex returns the value as it appears in the source code or whether the value is upshifted.
$ If Rational Apex returns the name with the same case as keyed this information will be helpful: If a variable name, which is represented as A_Simple_Name, had been specified as openFile, this function returns openFile. Because of this, it is possible that two names won't match but nonetheless represent the same entity. You could use the You could use the You could use the You could use the You could use the Name_Definition function to determine if the function to determine if the function to determine if the function to determine if the function to determine if the elements represent the same entity name definition, or elements represent the same entity name definition, or elements represent the same entity name definition, or elements represent the same entity name definition, or elements represent the same entity name definition, or Name_Declaration to see if they result from the same declaration to see if they result from the same declaration to see if they result from the same declaration to see if they result from the same declaration to see if they result from the same declaration.
Implicit subtypes that might be encountered while traversing the semantic information embedded in implicit derived subprogram declarations (Ada83 LRM 3.4(14), Ada95 LRM 3.4) might have names that are duplicated within their scope. These subtypes are Is_Implicit declarations that do not form part of the physical text of the compilation unit.
Parameters
Name : in Asis.Element;Specifies the name that should be queried. The name must be of the following kinds:
return String;Returns the text image of the name associated with the specified Name parameter.
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.
Examples
Cross-References
Function Name_Declaration
function Name_Declaration (Reference : in Asis.Expression) return Asis.Declaration;Expanded Name Asis.Expressions.Name_Declaration
Returns the declaration that declared the specified entity
reference.Description
This function is functionally equivalent to:
Result := Asis.Expressions.Name_Definition (Reference);if not Asis.Expression.Is_Nil (Result) then Result := Asis.Elements.Enclosing_Element (Result);end if;return Result;See the Name_Definition function for a detailed description of the definitions returned for each kind of element and what their enclosing elements are.
Parameters
Reference : in Asis.Expression;Specifies the entity reference that should be queried. The reference must be of the following kinds:
return Asis.Declaration;The returned element is of the following kinds:
Element_Kinds
A_Declaration
A_Statement
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.
Examples
Cross-References
Function Name_Definition
function Name_Definition (Reference : in Asis.Element) return Asis.Entity_Name_Definition;Expanded Name Asis.Expressions.Name_Definition
Returns the first definition of the name indicated by the specified reference.
Description
An Ada entity definition can be either:
- A one-part definition, such as subtype definitions, variable declarations, statement labels, and block names
- A two-part definition, such as function declarations and calls to the function, record declarations followed by references to the components, and package specifications and the corresponding package bodies
Various ASIS functions allow you to move between the halves of specific kinds of two-part definitions. For example, Declarations.Corresponding_Specification returns the specification that corresponds to a given body and Declarations.Corresponding_Constant_Declaration returns the full constant declaration for a specified deferred constant.
Given an entity representing an implementation or use, the Name_Definition function can provide the entity's definition. For example, if a specified element represents A_Simple_Name of a variable's use, An_Entity_Name_Definition from the variable's declaration is returned.
If provided with the second part of a two-part entity definition, Name_Definition returns the first part. If provided with the first part of a one- or two-part definition, it acts as an identity function and returns the argument.
The Name_Definition function returns a non-nil result except when provided with an attribute reference that is not an attribute function. Such attributes have no defining instance. The Element_Kinds of a non-nil result is always An_Entity_Name-_Definition.
A non-nil Name_Definition always has an enclosing element with an Element_Kinds of A_Declaration or A_Statement.
- The specified reference if it is a single-part entity definition such as a subtype, variable, generic instantiation, statement label, loop or block name, and so on.
- The specified reference if it is already the first part of a two-part entity definition such as a package specification, deferred constant declaration, or private type declaration.
- The entity-name definition of the first part if the specified reference is the second part of a two-part definition.
- The entity-name definition of the record discriminant or component declaration if the specified reference is to a record component. For derived types, the result will be a structural (syntactic) subcomponent from the declaration of the parent type definition.
- A Declarations.Is_Part_Of_Implicit name definition if the specified reference is to an implicit operator, attribute function, or a derived subprogram.
If the reference is to an attribute that is not an attribute function, Asis.Nil_Element is returned.
The Elements.Enclosing_Element of the name definition is the implicit declaration for the operation. The Enclosing-_Element of the declaration of the operation is the associated type definition (see Declarations.Corresponding_Type).
- A name from the expanded generic specification instance if the specified reference is to a visible component of an instantiated generic package. For example, a reference to an entity representing an instantiated function name returns an entity representing the name of the function from the expanded generic specification.
- A name from the appropriate expanded specification or body instance if the specified reference is within an expanded generic instance that refers to other components of the same, or an enclosing, expanded generic instance.
Parameters
Reference : in Asis.Element;Specifies the entity reference that should be queried. The reference must be of the following kinds:
return Asis.Entity_Name_Definition;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 Value-_Error if passed a pragma argument that does not reference an object or declaration.
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
- function Name_Declaration
- function Declarations.Corresponding_Type
- function Declarations.Is_Part_Of_Implicit
- function Elements.Enclosing_Element
Function Named_Packages
function Named_Packages (Clause : in Asis.Element) return Asis.Expression_List;Expanded Name Asis.Expressions.Named_Packages
Returns an expression list containing the package names appearing in the specified clause.
Description
Use clauses are defined by the following syntax:
use_clause ::=
use package_name {, package_name};This function returns a list of the package names associated with the specified use clause.
The names are returned in their order of appearance in the source code. However, some implementations normalize all use clauses containing multiple package names into an equivalent sequence of corresponding single use clauses. Similarly, an implementation may keep a name only once even though the name may appear more than once in a use clause (Ada83 LRM 8.4(9), Ada95 LRM 8.4).
Parameters
Clause : in Asis.Element;Specifies the use clause that should be queried. The clause must be of the following kind:
Element_Kinds
A_Use_Clause
return Asis.Expression_List;The returned list contains elements of the following kinds:
Element_Kinds Expression_Kinds
An_Expression A_Simple_Name
A_Selected_Component
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.
Examples
Cross-References
- function Compilation_Units.Context_Clause_Elements
- function Declarations.Private_Part_Declarative_Items
- function Declarations.Visible_Part_Declarative_Items
- function Statements.Declarative_Items
- "Processing Use Clauses"
- Ada83 LRM 8.4, Ada95 LRM
8.4
Function Operator_Kind
function Operator_Kind (Name : Asis.Element) return Operator_Kinds;Expanded Name Asis.Expressions.Operator_Kind
Returns the kind of the specified operator name.
Description
This function returns the kind of operator represented by the specified name (Ada83 LRM 4.5, Ada95 LRM 4.5).
The Operator_Kinds enumeration does not include short-circuit evaluation or membership tests. ASIS refers to these as special operations and they are described separately (see "Processing Special Operations" for more information).
Parameters
Name : Asis.Element;Specifies the name that should be queried. The name must be of the following kinds:
Element_Kinds Expression_Kinds
An_Entity_Name_Definition A_Simple_Name
An_Operator_Symbol
An_Expression A_Simple_Name
An_Operator_Symbol
return Operator_Kinds;Returns the operator kind for all elements in the above table that represent operator symbols and Not_An_Operator for all other elements.
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.
Examples
Cross-References
- "Processing Implicit Subprograms"
- "Processing Operators"
- "Processing Special Operations"
- Ada83 LRM 4.5, Ada95 LRM 4.5
Type Operator_Kinds
type Operator_Kinds is (...);Expanded Name Asis.Expressions.Operator_Kinds
Describes the kinds of operators available.
Description
Operators are defined by the following syntax:
logical_operator ::= and | or | xor
relational_operator ::= =
| /= | < | <= | > | >=binary_adding_operator ::= + | - | &
unary_adding_operator ::= + | -
multiplying_operator ::= * | / | mod | rem
highest_precedence_operator ::= ** | abs | not
This type describes the operators shown above.
Enumerations
A_Concatenate_OperatorIndicates that the element represents the binary adding operator "&".
A_Divide_OperatorIndicates that the element represents the multiplying operator "/".
A_Greater_Than_OperatorIndicates that the element represents the relational operator ">".
A_Greater_Than_Or_Equal_OperatorIndicates that the element represents the relational operator ">=".
A_Less_Than_OperatorIndicates that the element represents the relational operator "<".
A_Less_Than_Or_Equal_OperatorIndicates that the element represents the relational operator "<=".
A_Minus_OperatorIndicates that the element represents the binary adding operator "-".
A_Mod_OperatorIndicates that the element represents the multiplying operator "mod".
A_Not_Equal_OperatorIndicates that the element represents the relational operator "/=".
A_Not_OperatorIndicates that the element represents the highest-precedence operator "not".
A_Plus_OperatorIndicates that the element represents the binary adding operator "+".
A_Rem_OperatorIndicates that the element represents the multiplying operator "rem".
A_Times_OperatorIndicates that the element represents the multiplying operator "*".
A_Unary_Minus_OperatorIndicates that the element represents the unary adding operator "-".
A_Unary_Plus_OperatorIndicates that the element represents the unary adding operator "+".
An_Abs_OperatorIndicates that the element represents the highest-precedence operator "abs".
An_And_OperatorIndicates that the element represents the logical operator "and".
An_Equal_OperatorIndicates that the element represents the relational operator "=".
An_Exponentiate_OperatorIndicates that the element represents the highest-precedence operator "**".
An_Or_OperatorIndicates that the element represents the logical operator "or".
An_Xor_OperatorIndicates that the element represents the logical operator "xor".
Not_An_OperatorIndicates that the element does not represent an operator.
Cross-References
Function Position_Number_Image
function Position_Number_Image (Expression : in Asis.Expression) return String;Expanded Name Asis.Expressions.Position_Number_Image
Returns the text image of the position, within the base type, of the specified character or enumeration literal.
Description
This function returns the same text image as the 'Pos attribute returns when provided with the character or enumeration value (Ada83 LRM 3.3, Ada95 LRM 3.2).
Parameters
Expression : in Asis.Expression;Specifies the character or enumeration literal that should be queried. The expression must be of the following kinds:
Element_Kinds Expression_Kinds
An_Entity_Name_Definition A_Character_Literal
An_Enumeration_Literal
An_Expression A_Character_Literal
An_Enumeration_Literal
return Asis.String;Returns the text image of the position, within the base type, of the specified character or enumeration literal.
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
- "Processing Literals"
- Ada83 LRM 3.5.5, Ada95 LRM 3.5.5
Function Prefix
function Prefix (Expression : in Asis.Expression) return Asis.Expression;Expanded Name Asis.Expressions.Prefix
Returns the prefix of the specified function call, selected component, slice, attribute, or indexed component.
Description
Prefixes appear in function calls, indexed components, slices, selected components, and attributes. These are defined by the following syntactic components:
prefix ::= name | function_call
Ada83 LRM 4.1.1, Ada95 LRM 4.1.1
indexed_component ::=
prefix(expression {, expression})Ada83 LRM 4.1.2, Ada95 LRM 4.1.2
slice ::= prefix(discrete_range)
Ada83 LRM 4.1.3, Ada95 LRM 4.1.3
selected_component ::= prefix.selector
Ada83 LRM 4.1.4, Ada95 LRM 4.1.4
attribute ::= prefix'attribute_designator
The prefix value returned for each acceptable Expression_Kinds is shown in the following table:
The returned expression can be a complex expression.
Examples of each value Expression_Kinds are shown below:
Expression_Kinds Example
A_Function_Call Foo (...) or Integer'Image (...)
A_Selected_Component A.B.C
A_Slice An_Array (3 .. 5)
An_Attribute T'Base'First
An_Indexed_Component An_Array (3)
Parameters
Expression : in Asis.Expression;Specifies the name from an expression that should be queried. The expression must be of the following kinds:
Element_Kinds Expression_Kinds
An_Expression A_Function_Call
A_Selected_Component
A_Slice
An_Attribute
An_Indexed_Component
return Asis.Expression;The returned element is of the following kind:
Element_Kinds
An_Expression
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.
Examples
Cross-References
Rational Software Corporation
http://www.rational.com support@rational.com techpubs@rational.com Copyright © 1993-2001, Rational Software Corporation. All rights reserved. |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |