gnat_rm.texi

来自「理解和实践操作系统的一本好书」· TEXI 代码 · 共 1,978 行 · 第 1/5 页

TEXI
1,978
字号
compilation unit Namet in the compiler sources for details).The remaining parameters (OVERLOADING_RESOLUTION) are optionally usedto distinguish between overloaded subprograms. If a pragma does not containthe OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloadedsubprograms denoted by the first two parameters.Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogramto be eliminated in a manner similar to that used for the extended@code{Import} and @code{Export} pragmas, except that the subtype names arealways given as strings. At the moment, this form of distinguishingoverloaded subprograms is implemented only partially, so we do not recommendusing it for practical subprogram elimination.Note that in case of a parameterless procedure its profile is representedas @code{Parameter_Types => ("")}Alternatively, the @code{Source_Location} parameter is used to specifywhich overloaded alternative is to be eliminated by pointing to thelocation of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in thesource text. The string literal (or concatenation of string literals)given as SOURCE_TRACE must have the following format:@smallexample @c adaSOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}LBRACKET ::= [RBRACKET ::= ]SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBERFILE_NAME       ::= STRING_LITERALLINE_NUMBER     ::= DIGIT @{DIGIT@}@end smallexampleSOURCE_TRACE should be the short name of the source file (with no directoryinformation), and LINE_NUMBER is supposed to point to the line where thedefining name of the subprogram is located.For the subprograms that are not a part of generic instantiations, only oneSOURCE_LOCATION is used. If a subprogram is declared in a packageinstantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one isthe location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and thesecond one denotes the declaration of the corresponding subprogram in thegeneric package. This approach is recursively used to create SOURCE_LOCATIONsin case of nested instantiations.The effect of the pragma is to allow the compiler to eliminatethe code or data associated with the named entity.  Any reference toan eliminated entity outside the compilation unit it is defined in,causes a compile time or link time error.The intention of pragma @code{Eliminate} is to allow a program to be compiledin a system independent manner, with unused entities eliminated, withoutthe requirement of modifying the source text.  Normally the required setof @code{Eliminate} pragmas is constructed automatically using the gnatelimtool. Elimination of unused entities local to a compilation unit isautomatic, without requiring the use of pragma @code{Eliminate}.Note that the reason this pragma takes string literals where names mightbe expected is that a pragma @code{Eliminate} can appear in a context where therelevant names are not visible.Note that any change in the source files that includes removing, splitting ofadding lines may make the set of Eliminate pragmas using SOURCE_LOCATIONparameter illegal.It is legal to use pragma Eliminate where the referenced entity is adispatching operation, but it is not clear what this would mean, sincein general the call does not know which entity is actually being called.Consequently, a pragma Eliminate for a dispatching operation is ignored.@node Pragma Export_Exception@unnumberedsec Pragma Export_Exception@cindex OpenVMS@findex Export_Exception@noindentSyntax:@smallexample @c adapragma Export_Exception (     [Internal =>] LOCAL_NAME  [, [External =>] EXTERNAL_SYMBOL]  [, [Form     =>] Ada | VMS]  [, [Code     =>] static_integer_EXPRESSION]);EXTERNAL_SYMBOL ::=  IDENTIFIER| static_string_EXPRESSION@end smallexample@noindentThis pragma is implemented only in the OpenVMS implementation of GNAT@.  Itcauses the specified exception to be propagated outside of the Ada program,so that it can be handled by programs written in other OpenVMS languages.This pragma establishes an external name for an Ada exception and makes thename available to the OpenVMS Linker as a global symbol.  For further detailson this pragma, see theDEC Ada Language Reference Manual, section 13.9a3.2.@node Pragma Export_Function@unnumberedsec Pragma Export_Function@cindex Argument passing mechanisms@findex Export_Function@noindentSyntax:@smallexample @c adapragma Export_Function (     [Internal         =>] LOCAL_NAME  [, [External         =>] EXTERNAL_SYMBOL]  [, [Parameter_Types  =>] PARAMETER_TYPES]  [, [Result_Type      =>] result_SUBTYPE_MARK]  [, [Mechanism        =>] MECHANISM]  [, [Result_Mechanism =>] MECHANISM_NAME]);EXTERNAL_SYMBOL ::=  IDENTIFIER| static_string_EXPRESSION| ""PARAMETER_TYPES ::=  null| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}TYPE_DESIGNATOR ::=  subtype_NAME| subtype_Name ' AccessMECHANISM ::=  MECHANISM_NAME| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})MECHANISM_ASSOCIATION ::=  [formal_parameter_NAME =>] MECHANISM_NAMEMECHANISM_NAME ::=  Value| Reference| Descriptor [([Class =>] CLASS_NAME)]CLASS_NAME ::= ubs | ubsb | uba | s | sb | a@end smallexample@noindentUse this pragma to make a function externally callable and optionallyprovide information on mechanisms to be used for passing parameter andresult values.  We recommend, for the purposes of improving portability,this pragma always be used in conjunction with a separate pragma@code{Export}, which must precede the pragma @code{Export_Function}.GNAT does not require a separate pragma @code{Export}, but if none ispresent, @code{Convention Ada} is assumed, which is usuallynot what is wanted, so it is usually appropriate to use thispragma in conjunction with a @code{Export} or @code{Convention}pragma that specifies the desired foreign convention.Pragma @code{Export_Function}(and @code{Export}, if present) must appear in the same declarativeregion as the function to which they apply.@var{internal_name} must uniquely designate the function to which thepragma applies.  If more than one function name exists of this name inthe declarative part you must use the @code{Parameter_Types} and@code{Result_Type} parameters is mandatory to achieve the requiredunique designation.  @var{subtype_mark}s in these parameters mustexactly match the subtypes in the corresponding function specification,using positional notation to match parameters with subtype marks.The form with an @code{'Access} attribute can be used to match ananonymous access parameter.@cindex OpenVMS@cindex Passing by descriptorPassing by descriptor is supported only on the OpenVMS ports of GNAT@.@cindex Suppressing external nameSpecial treatment is given if the EXTERNAL is an explicit nullstring or a static string expressions that evaluates to the nullstring. In this case, no external name is generated. This formstill allows the specification of parameter mechanisms.@node Pragma Export_Object@unnumberedsec Pragma Export_Object@findex Export_Object@noindentSyntax:@smallexample @c adapragma Export_Object      [Internal =>] LOCAL_NAME   [, [External =>] EXTERNAL_SYMBOL]   [, [Size     =>] EXTERNAL_SYMBOL]EXTERNAL_SYMBOL ::=  IDENTIFIER| static_string_EXPRESSION@end smallexample@noindentThis pragma designates an object as exported, and apart from theextended rules for external symbols, is identical in effect to the use ofthe normal @code{Export} pragma applied to an object.  You may use aseparate Export pragma (and you probably should from the point of viewof portability), but it is not required.  @var{Size} is syntax checked,but otherwise ignored by GNAT@.@node Pragma Export_Procedure@unnumberedsec Pragma Export_Procedure@findex Export_Procedure@noindentSyntax:@smallexample @c adapragma Export_Procedure (     [Internal        =>] LOCAL_NAME  [, [External        =>] EXTERNAL_SYMBOL]  [, [Parameter_Types =>] PARAMETER_TYPES]  [, [Mechanism       =>] MECHANISM]);EXTERNAL_SYMBOL ::=  IDENTIFIER| static_string_EXPRESSION| ""PARAMETER_TYPES ::=  null| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}TYPE_DESIGNATOR ::=  subtype_NAME| subtype_Name ' AccessMECHANISM ::=  MECHANISM_NAME| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})MECHANISM_ASSOCIATION ::=  [formal_parameter_NAME =>] MECHANISM_NAMEMECHANISM_NAME ::=  Value| Reference| Descriptor [([Class =>] CLASS_NAME)]CLASS_NAME ::= ubs | ubsb | uba | s | sb | a@end smallexample@noindentThis pragma is identical to @code{Export_Function} except that itapplies to a procedure rather than a function and the parameters@code{Result_Type} and @code{Result_Mechanism} are not permitted.GNAT does not require a separate pragma @code{Export}, but if none ispresent, @code{Convention Ada} is assumed, which is usuallynot what is wanted, so it is usually appropriate to use thispragma in conjunction with a @code{Export} or @code{Convention}pragma that specifies the desired foreign convention.@cindex OpenVMS@cindex Passing by descriptorPassing by descriptor is supported only on the OpenVMS ports of GNAT@.@cindex Suppressing external nameSpecial treatment is given if the EXTERNAL is an explicit nullstring or a static string expressions that evaluates to the nullstring. In this case, no external name is generated. This formstill allows the specification of parameter mechanisms.@node Pragma Export_Value@unnumberedsec Pragma Export_Value@findex Export_Value@noindentSyntax:@smallexample @c adapragma Export_Value (  [Value     =>] static_integer_EXPRESSION,  [Link_Name =>] static_string_EXPRESSION);@end smallexample@noindentThis pragma serves to export a static integer value for external use.The first argument specifies the value to be exported. The Link_Nameargument specifies the symbolic name to be associated with the integervalue. This pragma is useful for defining a named static value in Adathat can be referenced in assembly language units to be linked withthe application. This pragma is currently supported only for theAAMP target and is ignored for other targets.@node Pragma Export_Valued_Procedure@unnumberedsec Pragma Export_Valued_Procedure@findex Export_Valued_Procedure@noindentSyntax:@smallexample @c adapragma Export_Valued_Procedure (     [Internal        =>] LOCAL_NAME  [, [External        =>] EXTERNAL_SYMBOL]  [, [Parameter_Types =>] PARAMETER_TYPES]  [, [Mechanism       =>] MECHANISM]);EXTERNAL_SYMBOL ::=  IDENTIFIER| static_string_EXPRESSION| ""PARAMETER_TYPES ::=  null| TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}TYPE_DESIGNATOR ::=  subtype_NAME| subtype_Name ' AccessMECHANISM ::=  MECHANISM_NAME| (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})MECHANISM_ASSOCIATION ::=  [formal_parameter_NAME =>] MECHANISM_NAMEMECHANISM_NAME ::=  Value| Reference| Descriptor [([Class =>] CLASS_NAME)]CLASS_NAME ::= ubs | ubsb | uba | s | sb | a@end smallexample@noindentThis pragma is identical to @code{Export_Procedure} except that thefirst parameter of @var{LOCAL_NAME}, which must be present, must be ofmode @code{OUT}, and externally the subprogram is treated as a functionwith this parameter as the result of the function.  GNAT provides forthis capability to allow the use of @code{OUT} and @code{IN OUT}parameters in interfacing to external functions (which are not permittedin Ada functions).GNAT does not require a separate pragma @code{Export}, but if none ispresent, @code{Convention Ada} is assumed, which is almost certainlynot what is wanted since the whole point of this pragma is to interfacewith foreign language functions, so it is usually appropriate to use thispragma in conjunction with a @code{Export} or @code{Convention}pragma that specifies the desired foreign convention.@cindex OpenVMS@cindex Passing by descriptorPassing by descriptor is supported only on the OpenVMS ports of GNAT@.@cindex Suppressing external nameSpecial treatment is given if the EXTERNAL is an explicit nullstring or a static string expressions that evaluates to the nullstring. In this case, no external name is generated. This formstill allows the specification of parameter mechanisms.@node Pragma Extend_System@unnumberedsec Pragma Extend_System@cindex @code{system}, extending@cindex Dec Ada 83@findex Extend_System@noindentSyntax:@smallexample @c adapragma Extend_System ([Name =>] IDENTIFIER);@end smallexample@noindentThis pragma is used to provide backwards compatibility with otherimplementations that extend the facilities of package @code{System}.  InGNAT, @code{System} contains only the definitions that are present inthe Ada RM@.  However, other implementations, notably the DEC Ada 83implementation, provide many extensions to package @code{System}.For each such implementation accommodated by this pragma, GNAT provides apackage @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83implementation, which provides the required additional definitions.  Youcan use this package in two ways.  You can @code{with} it in the normalway and access entities either by selection or using a @code{use}clause.  In this case no special processing is required.However, if existing code contains references such as@code{System.@var{xxx}} where @var{xxx} is an entity in the extendeddefinitions provided in package @code{System}, you may use this pragmato extend visibility in @code{System} in a non-standard way thatprovides greater compatibility with the existing code.  Pragma@code{Extend_System} is a configuration pragma whose single argument isthe name of the package containing the extended definition(e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled undercontrol of this pragma will be processed using special visibilityprocessing that looks in package @code{System.Aux_@var{xxx}} where@code{Aux_@var{xxx}} is the pragma argument for any entity referenced inpackage @code{System}, but not found in package @code{System}.You can use this pragma either to access a predefined @code{System}extension supplied with the compiler, for example @code{Aux_DEC} oryou can construct your own extension unit 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?