From rybin@possum.srcc.msu.su Mon Jan 27 02:00:49 1997 Return-Path: Received: from ida.org by cronus.csed.ida.org (SMI-8.6/SMI-SVR4) id CAA07426; Mon, 27 Jan 1997 02:00:49 -0500 Received: from sw-eng.falls-church.va.us (ns1.sw-eng.falls-church.va.us) by ida.org (4.1/SMI-4.1) id AA15012; Mon, 27 Jan 97 02:01:09 EST Received: from crocus.gamma.ru by sw-eng.falls-church.va.us (8.7.1/) id GAA23557; Mon, 27 Jan 1997 06:54:49 GMT Received: from srcc.UUCP (uucp@localhost) by crocus.gamma.ru (8.7.6/8.7.3) with UUCP id JAA10417 for asis-officers@sw-eng.falls-church.va.us; Mon, 27 Jan 1997 09:57:20 +0300 (MSK) Received: by gamma.srcc.msu.su; Mon, 27 Jan 1997 09:57:08 +0300 Received: by possum.srcc.msu.su (UUPC/@ v5.09gamma, 14Mar93); Mon, 27 Jan 1997 09:54:57 +0300 To: asis-officers@sw-eng.falls-church.va.us Message-Id: Organization: Information Systems, SRCC, MSU From: "Sergey I. Rybin" Date: Mon, 27 Jan 97 09:54:57 +0300 X-Mailer: BML [MS/DOS Beauty Mail v.1.36] Subject: Corresponding_Name_Definiton and renaming declarations Lines: 142 Content-Length: 5668 Status: OR Consider the following example: A : Integer; ...... B : Integer renames A; ... begin Do_Something_With (B); ^^^ | E Suppose E is the Element representing the occurrence of B as an actual parameter in a procedure call. The question is: what should be the result of the call Corresponding_Name_Definition (E)? The documentation of the Corresponding_Name_Definition says: -- Returns the defining_identifier, defining_character_literal, -- defining_operator_symbol, or defining_program_unit_name from the -- declaration of the referenced entity. ^^^^^^^^^^^^^^^^^^^^^^^^^ (The full documentation of Corresponding_Name_Definition is appended) RM 95 8.5 (1) says: A renaming_declaration declares another name for an entity, such ^^^^^^^^^^^^^^^^^^^^^^^^^^ as an object, exception, package, subprogram, entry, or generic unit. Alternatively, a subprogram_renaming_declaration can be the completion of a previous subprogram_declaration. So in our example, the declaration of the referenced *entity* for the direct name B represented by the Element E is the object declaration with the defining name A, but not the renaming declaration with the defining name B. Am I right in this analysis? If I am, should this be stated in the documentation of Corresponding_Name_Definition? Sergey Rybin ------------------------------------------------------------------------------ -- Section 17.6 function Corresponding_Name_Definition ------------------------------------------------------------------------------ function Corresponding_Name_Definition (Reference : in Asis.Expression) return Asis.Defining_Name; ------------------------------------------------------------------------------ -- Reference - Specifies an expression to query -- -- Returns the defining_identifier, defining_character_literal, -- defining_operator_symbol, or defining_program_unit_name from the -- declaration of the referenced entity. -- -- - Record component references, return the defining_name of the -- record discriminant or component_declaration. For derived types, the -- result will be an Is_Part_Of_Implicit structural (syntactic) -- component from the declaration of the parent type definition. -- -- - References to implicit operators and inherited subprograms will return -- an Is_Part_Of_Implicit defining name for the operation. The -- Enclosing_Element of the name is an implicit declaration for the -- operation. The Enclosing_Element of the declaration is the associated -- derived_type_definition. -- -- - References to formal parameters given in calls to inherited subprograms -- will return an Is_Part_Of_Implicit defining name for the -- Parameter_Specification from the inherited subprogram specification. -- -- - References to visible components of instantiated generic packages will -- return a name from the expanded generic specification instance. -- -- - References, within expanded generic instances, that refer to other -- components of the same, or an enclosing, expanded generic instance, -- return a name from the appropriate expanded specification or body -- instance. -- -- Returns a Nil_Element if the reference is to an implicitly declared -- element for which the implementation does not provide declarations and -- defining_name elements. -- -- The Enclosing_Element of Ä non-Nil result is either a Declaration or a -- Statement. -- -- Appropriate Expression_Kinds: -- An_Identifier -- An_Operator_Symbol -- A_Character_Literal -- An_Enumeration_Literal -- -- Returns Element_Kinds: -- Not_An_Element -- A_Defining_Name -- --|IP Implementation Permissions: --|IP --|IP Some implementations do not represent all forms of implicit --|IP declarations such that elements representing them can be easily --|IP provided. An implementation can choose whether or not to construct --|IP and provide artificial declarations for implicitly declared elements. --|IP --|IR Implementation Requirements: --|IR -- Raises Asis_Inappropriate_Element, with a Status of Value_Error, if passed -- a reference that does not have a declaration: -- -- - a reference to an attribute_designator. Attributes are defined, but -- have no implicit or explicit declarations. -- -- - a name argument from a pragma identifier that does not actually -- reference a declared object. A contrived example of such an argument -- would be: -- -- pragma Should_I_Check ( Really => Yes ); -- -- In this example, the name Yes has no declaration. -- -- Raises Asis_Inappropriate_Element, with a Status of Data_Error, if passed -- a portion of a pragma that was "ignored" by the compiler and which does -- not have (sufficient) semantic information for a proper return result -- to be computed. For example, -- -- pragma I_Am_Ignored (Foof); -- -- The "Foof" expression would be An_Identifier but would raise this exception -- if passed to Corresponding_Name_Definition if the pragma was ignored -- or unprocessed. -- -- Raises Asis_Inappropriate_Element, with a Status of Use_Error, if passed -- a portion of a pragma that is an ambiguous reference to more than one -- entity. For example, -- -- pragma Inline ("+"); -- Inlines all "+" operators -- -- The "+" expression would be An_Operator_Symbol but would raise this -- exception if it actually referenced more than one "+" operator. In this -- case, the Corresponding_Name_Definition_List query can be used to obtain a -- list of referenced entities. From sblake@alsys.com Mon Jan 27 11:14:37 1997 Return-Path: Received: from ida.org by cronus.csed.ida.org (SMI-8.6/SMI-SVR4) id LAA08256; Mon, 27 Jan 1997 11:14:37 -0500 Received: from sw-eng.falls-church.va.us (ns1.sw-eng.falls-church.va.us) by ida.org (4.1/SMI-4.1) id AA20679; Mon, 27 Jan 97 11:14:51 EST Received: from gw.alsys.com by sw-eng.falls-church.va.us (8.7.1/) id QAA29734; Mon, 27 Jan 1997 16:09:03 GMT Received: from rasht.alsys.com (mailhub.alsys.com) by gw.alsys.com (4.1/SMI-4.1.1) id AA20682; Mon, 27 Jan 97 08:11:43 PST Received: from pulsar.telesoft by rasht.alsys.com (4.1/TS-1.2c) id AA02254; Mon, 27 Jan 97 08:10:52 PST Received: by pulsar.telesoft (5.x/SMI-SVR4) id AA05673; Mon, 27 Jan 1997 08:09:46 -0800 Date: Mon, 27 Jan 1997 08:09:46 -0800 From: sblake@alsys.com (Steve Blake @pulsar) Message-Id: <9701271609.AA05673@pulsar.telesoft> To: asis-officers@sw-eng.falls-church.va.us, rybin@possum.srcc.msu.su Subject: Re: Corresponding_Name_Definiton and renaming declarations Content-Length: 6038 Status: OR >>> Consider the following example: A : Integer; ...... B : Integer renames A; ... begin Do_Something_With (B); ^^^ | E Suppose E is the Element representing the occurrence of B as an actual parameter in a procedure call. The question is: what should be the result of the call Corresponding_Name_Definition (E)? The documentation of the Corresponding_Name_Definition says: -- Returns the defining_identifier, defining_character_literal, -- defining_operator_symbol, or defining_program_unit_name from the -- declaration of the referenced entity. ^^^^^^^^^^^^^^^^^^^^^^^^^ (The full documentation of Corresponding_Name_Definition is appended) RM 95 8.5 (1) says: A renaming_declaration declares another name for an entity, such ^^^^^^^^^^^^^^^^^^^^^^^^^^ as an object, exception, package, subprogram, entry, or generic unit. Alternatively, a subprogram_renaming_declaration can be the completion of a previous subprogram_declaration. So in our example, the declaration of the referenced *entity* for the direct name B represented by the Element E is the object declaration with the defining name A, but not the renaming declaration with the defining name B. Am I right in this analysis? If I am, should this be stated in the documentation of Corresponding_Name_Definition? >>>>>>> Yes, you are correct. However, the desired result of Corresponding_Name_Definition should be the definition of B. This primitive functionality allows renamings to be traced, rather than ignored. A secondary function could easily be written to return the definition of the real entity A. I would suggest some clarifying commentary be added. Steve Sergey Rybin ------------------------------------------------------------------------------ -- Section 17.6 function Corresponding_Name_Definition ------------------------------------------------------------------------------ function Corresponding_Name_Definition (Reference : in Asis.Expression) return Asis.Defining_Name; ------------------------------------------------------------------------------ -- Reference - Specifies an expression to query -- -- Returns the defining_identifier, defining_character_literal, -- defining_operator_symbol, or defining_program_unit_name from the -- declaration of the referenced entity. -- -- - Record component references, return the defining_name of the -- record discriminant or component_declaration. For derived types, the -- result will be an Is_Part_Of_Implicit structural (syntactic) -- component from the declaration of the parent type definition. -- -- - References to implicit operators and inherited subprograms will return -- an Is_Part_Of_Implicit defining name for the operation. The -- Enclosing_Element of the name is an implicit declaration for the -- operation. The Enclosing_Element of the declaration is the associated -- derived_type_definition. -- -- - References to formal parameters given in calls to inherited subprograms -- will return an Is_Part_Of_Implicit defining name for the -- Parameter_Specification from the inherited subprogram specification. -- -- - References to visible components of instantiated generic packages will -- return a name from the expanded generic specification instance. -- -- - References, within expanded generic instances, that refer to other -- components of the same, or an enclosing, expanded generic instance, -- return a name from the appropriate expanded specification or body -- instance. -- -- Returns a Nil_Element if the reference is to an implicitly declared -- element for which the implementation does not provide declarations and -- defining_name elements. -- -- The Enclosing_Element of Ä non-Nil result is either a Declaration or a -- Statement. -- -- Appropriate Expression_Kinds: -- An_Identifier -- An_Operator_Symbol -- A_Character_Literal -- An_Enumeration_Literal -- -- Returns Element_Kinds: -- Not_An_Element -- A_Defining_Name -- --|IP Implementation Permissions: --|IP --|IP Some implementations do not represent all forms of implicit --|IP declarations such that elements representing them can be easily --|IP provided. An implementation can choose whether or not to construct --|IP and provide artificial declarations for implicitly declared elements. --|IP --|IR Implementation Requirements: --|IR -- Raises Asis_Inappropriate_Element, with a Status of Value_Error, if passed -- a reference that does not have a declaration: -- -- - a reference to an attribute_designator. Attributes are defined, but -- have no implicit or explicit declarations. -- -- - a name argument from a pragma identifier that does not actually -- reference a declared object. A contrived example of such an argument -- would be: -- -- pragma Should_I_Check ( Really => Yes ); -- -- In this example, the name Yes has no declaration. -- -- Raises Asis_Inappropriate_Element, with a Status of Data_Error, if passed -- a portion of a pragma that was "ignored" by the compiler and which does -- not have (sufficient) semantic information for a proper return result -- to be computed. For example, -- -- pragma I_Am_Ignored (Foof); -- -- The "Foof" expression would be An_Identifier but would raise this exception -- if passed to Corresponding_Name_Definition if the pragma was ignored -- or unprocessed. -- -- Raises Asis_Inappropriate_Element, with a Status of Use_Error, if passed -- a portion of a pragma that is an ambiguous reference to more than one -- entity. For example, -- -- pragma Inline ("+"); -- Inlines all "+" operators -- -- The "+" expression would be An_Operator_Symbol but would raise this -- exception if it actually referenced more than one "+" operator. In this -- case, the Corresponding_Name_Definition_List query can be used to obtain a -- list of referenced entities. From rybin@possum.srcc.msu.su Mon Jan 27 02:00:49 1997 Return-Path: Received: from ida.org by cronus.csed.ida.org (SMI-8.6/SMI-SVR4) id CAA07426; Mon, 27 Jan 1997 02:00:49 -0500 Received: from sw-eng.falls-church.va.us (ns1.sw-eng.falls-church.va.us) by ida.org (4.1/SMI-4.1) id AA15012; Mon, 27 Jan 97 02:01:09 EST Received: from crocus.gamma.ru by sw-eng.falls-church.va.us (8.7.1/) id GAA23557; Mon, 27 Jan 1997 06:54:49 GMT Received: from srcc.UUCP (uucp@localhost) by crocus.gamma.ru (8.7.6/8.7.3) with UUCP id JAA10417 for asis-officers@sw-eng.falls-church.va.us; Mon, 27 Jan 1997 09:57:20 +0300 (MSK) Received: by gamma.srcc.msu.su; Mon, 27 Jan 1997 09:57:08 +0300 Received: by possum.srcc.msu.su (UUPC/@ v5.09gamma, 14Mar93); Mon, 27 Jan 1997 09:54:57 +0300 To: asis-officers@sw-eng.falls-church.va.us Message-Id: Organization: Information Systems, SRCC, MSU From: "Sergey I. Rybin" Date: Mon, 27 Jan 97 09:54:57 +0300 X-Mailer: BML [MS/DOS Beauty Mail v.1.36] Subject: Corresponding_Name_Definiton and renaming declarations Lines: 142 Content-Length: 5668 Status: OR Consider the following example: A : Integer; ...... B : Integer renames A; ... begin Do_Something_With (B); ^^^ | E Suppose E is the Element representing the occurrence of B as an actual parameter in a procedure call. The question is: what should be the result of the call Corresponding_Name_Definition (E)? The documentation of the Corresponding_Name_Definition says: -- Returns the defining_identifier, defining_character_literal, -- defining_operator_symbol, or defining_program_unit_name from the -- declaration of the referenced entity. ^^^^^^^^^^^^^^^^^^^^^^^^^ (The full documentation of Corresponding_Name_Definition is appended) RM 95 8.5 (1) says: A renaming_declaration declares another name for an entity, such ^^^^^^^^^^^^^^^^^^^^^^^^^^ as an object, exception, package, subprogram, entry, or generic unit. Alternatively, a subprogram_renaming_declaration can be the completion of a previous subprogram_declaration. So in our example, the declaration of the referenced *entity* for the direct name B represented by the Element E is the object declaration with the defining name A, but not the renaming declaration with the defining name B. Am I right in this analysis? If I am, should this be stated in the documentation of Corresponding_Name_Definition? Sergey Rybin ------------------------------------------------------------------------------ -- Section 17.6 function Corresponding_Name_Definition ------------------------------------------------------------------------------ function Corresponding_Name_Definition (Reference : in Asis.Expression) return Asis.Defining_Name; ------------------------------------------------------------------------------ -- Reference - Specifies an expression to query -- -- Returns the defining_identifier, defining_character_literal, -- defining_operator_symbol, or defining_program_unit_name from the -- declaration of the referenced entity. -- -- - Record component references, return the defining_name of the -- record discriminant or component_declaration. For derived types, the -- result will be an Is_Part_Of_Implicit structural (syntactic) -- component from the declaration of the parent type definition. -- -- - References to implicit operators and inherited subprograms will return -- an Is_Part_Of_Implicit defining name for the operation. The -- Enclosing_Element of the name is an implicit declaration for the -- operation. The Enclosing_Element of the declaration is the associated -- derived_type_definition. -- -- - References to formal parameters given in calls to inherited subprograms -- will return an Is_Part_Of_Implicit defining name for the -- Parameter_Specification from the inherited subprogram specification. -- -- - References to visible components of instantiated generic packages will -- return a name from the expanded generic specification instance. -- -- - References, within expanded generic instances, that refer to other -- components of the same, or an enclosing, expanded generic instance, -- return a name from the appropriate expanded specification or body -- instance. -- -- Returns a Nil_Element if the reference is to an implicitly declared -- element for which the implementation does not provide declarations and -- defining_name elements. -- -- The Enclosing_Element of Ä non-Nil result is either a Declaration or a -- Statement. -- -- Appropriate Expression_Kinds: -- An_Identifier -- An_Operator_Symbol -- A_Character_Literal -- An_Enumeration_Literal -- -- Returns Element_Kinds: -- Not_An_Element -- A_Defining_Name -- --|IP Implementation Permissions: --|IP --|IP Some implementations do not represent all forms of implicit --|IP declarations such that elements representing them can be easily --|IP provided. An implementation can choose whether or not to construct --|IP and provide artificial declarations for implicitly declared elements. --|IP --|IR Implementation Requirements: --|IR -- Raises Asis_Inappropriate_Element, with a Status of Value_Error, if passed -- a reference that does not have a declaration: -- -- - a reference to an attribute_designator. Attributes are defined, but -- have no implicit or explicit declarations. -- -- - a name argument from a pragma identifier that does not actually -- reference a declared object. A contrived example of such an argument -- would be: -- -- pragma Should_I_Check ( Really => Yes ); -- -- In this example, the name Yes has no declaration. -- -- Raises Asis_Inappropriate_Element, with a Status of Data_Error, if passed -- a portion of a pragma that was "ignored" by the compiler and which does -- not have (sufficient) semantic information for a proper return result -- to be computed. For example, -- -- pragma I_Am_Ignored (Foof); -- -- The "Foof" expression would be An_Identifier but would raise this exception -- if passed to Corresponding_Name_Definition if the pragma was ignored -- or unprocessed. -- -- Raises Asis_Inappropriate_Element, with a Status of Use_Error, if passed -- a portion of a pragma that is an ambiguous reference to more than one -- entity. For example, -- -- pragma Inline ("+"); -- Inlines all "+" operators -- -- The "+" expression would be An_Operator_Symbol but would raise this -- exception if it actually referenced more than one "+" operator. In this -- case, the Corresponding_Name_Definition_List query can be used to obtain a -- list of referenced entities. From rybin@possum.srcc.msu.su Mon Jan 27 02:00:49 1997 Return-Path: Received: from ida.org by cronus.csed.ida.org (SMI-8.6/SMI-SVR4) id CAA07426; Mon, 27 Jan 1997 02:00:49 -0500 Received: from sw-eng.falls-church.va.us (ns1.sw-eng.falls-church.va.us) by ida.org (4.1/SMI-4.1) id AA15012; Mon, 27 Jan 97 02:01:09 EST Received: from crocus.gamma.ru by sw-eng.falls-church.va.us (8.7.1/) id GAA23557; Mon, 27 Jan 1997 06:54:49 GMT Received: from srcc.UUCP (uucp@localhost) by crocus.gamma.ru (8.7.6/8.7.3) with UUCP id JAA10417 for asis-officers@sw-eng.falls-church.va.us; Mon, 27 Jan 1997 09:57:20 +0300 (MSK) Received: by gamma.srcc.msu.su; Mon, 27 Jan 1997 09:57:08 +0300 Received: by possum.srcc.msu.su (UUPC/@ v5.09gamma, 14Mar93); Mon, 27 Jan 1997 09:54:57 +0300 To: asis-officers@sw-eng.falls-church.va.us Message-Id: Organization: Information Systems, SRCC, MSU From: "Sergey I. Rybin" Date: Mon, 27 Jan 97 09:54:57 +0300 X-Mailer: BML [MS/DOS Beauty Mail v.1.36] Subject: Corresponding_Name_Definiton and renaming declarations Lines: 142 Content-Length: 5668 Status: OR Consider the following example: A : Integer; ...... B : Integer renames A; ... begin Do_Something_With (B); ^^^ | E Suppose E is the Element representing the occurrence of B as an actual parameter in a procedure call. The question is: what should be the result of the call Corresponding_Name_Definition (E)? The documentation of the Corresponding_Name_Definition says: -- Returns the defining_identifier, defining_character_literal, -- defining_operator_symbol, or defining_program_unit_name from the -- declaration of the referenced entity. ^^^^^^^^^^^^^^^^^^^^^^^^^ (The full documentation of Corresponding_Name_Definition is appended) RM 95 8.5 (1) says: A renaming_declaration declares another name for an entity, such ^^^^^^^^^^^^^^^^^^^^^^^^^^ as an object, exception, package, subprogram, entry, or generic unit. Alternatively, a subprogram_renaming_declaration can be the completion of a previous subprogram_declaration. So in our example, the declaration of the referenced *entity* for the direct name B represented by the Element E is the object declaration with the defining name A, but not the renaming declaration with the defining name B. Am I right in this analysis? If I am, should this be stated in the documentation of Corresponding_Name_Definition? Sergey Rybin ------------------------------------------------------------------------------ -- Section 17.6 function Corresponding_Name_Definition ------------------------------------------------------------------------------ function Corresponding_Name_Definition (Reference : in Asis.Expression) return Asis.Defining_Name; ------------------------------------------------------------------------------ -- Reference - Specifies an expression to query -- -- Returns the defining_identifier, defining_character_literal, -- defining_operator_symbol, or defining_program_unit_name from the -- declaration of the referenced entity. -- -- - Record component references, return the defining_name of the -- record discriminant or component_declaration. For derived types, the -- result will be an Is_Part_Of_Implicit structural (syntactic) -- component from the declaration of the parent type definition. -- -- - References to implicit operators and inherited subprograms will return -- an Is_Part_Of_Implicit defining name for the operation. The -- Enclosing_Element of the name is an implicit declaration for the -- operation. The Enclosing_Element of the declaration is the associated -- derived_type_definition. -- -- - References to formal parameters given in calls to inherited subprograms -- will return an Is_Part_Of_Implicit defining name for the -- Parameter_Specification from the inherited subprogram specification. -- -- - References to visible components of instantiated generic packages will -- return a name from the expanded generic specification instance. -- -- - References, within expanded generic instances, that refer to other -- components of the same, or an enclosing, expanded generic instance, -- return a name from the appropriate expanded specification or body -- instance. -- -- Returns a Nil_Element if the reference is to an implicitly declared -- element for which the implementation does not provide declarations and -- defining_name elements. -- -- The Enclosing_Element of Ä non-Nil result is either a Declaration or a -- Statement. -- -- Appropriate Expression_Kinds: -- An_Identifier -- An_Operator_Symbol -- A_Character_Literal -- An_Enumeration_Literal -- -- Returns Element_Kinds: -- Not_An_Element -- A_Defining_Name -- --|IP Implementation Permissions: --|IP --|IP Some implementations do not represent all forms of implicit --|IP declarations such that elements representing them can be easily --|IP provided. An implementation can choose whether or not to construct --|IP and provide artificial declarations for implicitly declared elements. --|IP --|IR Implementation Requirements: --|IR -- Raises Asis_Inappropriate_Element, with a Status of Value_Error, if passed -- a reference that does not have a declaration: -- -- - a reference to an attribute_designator. Attributes are defined, but -- have no implicit or explicit declarations. -- -- - a name argument from a pragma identifier that does not actually -- reference a declared object. A contrived example of such an argument -- would be: -- -- pragma Should_I_Check ( Really => Yes ); -- -- In this example, the name Yes has no declaration. -- -- Raises Asis_Inappropriate_Element, with a Status of Data_Error, if passed -- a portion of a pragma that was "ignored" by the compiler and which does -- not have (sufficient) semantic information for a proper return result -- to be computed. For example, -- -- pragma I_Am_Ignored (Foof); -- -- The "Foof" expression would be An_Identifier but would raise this exception -- if passed to Corresponding_Name_Definition if the pragma was ignored -- or unprocessed. -- -- Raises Asis_Inappropriate_Element, with a Status of Use_Error, if passed -- a portion of a pragma that is an ambiguous reference to more than one -- entity. For example, -- -- pragma Inline ("+"); -- Inlines all "+" operators -- -- The "+" expression would be An_Operator_Symbol but would raise this -- exception if it actually referenced more than one "+" operator. In this -- case, the Corresponding_Name_Definition_List query can be used to obtain a -- list of referenced entities. From sblake@alsys.com Mon Jan 27 11:14:37 1997 Return-Path: Received: from ida.org by cronus.csed.ida.org (SMI-8.6/SMI-SVR4) id LAA08256; Mon, 27 Jan 1997 11:14:37 -0500 Received: from sw-eng.falls-church.va.us (ns1.sw-eng.falls-church.va.us) by ida.org (4.1/SMI-4.1) id AA20679; Mon, 27 Jan 97 11:14:51 EST Received: from gw.alsys.com by sw-eng.falls-church.va.us (8.7.1/) id QAA29734; Mon, 27 Jan 1997 16:09:03 GMT Received: from rasht.alsys.com (mailhub.alsys.com) by gw.alsys.com (4.1/SMI-4.1.1) id AA20682; Mon, 27 Jan 97 08:11:43 PST Received: from pulsar.telesoft by rasht.alsys.com (4.1/TS-1.2c) id AA02254; Mon, 27 Jan 97 08:10:52 PST Received: by pulsar.telesoft (5.x/SMI-SVR4) id AA05673; Mon, 27 Jan 1997 08:09:46 -0800 Date: Mon, 27 Jan 1997 08:09:46 -0800 From: sblake@alsys.com (Steve Blake @pulsar) Message-Id: <9701271609.AA05673@pulsar.telesoft> To: asis-officers@sw-eng.falls-church.va.us, rybin@possum.srcc.msu.su Subject: Re: Corresponding_Name_Definiton and renaming declarations Content-Length: 6038 Status: OR >>> Consider the following example: A : Integer; ...... B : Integer renames A; ... begin Do_Something_With (B); ^^^ | E Suppose E is the Element representing the occurrence of B as an actual parameter in a procedure call. The question is: what should be the result of the call Corresponding_Name_Definition (E)? The documentation of the Corresponding_Name_Definition says: -- Returns the defining_identifier, defining_character_literal, -- defining_operator_symbol, or defining_program_unit_name from the -- declaration of the referenced entity. ^^^^^^^^^^^^^^^^^^^^^^^^^ (The full documentation of Corresponding_Name_Definition is appended) RM 95 8.5 (1) says: A renaming_declaration declares another name for an entity, such ^^^^^^^^^^^^^^^^^^^^^^^^^^ as an object, exception, package, subprogram, entry, or generic unit. Alternatively, a subprogram_renaming_declaration can be the completion of a previous subprogram_declaration. So in our example, the declaration of the referenced *entity* for the direct name B represented by the Element E is the object declaration with the defining name A, but not the renaming declaration with the defining name B. Am I right in this analysis? If I am, should this be stated in the documentation of Corresponding_Name_Definition? >>>>>>> Yes, you are correct. However, the desired result of Corresponding_Name_Definition should be the definition of B. This primitive functionality allows renamings to be traced, rather than ignored. A secondary function could easily be written to return the definition of the real entity A. I would suggest some clarifying commentary be added. Steve Sergey Rybin ------------------------------------------------------------------------------ -- Section 17.6 function Corresponding_Name_Definition ------------------------------------------------------------------------------ function Corresponding_Name_Definition (Reference : in Asis.Expression) return Asis.Defining_Name; ------------------------------------------------------------------------------ -- Reference - Specifies an expression to query -- -- Returns the defining_identifier, defining_character_literal, -- defining_operator_symbol, or defining_program_unit_name from the -- declaration of the referenced entity. -- -- - Record component references, return the defining_name of the -- record discriminant or component_declaration. For derived types, the -- result will be an Is_Part_Of_Implicit structural (syntactic) -- component from the declaration of the parent type definition. -- -- - References to implicit operators and inherited subprograms will return -- an Is_Part_Of_Implicit defining name for the operation. The -- Enclosing_Element of the name is an implicit declaration for the -- operation. The Enclosing_Element of the declaration is the associated -- derived_type_definition. -- -- - References to formal parameters given in calls to inherited subprograms -- will return an Is_Part_Of_Implicit defining name for the -- Parameter_Specification from the inherited subprogram specification. -- -- - References to visible components of instantiated generic packages will -- return a name from the expanded generic specification instance. -- -- - References, within expanded generic instances, that refer to other -- components of the same, or an enclosing, expanded generic instance, -- return a name from the appropriate expanded specification or body -- instance. -- -- Returns a Nil_Element if the reference is to an implicitly declared -- element for which the implementation does not provide declarations and -- defining_name elements. -- -- The Enclosing_Element of Ä non-Nil result is either a Declaration or a -- Statement. -- -- Appropriate Expression_Kinds: -- An_Identifier -- An_Operator_Symbol -- A_Character_Literal -- An_Enumeration_Literal -- -- Returns Element_Kinds: -- Not_An_Element -- A_Defining_Name -- --|IP Implementation Permissions: --|IP --|IP Some implementations do not represent all forms of implicit --|IP declarations such that elements representing them can be easily --|IP provided. An implementation can choose whether or not to construct --|IP and provide artificial declarations for implicitly declared elements. --|IP --|IR Implementation Requirements: --|IR -- Raises Asis_Inappropriate_Element, with a Status of Value_Error, if passed -- a reference that does not have a declaration: -- -- - a reference to an attribute_designator. Attributes are defined, but -- have no implicit or explicit declarations. -- -- - a name argument from a pragma identifier that does not actually -- reference a declared object. A contrived example of such an argument -- would be: -- -- pragma Should_I_Check ( Really => Yes ); -- -- In this example, the name Yes has no declaration. -- -- Raises Asis_Inappropriate_Element, with a Status of Data_Error, if passed -- a portion of a pragma that was "ignored" by the compiler and which does -- not have (sufficient) semantic information for a proper return result -- to be computed. For example, -- -- pragma I_Am_Ignored (Foof); -- -- The "Foof" expression would be An_Identifier but would raise this exception -- if passed to Corresponding_Name_Definition if the pragma was ignored -- or unprocessed. -- -- Raises Asis_Inappropriate_Element, with a Status of Use_Error, if passed -- a portion of a pragma that is an ambiguous reference to more than one -- entity. For example, -- -- pragma Inline ("+"); -- Inlines all "+" operators -- -- The "+" expression would be An_Operator_Symbol but would raise this -- exception if it actually referenced more than one "+" operator. In this -- case, the Corresponding_Name_Definition_List query can be used to obtain a -- list of referenced entities.